Localization - Timmeey86/Mindustry GitHub Wiki

Basic Concept

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.

Usage in Code

Loading and retrieving information stored in bundles

  • Within Mindustry's core library, class io.anuke.mindustry.io.BundleLoader loads the localization bundle. In addition to the libGDX mechanism, it allows placing a custom, external bundle in a bundle subfolder. 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.

Example

This is how item descriptions are retrieved in code:

import io.anuke.ucore.util.Bundles;
this.description = Bundles.getOrNull("item." + this.name + ".description");

Changing the translation

TODO: Describe which class loads the configured language at which time during startup.

Location of translation files

Within the source code, translation files are located at `Mindustry/core/assets/bundles'

Structure of keys in a localization file

  • 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.gameover and text.sector.retry

Automatic reordering and extension of localization files

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:

  1. Click on Run->Edit Configurations.
  2. Click the + symbol and select Gradle.
  3. Set the name to "Update Bundles".
  4. Click the folder icon in the Gradle porject line and select :tools. The content should be set to Mindustry:tools.
  5. In the Tasks field, enter updateBundles.
  6. Click OK
  7. 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.
⚠️ **GitHub.com Fallback** ⚠️