Skip to content

Translation and Localization

muerteFR edited this page Jan 14, 2022 · 19 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.

Standardization of translation contexts:

The contexts of the translation tags of the scenarios included in EE have been standardized in order to facilitate the work of the translators but also to allow the authors of the future scenarios to add the tags themselves. A lot of retroactive work has been done on the translations of the scenarios for 1 year, but ideally, the authors could add the tags to the writing of the scenario.

In a context, there are now 2 very distinct parts separated by a dash "-": A 1st part indicating the place where this text to be translated is found in the game (shipLog, science, comms ...), indicating sometimes the limited in size (button, Tab, msgMainscreen ... the Fr language is longer than the EN language per example), and a second part situating this text in the story of the scenario, allowing to better understand its meaning and avoid off-topic in translations or translate expressions that do not necessarily have the same meaning from one language to another. Even more if you don't know the scenario well. Depending on the scenario, it is sometimes more judicious to place the 1st part in front and sometimes behind because in translation software like Poedit, you can sort by context.

Xansta's scenarios --> Translators can also copy and paste the common text "database" that Xansta sometimes uses in these scenarios (in DefenderHunter, 400 sentences to translate already exist in other scenarios), which saves a lot of time.

List of contexts:

Clone this wiki locally