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 <jh...@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@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to