Translations of Qt-provided texts in the wrong language



  • Hi all,

    I have added some translations to my app like so:

    @
    auto mainAppTranslator = new QTranslator(this);
    mainAppTranslator->load(QLocale::system(), "app", "_", ":/app", ".qm");
    installTranslator(mainAppTranslator);
    @

    Now, when switching between languages, the app correctly displays texts translated by qtTrId().
    But any string coming from Qt itself remains in english. For example when using QMessageBox::question it will show "Yes" and "No" buttons instead of the german equivalents "Ja" and "Nein".

    More interestingly, it's the other way around in the Qt-developer tools: Qt Assistant will always show a german UI even if my display language is set to english and the rest of the system correctly shows english translations.

    Any ideas would be much appreciated. It should be noted that even when my system display language is set to english, the currency and date format are set to german.
    But nonetheless: all the translations I do myself using qtTrId() are correct.

    All the best
    Marcus



  • Hi,
    All messageboxes etc have translatable bit to indicate the translation should be made for the given object.
    Also in your code to have the QString translatable you must place the string into the tr() function. This tr() function sets the QSTring up for translation.
    Also, a changeEvent needs to be code to retranslate all element when language is switched. (try a simple QtDesigner form with a QLabel and check out the given ui_xx.h file. At the bottom there is a ui->retranslate function).
    Hope this gives some idea.



  • Hi,

    thanks for the answer. But as I wrote, the translations I do myself are already working as expected.
    I only wonder what I would need to do to make QMessageBox translate the button texts. The documentation for QMessageBox says nothing about a translatable bit and I also checked everything around the QMessageBox::StandardButton enum, without coming across any mention about translating their text representation.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.