It is possible to provide additional translations for the game. The strings are stored in precompiled .mo
libraries. They can be found in the res/strings/
folder. There is a subfolder for each natively supported language: de
for German, en
for English, …, zh_CN
for Simplified Chinese and zh_TW
for Traditional Chinese. The folders are named as <language>_<region>
where
<language>
is a two letter ISO 639-1 code.<region>
is an optional two letter ISO 3166-1 code for the region.
For example de
is the general German and fallback for all other german translations while de_CH
is Swiss German and de_AT
is Austrian German.
Inside each folder, there is a info.lua
file and a LC_MESSAGES/
folder. The info.lua
contains some meta information:
function data() return { name = "German", locale = "de_CH", fontMap = { regular = "Lato2OFL/Lato-Regular.ttf", bold = "Lato2OFL/Lato-Bold.ttf", monoRegular = "Noto/NotoSansMono-Regular.ttf", monoBold = "Noto/NotoSansMono-Bold.ttf", }, } end
The properties are:
name
is the string that is displayed in the settings menu to select the language.locale
is the identifier that can be used by other mods to provide compatible translations. In addition, it is used to select the right format for numbers (e.g. decimal point).fontMap
is a mapping of font types.
In the LC_MESSAGES/
folder, there are two files:
base.mo
contains all the basic strings that are used by the UI.res.mo
contains all the content related strings, e.g. for object descriptions and mission texts.
A mod that provides additional translations needs to contain a structure analogue to the default languages with the info.lua
and the LC_MESSAGES/
folder.
The translation is a three step process:
.mo
files to .po
files that are editable.po
files to .mo
files that are usable by the game
To start a new translation, it's recommend to base on the default translation. There are some tools that can be used to decompile the .mo
files:
.po
files that comes with a tool to convert the files.
To convert with that tool, install Poedit. Then you can find a msgunfmt.exe
in the installation subfolder Poedit/GettextTools/bin/
. Execute path/to/msgunfmt.exe “path/to/xyz.mo” -o “path/to/xyz.po”
in a command line interface to convert the file.
The .po
file can be opened by any text editor. For more convenience, programs like Poedit itself can be used to edit the files.
Make sure to set the correct target language. This can be done in Catalogue > Properties
at the Language dropdown.
The editor consists of three big areas:
%1%
or {townName}
. They are replaced by some numbers or names ingame. Try to use them equally in the translation too. Some source strings come with different forms for singular and plural. Don't forget to translate all versions that are shown under small tabs.
Once the translation should be compiled, either use Poedit File > Compile to MO…
or execute path/to/msgunfmt.exe “path/to/xyz.po” -o “path/to/xyz.mo”
in a command line interface to convert the file into .mo
format.
With new game releases, there may come new strings too. You can use Poedit to merge new key strings from an updated PO file into yours. Select Catalog > Update from POT file
from the menu.
To support additional languages in mods, simply add another table with the identifier from the locale
property in the strings.lua
:
function data() return { en = { ["modname_name"] = "Urban Games Translation Demo", ["modname_desc"] = "This mod shows an exemplaric translation", }, de = { ["modname_name"] = "Urban Games Übersetzungsdemo", ["modname_desc"] = "Diese Mod zeigt eine beispielhafte Übersetzung", }, de_ch = { ["modname_name"] = "Urban Games Öbersetzigsdemo", ["modname_desc"] = "Die Mod zeigt es guets Bispel för en Öbersetzig", }, ... }