The K Desktop Environment

Next Previous Table of Contents

11. Internationalization

11.1 What is i18n ?

i18n is an internationalization standard that is used to offer internationalized versions of an application or project. The difficulty with writing applications is that they only support the language they originally are composed with; visually this can be seen on labels, menuentries and the like. Goal of the internationalization is to provide applications and library functions in the language of the user; therefore enabling users that are not capable of the original language to make use of the provided functionality.

11.2 How KDE supports Internationalization

KDE, as one of the most modern desktop environments, has set one of it's numerous goals to provide applications for users in their native language, and simplifies the work for developers to provide their application in any of the supported language.

Technically, this is realized by the KDE File System Standard which contains localization support for languages in terms of documentation and by providing application internationalization through the use of the KDE-core library class KLocale. This class does all the translation, dependend on the prefered language set in the KDE Control Center.

The developer on the other hand only has to know two things to make his application able to use this feature:

  1. include kapp.h into your sourcecode wherever a visible text appears in your application, e.g. in source files that contain QLabels.
  2. wherever you set the visual string, embrace it with the i18n() macro provided by kapp.h.

That is almost all you have to watch for while coding. Mind that you should not internationalize any configuration strings that are used by KConfig, because this is not necessary on one hand and doesn't work for reading in values on the other; besides messes too much in the translation files.

11.3 Translation Team Contacts

The KDE Team also provides numerous contacts to developers that are contributing to the KDE project as translators. Those are organized in language teams and coordinate the translation work.

For a full list and information who to ask for translating your application, see http://www.kde.org.

11.4 Adding a Language to your Project

Before your application can support internationalization, you have to run "Make Messages and merge" from the "Project" menu. This will scan all of your sourcefiles for the i18n() macro and extracts the strings into a <yourapp>.pot file, which is then placed into the po subdirectory of your project.

Then select the desired language by choosing "Add new translation file" from the "Project" menu. After pressing "OK", the translation file will be build and added to the project in form of <language_prefix>.po, placed in the po directory.

When translation files have to be updated, run "Make Messages and merge" form the "Project" menu to extract the i18n() macros again into the pot file. In this context, merging means that the new strings that are added will be added to all currently integrated po files. Translators then only have to look for the strings currently not translated.

11.5 Translating po files

To translate the po files, the KDE SDK offers a tool that is called KTranslator. In case it is installed, selecting a po file will open the file with KTranslator in the Tools-window where the message strings can be translated using the existing translation files installed at the translator's KDE locale directory. If KTranslator is not installed, the po file is opened in the Resource window where it can be edited manually as a text file.

Next Previous Table of Contents