๐คMultiligual
Introduction
NML provides multilingual support for mods. You can switch language in game.
NML supports to load two format locale files: csv and json.
Load Manually ExampleAbout line 62, in Reload, find it yourself.
Usage
NeoModLoader.General.LM provides some utilities to use localization
LM.Get is used to get text of a given key in current language
LM.Get("Humans"); // It returns "ไบบ็ฑป" if your game language is ChineseLM.LoadLocales is used to load .csv format locale file.
LM.LoadLocales("path-to-csv-file");LM.LoadLocale is used to load .json format locale file. To be attention, filename of the file should be target language short name. Such as:
LM.LoadLocale("path-to-mod-folder/Locales/en.json"); // Load English locale file
LM.LoadLocale("path-to-mod-folder/Locales/cz.json"); // Load Simplified Chinese locale fileLM.AddToCurrentLocale is used to add a localization at runtime instantaneously.
LM.AddToCurrentLocale("Humans", "New Humans Name Locale");LM.Add is used to add a localization at runtime for a given language.
LM.Add("en", "Humans", "New Humans Name Locale");LM.ApplyLocale applies all changes
LM.ApplyLocale(); // Apply changes of current language and update all LocalizedText
LM.ApplyLocale(False); // Apply changes of current language but not update all LocalizedText
LM.ApplyLocale("cz"); // Apply changes of Simplified Chinese and update all LocalizedText
LM.ApplyLocale("cz", False); // Apply changes of Simplified Chinese but not update all LocalizedTextcsv format locale file
The following is an example of lang.csv
key,cz,en,ch
Humans,ไบบ็ฑป,Humans,ไบบ้ก
Orcs,ๅ
ฝไบบ,Orcs,็ธไบบFilename of csv format file is not important
json format locale file
The following is an example for Simplified Chinese
// cz.json
{
"Humans": "ไบบ็ฑป",
"Orcs": "ๅ
ฝไบบ"
}Filename of json format file should be correspond to its language.
Automatically load
You need to implements ILocalizable interface for you mod main class. GetLocaleFilesDirectory returns path to locale files' folder. .csv and .json files in the folder will be loaded before your mod's loading.
Last updated