Details
-
User Story
-
Resolution: Unresolved
-
P3: Somewhat important
-
6.0
Description
Since 5.10, Qt provides QQmlEngine::retranslate(). This helps to switch the UI to a new language in the app w/o restarting the app, for example switching from English to German in the UI.
Still, quite some additional code is required to get this done:
- the language code should be attached to a base name of the compiled language (qm) files
- Most probably, the locale should be switched to match the new language
- Ideally, the same module should provide a list of available languages to the UI which then can be directly used in settings of the app.
One of the projects in Qt has already implemented this as a QML plugin and used this system in a reference UI:
https://code.qt.io/cgit/qt-apps/neptune3-ui.git/tree/plugins/translation
After an initial review, it was seen as impossible to add this functionality a new generic API, since it would lead to a dependency on QtCoreApplication. Plus, retranslate() is an expensive operation leading to reevaluation of all bindings.
Since this code remains the same in any app and would be needed in basically any Qt Quick app which provides UI in multiple languages, it might make sense to provide this functionality as an additional module Qt Declatative or Qt Quick.