๐ค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.Add is used to add a localization at runtime for a given language.
LM.ApplyLocale applies all changes
csv format locale file
The following is an example of lang.csv
Filename of csv format file is not important
json format locale file
The following is an example for Simplified Chinese
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