View Single Post
Posts: 339 | Thanked: 1,623 times | Joined on Oct 2013 @ France
#10
Originally Posted by anig View Post
Since this is the first time I've used translation I didn't realise that when a translation language doesn't exit it only shows the id. How can I have the source language showing instead?
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 http://doc.qt.io/archives/qt-4.8/qtr...or.html#load-2), 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 http://doc.qt.io/archives/qt-4.8/qlo...ml#uiLanguages) 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:
If the file name does not exist, other file names are tried in the following order:
File name without suffix appended.
File name with ui language part after a "_" character stripped and suffix.
File name with ui language part stripped without suffix appended.
File name with ui language part stripped further, etc.
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.
 

The Following 8 Users Say Thank You to Zeta For This Useful Post: