[Interest] Dynamic translations for mobile apps at runtime?

Jason H jhihn at gmx.com
Fri Mar 11 17:17:00 CET 2016


Ooops. I concretely missed the `virtual`.


> Sent: Friday, March 11, 2016 at 11:15 AM
> From: "Julien Cugnière" <julien.cugniere at gmail.com>
> To: "Jason H" <jhihn at gmx.com>
> Cc: "interest at qt-project.org Interest" <interest at qt-project.org>
> Subject: Re: [Interest] Dynamic translations for mobile apps at runtime?
>
> QTranslator::translate is virtual. Its documentation even says "If you
> need to programatically insert translations into a QTranslator, this
> function can be reimplemented." :-)
> 
> So you can create a QTranslator based class that returns translations
> from your own list if the QM file found nothing.
> Julien Cugnière
> 
> 
> 2016-03-11 17:08 GMT+01:00 Jason H <jhihn at gmx.com>:
> > So we had a great thread about "dynamic translations" Its in and working well. (Thanks everyone)
> >
> > And while I have a slick update procedure for adding dictionaries at run time, I am wondering about adding translation strings at runtime?
> >
> > Here's what's happening:
> > - App is in a language (Now, can be more than English)
> > - User logs in, the user has a language on their profile
> > - That profile is selected on the UI
> > - The server sends content in that language (JSON)
> >
> > The reason for this is some of the content is user-configurable, and as a result, the server has it's own internal translation tables. Currently, I can toggle the UI language, but the server delivered content stays the same. It would be nice if I could retranslate both. However the lupdate/lrelease workflow won't work someone suggested using localise.biz, but then we have to coordinate the strings, and we want to have the web UI without dependencies. My backend team won't be happy, but we (really just me) . I could then:
> > My options are:
> > a. could write a binary for direct DB tables-to-QM file translation, load the server translations into a QTranslator and have it just work,
> > or
> > b. use some QTranslator API to dynamically add translations at runtime.
> >
> > Both don't seem possible as there is no non-private API to write QM files, and there is no API to alter the QTranslator.
> >
> > I'm hoping maybe the QM file format is just some kind of QMap?
> >
> >
> >
> >
> > _______________________________________________
> > Interest mailing list
> > Interest at qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/interest
>



More information about the Interest mailing list