Several translation languages in same time
-
Hi,
By using the qsTr/qsTranslate... is it possible to specify which language to use ?
I would like to be able to load several translations files, like French, Spanish, Chinese and display in same time the three translations.Here is an idea of what I'm expecting...
For the loader, we charge 3 languages Fr/Cn/Es
@
QTranslator qt( 0 );
qt.load( QString( "qml/i18n/lang_fr.qm" ), "." );
app->installTranslator( &qt );
qt.load( QString( "qml/i18n/lang_cn.qm" ), "." );
app->installTranslator( &qt );
qt.load( QString( "qml/i18n/lang_es.qm" ), "." );
app->installTranslator( &qt );
@For the implementation in QML (but it can be in C++ also)
@
Text {
text: {
var res = "";
res += "FR:" + qsTr("fr", "hello") + "\n";
res += "ES:" + qsTr("es", "hello") + "\n";
res += "CN:" + qsTr("cn", "hello") + "\n";
res += "DE:" + qsTr("de", "hello") + "\n"; // <-- this one would return "hello" as the language "de" is not loaded.return res; } }
@
Thanks for your comments.
Best regards.
Nouch. -
No, this doesn't work. Qt only supports one translation at a time.
-
Hi,
Thanks for the reply.
I will try in that case to make it with some temporary containers and playing with the load/unload of the languages...I'l keep update the thread if I have a good solution.
Best regards,
Nouch.