In my application I am using just: QString locale = QLocale::system().name(); QTranslator translator; if (translator.load(QString("i18n:quandoparte_") + locale)) { qDebug() << "Translation for locale" << locale << "loaded"; a->installTranslator(&translator); } else { qDebug() << "Translation for locale" << locale << "not found"; }
Why do I need to check the environment? Isn't QLocale::system() using it behind the scenes anyway? Thank you, Luciano On Mon, Jan 13, 2014 at 4:28 PM, Timur Kristóf <timur.kris...@gmail.com> wrote: > Not sure what you mean by "already performs all the checks you do" - it > doesn't check LANG, nor does it check QLocale::system().name() > > > Timur > > > > On Mon, Jan 13, 2014 at 1:21 PM, Thomas Tanghus <tho...@tanghus.net> wrote: >> >> On Monday 13 January 2014 12:52 Timur Kristóf wrote: >> > Here is how I do it: >> > >> > 1. Check the LANG environment variable >> > 2. Check QLocale::system().name() >> > >> > Take a look at the code here: >> > https://github.com/Venemo/puzzle-master/blob/master/helpers/util.cpp#L24 >> >> QTranslator::load()[1] already performs all the checks you do, so is there >> really a need to do more than this? >> >> QTranslator* translator = new QTranslator; >> QString locale = QLocale::system().name(); >> if(!translator->load(SailfishApp::pathTo("translations").toLocalFile() >> + "/" + locale + ".qm")) { >> qDebug() << "Couldn't load translation"; >> } >> >> [1] http://qt-project.org/doc/qt-5.0/qtcore/qtranslator.html#load >> >> -- >> Med venlig hilsen / Best Regards >> >> Thomas Tanghus >> _______________________________________________ >> SailfishOS.org Devel mailing list > > > > _______________________________________________ > SailfishOS.org Devel mailing list -- Luciano Montanaro Anyone who is capable of getting themselves made President should on no account be allowed to do the job. -- Douglas Adams _______________________________________________ SailfishOS.org Devel mailing list