Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgramComputer committed Jan 1, 2024
2 parents 8100db5 + f8c54e3 commit 89b1227
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 58 deletions.
21 changes: 13 additions & 8 deletions do_text_text.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ function getTextData($textid)
*
* @return array{LgName: string, LgDict1URI: string,
* LgDict2URI: string, LgGoogleTranslateURI: string, LgTextSize: int,
* LgRemoveSpaces: int, LgRightToLeft: int}|false|null Record corresponding to this language.
* LgRegexpWordCharacters: string, LgRemoveSpaces: int,
* LgRightToLeft: int, Lg}|false|null Record corresponding to this language.
*
* @global string $tbpref Table name prefix
*
Expand All @@ -79,7 +80,7 @@ function get_language_settings($langid)
global $tbpref;
$sql =
'SELECT LgName, LgDict1URI, LgDict2URI, LgGoogleTranslateURI,
LgTextSize, LgRemoveSpaces, LgRightToLeft
LgTextSize, LgRegexpWordCharacters, LgRemoveSpaces, LgRightToLeft
FROM ' . $tbpref . 'languages
WHERE LgID = ' . $langid;
$res = do_mysqli_query($sql);
Expand Down Expand Up @@ -759,24 +760,28 @@ function do_text_text_content($textid, $only_body=true): void
$var_array = array(
// Change globals from jQuery hover
'LWT_DATA' => array(

'language' => array(
'dict_link1' => $wb1,
'dict_link2' => $wb2,
'translator_link' => $wb3,
'delimiter' => tohtml(
str_replace(
array('\\',']','-','^'),
array('\\\\','\\]','\\-','\\^'),
getSettingWithDefault('set-term-translation-delimiters')
)
),
str_replace(
array('\\',']','-','^'),
array('\\\\','\\]','\\-','\\^'),
getSettingWithDefault('set-term-translation-delimiters')
)
),
'word_parsing' => $record['LgRegexpWordCharacters'],
'rtl' => $rtlScript
),

'text' => array(
'id' => $textid,
'reading_position' => $pos,
'annotations' => json_decode(annotation_to_json($ann))
),

'settings' => array(
'jQuery_tooltip' => (
getSettingWithDefault('set-tooltip-mode') == 2 ? 1 : 0
Expand Down
25 changes: 16 additions & 9 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,20 @@ ones are marked like "v1.0.0-fork".
* On `inc/kernel_utility.php`: `LWT_APP_VERSION` and `LWT_RELEASE_DATE`.
* On `api.php`: `LWT_API_VERSION` and `LWT_API_RELEASE_DATE`.
* `src/js/jq_pgm.js`: `LWT_DATA`.
* Word reading can be allowed on hover or on click.
Pull request [#147](https://github.com/HugoFara/lwt/pull/147) by
[@ProgramComputer](https://github.com/ProgramComputer).
* You can add a custom text reader with the new voice API feature!
A courtesy of [@ProgramComputer](https://github.com/ProgramComputer) on pull request
[#153](https://github.com/HugoFara/lwt/pull/153).
A feature first requested on [#143](https://github.com/HugoFara/lwt/issues/143).
Discussion in open on [#174](https://github.com/HugoFara/lwt/discussions/174).
* Starts a cleaner database management. Database schema is defined in `db/schema/baseline.sql` and no longer in PHP code.
* Imprtant additions to Text-To-Speech (TTS):
* Word can be read on hover or on click.
Pull request [#147](https://github.com/HugoFara/lwt/pull/147) by
[@ProgramComputer](https://github.com/ProgramComputer).
* You can add a custom text reader with the new voice API feature!
A courtesy of [@ProgramComputer](https://github.com/ProgramComputer) on pull request
[#153](https://github.com/HugoFara/lwt/pull/153).
A feature first requested on [#143](https://github.com/HugoFara/lwt/issues/143).
Discussion in open on [#174](https://github.com/HugoFara/lwt/discussions/174).
* New JS functions: `readTextWithExternal` to read a text with an external
application and `speechDispatcher` that can choose a text reader
(browser or third party).
* Starts a cleaner database management. Database schema is defined in
`db/schema/baseline.sql` and no longer in PHP code.

### Changed

Expand All @@ -41,6 +46,8 @@ Discussion in open on [#174](https://github.com/HugoFara/lwt/discussions/174).
Solves [#129](https://github.com/HugoFara/lwt/issues/129), thanks to the help of PR
[#168](https://github.com/HugoFara/lwt/pull/168).
* Text reading position was not working consistently when adding several known words.
* Japanese was always requiring MeCab for TTS, even if it was not used
([#155](https://github.com/HugoFara/lwt/pull/155)).

### Deprecated

Expand Down
14 changes: 12 additions & 2 deletions docs/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -2195,15 +2195,23 @@ <h4>Added</h4>
<code>src/js/jq_pgm.js</code>: <code>LWT_DATA</code>.</li>
</ul>
</li>
<li>Word reading can be allowed on hover or on click.
<li>Imprtant additions to Text-To-Speech (TTS):
<ul>
<li>Word can be read on hover or on click.
Pull request <a href="https://github.com/HugoFara/lwt/pull/147">#147</a> by
<a href="https://github.com/ProgramComputer">@ProgramComputer</a>.</li>
<li>You can add a custom text reader with the new voice API feature!
A courtesy of <a href="https://github.com/ProgramComputer">@ProgramComputer</a> on pull request
<a href="https://github.com/HugoFara/lwt/pull/153">#153</a>.
A feature first requested on <a href="https://github.com/HugoFara/lwt/issues/143">#143</a>.
Discussion in open on <a href="https://github.com/HugoFara/lwt/discussions/174">#174</a>.</li>
<li>Starts a cleaner database management. Database schema is defined in <code>db/schema/baseline.sql</code> and no longer in PHP code.</li>
<li>New JS functions: <code>readTextWithExternal</code> to read a text with an external
application and <code>speechDispatcher</code> that can choose a text reader
(browser or third party).</li>
</ul>
</li>
<li>Starts a cleaner database management. Database schema is defined in
<code>db/schema/baseline.sql</code> and no longer in PHP code.</li>
</ul>
<h4>Changed</h4>
<ul>
Expand All @@ -2225,6 +2233,8 @@ <h4>Fixed</h4>
Solves <a href="https://github.com/HugoFara/lwt/issues/129">#129</a>, thanks to the help of PR
<a href="https://github.com/HugoFara/lwt/pull/168">#168</a>.</li>
<li>Text reading position was not working consistently when adding several known words.</li>
<li>Japanese was always requiring MeCab for TTS, even if it was not used
(<a href="https://github.com/HugoFara/lwt/pull/155">#155</a>).</li>
</ul>
<h4>Deprecated</h4>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion edit_languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ function (translation) {
LWT_DATA.language.ttsVoiceApi = api_value;
const text = document.forms.lg_form.LgVoiceAPIDemo.value;
const lang = <?php echo json_encode($sourceLg); ?>;
readTextAloud(text, lang);
speechDispatcher(text, lang);
LWT_DATA.language.ttsVoiceApi = prevApi;
},

Expand Down
2 changes: 1 addition & 1 deletion ggl.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function translate_term($text, $file, $sl, $tl): void

$('#textToSpeech').on('click', function () {
const txt = <?php echo json_encode($text); ?>;
readTextAloud(txt, <?php echo json_encode($sl); ?>);
speechDispatcher(txt, <?php echo json_encode($sl); ?>);
});

$(document).ready(function() {
Expand Down
Loading

0 comments on commit 89b1227

Please sign in to comment.