[Interest] Dynamic translations for mobile apps at runtime?
Julien Cugnière
julien.cugniere at gmail.com
Thu Mar 3 20:37:49 CET 2016
2016-03-03 18:50 GMT+01:00 Jérôme Godbout <jerome at bodycad.com>:
> We did the same thing into Qml, we have a C++ singleton equivalent to your
> backend, that select the current language files and emit the QString
> property changed.
> qsTr("String to convert") + I18n.revaluate
>
> I wish they made underlying hook to revaluate the qsTr() with a signal
> connected like if the qsTr() have changed. This pollute the code all over,
> only to be able to swap language on the fly.
Just an idea : you might be able to hide that I18n.revaluate with
something along the lines of :
function myTr(s) {
return qsTr(s) + I18n.revaluate;
}
Text {
text: myTr("String to convert")
}
Then you need to get lupdate to understand "myTr", which can be done
with the command line option "-tr-function-alias qsTr=myTr".
Although this incurs the overhead of a function call, which might
prevent QML from using its fast path for bindings evaluation. Not sure
if it matters.
Julien Cugnière
More information about the Interest
mailing list