private void Awake() { //Setting whether to use system language first. If it is on, then setting current language has no effect. LocalizationSupport.UseSystemLanguage = UseSystemLanguage; /* * if (Language.CompareTo ("English") == 0 || Language.CompareTo ("German") == 0) { * * } else { * Language = "English"; * }*/ LocalizationSupport.CurrentLanguage = LocalizationSupport.StringToLanguage(Language); string originalPath = LocalizationSupport.StringsXMLPath; try { LocalizationSupport.StringsXMLPath = Path.GetFileNameWithoutExtension(StringsXmlResource); } catch (Exception) { Debug.LogError("Localization Configuration: Strings XML Path string is invalid!"); } if ((!LocalizationSupport.StringsLoaded) || (originalPath != StringsXmlResource)) { LocalizationSupport.LoadStrings(); } }
//****** Here is how you change language at runtime. ****** //Alternatively, you can setup language settings for the whole game in editor using LocalizationSupportSetup prefab (refer to the second demo scene). private void UpdateLanguage() { //First set whether to overwrite any language setting with system language. LocalizationSupport.UseSystemLanguage = autodetectToggle.isOn; //Set the language you want. Has no effect if UseSystemLanguage is on. LocalizationSupport.CurrentLanguage = LocalizationSupport.StringToLanguage(languages[currentLanguage]); //Reload the level to apply changes to UI. Note LocalizationSupport.GetString(string) will work without reloading the scene. Application.LoadLevel(0); }