HugoFara / lwt

Learn languages by reading! A language learning app stemmed from Learning with Texts (LWT).
https://hugofara.github.io/lwt/
The Unlicense
168 stars 19 forks source link

TTS and unrecognized language names #113

Closed HenryWales closed 8 months ago

HenryWales commented 1 year ago

In the original LWT, apart from populating initial fields on creation the name of a language didn't matter.

Here, it is used to convert into language-code for text-to-speech.

This mean that an unrecognized language name displays an error message on every single text.

Warning: Undefined array key "<Language>" in C:\xampp\htdocs\lwt\do_text_header.php on line 181

Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\lwt\do_text_header.php on line 181

I propose that instead of doing the conversion every time, the language-code is added as a field when creating or editing a language. This allows the use of native language names instead of the english names without breaking TTS or displaying errors at the top of each text.

HugoFara commented 1 year ago

Thanks for the bug report! Languages names are currently a limitation of this version of LWT. As I tried to get rid of this kind of issue, I built robust tool for detecting a language in 2.8, so I will try to fix everything with 2.9!

In the meantime, the simplest solution is to keep unmodified language names...

I already though of a language code system, but as explained in #86 , new features should go to jzohrab/lute, the current purpose of this project is too maintain backward compatibility more than anything...

HugoFara commented 8 months ago

The issue is fixed, I changed the way things work.

Before: use language name → search in languages array

After: use languages id → get language name + translator URI → search in languages array with name. → if not found, use translator URI.

It won't work still if you change language name AND use an unknown translator URL. In this last case I will try to look for a small review of the text-to-speech feature.

At any rates, the warnings won't show whatever happens!