PDA

View Full Version : How to load the translating file in KDE program?



lum
11th September 2006, 15:46
Hello,
I have written a KDE GUI program in which the messages displayed in UI are in English.
And now, I want to change the messages to another language.

I found that in Qt by using "QTextCodec::locale()" user program can get the locale and then use the Qtranslator to load the corresponding qm file.

But in KDE, I didn't find somthing like this to get locale and to load corresponding mo file.
QTranslator can not load mo file!

How should I do in KDE? And where my mo file should be placed, in /usr/share/locale/XX/
LC_MESSAGES/abc.mo ?(assumes abc is my program's name)

Thank you very much!

jacek
12th September 2006, 19:06
Maybe this will help ?
http://developer.kde.org/documentation/library/kdeqt/kde3arch/kde-i18n-howto.html

It seems that it is handled automatically by KLocale.

lum
13th September 2006, 10:11
I found many programs' source codes in KDE.
All of them do not have the locale codes explicitily.
When kapp begin running, it will get locale and find a mo file in /usr/share/locale/ according to the locale.

the documentation just tells me how to extract a po file from source code.
It doesn't say how to code in KDE program's main function.

And, in KDevelop, there is a menu item "Add Translation...", you can choose a kind of language to generate a po file in po directory, but the file is NULL.
I don't understand it.