Crossfire Server, Trunk  R20608
Internationalisation and localisation

i18n's routines are located in the languages.c file.

To use i18n in the server code, instead of putting strings, use

i18n(who, "This is a translatable message.");

with who the player's object you wish to translate for.

The string can be anything you want, and will get replaced by the localised version. They must not contain a | character. If the string doesn't exist for the language, the code will be returned.

The recommanded strategy for translation is:

  • use English sentences anywhere they are required, as usual but with the i18n call
  • translate them using the language files, but don't write the English (messages.en file) version
  • if the sentence contains a |, then use an arbitrary code, and do put it in the messages.en file

Language files are located in lib/i18n/messages.xx files, with xx the language's code, "en" or "fr" for instance.

They are installed as part of make install.

The format is straightforward:

  • any line starting with #┬áis a comment
  • a line is in the format sentence code|localised version
  • if the line is simply sentence code, without any |, the localised version is the code
  • newlines can be written as \n
  • there must be a line with the code LN, which contains the native language's name
  • lines can contain printf format specifiers, it is your responsability to give the correct arguments

Warning: currently the order of arguments is fixed, as defined by the print call (English version if you followed this guide) in the code.