A Xenonauts 2 mod that adds custom translation strings without replacing the game’s original localization files.
Before the translation table is parsed, the mod merges rows from your CSV files into the text the game already loaded from its own *.csv files.
- The mod hooks when the game parses the next localization CSV.
- From that file it determines the language code (e.g.
ru-RU,en-US). - It compares that code to its own file at
%mod_folder%/locale/<code>.csv. - If they match, it appends the mod’s rows to the text before parsing; if there is no mod file for that language, it does nothing for that pass.
Every language file the game loads is processed this way: only locales for which your mod has a matching CSV are merged.
The mod itself does not add new lines to the game, it is only needed so that other modders can add their own translations.
-
Place the built
X2-Runtime-Localization.dllin%mod_folder%/assembly/common/. -
GUIDs for translations must match the
LocalizableGUIDblock in the JSON asset (name and description use different GUIDs). Example:
{
"$content": [
{
"GUID": "5835459a-3694-43b9-b2d1-cf0b4f89ab41",
"TargetComponent": "Common.Components.NameComponent",
"Request": "Translate"
},
{
"GUID": "09b7dc44-1fea-4015-a979-db7c8fd461ee",
"TargetComponent": "Common.Components.DescriptionComponent",
"Request": "Translate"
}
],
"$t": "LocalizableGUID"
}-
Mod translation files go in
%mod_folder%/locale/, with the same names as in the game:en-US.csv,ru-RU.csv, etc.
Row format matches the game (see the originals), for example:Xenonauts2\Assets\Assets\xenonauts\data\common\localization\locales\en-US.csvAt minimum: a header row and data rows with columns
GUID,Key,Text,Translation. -
Launch — enable the mod in the launcher and start the game.
Optional: on first launch the mod creates a DEBUG_FALSE file in %mod_folder%/locale_mode/. To enable debug logging, rename it to DEBUG_TRUE. When debug is on, messages are written both to the normal game log (if logging is enabled there) and to %mod_folder%/locale_mode/logs/ (file runtime_localization.log).
The code was written quickly and has not been properly tested. Comments, bugs, and suggestions are welcome on GitHub or Discord.