Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe the changes
Currently the translation files for the backend are missing and the translation for the WebUI isn't working. This PR creates a demo for translating the UI, to have a base for discussing further development. It also addresses issue: #3725
First the easy one: Issue #3725: The traceback is thrown because there are no locale files for "en", but this will also never happen, so I added a
if lang == "en":
do not output traceback expression.Next one: The webserver is initialized in __init__() function, so self._ is not a valid function, therefore the "starting webserver" message is never outputted translated, as it's the only string in webserver thread to translate, I removed the corresponding function.
I added demo files for the german translation (only a few strings are translated, as demo). The mechanism for doing the WebUI translation is setting the default locale to the choosen language, so a language change requires a restart of pyload-ng.
The code conflicts a bit with the path_prefix change, I hope you can manage this for getting a basic impression.
Now my questions:
The implementation now uses 2 language files for backend (pyload.mo) and frontend (message.mo), shall we change it to one file, or leave it seperate?
How do you plan to generate the language files (looks like apart from documentation it should be babel), then it would be better to have one language file (.mo) where both (back- and frontend) take their translations from?
Do you want to use crowdin for doing the translation work?
Is it okay to have the language change valid after reboot (changing this would create bigger impact, as I can oversee it now)?
Adding translated languages to pyload-ng currently requires a manual edit of pyload.cfg file, shall this be also the future way?
Is this related to a problem?
Translation of UI is currently not working
Additional references