Skip to content

Language manager

高凯 edited this page Feb 5, 2018 · 1 revision

Introduction

Language manager allows you to easily manage multi-language programs, providing module division to avoid your language file is too large

editor

Window -> 多语言编辑器(Language manager)

Instructions

  • In the 新增语言(New Languages) ​​tab, select the language you want to use and click 新增(Add)
  • Select the language you just added in the 当前语言(current language) tab
  • In the 新增模块(new module) tab, add multi-language modules, such as UI, Game and so on
  • Under the language module, add a language field
  • In the language data column, fill the language data corresponding to the language field
  • You can set the current language as the default language. When it is detected that there is no corresponding language solution in the system language, the default language will be used

Translation

当前语言 Current language  
多语言模块列表 Multilingual module list  
默认语言 default language  
新增模块 Add module  
模块名 Module name  
保存 save  
新增语言  Add language  
语言类型 Language type  
新增 Added  

API

LanguageManager
static void Init () Language Manager initialized
static void SetLanguage (SystemLanguage lang) Set the language
static string GetContent (string moduleName, string contentID, params object [] contentParams) Get a language text

Example

public void SetTextByLangeage (string textID, string moduleName, string contentID, params object [] objs)
{
    GetText (textID) .text = LanguageManager.GetContent (moduleName, contentID, objs);
}
// WinDiamond content is "{0}, You get {1} Diamond!"

Debug.Log (LanguageManager.GetContent ("UI", "WinDiamond", "Jack", 3));

// Show: "Jack, You get 3 Diamond!"

Tip

  • Multilingual files are stored as data under Data + / + langeuageName
  • If there is a {subscript} in the language field, the content of object [] objs is automatically replaced by the content of the corresponding subscript
Clone this wiki locally