Important: Please read the Qt Code of Conduct -

Changing Translator source text affects all translation files

  • Hi there,

    I’m developing an application that needs to be translated to different languages, so I started using the translator syntax tr(“source text”); and that works pretty good translating to all languages. The problem that I see is when the “source text” needs to be changed, because all translations are referenced to this “source text” and this reference will not exist anymore.

    For example:
    I have a button with the German text “Schließen” and it has been translated into English “Close” and Spanish “Cerrar”. Then it was decided that the source text in German should be changed to “Beenden” but the English and Spanish text stay the same. After this change, loading the translations (English or Spanish) will fail to translate this button because its reference doesn’t exist and the changed text needs to be translated again in all languages…

    I am thinking about using keywords as source text, for example tr(“STR_CLOSE”); so that single changes are done directly in the .ts file and not in my code, and all the translations are referenced to this keywords that doesn’t need to be changed. But since I don’t have much experience with translations I am asking for some advice.


  • Moderators

    The general advice is to always write all the strings in the source code in English.

    As for your case: this is understood. The translation system has no way of knowing that "Schliessen" and "Beenden" mean the same thing, so it treats it as a complete change. There is not really any way around this, with the exception of translating the software after it is released/ string frozen (then you can be certain that the string will not change).

    Your idea with keywords is valid, but seems like too much work. And it would make the job of translation team much harder (right now they can simply translate what they see into their language. With keywords, they would first need to check what does the keyword mean, and then translate that).

  • Thanks for your reply

    I will follow your advice and keep all sources in English. Assuming that in most of the cases a change in source code also implies a change in other languages the the use of keywords doesn't bring much advantage...

Log in to reply