NGUI: Next-Gen UI kit  3.7.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
Localization Class Reference

Localization manager is able to parse localization information from text assets. Using it is simple: text = Localization.Get(key), or just add a UILocalize script to your labels. You can switch the language by using Localization.language = "French", for example. This will attempt to load the file called "French.txt" in the Resources folder, or a column "French" from the Localization.csv file in the Resources folder. If going down the TXT language file route, it's expected that the file is full of key = value pairs, like so: More...

Public Member Functions

delegate byte[] LoadFunction (string path)
 

Static Public Member Functions

static void Load (TextAsset asset)
 Load the specified asset and activate the localization. More...
 
static void Set (string languageName, byte[] bytes)
 Set the localization data directly. More...
 
static bool LoadCSV (TextAsset asset)
 Load the specified CSV file. More...
 
static bool LoadCSV (byte[] bytes)
 Load the specified CSV file. More...
 
static void Set (string languageName, Dictionary< string, string > dictionary)
 Load the specified asset and activate the localization. More...
 
static string Get (string key)
 Localize the specified value. More...
 
static string Localize (string key)
 
static bool Exists (string key)
 Returns whether the specified key is present in the localization dictionary. More...
 

Static Public Attributes

static LoadFunction loadFunction
 Want to have Localization loading be custom instead of just Resources.Load? Set this function. More...
 
static bool localizationHasBeenSet = false
 Whether the localization dictionary has been loaded. More...
 

Properties

static Dictionary< string,
string[]> 
dictionary [get, set]
 Localization dictionary. Dictionary key is the localization key. Dictionary value is the list of localized values (columns in the CSV file). Be very careful editing this via code, and be sure to set the "KEY" to the list of languages. More...
 
static string[] knownLanguages [get]
 List of loaded languages. Available if a single Localization.csv file was used. More...
 
static string language [get, set]
 Name of the currently active language. More...
 
static bool isActive [get]
 

Detailed Description

Localization manager is able to parse localization information from text assets. Using it is simple: text = Localization.Get(key), or just add a UILocalize script to your labels. You can switch the language by using Localization.language = "French", for example. This will attempt to load the file called "French.txt" in the Resources folder, or a column "French" from the Localization.csv file in the Resources folder. If going down the TXT language file route, it's expected that the file is full of key = value pairs, like so:

LABEL1 = Hello LABEL2 = Music Info = Localization Example

In the case of the CSV file, the first column should be the "KEY". Other columns should be your localized text values, such as "French" for the first row:

KEY,English,French LABEL1,Hello,Bonjour LABEL2,Music,Musique Info,"Localization Example","Par exemple la localisation"

Member Function Documentation

static bool Localization.Exists ( string  key)
static

Returns whether the specified key is present in the localization dictionary.

static string Localization.Get ( string  key)
static

Localize the specified value.

static void Localization.Load ( TextAsset  asset)
static

Load the specified asset and activate the localization.

static bool Localization.LoadCSV ( TextAsset  asset)
static

Load the specified CSV file.

static bool Localization.LoadCSV ( byte[]  bytes)
static

Load the specified CSV file.

delegate byte [] Localization.LoadFunction ( string  path)
static string Localization.Localize ( string  key)
static
static void Localization.Set ( string  languageName,
byte[]  bytes 
)
static

Set the localization data directly.

static void Localization.Set ( string  languageName,
Dictionary< string, string >  dictionary 
)
static

Load the specified asset and activate the localization.

Member Data Documentation

LoadFunction Localization.loadFunction
static

Want to have Localization loading be custom instead of just Resources.Load? Set this function.

bool Localization.localizationHasBeenSet = false
static

Whether the localization dictionary has been loaded.

Property Documentation

Dictionary<string, string[]> Localization.dictionary
staticgetset

Localization dictionary. Dictionary key is the localization key. Dictionary value is the list of localized values (columns in the CSV file). Be very careful editing this via code, and be sure to set the "KEY" to the list of languages.

bool Localization.isActive
staticget
string [] Localization.knownLanguages
staticget

List of loaded languages. Available if a single Localization.csv file was used.

string Localization.language
staticgetset

Name of the currently active language.


The documentation for this class was generated from the following file: