Latest Posts

Changes in TranslatingWidelands

Editor Comment

Msgmerge tip.


Revision Differences of Revision 2

## Translating Widelands ¶

#### The basics for widelands locales ¶

Widelands is using the GNU gettext package for translations. This has the advantage that we have portable translations which work easily out of the box on a lot of systems. It means also, that translations are not terribly easy to do. Read on. ¶

Gettext uses a catalog system. Each and every translatable string in the source files (may it be source code or configuration files of tribes, worlds or maps) are tagged and listed in a file with file ending.pot. The name of the file is determinded from where it comes from, gettext slang for this is textdomain. Widelands defines the following text domains: ¶

* maps ¶
** Names and description of maps ¶
* texts ¶
** License and miscellaneous texts ¶
* widelands ¶
** The executeable including editor ¶
* tribes/* ¶
** One for each tribe ¶
* worlds/* ¶
** One for each world ¶
* campaigns/* ¶
** One for each campaign ¶
So the_domain.pot_file is generated automatically. This file is then usually copied to_<lang_shortcut>/domain.po_(note: not.pot but.po). Lang shortcut is usually something like de_DE or fr_BE. Then one edits this.po file, adding file encoding (which should always be utf-8) and translating the msgid string by string to msgstr lines, finally saving the file. Then the files are compiled, generating the machine-readable locales to use. ¶

### Helping out with a translation ¶

If you want to help out with translation in a language, which translation still is in progress contact the person you think is responsible for this particular translation, this should help you getting things set up. If you cannot find out who is responsible for this translation contact the elder of translations ( [Azagtoth](http://xoops.widelands.org/userinfo.php?uid=31) ). ¶
Generally you should just run the script as described in the next paragraph and edit the according.po file, then run the script again. ¶




#### Translation process ¶

#### New translation ¶

To add a new translation to the game, you need to obtain an up-to-date copy of the game via SVN and edit the file_src/languages.h_. Add your language name (in your local language) and language code as you find are the others. Besides adding your language, the_#define NR_LANGUAGES_in that file must be increased by one. Note that this file MUST be saved with utf-8 encoding. Create a new directory_po/<lang>_by calling the script_utils/buildcat.py <lang>_. For example_$ utils/buildcat.py de_DE_. This creates a first set of files with messages to translate. Recompile the game. ¶

#### Updates to existing translations ¶

From now on, the process is the same if you're creating a new translation, or updating an existing one. Start by updating your source tree with the newest svn release. ¶

Translate the files under the directory for your language with your favorite editor (e.g._vim po/de_DE/widelands.po_or see below for advice on editors). ¶

During your translation work, you can test your localized messages in-game at any time, just go to widelands source base directory and run_$ utils/buildlocale.py <lang>_. If everything went OK, you should see the messages you translated ingame. You have to configure the game to display messages in your language of course. This can be done with the ingame options menu. You Operating System has to support the locale as well. See its documentation if you have trouble or ask. ¶

#### Notes ¶

* Please announce your work on a new translation in the forum or even better, on the mailing list, so that there is no doubled translation&nbsp;:-) ¶
* Best is to use current SVN to translate since strings are added and removed all the time. ¶
* If you are unable to run the scripts (because you can't use python or the gettext programs, for example), contact [Azagtoth](http://xoops.widelands.org/userinfo.php?uid=31), and I'll send you a <lang> subdir that you could use. ¶
* Keep full headers to po files. See below for an example file header. ¶
* Do not forget to insert your utf-8 file encoding into the header of the po file. ¶
* Do not forget to actually SAVE your files in the correct encoding. ¶
### Gettext informations ¶

#### Gettext translation tools ¶

There are several tools to work with.po files: ¶

* KBabel (Unix KDE) ¶
* GTranslator (Unix Gnome) ¶
* poEdit (Multiplatform) ¶
* Emacs with po-mode (Multiplatform) ¶
* Vim with PO plug-in (Multiplatform) ¶



#### Gettext Terms ¶

* textdomain ¶
** The part of the package the text belongs to ¶
* fuzzy string ¶
** This string has been changed by the content creator and is maybe no longer correctly translated. ¶



#### Example.po file header ¶

_# Widelands FILENAME.po ¶
__# Copyright (C) 2005-2007 Widelands Development Team ¶
__# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. ¶
__# ¶
__msgid "" ¶
__msgstr "" ¶
__"Project-Id-Version: Widelands (svnrev)\n" ¶
__"Report-Msgid-Bugs-To: \n" ¶
__"POT-Creation-Date: YYYY-MM-DD hh:mm+0000\n" ¶
__"PO-Revision-Date: YYYY-MM-DD hh:mm+0000\n" ¶
__"Last-Translator: YOUR NAME <EMAIL@ADDRESS>\n" ¶
__"Language-Team: Language <widelands-public@lists.sourceforge.net>\n" ¶
__"MIME-Version: 1.0\n" ¶
__"Content-Type: text/plain; charset=UTF-8\n" ¶
__"Content-Transfer-Encoding: 8bit\n" ¶
_ ¶

The.pot files are generated in this style. So there is not much to be done. You find the placeholders that you would update for new.po files. Some others are to be updated on each change. The Language-Team: header is meant as default. Change it if you like. ¶

###
# Repeated strings in different .po files ¶

Tired of re-translating the same string in multiple tribe files? Want to take advantage of existing compendiums of good UI translations in your language? Msgmerge can help you out. The spell you are looking for is: ¶

msgmerge --compendium=file_to_get_translations_from.po working_file.po working_file_template.pot -o working_file.pox ¶

So, for example after you've translated the dozen different "resource indicator" strings in po/(language)/tribes/barbarians.po, you can merge the translations into empire.po by changing into the po/(language)/tribes/ directory and typing: ¶

msgmerge --compendium=barbarians.po empire.po ../../pot/tribes/empire.pot -o empire.pox ¶

Then you can check that empire.pox contains what you want (e.g. with diff empire.po empire.pox) and copy/move it over the old empire.po. Yay! (If you leave the compendium out, this will only update empire.po with new strings to translate form empire.pot and split overlong lines into multiple lines neatly while at it. Note that the updates go to empire.pox, not directly to empire.po.) ¶

###
Need help? ¶

If you have a problem with localisation and you can't fix it, contact [Azagtoth](http://xoops.widelands.org/userinfo.php?uid=31) ¶