U3D
Open-source, cross-platform 2D and 3D game engine built in C++
|
The Localization subsystem provides a simple way to creating multilingual applications.
Before using the subsystem, the localization string collection(s) need to be loaded. A common practice is to do this at application startup. Multiple collection files can be loaded, and each can define either just one or several languages. For example:
JSON files must be in UTF8 encoding without BOM. Sample files are in the bin/Data directory. The JSON files must have one of the following formats:
LoadJSONFile("StringsEnRu.json")
method will automatically pick the language from the JSON file LoadJSONFile("StringsLv.json", "lv")
method to tell the parser which language will be loaded Any number of languages can be defined. Remember that language names and string identifiers are case sensitive. "En" and "en" are considered different languages. During the loading process languages are numbered in order of finding. Indexing starts from zero. The first found language is set to be initially active.
The Get function returns a string with the specified string identifier in the current language.
If the string id is empty, an empty string will be returned. If the translation is not found, the id will be returned unmodified and a warning will be logged.
Use SetLanguage() function to change language at runtime.
When the language is changed, the E_CHANGELANGUAGE event will be sent. Subscribe to it to perform the necessary relocalization of your user interface (texts, sprites etc.)
Text UI elements also support automatic translation to avoid manual work.
Wherein text value is used as an identifier.
Also see the example 40_Localization.