I have the problem for my application Opale, which used to be KDE only and is now both Qt and KDE.
The first thing I’ve done is to switch from *.po (gettext) to *.ts (qt), because Qt can not (or can it ? tell me how !) handle gettext files. Then, I needed to use qApp->addTranslator() to load the Qt translation files (the *.qm generated from *.ts). So far it’s easy.
But then I had a problem : if I start the application, the strings from KDE are not translated. Especially the menu entries created using KStandardAction::*. The reason is that the application does not load any *.mo, and this is what triggers the loading of KDE messages.
The solution is to give “kdeinit4″ as second argument to KAboutData::KAboutData() instead of 0 as is usually done. Instead of trying to load your application translation, fail, and finally not load anything at all, it will load the ones for KDE directly. And you can still use qApp->addTranslator() , isn’t it great ?
Thanks a lot to tsdgeos and Chusslove on #kde-devel for their help, they are the ones who found out.
If you want an example of how to do, you can refer to Opale’ source, and most importantly to the following files:

Recent Comments »