Mod Tutorial
  • ๐Ÿ Home
  • ๐Ÿ˜€Introduction
  • ๐Ÿ˜‡Player Manual
    • ๐Ÿ“•Installation
    • ๐Ÿ“”How to use it
    • ๐ŸดAttention
  • ๐Ÿ˜…Make Mod
    • ๐Ÿ˜…Prepare
    • ๐Ÿ˜ŽCreate a mod
    • ๐Ÿ˜˜Common Features of NML
    • ๐Ÿค”Others Common
    • ๐ŸฅธBepInEx
  • ๐Ÿค”Basic Concepts
    • ๐Ÿ‘ŒMod Declaration
    • ๐ŸŽจMod Interface
    • ๐ŸฅณMod Configuration
    • ๐Ÿ‘Mod Dependency
    • ๐Ÿค—Multiligual
  • ๐Ÿ˜ถโ€๐ŸŒซ๏ธResources
    • ๐Ÿ˜ฃOverview
    • ๐Ÿ˜ฎResources
    • ๐Ÿ˜ฃAssetBundle
  • ๐Ÿ˜ชOther techs
    • ๐Ÿ‘ŒMod Reload
    • ๐ŸซฅEvent Handle
    • ๐Ÿ˜ซMod Upload
  • ๐ŸซจGame Contents
    • ๐ŸฅณCreate Equipment Asset
  • ๐ŸคฉUser Interface
    • ๐Ÿ˜Button
    • ๐Ÿ˜‚Tab
    • ๐Ÿ˜„Prefab
    • ๐Ÿ˜†Common Window
    • ๐Ÿ˜‹Autolayout Window
  • ๐Ÿ˜˜Packed
    • ๐Ÿ˜Basic Mod
  • ๐Ÿš—NML Development and OpenMods Projects
    • Introduction
    • NML Development
    • NML Documentation
    • Example Mod
    • Unity Development Toolkit
    • Game Documentation
Powered by GitBook
On this page
  • Introduction
  • Usage
  • csv format locale file
  • json format locale file
  • Automatically load
  1. Basic Concepts

Multiligual

PreviousMod DependencyNextOverview

Last updated 1 year ago

Introduction

NML provides multilingual support for mods. You can switch language in game.

NML supports to load two format locale files: csv and json.

About 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 Chinese

LM.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 file

LM.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 LocalizedText

csv 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.

๐Ÿค”
๐Ÿค—
csv Example
json Example
Load Manually Example