Switching languages
-
When the user selects that they wish to change languages, should I do this:
qApp->removeTranslator(&theAppTranslator); // // Install the language if it actually exists. // if (theAppTranslator.load("DSS." + language, ":/i18n/")) { qApp->installTranslator(&theAppTranslator); }
or should I not call removeTranslator()?
Thanks
David -
Hi,
That's really up to you. You have a description of the use of multiple translation in the class documentation. See if it applies to your use case.
-
Let me seek clarification then - when and why would I wish to remove the previous translator, and when and why would I choose NOT to do so?
AFAICT, not calling remove means that multiple languages will be installed in the translator but only the latest one loaded will be used? Is that so?
Thanks
D. -
@Perdrix said in Switching languages:
will be installed in the translator but only the latest one loaded will be used? Is that so?
No, the translators are traversed - if it's not found in the first one the next will be used.
-
@Perdrix said in Switching languages:
I was working on the assumption that the translation files were complete so the answer would always be found in the first one
Why should be all translations in one translation file? Or do you translate e.g. the Qt internal messages in your translation file?
You can load more than one translation file.