[Qt-interest] Localization of plugins

R. Reucher rene.reucher at batcom-it.net
Mon Nov 2 13:00:24 CET 2009


On Mon, 02 Nov 2009 11:56:24 +0000, Anatoly Burakov wrote:

> R. Reucher wrote:
>> On Mon, 02 Nov 2009 11:43:40 +0000, Anatoly Burakov wrote:
>>   
>>> I have a program that has multilingual interface. It loads *.qm files
>>> perfectly. However, i can't seem to find a way for a plugin loaded by
>>> a program to load its own *.qm file. Is there any way to do that at
>>> all?
>>>     
>> I don't think there's a restriction of that sort in the plugin
>> mechanism, however, when you load the plugin, you can also load the
>> corresponding *.qm file _additionally_ -- using an additional
>> QTranslator!
>>
>>   QString lang = "de";
>>   ...
>>   myAppTranslator = new QTranslator(0);
>>   myAppTranslator->load("data/lang/myapp_") + lang + ".qm");
>>   qApp->installTranslator(myAppTranslator); ...
>>   myPluginTranslator = new QTranslator(0);
>>   myPluginTranslator->load("data/lang/plugin_") + lang + ".qm");
>>   qApp->installTranslator(myPluginTranslator); ...
>>
>> HTH, René
>>   
> I remember reading QT documentation and it said that whenever i install
> a translator it removes any previous translators... However, i'll check
> it out once again, thanks!
No. The docs say that qApp->installTranslator() _adds_ a translator... 
you can remove it explicitly, though.

See
http://qt.nokia.com/doc/4.5/qcoreapplication.html#installTranslator
http://qt.nokia.com/doc/4.5/qcoreapplication.html#removeTranslator

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



More information about the Qt-interest-old mailing list