Difference between revisions of "GettextForWesnothDevelopers"
(Removed various obsolete sections) |
(Removed another obsolete section) |
||
Line 16: | Line 16: | ||
any translation update gets used instead of the current one) | any translation update gets used instead of the current one) | ||
* check ''cvs diff'' and commit | * check ''cvs diff'' and commit | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== General design of gettext use == | == General design of gettext use == |
Revision as of 19:47, 6 July 2012
This page is used to help Wesnoth developers to work with the internationalization (i18n) system, based on GNU gettext.
Warning: this page still contains a couple of outdated items to be removed.
How to move strings from one textdomain to another
- run make -C po update-po and commit, to be sure to only commit your own changes
- move the file into the corect po/*/POTFILES.in
- add or change #define GETTEXT_DOMAIN "wesnoth-lib" at top of the file, before the includes
- update the target POT file to include the new strings in its template (eg. make -C po/wesnoth-editor
wesnoth-editor.pot-update)
- copy the translations using utils/po2po (eg. ./utils/po2po wesnoth wesnoth-editor)
- update the source POT file to get rid of the old strings (eg. make -C po/wesnoth update-po), then preferably
remove the translation from obsolete strings in all languages, to make sure, in case the strings have to move back, that any translation update gets used instead of the current one)
- check cvs diff and commit
General design of gettext use
Gettextized programs usually contain the English strings within program code, with calls like printf (_("Hello world. "));, so that the binary can work (in English) when the system does not support i18n. However, in Wesnoth all strings were moved into translations/english.cfg, and fetched using a label, like in translate_string("hello_world");.
So we will need to put such strings (mostly GUI material) back into the C++ files. That part will be quite easy, except we'll have to deal with importing existing translations. We will use the wesnoth text domain for this (that is, a single wesnoth.po file for each language).
The general idea for strings in WML files is to use distinct text domains for each campaign, so that campaign writers can easily ship translations together with their campaigns. It will require WML files to declare which text domain they belong to.
If some strings look the same in english but should not necessarily look identical in translations (eg. all those prefix/suffix strings, many of which are empty in english). To hande this, those strings can be prefixed with any descriptive string and a ^ character, thanks to the sgettext implementation partly stolen from the gettext manual (eg. foo_prefix = _ "foo prefix^")