Important: Please read the Qt Code of Conduct -

QT Translate on Android

  • Hi,

    I have an app running on Mac Desktop, Windows Desktop, IPhone and Andrioid. And the translation feature works well for the three first mentioned, but on Andriod only the default translation works.

    I can see that I got the expected language-code on all four platforms (sv_SE) but still the translation fails on Andriod. Any idea why? Is it a known problem?


  • Hi,

    I am using QTranslate in my Android app and it works perfectly. Do you load and install translation before you load your view?
    In my QML app I needed to load translation before loading main.qml file.

    BTW its Qt not QT(QuickTime)

  • Thank you for rapid answer!

    I load the translation (from a resource file) the first thing in my main C++ app (before loading main.qml)

    / Hakan

  • So are you sure the file exists(the one with translation)? Can you check it @QFile::exists()@

    Are you installing translator properly?

  • Hi,

    I currently don't use Qlocale::setDefault() but still the translation works for Mac, Windows and IOS


  • can you check if the file with translations exists? using QFile::exists()?

  • Absolutely. I do it later tonight. But it exist on Mac, Windows and IOS!



  • Meanwhile ...

    My code in main looks like this;

    QTranslator translator;
    if(translator.load(":/xxx.qm") != 1) { ...}

    And my resource file like this:

    <file alias="xxx.qm">tr/xxx_en.qm</file>
    <qresource lang="sv">
    <file alias="xxx.qm">tr/xxx_sv.qm</file>
    <qresource lang="de">
    <file alias="xxx.qm">tr/xxx_de.qm</file>


  • QFile.exists() returns OK! And I think that translator.load() returns error if the given file/resource don't exist

    / Hakan

  • did you check if the language detection works on android?
    e.g. with
    if not your have to set it manually like kolegs said, also you should try and set the file manually and see if that works on android first.

  • Yes the language detection works fine also on andriod

    / Hakan

  • Which Qt version do you use? There seems a buf in Qt 5.1 that may affect you (prevents to find the correct locale), see QTBUG-31651; referenced in

Log in to reply