Small Guide to GNU gettext

This is a quick description of the gettext system.

For more complete, definitive information, see the manual.

Basic .po file format

.po files are human-editable text files. A comment is begun by a '#' character in the first column, and extends until the end of the line. Comment lines are also used by gettext's programs to indicate special "flags" and useful information.

All .po files contain "entries", one entry for each string to be translated. Entries should be separated from each other by a single blank line.

A typical entry looks like:

	#: DialogsWxw/AddFilesDialog.cpp:1124
	#, c-format
	msgid "Set format to %s"
	msgstr "Setze Format auf %s"

The first line of the entry, which begins with "#:", is a list of all the places in the source code that contains the string being translated. There may be several of these lines.

The second line, which begins with "#,", contains "flags". The flags line is not always present. In this case a single flag (", c-format") is specified - this means that the string being translated is a C format string, i.e. it contains markers such as %s and %d which will be replaced with other text when the program runs.

Note that a few of the strings in the Setup folder contains the marker %n - this is a special marker used by the installer to indicate a line break.

The third line, which begins with "msgid", is the English-language string being translated. It may span more than one line, as in:

	#: CVSGlue/CVSAction.cpp:919
	#, c-format
	msgid ""
	"The server's host key is not cached in the registry.\n"
	"Key fingerprint: %s\n"
	"If you trust this host, hit \"Yes\" to add the key to the cache.\n"
	"If you want to connect just once, hit \"No\".\n"
	"If you don't trust this host, hit \"Cancel\".\n"

The fourth line, which begins with "msgstr", is the translated string. It may also span more than one line.

In the text above, the sequence \n indicates a line break. You will usually want to keep the line breaks at the same places in the translated string.

How to check your .po file

To check for errors in the .po file, run the script located in the same folder as the .po files. (You will need Perl installed to do this).

Fuzzy entries

When the messages in the TortoiseCVS source code are changed, or new messages are added, the existing PO files are automatically updated.

If a message has been added to the source code, it is simply inserted into the PO files without a translation.

If a message has changed since the translation was made, several things happen:

When you next check the translation, search for any entries marked as "fuzzy". Then, update the translation as required, and remove the "fuzzy" flag. Be careful here: If there are no other flags, simply remove the entire line. If there are other flags, e.g.

	#, fuzzy, c-format
remove only the "fuzzy" flag:
	#, c-format