Kommute Localization Guide

This complete guides is based on the Qt Linguist Manual for Qt 4.1 by Trolltech

Translators Guide

This guide should give a quick hint how to translate kommute for your language.

  1. The developer's way
  2. The non developer's way
  3. The translation
  4. Compiling and testing
  5. Submit the translation

1) The developer's way


This way is only for developers. You need:

Get the module kommuteQT4 from kommute cvs. In the src folder you can find a file called src.pro. You can also look at this file at the kommute cvs. Here is our starting point.

The next steps are the same as for the non developer way, so we continue at 3)

2) The non developer's way


Non developers need to subscribe to the kommute translation list. If they are subscribed, they can send a message there with the subject: translation support: language, where language would be the language you want to translate to. Please include your email address in the message. On of the developers will send you a translation file.

3) The translation


4) Compile and install Kommute


5) Submit the translation


Programmers Guide

This guide should give a quick hint for programmers how to prepare the kommute source for translation.

  1. Preparing User-Visible Strings
  2. Preparing special cases of User-Visible Strings
  3. Let Kommute load the language file at startup

1) Preparing User-Visible Strings

In most cases the user-visible strings are in user interfaces, as example in a QDialog. So they are in a class derived from QObject. In all this QObject subclasses, also user ones, you replace

button = new QPushButton("&Quit", this);
with
button = new QPushButton(tr("&Quit"), this);
All QObject subclasses that use the Q_OBJECT macro implement the tr() function.
In most cases the user-visible strings will be part of a gui created with the Qt-Designer. The strings used there have the tr() function already in there. Have a look at the retranslateUi functions in the ui_ files created out of the designer files ( .ui ). The above mentioned is in the kommute project only necessary at strings that change during runtime. An example can be found in setupwizard.cpp, where the "Next" button transforms to a "Finish" button at the last widget.

2) Preparing special cases of User-Visible Strings

You can also translate Ctrl key accelerators:

exitAct = new QAction(tr("Exit") this);
exitAct->setShortcut(tr("Ctrl+Q", "Quit"));
There are also other cases, but these cases are so rare, so if there are problems, look at QT 4.1 Linguist Programmers Guide or mail to the kommute-devel mailing list

3) Let Kommute load the language file at startup

Yes, it's true. Qt loads the translation at runtime, it doesn't need them at compile time. Through this behavior it's possible to provide language files if their is no update to the kommute source.
But now, how to set Kommute to load the language file:
Your main.cpp (here starts every c++ app) consists of something like

QApplication app(argc, argv);
After this lines, insert
QString locale = QLocale::system().name();
QTranslator translator;
translator.load(QString("kommute_") + locale);
app.installTranslator(&translator);
This isn't necessary anymore, the main.cpp of Kommute is already prepared to translate Kommute.

&

Credits