Internationalization & translation

Chapter 5. Internationalization & translation

i18n (an abbreviation of internationalization) is the process of translating the user interface and documentation of a piece of software into another language. is the central information point for the effort to translate KDE software into other languages.

Translation of the user interface an application is done using .pot files and .po files. A .pot file, is generated from the source code of the program itself, and contains all of the strings / fragments of text, that are used in the program.

Before a string in a program is include in the .pot file, it needs to be marked with the i18n().

#!/usr/bin/env python
from kdecode import *

        mylabel = QLabel(i18n("Select new directory:"))
The i18n() is part of the kdecode package and needs to be imported.

PyKDE Extensions provides support for generating .pot files and managing and updating .po files.

By using the i18n argument to setup() in your, you can specify the directory that should contain the .pot and .po files. The argument for i18n is a tuple. The first item is the relative path to the directory where the translation files should be stored. The second item is a list of directories that should be scanned for Python source files containing translatable strings.

    i18n = ('po',['.','mymodule'])

Once your is configured, use this command in the shell to generate the .pot file.

python update_messages
This command also updates any already existing .po files with any new messages.

PyKDE Extensions also handles installing translation files and converting .po files into the special binary format needed by the application at runtime.