[Interest] Dynamic translations for mobile apps at runtime?
Jérôme Godbout
jerome at bodycad.com
Thu Mar 3 21:41:26 CET 2016
Nice, I didn't knew about "-tr-function-alias", indeed this seem like the
right thing to do. Will try this out. About speed, for the number of time
you use the change language during runtime, it doesn't really matter, if it
take a few ms more.
Thanks for the tips!
On Thu, Mar 3, 2016 at 2:37 PM, Julien Cugnière <julien.cugniere at gmail.com>
wrote:
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160303/700091d5/attachment.html>
More information about the Interest
mailing list