QTranslator on Android

57 views
Skip to first unread message

Marnando Júnior

unread,
Feb 27, 2014, 12:33:55 PM2/27/14
to andro...@googlegroups.com
Hi, 
I have an application that has been translated into 3 languages. After porting to Android the translations not work anymore. I did the translations using Qt Linguist, and the archives .qm has been included in .qrc.

Please, if anybody know what the problem I thanks.

Att. Marnando Júnior

PAT

unread,
Mar 6, 2014, 2:51:59 AM3/6/14
to andro...@googlegroups.com
Hey ya,
here I got a good guide.
On android, you first of all got to figure out, which language is confugured, and the you load the translation file:

    // translation
    // returns "lang_LOCAL", depending on th device config
    QString locale = QLocale::system().name();
    // if its not the default language... --> english
    if (!locale.startsWith("en_"))
    {
        qDebug()<<"LOCALE: " << locale;
        QString filename = "languages/lang_" + locale;  //e.g.: de_DE";

        static QTranslator translator;
        if (translator.load(filename, ":/") ){
            app.installTranslator(&translator);
            qDebug() << "Translation file loaded" << filename;
        } else {
            qWarning() << "Translation file not loaded:" << filename;
            qWarning() << "Language " << locale << " not supported yet";
        }
    }

Just look at the ling. It is all written down there. 

Marnando Júnior

unread,
Mar 17, 2014, 7:55:13 AM3/17/14
to andro...@googlegroups.com
Thanks, I'll try to make changes in the code, you will return the result.
Reply all
Reply to author
Forward
0 new messages