Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Translations of Qt-provided texts in the wrong language
Qt 6.11 is out! See what's new in the release blog

Translations of Qt-provided texts in the wrong language

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    milgner
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      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.

      Greetz, Jeroen

      1 Reply Last reply
      0
      • M Offline
        M Offline
        milgner
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved