Liberi Developer Guide: Localization

From EQUIS Lab Wiki

Revision as of 21:26, 11 August 2014 by Zi (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

About

The localization framework is used to support multiple languages and regional settings. It also improves organization and makes the project more maintainable by keeping all "linguistic content" in one place. This avoids nightmare situations where UI captions and alert messages are scattered all over various scripts and prefabs.

Assets

Localization packages are stored in the Resources/Localization folder of the Unity project. Each language is in its own folder. Currently, the framework only supports the localization of strings, but it can be easily extended to localize textures, sounds or any other resource. Under each language folder, there is a Strings folder, containing a number of Jeli documents. Each document essentially stores a string dictionary, mapping language-neutral "keys" onto localized strings. The idea is that all code in the game will always acquire localized strings via their keys. As such, no string in the code should ever appear in the game. The organization of the files inside the Strings folder is unimportant, since all entries from all files are loaded into one dictionary. Just make sure that all keys are unique. Localizing the game for a new language is as simple as duplicating an existing language folder, and translating its contents. See the Client Configuration article for how to specify the language used by the game.

API

The Localizer class is used to fetch localized resources via keys. As of right now, the framework only supports localization of strings.

Methods

  • GetString
Use this method to get a localized string via its key. If the language is not specified, it will localize using the game's currently selected language. For example, Localizer.GetString("gekku_race.go") would return "GO!", while Localizer.GetString("name", SystemLanguage.French) would return "français".