Translations

buch415 edited this page Mar 6, 2013 · 4 revisions

1. CREATING A NEW TRANSLATION

Translations are currently supported for those languages with standard latin alphabet (that is: no cyrillic, no Chinese, etc.). Translation files are located under data/cfg/locale/.

The program checks system locale at startup and looks for the corresponding .cfg file inside the translation folder (for example, if the language is English, it'll look for data/cfg/locale/en.cfg). If that file's not found, the default locale will be loaded (English).

Localization files have this syntax:

language [language_code] {
    [string_id] = [string_text];
};

Take a look to one of the core translations to see which strings are supported; their identifiers should be quite self-explanatory.

NOTE: the language is automatically set from the system language; thus, your language code must follow the ISO 639 standard.

So, to add a new translation just create the corresponding .cfg file inside the data/cfg/locale/ folder and type in the necessary strings.

NOTE: if a string is not found it will be replaced by its identifier; for example, if you forget to include the title string, you'll see 'title' instead of 'PHYSICA' on the main menu.

2. NAMESPACED STRINGS

Strings can also be put inside level pack and achievement files. Just add the same syntax inside the file and the string will be added to database when loading the pack or the achievement. Note that those strings are namespaced. In the example below (within a level pack file),

id = fancyPack;

//...other level pack information

language en {
    name = fancyPackName;
};

you have created a string whose identifier is fancyPack.name. This is to prevent conflicts between strings with the same identifier.

You can also add namespaced strings directly inside the language file. For example, inside the it.cfg file (for Italian translation) you can find something like:

language tutorial {
    name = Tutorial;

    msg1-1 = Guida il blocco verde a quello giallo;
    //...and other stuff
};

This way, when the tutorial gets loaded in Italian, it will recall the string tutorial.name for its name, which is defined inside the it.cfg file.

3. LOCALIZATION SETTINGS

Some languages might require you to change the font due to charset (e.g. Russian or Chinese). To do so, you have to write a new themes file (the best way to do that is to copy the standard one) and then specify the path to that theme in the localization file. For example (on top of an ipothetical data/cfg/locale/lang.cfg file):

themesFile = data/cfg/locale/lang_themes.cfg;
//other language specification

The themes file just made must be modified to apply the requested font. That should be done pretty easily replacing the fontFile fields along the theme file with the path to the font you want to set.