Skip to content

Translation and Localization

Tsht edited this page Aug 5, 2021 · 22 revisions

This page documents the ongoing effort of setting up EmptyEpsilon for different languages.

There are 5 major aspects that need to be worked on:

  1. Updating the C++ code to allow for translations
  2. Updating the shared lua code to allow for translations
  3. Updating scenarios to allow for translations
  4. Adding main translations
  5. Adding scenario translations

Updating the C++ code to allow for translations

The code was originally not written to account for translations. This means many parts still need to be updated to allow for translations.

Most patches will look like this: https://github.com/daid/EmptyEpsilon/commit/90fbe46dcf9256b7267bfc3e32a6911a53fe5000

Where the tr() function is put around static strings in the code so they can be translated. The function has 2 forms, with 1 or with 2 parameters. The one with two parameters is to give the string context. For example translating the string "Both" can be hard without context. But with the context "jump/warp" it indicates that this is about jump/warp selection.

Pull requests are welcome. But try to do small sections at once. As mistakes might happen, and some parts will require more complex changes to properly setup formatting instead of adding parts of strings together to make a whole.

Updating the shared lua code to allow for translations

The lua ship templates, science database and main comms scripts can simply be updated. In lua the _() function will handle translation. Just like the tr() function in C++ a single parameter marks that string for translation, and two parameters will setup the first parameter as context. Some places might need the string.format() function instead of string concatenation ("" .. "")

Updating scenarios to allow for translations

Same as the previous item. Just need _() function calls. However, this will be a lot of work, as there are many strings that need to be updated to use the string.format() function.

Please only work on a single scenario at a time.

Adding main translations

Main translations are copies of https://github.com/daid/EmptyEpsilon/blob/master/resources/locale/main.en.po with different filenames. The main english translation file can be updated with the build target "update_locale". (make update_locale) Please do not update the english locale file in pull requests. This will be done directly on master.

Adding scenario translations

Scenario translations will be kept next to the scenario script. For example, scenario_01_waves.lua will have a translation file locale/scenario_01_waves.fr.po. Currently these will be properly loaded already. But no scripts have been setup to generate the initial translation file yet.

Note about characters in your translations:

As EmptyEpsilon did not support unicode, you should be careful about the characters you are using. In theory iso-encoding can work, but the outcome is quite unpredictable. So to be safe, and to make sure the user won't see strange symbols instead of letters, you should have avoided all non-ASCII characters, if possible. This basically meant: if possible use no letters outside of the latin alphabet and use substitution rules if they exist for the target language.

Change by EE-2021.03.16: By this release, basic Unicode support was added (for text labels, but not for text input boxes). So non-ASCII characters should work now. As this is a new feature, better be careful and double check before filing a pull request.

Clone this wiki locally