-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for translations + French #418
base: dev
Are you sure you want to change the base?
Conversation
Looks great at the first glance, although I did not fully understand gettext... :D - Could you also look into potential support for platforms like Weblate |
Weblate is compatible with gettext (see here), but I didn't find how to import English strings in it (it may become evident with an account). |
Hey, thanks for moving forward with this! This is a very important topic! Give me some time to look into it, but at first glance it looks good :) (even though I don't link passing One major open questions with regards to translation is that the configs currently contain "hard coded" text (in English) that is displayed in the application. One way forward might be to standardize all config texts and use gettext with that 🤔 |
Yes, passing For config files, I have two ideas
|
This works like a charm! I'm really eager to get this merged and add support for more languages (and potentially integrate weblate).
|
Automation... Like automatically launch Yes, IIRC you can create several |
Yeah, automation in the sense, that xgettext is installed in the developer setup, there is documentation for it and the translation are automatically updated if the source files are changed. But that I can do. It was not a request for you, just a mental note for me :D
Oh yes, exactly like the first point of your previous message 🙈 I guess I would go that way. The other way you suggested would be cleaner and saver, but also less flexible and harder to read. 🤔 |
Actually, if source code is changed, two options :
So... It's already somewhat automated ^^ Yes, and the first point is better in case of missing translations... |
@tsterbak What are your plans for this PR? I can work on it if needed :) |
I planned to properly work on this later this year. But you can continue working on it if you have time and I'm happy to assist. |
We already started discussing of the way to do, and in case of partially translated language, I think it's better to keep plain English strings, so users will not be stuck during installation with texts like "unlock_bootloader_warning"... |
There should be a default fallback to english if no string is found. The framework should support it. We should definitely use ids like "unlock_bootloader_warning" since otherwise it will be very annoying to ever change texts and it will clutter the translation files a lot.
I agree. But replacement should be done carefully to not delete information that is in there, even if they are similar they might not always be the same. |
You're right, I will do that. |
"Classic" gettext translations do not use keys and insist on keeping the original English text. Every time the original string change, that invalidates the translations. This is totally wanted, otherwise, you may update the English strings and no translator would realize the main (English) string changed, that could lead to serious semantic bugs. The gettext translation toolchain is taken this process into account. Typically, when a string changes, the previous original string is kept in the po file so translators can compare and see what changed. From a developer point of view, the only task is to properly mark the strings for translation, and the rest is taken care of by the translation toolchain. |
This PR adds a working translation of OAI in French.
As suggested in #72, this PR use gettext for all strings (I think), except logs (and for now, config files)
The user's language is detected, and if available, the corresponding translation is used. Else, OAI is still shown in English.
All English text strings are still in the code. Translation files are bigger, but partial translations files show English version if not translated. We may also use little strings to refer to the text for all languages, including English, but a change may not automatically be reflected in others languages and the code is less legible.
To generate
.pot
file (empty template), use the following command on Linux :xgettext -d base -o locales/base.pot openandroidinstaller/*.py openandroidinstaller/views/*.py
To generate
.mo
file (binary data), use this command on the.mo
file' folder :msgfmt -o base.mo base
PS : First commit is messy and a temporary fix. We have to find a better way to handle Python versions.
EDIT : Oops, I didn't ask for the two first commits, lancelot is another PR...
Ah, it's because you pushed to main these two today... (instead of dev?)