-
Bug
-
Resolution: Unresolved
-
P2: Important
-
6.9.2
-
None
While it is possible to install various QTranslator via QCoreApplication::installTranslator() there is currently no interface to retrieve whatever languages are installed and, especially, which one is currently used.
QCoreApplication::translate() queries all installed QTranslator starting with the most recent one added and returns the first successful translation.
Furthermore the UI language may be set freely using Qt.uiLanguage which is a wrapper for QJSEngine::uiLanguage(). By default it will have the value of QLocale().bcp47Name().
The attached MWE loads different translations via QCoreApplication::installTranslator() and allows to set Qt.uiLanguage directly in the QML UI. If doing so and enabling the logging category qt.core.qtranslator one can see that the logic from QQmlApplicationEnginePrivate::_q_loadTranslations() tries to load the translation for the new language too.
Strangely enough it searches for an unexpected file in an unexpected location (at least from my expections):
qt.core.qtranslator: Searching translation for qml_QLocale(French, Latin, France).qm in :/qt/qml/mweUiLanguageVsInstallTranslator/i18n qt.core.qtranslator: Requested UI languages QList("fr_Latn_FR", "fr_FR", "fr_Latn", "fr") qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_fr_Latn_FR.qm" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_fr_Latn_FR" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_fr_latn_fr.qm" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_fr_latn_fr" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_fr_FR.qm" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_fr_FR" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_fr_fr.qm" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_fr_fr" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_fr_Latn.qm" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_fr_Latn" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_fr_latn.qm" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_fr_latn" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_fr.qm" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_fr" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml.qm" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml_" false qt.core.qtranslator: Testing file ":/qt/qml/mweUiLanguageVsInstallTranslator/i18n/qml" false
I'm not quite sure as to what this tries to achieve and how users would provide these files.
Are these "qml internal" translations? if so why are the searched in "my" applications subdirectory?
Bottom line:
- There should be an interface to get the most likely UI language (last QTranslator installed).
- How do we want to handle the syncing between that interface and Qt.uiLanguage?