-
Notifications
You must be signed in to change notification settings - Fork 262
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
imagewriter: Use QCoreApplication::translate #805
Conversation
tr() is not safe for strings that you move between contexts, as it fails to provide a mechanism for specifying the context of the string. Regenerate the translation files, and use QCoreApplication to locate the real translations. Additionally, bodge a race condition between translator replacement and OS list fetching, by marking the OS list as something to be re-calculated on a translator change. Fixes raspberrypi#799
Apologies if this is a stupid question, but how do you identify which strings "you move between contexts" ? (and therefore where you need to use |
Unfortunately as I've mentioned the tooling doesn't help here. It's down to the individual developer to notice they are moving a translatable string, and annotate the new location with the previous context. |
Ahhh, I misunderstood - I thought you were talking about the strings moving between different contexts at runtime, rather than simply the translatable strings being moved to a different "context" (i.e. file) in the source-code 🙂 |
Were it so simple! Contexts are logical units inside the source tree - typically tied to a QObject name, but I can't see any reason you couldn't have arbitrary ones. Moving things to arbitrary named contexts might prove more durable longer-term. |
I guess that would also allow you to re-organise the translatable strings into groupings that make more (logical) sense for the people doing the translations, rather than simply being grouped depending on where those strings appear in the source code? Does the qml-side of this whole translation-shenanigans also allow the use of arbitrary named contexts? |
Yes, that's one of the advantages I can see. qml does offer a similar context-selecting translation function: https://doc.qt.io/qt-6/qml-qtqml-qt.html#qsTranslate-method |
tr() is not safe for strings that you move between contexts, as it fails to provide a mechanism for specifying the context of the string.
Regenerate the translation files, and use QCoreApplication to locate the real translations.
Additionally, bodge a race condition between translator replacement and OS list fetching, by marking the OS list as something to be re-calculated on a translator change.
Fixes #799