Localization - Timmeey86/Mindustry GitHub Wiki
One of Mindustry's core features is multi language support. It is based on the "Bundle" concept of libGDX. They already described perfectly how it works, so we won't repeat that here.
The language setting will only be loaded at startup, which means a language change enforces a restart. There are currently no plans to support on-the-fly retranslation.
- Within Mindustry's
corelibrary, classio.anuke.mindustry.io.BundleLoaderloads the localization bundle. In addition to thelibGDXmechanism, it allows placing a custom, external bundle in abundlesubfolder. This feature allows translators to test their translation file without having to compile Mindustry on their own. - Localized texts can be retrieved through the static helper class
io.anuke.ucore.util.Bundles, which serves as a static wrapper in order to handle things like missing translations, missing keys, checking for keys and so on. Note that this class is part of uCore, not Mindustry directly.
This is how item descriptions are retrieved in code:
import io.anuke.ucore.util.Bundles;
this.description = Bundles.getOrNull("item." + this.name + ".description");TODO: Describe which class loads the configured language at which time during startup.
Within the source code, translation files are located at `Mindustry/core/assets/bundles'
- Keys for simple texts have the form
text.<unique descriptor>. Example:text.credits = Credits - Keys for texts related to properties of classes for items, liquids, mechs, blocks have the form
<item|liquid|mech|block>.<unique entity name>.<property>. Example:block.conveyor.name = Conveyor - Keys for tutorial texts have the form
tutorial.<unique descriptor>. - Simple texts can be grouped together, e.g.
text.sector.gameoverandtext.sector.retry
After adding or removing texts in the default (english) localization file, the other translation files can be adatped by running the updateBundles job using the Mindustry/tools/build.gradle file.
In IntelliJ IDEA, this can be executed/debugged as follows:
- Click on
Run->Edit Configurations. - Click the
+symbol and selectGradle. - Set the name to "Update Bundles".
- Click the folder icon in the
Gradle porjectline and select:tools. The content should be set toMindustry:tools. - In the
Tasksfield, enterupdateBundles. - Click OK
- In the top-right corner of IntelliJ IDEA, the created configuration should already be selected, so you can sipmly press the Run (arrow) or Debug (bug) icons.