Thread Tools
Posts: 79 | Thanked: 137 times | Joined on Jan 2012
Originally Posted by Zeta View Post
I took a look at your code and discovered the qsTrId() function you used.

I usually use qsTr(), where you put for example directly the english text, and then it search for translations and if there is none then fallback to this english text.

But qsTrId() is different in that it works with an id to the translated text. I can see how that could be more efficient depending on the magic they put behind the qsTr() function, but means you must somehow define a default language as a fallback.
That is not too difficult from C++ (see, as the "load" function returns a boolean to tell if the locale was correctly found or not, and then loading the english could be done.
For the translations, the QLocal class provides uiLanguages (the function which "returns an ordered list of locale names for translation purposes in preference order". There may be a way to add the english language as a low rank choice in there...

Finally, back to the load() function from QTranslator that must be used under the hood in the QML launcher, we see the logic for finding the translations files:

So maybe renaming/symlinking/copying the english translation file as "kids-mode.ts" should be enough. I see this file is already there in your repo, but with "<translation type="unfinished"></translation>" everywhere, which I suppose would not be displayed.
Thanks as per the sourcecode of sailfish the load function is used.
So in theory it should work. However it doesn't in practice. In the end I removed the language tag in kids-mode.ts and left everything untranslated. I then genereated the qm using:
lrelease -idbased -markuntranslated "" kids-mode.ts

Finally in the spec file I check the locale and if the translation file doesn't exist then I create the symlink.

Thanks for the advice.

The Following 2 Users Say Thank You to anig For This Useful Post:

Thread Tools

Forum Jump

All times are GMT. The time now is 09:01.