Adding Custom Localization - KittenAqua/TrainworksModdingTools GitHub Wiki
These wiki pages are deprecated and are outdated. Please find the newer tutorials here
Custom Localization is supported by the framework, by loading a CSV file. There are two parts to implementing it in your mod!
To import the CSV, you must call CustomLocalizationManager.ImportCSV(path). This must be done at some point after the base game has loaded their localization library. If done before that, the game will crash gloriously. If done afterwards, you can import at any time, as many times as you like. The suggested method for most users is to call it once using the following hook.
[HarmonyPatch(typeof(LocalizationManager), "UpdateSources")]
class RegisterLocalizationStrings
{
// The path passed here is relative to BepInEx/plugins/
static void Postfix()
{
CustomLocalizationManager.ImportCSV("mymodfolder/localization.csv");
}
}
You can craft a CSV in Excel, Google Sheets, or a text editor. The CSV should contain the following headers which you can copy-paste into any of the previous software easily. The Type column must be 'Text' for all entries, and is mandatory.
Key,Type,Desc,Plural,Group,Descriptions,English [en-US],French [fr-FR],German [de-DE],Russian,Portuguese (Brazil),Chinese [zh-CN]
You can get a sample csv (of all the text in game) by calling
CustomLocalizationManager.ExportCSV(path)
at any time.
CSV Template: https://docs.google.com/spreadsheets/d/1RxlbAcUtrf8RFC1eOE_NqWbgztq6ROJf-zwtPylHupw/edit?usp=sharing
Plural data is broken in the library when importing from csv, and I was too lazy to debug, so there's no plural support currently. Notes on how to implement are in the source file.
The following in descriptions will be replaced with the appropriate symbol or value
#: replace # with an a positive int
Text: Replace with Text of your choice
[coin]
[gold]
[attack]
[health]
[capacity]
[armor]
[ember]
[x]
[enhance]
[resolve]
[harvest]
[summon]
[freeze]
[effect#] refers to the effect at Index, can be used to access data of effectState
[effect#.power]: get the ParamInt of Effect at Index
[effect#.status#.power]: get the ParamInt of the Status at Index of the Effect at Index
[effect#.upgrade.bonussize]:
<b>Text</b>: Bolds Text
<br>: Line Break