# Internationalization

dopewars uses the GNU gettext utilities for internationalization (i18n) support. This allows the software to be translated into the local language at runtime - run dopewars in the UK and it'll talk to you in English, but run it in Germany and it'll talk to you in German. This relies on translators to translate the program's output into each language beforehand, of course, and so native language speakers to carry out this task are always needed!

- Running dopewars with i18n support
- Adding a new translation
- dopewars specifics
- Updating a translation for a new dopewars version
- Currently available translations

## Running dopewars with i18n support

i18n is only included in versions of dopewars later than 1.4.8. By default, "Native Language Support" is compiled in; binary installations should be already set up for i18n. When compiling dopewars from source code, the `configure` script should detect whether your system can support GNU gettext. If it can, but the gettext utilities themselves are not present, an included copy in the `intl/` subdirectory is used. To disable i18n, pass the `--disable-nls` option to the `configure` script.

When you run your installed copy of dopewars, it should detect your "locale" automatically and talk to you in your native language. If this does not happen, the following are some possible explanations:-

- dopewars cannot find the locale-specific language file - by default, stored under /usr/local/share/locale/
- Your language is not yet supported - why not add it yourself?
- Your system does not have locale support.
- On a Windows system, you need to select the language from the relevant section of Control Panel (or set the LANG environment variable, below). i18n under Windows is only supported by version 1.5.3 and later.
- You haven't set an environment variable to specify your locale (usually this is done automatically). For example, if you're using the `bash` shell and want a German translation, the command "`export LANG=de_DE`" should ensure that dopewars (and all other i18n-aware programs launched from this shell) will use the German language.

## Adding a new translation

Translation files are kept in the subdirectory `po/` of the dopewars source code distribution. They are named by 2-letter language codes followed by the `.po` extension - for example, the German translation is stored in the file `po/de.po`. They are simple text files, consisting of lists of the original English string (labelled by "msgid") followed by the translated string (labelled by "msgstr").

Adding a new translation is simply a matter of copying the reference file `dopewars.pot` to your language-specific `.po` file in the `po/` directory, and filling in the "msgstr" entries. Once this is done, edit the `configure.in` file in the top dopewars directory to add your language code to the `ALL_LINGUAS` variable. Then run `autoconf` to rebuild the `configure` script, before making and installing dopewars as usual. The new translation should now be available. Once this is complete, please send the translation to be included in the next dopewars version.

Please note that some strings are format strings containing the % character. These are used in the program code for substituting numbers and other pieces of text into the string - these substitutions are are performed using variables which are specified in the same order as the % characters in the format string. For example, the following format string substitutes in a string (%s) and an integer number (%d):-
`"String '%s' has %d characters"`
The string and number are specified in order in the code. This is problematic if your translation changes the order - for example, a valid German translation of the string would be
`"%d Zeichen lang ist die Zeichenkette '%s'"`
Now the number and string are specified in the wrong order, and this will probably crash the program on running! To fix this, use the special notation
`"%2$d Zeichen lang ist die Zeichenkette '%1$s'"`
(i.e. replace %x with %n$x where n is the index that the format specifier "should" have, starting from 1.)

## dopewars specifics

- When questions are asked in the curses (text mode) client, the keys that you are allowed to press in reply are stored in a string. This should be translated to suitable keys in your language, in the same order as the original - e.g. "`YN`" (for Yes/No) could be translated in German to "`JN`" (for Ja/Nein).

- When a dopewars server asks a client a question, the valid replies are sent at the start of the message, followed by a "`^`" character. These replies define the dopewars protocol, and so should not be translated - they will prevent clients and servers from talking to each other properly. So for example, the string "`YN^Would you like to visit %s?`" should be translated as you wish, but with the "`YN^`" at the start left unchanged.

- The `%txx` notation is used for "translated strings". This notation is exactly equivalent to the standard C "`%s`" notation for a string, and does essentially the same thing, except that the two-letter code which follows the `%t` is used to select an "alternative form" of the word - for example, your language may have different words for "bitch" depending on whether the word is the subject or the object of the sentence. You are free to translate `%txx` to use the most appropriate form of the word. If you wish to capitalise the first letter of the word (as used in English for titles, etc.) then use "`%T`" rather than "`%t`".

  Obviously dopewars cannot guess what your "alternative forms" are; you must specify them yourself. Essentially, when setting a string in a dopewars configuration file (or the defaults, which are set in dopewars.c) alternative forms can be added by alternating two-letter codes and alternative forms after the original word, separating them by _ (underline) symbols. For example,
  `Names.Bitch = "bitch_no_bitcho_ac_bitche"`
  specifies two alternative forms for "bitch", identified by the "`no`" and "`ac`" codes. You can then use "bitcho" anywhere that "bitch" is normally used by translating the relevant string as "`%tno`" (and to get "bitche" use "`%tac`"). If you specify a two letter code in the translation that you haven't given an alternative form for, the default word ("bitch") will be used. In the original English, "`%tde`" is used for this purpose, but there is nothing special about the "`de`" code - you can use it yourself if you like, and you can use as many different two-letter codes as you want to.

  Additionally, prices in dopewars are automatically formatted into strings by means of the %P notation, and comments can be introduced into format strings by means of the %/.../ notation. Everything between the two / characters is not printed. This is used to "qualify" some strings for translation, and the %/.../ can be left out of the translated string if desired (the comment does not need to be translated).

## Updating a translation for a new dopewars version

New versions of dopewars will often change what is printed to the user, and so may may require changes to the translation. To update an existing translation, change into the `po` subdirectory of the dopewars source code, and do a "`make dopewars.pot`". This creates the `dopewars.pot` file, which lists the strings that need translating. Next, create a new translation file from your "old" translation file (we'll assume it's called `de.po`) and `dopewars.pot` with the `msgmerge` command:-
`msgmerge -o newfile de.po dopewars.pot`
Examine this new file `newfile` for translations that need updating (a search for "fuzzy" should find most of them) and then overwrite your old translation with the new one:
`mv newfile de.po`
Rebuild and reinstall dopewars, and the new translations should become available. Again, it is deeply appreciated if such updated files are contributed to the main dopewars distribution!

## Currently available translations

- French (`fr.po`)
  - Maintained by: leonard
  - Version required: 1.5.2 or later
- German (`de.po`)
  - Maintained by: Tobias Mathes
  - Version required: 1.5.0 or later
- Polish (`pl.po`)
  - Maintained by: Slawomir Molenda
  - Version required: 1.5.0 or later
- Portuguese (Brazil) (`pt_BR.po`)
  - Maintained by: Hugo Cisneiros
  - Version required: 1.5.0 or later
- Norwegian Nynorsk (`nn.po`)
  - Maintained by: Åsmund Skjæveland
  - Version required: 1.5.7 or later

- Main index

Last update: 24-06-2002