LocalizationManager
LocalizationManager is your intrerface to the localization services in hard times. You should use it to ensure that strings and labels you are going to display in game will eb localized to the active language selected by the user. If localization manager can't find a label it will fallback on the default language (English). If a given label can't be found even in the english localization it will just display the label as is.
Properties
public static LocalizationManager instance
Contains a reference to the singleton instance. You can use it to call methods on the global object from any script:
if(LocalizationManager.instance.IsReady)
public Dictionary<string, string> localizedText
The complete big huge dictionary containing any single label and value for the currently active language.
public bool IsReady
Contains the ready state of the manager. Will be set to true by the engine when language loading is complete.
Public Methods
public List<string> GetAvailableLanguages()
Returns a List<string> object containing all the available languages that can be selected.
public void ChangeLanguage(string language)
Switches the active language to the one given as a string parameter. Must match one of the available languages returned from GetAvailableLanguages().
LocalizationManager.instance.ChangeLanguage("Italiano");
public string GetLocalizedValue(string key,List<string> parameters = null)
Basically this is the same of the static method GLV.
Static Methods
public static void ReloadAllLocalizedTexts()
This function should be called only by the internal engine. It's used to refresh all the LocalizedText elements in the scene, when language has been changed.
public static string GLV(string label, List<string> parameters = null)
This static method is used to obtain a localized string from a label. It accepts a second optional parameter with a list of strings to use it as parameters in the resulting localized text
//returns the localized text assigned to the "My Label" label. LocalizationManager.GLV("My Label"); // returns the localized text using the given parameters LocalizationManager.GLV("My Label", new List<string>(){"first param", "second param"});
In the corrisponding json lang file there should be something like this:
{ "key": "My Label", "value": "This label accepts two parameters: {?} and {?}" },
The {?} tag will be converted to the parameter value in the same occurring order.