Using KBabel
Prev
Next

Chapter 2. Using KBabel

Introduction

Usually program messages and documentation are written in English. Using a framework made of a set of tools and libraries, it is possible to have your favorite applications speak your native non-English language. This process of adapting an application to a specific language is known as localization. The localization process includes translating the program's interfaces and documentation to the various languages users need and, in some countries or regions, making the inputs and outputs conform to particular conventions. KBabel is a tool which will assist you in the localization process to make an application's interface speak many languages.

Every internationalization-aware program makes available for translation one or more message-catalog files. The extension of these files is .pot. POT is an acronym for “Portable Object Template”.

Each translator takes a copy of one of these POT templates and begins to fill in the blanks: each message is translated into the language desired. The file containing the translated text is referred to as a PO (Portable Object) file.

Once all the messages have been translated, the PO file is compiled into a machine-readable binary format, known as a MO (Machine Object) file. These files, which will be stored with a .mo extension (or a .gmo extension to show that they were processed by GNU gettext), act as a database to minimize the time taken by the applications to look up each translated message.

This suggests a question: do I need to know what is inside a PO file even though I have KBabel? The answer is, undoubtedly, yes. There are situations when a message catalog can become corrupted and needs to be manually fixed. Most of these problems are the so-hated CVS or SVN conflicts which occur when a translating process is coordinated by a version management system, like CVS or Subversion (SVN). KBabel cannot help you much if a problem like this arises so a text editor and some knowledge of PO-files are needed. Let's see how a PO file is made.

PO files consist of pairs of messages—a msgid and a msgstr. The msgid is the text in English and the msgstr is the text translated into the appropriate language. The text that accompanies each msgid and msgstr is enclosed within C-like double quotes. An example, taken from a PO file for Noatun, is msgid "Open a Playlist"

Empty lines and those starting with # are ignored. Lines starting with a # represent comments and are a useful way of providing a note detailing which file this message is going to be used in and, in the case of the application writers, to provide additional comments to help translation. KBabel displays these comment lines for every message.

In many cases the first msgid-msgstr pair in PO file is a fake entry (acting as PO file header) that contains various information about the translated PO file, such as the application name, translating date, translator name and so on.

An useful feature is called plural forms. English uses only singular and one plural form of nouns, for example,1 file ” and “10 files”. This leads many developers to an idea that the world is that simple and they can use messages like “Do you want to delete %1 file(s)?”, where %1 denotes a number of files to be deleted. But this is fundamentally wrong and for many languages such a kind of translation will not work. For Slovak translation you need 3 different forms of the message. This number is different for different languages and even when it is the same, for example, Czech uses 3 forms as well, the rule to decide which form to use can be very different. Plural forms in PO files are here to help.

Note

KDE developers have chosen a different implementation for the plural forms than GNU gettext and they have introduced their own format and handling for them. It is planned to use GNU gettext's plural forms in KDE version 4.

Prev
Next
Home


Would you like to comment or contribute an update to this page?
Send feedback to the TDE Development Team