Using Localization in Mods
This tutorial covers the setup of localization files for your mods, which will enable you to move all your text out of your SBC definitions. This is good practice but more importantly also allows you to include translations of your mod within the mod itself - without a need to create and maintain a second mod.
I. Required Tools
An editor capable of correctly displaying RESX files - for example Visual Studio Community 2019 or Visual Studio Code and the RESX editor extension.
II. Setup
Download the empty
MyTexts.resx
and theMyTexts.sbl
file. Place them as follows:[YOURMOD]\Data\Localization\MyTexts.resx [YOURMOD]\Data\Localization\MyTexts.sbl
Next, open
MyTexts.resx
and you should see something like this:Within your SBC's
DisplayName
orDescription
-tags, you can now place any string as a variable (preceded byDisplayName_
orDescription_
respectively) to connect it to a text bit saved within the RESX-file. This is done by wrapping the string into{LOC:
and}
:<DisplayName>{LOC:DisplayName_MyCoolString}</DisplayName> <Description>{LOC:Description_MyCoolString}</Description>
Now add that same string to the
Name
-column in theMyTexts.resx
-file. Place the text you want to show ingame into theValue
-column:DisplayName_MyCoolString | My Block Name Description_MyCoolString | My Block Description
The vanilla game does not need the {LOC: ... }
-wrap around the RESX reference. Only mods do.
III. Translations
In order to include translations in your mod, add a correctly named
MyTexts
-files for the respective language in your mod:Also add the corresponding SBL-file for the language to your mod.
Ensure that the
Name
-column always stays the same, but replace the strings within theValue
-column with the translation of the string in the respective language. When a player selects a certain language ingame, the correct translations should immediately be used.
There currently is an issue with Keen’s RESX-Implementation for mods: If you have the modded block on your toolbar, then save and reload the save, you will see its localization key instead of the localized name. Unfortunately there isn’t much that can be done about this right now. Keen is aware of the problem but has not gotten around to fixing the bug yet.