Ask / Submit
0

QLocale::system().name() does not return language nor country code

asked 2014-03-25 20:29:43 +0300

ISU gravatar image

I have tried to get the localization to work on my application. For some reason I cannot get QLocale::system().name() to return correct language nor country code. When I write "locale" in terminal of my Jolla phone it returns "LANG=fi_FI.utf8". However, my application gets only an empty string "".

I am aware of the this hack https://together.jolla.com/question/11041/bug-qlocalesystem-returns-incorrect-locale-while-run-in-debugger/ but I don't think that this should be a problem since mr. iiska stated that he has been able to run his code on the device correctly which I have not accomplished.

However, Aequanix is having same kind of issue when he/she is using SSH to find out the locale. https://together.jolla.com/question/31538/ssh-locale/

So far I have tried following code examples for implementing the translations/localizations: https://lists.sailfishos.org/pipermail/devel/2014-January/002630.html https://gitorious.org/xbmcremote/robertme-xbmcremote/source/428ccd127e0c86850650df4b1787b108588c3595:apps/sailfish/src/main.cpp#L42 http://qt-project.org/doc/qt-5/linguist-programmers.html and by studying code of KitchenTimer and friends -applications without any luck. Could some please advice? Is this a specific issue related to my phone or general issue? (I am running OS version 1.0.4.20)

edit retag flag offensive close delete

Comments

To make sure, is this with application started from the device? I.e. clicking icon on the application grid.

Pekka Vuorela ( 2014-03-26 15:49:16 +0300 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2014-03-26 20:50:34 +0300

ISU gravatar image

I think I found the culprit. I started a new project from scratch, created a C++ class with QObject and added method to return QLocale::system().name() to a text-field on a QML-page and it worked. After this it was relatively easy to debug the QTranslator.load() call and it seems that there was some confusion with the file location (folder) and .qm file naming.

However, my initial application still doesn't return the locale correctly when used "nearly" same kind of way. Luckily I was able to use the debugged QTranslator call and got the translations working so it doesn't matter to me any longer.

Hopefully, the Qt Creator debug mode is soon patched. It would have made this exercise faster. :)

edit flag offensive delete publish link more
Login/Signup to Answer

Question tools

Follow
1 follower

Stats

Asked: 2014-03-25 20:29:43 +0300

Seen: 675 times

Last updated: Mar 26 '14