Skip to content

Translation

The game server supports internationalisation ("i18n") using lean-i18n and i18next.

The intended workflow currently is the following:

  1. When you call lake build in your game, it should automatically create a template file .i18n/en/Game.pot. Alternatively you can call lake exe i18n --template to recreate it.
  2. Open the file Game.pot (the "t" stands for "template") with Poedit (or a similar software) and translate all strings. Save your work as .i18n/{language}/Game.po.
  3. Call lake exe i18n --export-json to create all Json files .i18n/{language}/Game.json which the server needs.
  4. Add your translations (i.e. .po and .json, but not the .mo files) and push your results, and publish the game.

If you choose the correct language in the "Preferences" of the game, you should see your translations.

Details (TO BE MERGED)

For the translations, codeblocks (starting with one or many backticks (`)) and latex blocks (starting with one or two $) are replaced by placeholders §n, you see the content of these in the comments. Moreover, single newlines (\n) will be stripped from the translated string.

These pre-processing steps aim to improve interaction with automated translation tooling.

Alternative: avoiding .po

Note: This workflow is subject to change, and it might be that in future the server can directly read .po files. Until then, there is also an alternative workflow you might choose:

  1. Add useJson: true to .i18n/config.json
  2. lake build or lake exe i18n --template will now create a Json instead: .i18n/en/Game.json.
  3. Add translations to a copy of this Json an save it as .i18n/{language}/Game.json

Non-English games

For games written in a language different than English, you should set the correct source language (sourceLang) in .i18n/config.json. Afterwards, on lake build the template should appear under the chosen language, and can be translated (e.g. into English) as described above.

Note that tools like pomerge might be useful: it allows you something like

pomerge de-en.po en-fr.po -o de-fr.po

For example, you can first create an English translation, then let people translate that into their own language and finally use pomerge to create the right PO-file from source to target language.

New languages

The server has a set number of languages one can select. If your game has been translated to a language not selectable, open an issue at lean4game requesting this new language. Or, even better, create a PR to translate the server interface into that new language.

Review

Since the maintainers of this repository (or of games) might not know most languages, it is encouraged that you find anybody from the Lean community who can review your translation and leave a positive comment on the PR.

The main intend for having a secondary reviewer from the community is to prevent wrong translations as well as offensive or inappropriate language.

A few suggestions:

  1. The JSON files are autogenerated from the PO files and can therefore be superficially reviewed.
  2. Formatting should be preserved during translation. While there are placeholders for code snippets, the reviewer might pay attention on details like punctuation, etc.
  3. POEdit is a great tool specifically designed for the translation and review process! Among other things, it allows you to specifically review a given range of sentences, e.g. 50-100 at a time, and allows to distribute the work more easily.