Important: Please read the Qt Code of Conduct -

Providing a no-op translation for QTranslator

  • What is the right way to provide a "no-op" QTranslator translation where all the UI strings are left as their original native language phrases?

    The scenario is this: QTermWidget is written in English and uses QTranslator and tr() for localization. It has *.qm translation files for fr, de, and other languages, but not one for English.

    The issue is that on a computer where English is the primary language, but it also has additional preferred languages defined where QTermWidget has a translation available (such as French), QTranslator seems to be picking up that translation and using it, instead of leaving the phrases untranslated, so the UI phrases are in the wrong language for the user's config.


    It seems we need to provide a no-op English en translation to prevent this from happening.

    What's the Right Way to do this? Can we provide an empty .ts file for en? Just copy the input qtermwidget.ts to qtermwidget_en.ts and leave all the <translation>s as "unfinished"? Manually fill them all out with the same strings as the original?

    Related: (maybe)

  • Lifetime Qt Champion

    I'm using an empty .ts file for this. Just copy another ts file, remove all inside <context>...</context> and change the language.

Log in to reply