Translations - DomeKeeperMods/Docs GitHub Wiki

Table of Contents


Introduction

ModLoader provides an API function for adding custom translations to your mod. If your mod contains any text content, we strongly advise adding a translation file.

The process for adding translations to your mod aligns closely with how translations function in Godot, with a bit of additional work.

Preparing a Translations.csv File

In your mod's folder (res://mods-unpacked/Your-Mod/), create a new folder labeled translations. In this folder, create a new, blank text file named yourmodname_text.csv (though you can choose a different name if you prefer).

The first line of this file must contain:

keys,en

If you wish to include additional languages, append their country codes to this line.

keys,en,de

Adding Text Translations

Most of Dome Keeper's texts are generated through scripts. When creating a mod, you'll likely encounter UI elements that feature your mod's name/ID along with some supplementary text.

For example, upgrades.hydralauncherdamage1.title or upgrades.hydralauncherdamage1.desc. These texts are automatically resolved if a matching translation key is available.

To resolve these example keys, your csv file should look like this:

keys,en,de
upgrades.hydralauncherdamage1.title,Missile Damage 1,Raketenschaden 1
upgrades.hydralauncherdamage1.desc,Increases the Damage of each Missile.,Erhöht den Schaden jeder Rakete.
keys en de
upgrades.hydralauncherdamage1.title Missile Damage 1 Raketenschaden 1
upgrades.hydralauncherdamage1.desc Increases the Damage of each Missile. Erhöht den Schaden jeder Rakete.

The translation csv file is automatically imported by Godot in the editor and will subsequently add a file for each language in your translations folder.

Integrating Your Mod's Translations into the Game

To incorporate these translations into the game, they must be added via the ModLoader API. This should occur in the mod's _init() function in your mod_main.gd script.

ModLoaderMod.add_translation("res://mods-unpacked/Author-Modname/translations/yourmodname_text.en.translation")

Utilizing Translations

💡 UI elements such as Labels and Buttons will automatically resolve translations when the corresponding key is used.

Alternatively, you can call tr(keyName:String) to obtain the resolved text for the currently selected language.

❗ Example:

var key = "upgrades.hydralauncherdamage1.title"
prints("Translation for key:", key, "->", tr(key))
# prints: "Translation for key: upgrades.hydralauncherdamage1.title -> Increases the Damage of each Missile.