[SailfishDevel] How to translate (lupdate) ?
Thomas Tanghus
thomas at tanghus.net
Tue Jan 14 14:15:56 UTC 2014
On Monday 13 January 2014 16:28 Timur Kristóf 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()
It does check LANG. That's how I test the translations:
$ LANG=da_DK harbour-myapp
> On Mon, Jan 13, 2014 at 1:21 PM, Thomas Tanghus <thomas at 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
More information about the Devel
mailing list