[Qt-interest] Translation of text taken from db

R. Reucher rene.reucher at batcom-it.net
Wed Oct 28 12:43:07 CET 2009


On Wed, 28 Oct 2009 12:25:35 +0200, Ender EREL wrote:

> Hi folks,
> 
> My situation is this: I have a database containing the names of certain
> criteria, which have identifier strings. What i want to achieve is when
> i take these identifiers from db, i want to translate them using
> QTranslator. But since these strings appear nowhere in the code, they
> don't come up when i run lupdate. I want to put those strings
> out-of-context in the translation file and when they are recieved from
> Db, translate them using QObject::tr().
> 
> Is there a way to achieve this?
Not really. All translations need to be part of a .qm file and be loaded 
& installed through QTranslator / QCoreApplication::installTranslator().

How should Qt now about the possible translation(s) beforehand? So, there 
must be some sort of a translation source anyway, which in your case 
could/should be the DB itself. Simply extend the data model and store 
translated versions of the texts in a "translation table". Then, query 
and present that.

HTH, René
-- 
René Reucher
rene.reucher at batcom-it.net
http://www.batcom-it.net/




More information about the Qt-interest-old mailing list