Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.7.1
-
None
Description
Under Windows OS(Under MacOS it works well) QML dialog standard buttons like 'OK', 'Cancel' etc are not retlanslated after the new language is chosen. Below is the minimal reproducable example:
Qml part with the combo box with 2 languages:
import QtQuick import QtQuick.Controls Window { width: 400 height: 400 visible: true Dialog { id: dialog width: 300 height: 300 anchors.centerIn: parent visible: true contentItem: Item { ComboBox { anchors.centerIn: parent model: ["ru", "en"] onCurrentTextChanged: { translator.setLanguage(currentText) } } } standardButtons: Dialog.Ok | Dialog.Cancel | Dialog.Apply } }
and the cpp part with the translation logic:
void Translator::setLanguage(const QString& languageCode) { const auto qtTrDir = QLibraryInfo::path(QLibraryInfo::TranslationsPath); const auto wasEmpty = qtTranslator_.isEmpty(); assert(qtTranslator_.load(QString\{"qt_%1.qm"}.arg(languageCode), qtTrDir)); if (wasEmpty) { assert(QCoreApplication::installTranslator(&qtTranslator_)); } engine_->retranslate(); }
Full code in the attached archive