Skip to content

Commit f3d3144

Browse files
committed
Fixes reading in TTTSettings for some lg codes.
Japanese was wrongly identified. Removes some parasitic paddings in the textarea.
1 parent c528c02 commit f3d3144

4 files changed

Lines changed: 18 additions & 9 deletions

File tree

‎docs/CHANGELOG.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ the intendended page. Same goes for "New Text" on "Archived Texts" page.
7474
* A warning when savings settings in ``settings.php`` was sometimes displayed ([#121](https://github.com/HugoFara/lwt/issues/121)).
7575
* Test header was different when testing languages or terms since 2.1.0-fork.
7676
* Wrong link to documentation (``info.php`` instead of ``docs/info.html``). Signaled by Mooncake on Discord.
77-
* The reading button is usable at last! Clicking the button a second time stops the reading process ([#108](https://github.com/HugoFara/lwt/issues/118)).
77+
* Text reading:
78+
* The reading button is usable at last! Clicking the button a second time stops the reading process ([#108](https://github.com/HugoFara/lwt/issues/118)).
79+
* Text language code was often wrong in TTT settings (``text_to_speech_settings.php``).
7880
* It was impossible to copy a similar term that had apostrophes ([#127](https://github.com/HugoFara/lwt/issues/127)).
7981
* A deprecation warning for ``trim`` was sent in simterms when no similar term was found.
8082
* During a text creation, the ``media_uri`` property of ``Text`` was used instead of ``source``. Thanks to [@hangug-eo](https://github.com/hangug-eo) for his PR [#133](https://github.com/HugoFara/lwt/pull/133)!

‎docs/info.html‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,7 +1956,12 @@ <h4>Fixed</h4>
19561956
<li>A warning when savings settings in <code>settings.php</code> was sometimes displayed (<a href="https://github.com/HugoFara/lwt/issues/121">#121</a>).</li>
19571957
<li>Test header was different when testing languages or terms since 2.1.0-fork.</li>
19581958
<li>Wrong link to documentation (<code>info.php</code> instead of <code>docs/info.html</code>). Signaled by Mooncake on Discord.</li>
1959+
<li>Text reading:
1960+
<ul>
19591961
<li>The reading button is usable at last! Clicking the button a second time stops the reading process (<a href="https://github.com/HugoFara/lwt/issues/118">#108</a>).</li>
1962+
<li>Text language code was often wrong in TTT settings (<code>text_to_speech_settings.php</code>).</li>
1963+
</ul>
1964+
</li>
19601965
<li>It was impossible to copy a similar term that had apostrophes (<a href="https://github.com/HugoFara/lwt/issues/127">#127</a>).</li>
19611966
<li>A deprecation warning for <code>trim</code> was sent in simterms when no similar term was found.</li>
19621967
<li>During a text creation, the <code>media_uri</code> property of <code>Text</code> was used instead of <code>source</code>. Thanks to <a href="https://github.com/hangug-eo">@hangug-eo</a> for his PR <a href="https://github.com/HugoFara/lwt/pull/133">#133</a>!</li>

‎inc/session_utility.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4708,12 +4708,14 @@ function trim_value(&$value): void
47084708
* @param string $text Text to be converted
47094709
* @param string $lang Language code (usually BCP 47 or ISO 639-1)
47104710
* @return string Parsed text in a phonetic format.
4711+
*
4712+
* @since 2.9.0 Any language starting by "ja" or "jp" is considered phonetic.
47114713
*/
47124714
function phonetic_reading($text, $lang)
47134715
{
47144716
global $tbpref;
47154717
// Many languages are already phonetic
4716-
if ($lang != 'ja' && $lang != 'jp-JP' && $lang != 'jp' ) {
4718+
if (!str_starts_with($lang, "ja") && !str_starts_with($lang, "jp")) {
47174719
return $text;
47184720
}
47194721

‎text_to_speech_settings.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,8 @@ function tts_demo()
154154
?>
155155
<th class="th1 center">Demo</th>
156156
<td class="td1 center" colspan="2">
157-
<textarea id="tts-demo" title="Enter your text here" class="respinput">
158-
Lorem ipsum dolor sit amet...
159-
</textarea>
157+
<textarea id="tts-demo" title="Enter your text here" class="respinput"
158+
>Lorem ipsum dolor sit amet...</textarea>
160159
</td>
161160
<td class="td1 right">
162161
<button onclick="readingDemo();">Read</button>
@@ -207,12 +206,13 @@ function getRegionCode()
207206
*/
208207
function readingDemo()
209208
{
210-
let lang =
209+
const lang = getLanguageCode() +
210+
(getRegionCode() ? '-' + getRegionCode() : '');
211211
readTextAloud(
212212
$('#tts-demo')[0].value,
213-
getLanguageCode + (getRegionCode() ? '-' + getRegionCode() : ''),
214-
$('#rate')[0].value,
215-
$('#pitch')[0].value
213+
lang,
214+
parseFloat($('#rate')[0].value),
215+
parseFloat($('#pitch')[0].value)
216216
);
217217
}
218218

0 commit comments

Comments
 (0)