<div dir="ltr"><div>Here is how I do it:<br><br></div><div>1. Check the LANG environment variable<br></div><div>2. Check QLocale::system().name()<br></div><div><br>Take a look at the code here:<br><a href="https://github.com/Venemo/puzzle-master/blob/master/helpers/util.cpp#L24">https://github.com/Venemo/puzzle-master/blob/master/helpers/util.cpp#L24</a><br>
<br></div>Cheers,<br>Timur<br></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><br>Timur<br><br></div></div>
<br><br><div class="gmail_quote">On Mon, Jan 13, 2014 at 11:16 AM, Oleksii Serdiuk <span dir="ltr"><<a href="mailto:contacts@oleksii.name" target="_blank">contacts@oleksii.name</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Here's alternative and faster approach to setting LC_ALL.<br>
<br>
I use QLocale().name() to get current locale code. This creates<br>
QLocale instance which equals to QLocale::system() by default, but can<br>
be changed by calling QLocale::setDefault().<br>
<br>
Then, when I want to test another language, I just put<br>
<br>
  QLocale::setDefault(QLocale(QLocale::Ukrainian, QLocale::Ukraine));<br>
<br>
somewhere before language loading code. Works like a charm.<br>
<div class="im"><br>
<br>
On 13/01/14 02:35, Antoine Reversat wrote:<br>
> When running from Qt Creator the locale is always C, when clicking<br>
> the app button on the emulator then the locale is right. I also run<br>
> my app from the emulator through ssh with something like :<br>
> LC_ALL="fr_FR.UTF-8" my_app to test different locales.<br>
><br>
><br>
> On Sun, Jan 12, 2014 at 12:20 PM, Unai IRIGOYEN<br>
</div><div class="im">> <<a href="mailto:u.irigoyen@gmail.com">u.irigoyen@gmail.com</a> <mailto:<a href="mailto:u.irigoyen@gmail.com">u.irigoyen@gmail.com</a>>> wrote:<br>
><br>
> Ok, I'm replying to myself here and for reference in case someone<br>
> else is disappointed. I launched the app from Jolla's app menu and<br>
> found out it was translated so in fact this only happens when<br>
> running from QtCreator. --<br>
><br>
> Unai IRIGOYEN<br>
><br>
> Le dimanche 12 janvier 2014 17:54:50, vous avez écrit :<br>
>> I followed those steps to try to fix my app translations but<br>
>> QLocale::system() still returns "C". Am I the only one in this<br>
>> case? I'm running my app on Jolla so it's not a problem with<br>
>> emulator.<br>
>><br>
>>> you can use any /usr/share/appname location. use qm file with<br>
>>> QTranslator and install translator to QGuiApplication<br>
>>><br>
>>> qsTr is enough<br>
>>><br>
>>> you can use LC_ALL<br>
>>><br>
>>> On 03.01.2014 02:26, Franck Routier (perso) wrote:<br>
</div><div><div class="h5">> Ok, now I have .ts file, I did translate the strings, and<br>
>> produced the<br>
> .qm file.<br>
><br>
> So my next questions are: 1) how do I include the qm file in the<br>
> rpm ? Should I put it in a specific directory, or directly in<br>
> /usr/share/MyApp ?<br>
><br>
> 2) is there something special I need to do in my app to<br>
>> trigger the<br>
> magic, or is using qsTr() in the qml files sufficient to to<br>
>> make it<br>
> happen ?<br>
><br>
> 3) Is there a way I can test if it is working from within the<br>
>> SDK (I<br>
> did not receive my device yet...) ? Should I ssh into the<br>
>> emulator and<br>
> play with LC_ALL, or is there another way ?<br>
><br>
> Thanks in advance,<br>
><br>
> Franck<br>
><br>
> Le 02/01/2014 21:02, Andrey Kozhevnikov a écrit :<br>
>>>>>> for directly use lupdare/lrelease you need to chroot to<br>
>>>>>> target (inside VM):<br>
>>>>>><br>
>>>>>> sb2 -t SailfishOS-armv7hl -s sdk-install<br>
>>>>>><br>
>>>>>> On 03.01.2014 02:00, Franck Routier (perso) wrote: I<br>
>>>>>> finally used the lupdate binary found in the Harmattan<br>
>>>>>> SDK somewhere on my<br>
>> hard<br>
>>>>>> disk.<br>
>>>>>><br>
>>>>>> Also, to make it process qml files, I used this trick<br>
>>>>>><br>
>> (<a href="https://developer.nokia.com/Community/Wiki/Lupdate_with_qml_files" target="_blank">https://developer.nokia.com/Community/Wiki/Lupdate_with_qml_files</a>),<br>
><br>
>><br>
> which consists in listing the qml files this way in the .pro file:<br>
>>>>>> evil_hack_to_fool_lupdate { SOURCES += \ qml/Splash.qml<br>
>>>>>> \ qml/Login.qml \ ... }<br>
>>>>>><br>
>>>>>> Notice that running lupdate with a ts.list file as<br>
>>>>>> Andrey suggested failed with a message telling me the<br>
>>>>>> files had a "no recognized extension."<br>
>>>>>><br>
>>>>>> Ok, this did the trick for now, but I'm still wondering<br>
>>>>>> how this is supposed to work from within the SailfishOS<br>
>>>>>> SDK...<br>
>>>>>><br>
>>>>>> Best regards,<br>
>>>>>><br>
>>>>>> Franck<br>
>>>>>><br>
>>>>>> Le 02/01/2014 19:11, Andrey Kozhevnikov a écrit :<br>
>>>>>>>>> i'm always using self-created ts.list text file<br>
>>>>>>>>> with list of paths to files contains strings<br>
>>>>>>>>><br>
>>>>>>>>> and my lupdate syntax:<br>
>>>>>>>>><br>
>>>>>>>>> lupdate -verbose -ts languages/en_US.ts @ts.list<br>
>>>>>>>>><br>
>>>>>>>>> On 02.01.2014 23:44, Franck Routier (perso) wrote:<br>
>>>>>>>>>> Le 02/01/2014 18:37, Andrey Kozhevnikov a écrit<br>
>>>>>>>>>> :<br>
>>>>>>>>>>> its inside build machine. qmake will run<br>
>>>>>>>>>>> lupdate/lrelease from internal path.<br>
>>>>>>>>>><br>
>>>>>>>>>> Ok, I understand. So I have to start the MerSDK<br>
>>>>>>>>>> virtual machine for lupdate to work.<br>
>>>>>>>>>><br>
>>>>>>>>>> Then, shouldn't it generate some .ts file in my<br>
>>>>>>>>>> project ? (its the first time I use QT Linguist,<br>
>>>>>>>>>> still learning, thanks for your patience)<br>
>>>>>>>>>><br>
>>>>>>>>>><br>
>>>>>>>>>> Regards, Franck<br>
>>>>>>>>>> _______________________________________________<br>
>>>>>>>>>> SailfishOS.org Devel mailing list<br>
>>>>>>>>><br>
>>>>>>>>> _______________________________________________<br>
>>>>>>>>> SailfishOS.org Devel mailing list<br>
>>>>>>><br>
>>>>>>> _______________________________________________<br>
>>>>>>> SailfishOS.org Devel mailing list<br>
>>>>>><br>
>>>>>> _______________________________________________<br>
>>>>>> SailfishOS.org Devel mailing list<br>
><br>
>>>> _______________________________________________<br>
>>>> SailfishOS.org Devel mailing list<br>
>>><br>
>>> _______________________________________________ SailfishOS.org<br>
>>> Devel mailing list<br>
> _______________________________________________ SailfishOS.org<br>
> Devel mailing list<br>
><br>
><br>
><br>
><br>
> _______________________________________________ SailfishOS.org<br>
> Devel mailing list<br>
><br>
<br>
--<br>
</div></div>With best regards,<br>
Olekii Serdiuk<br>
<br>
<br>_______________________________________________<br>
SailfishOS.org Devel mailing list<br></blockquote></div><br></div>