private static int ReadFile(string new_lang) { if (new_lang == lang) { return(1); } if (File.Exists(Application.StartupPath + "/Languages/" + new_lang + ".obl") && File.Exists(Application.StartupPath + "/Languages/keys.obl")) { FileStream ToRead = new FileStream(Application.StartupPath + "/Languages/" + new_lang + ".obl", FileMode.Open); StreamReader Reader = new StreamReader(ToRead); FileStream ToReadKeys = new FileStream(Application.StartupPath + "/Languages/keys.obl", FileMode.Open); StreamReader Keys = new StreamReader(ToReadKeys); Translations = new Dictionary <string, string>(); while (Reader.EndOfStream == false && Keys.EndOfStream == false) { Translations.Add(Keys.ReadLine(), Reader.ReadLine()); } Reader.Close(); Keys.Close(); return(1); } else { if (lang == null) { throw new Exception("Error while loading translations"); } string H = " "; if (LanguageChange != null) { LanguageChange.Invoke(H, new LanguageChangeArgs(lang)); } return(0); } }
/// <summary> /// Fire the LanguageChange event. /// </summary> public static void OnLanguageChange() { LanguageChange?.Invoke(); #if BEST_FIT_TEXT_INCLUDED BestFit.OnResolutionChange(); #endif }
public void GoLanguageChange(object state) { var page = new LanguageChange(); WidthDynamic = page.Width + 20; HeightDynamic = page.Height + 20; CurrentPage = page; }
public Task NotifyLanguageChange(string language) { if (LanguageChange != null) { return(LanguageChange.Invoke(language)); } return(Task.CompletedTask); }
public static void InitTranslations(string lng) { if (ReadFile(lng) == 1) { lang = lng; Configuration.SConfig.C["language"] = lng; string H = " "; loaded = true; if (LanguageChange != null) { LanguageChange.Invoke(H, new LanguageChangeArgs(lng)); } } }
/// <summary> /// Trigger LanguageChange event when default language is set /// </summary> private void OnLanguageChange() { LanguageChange?.Invoke(this, EventArgs.Empty); }
public static void SetLanguage(string path) { TextAsset textAsset = Resources.Load <TextAsset>(path); string fileText = textAsset.text; int index = 0, endIndex = 0, length = fileText.Length; string keyString, textString; while (index < length) { switch (fileText[index]) { case '#': // Метка предложения { endIndex = fileText.IndexOf(' ', index); index++; if (endIndex != -1) { keyString = fileText.Substring(index, endIndex - index); index = endIndex + 1; endIndex = IndexOfNewLine(fileText, index); if (endIndex == -1) { endIndex = length; } textString = fileText.Substring(index, endIndex - index); sentenceDictionary[keyString] = textString; //Debug.Log("Sentence added: " + keyString + " = " + textString); index = endIndex; } else { index = length; } break; } case '@': // Метка стандартного слова case '$': // Метка дополнительного слова { endIndex = fileText.IndexOf(' ', index); index++; if (endIndex != -1) { keyString = fileText.Substring(index, endIndex - index); index = endIndex + 1; endIndex = IndexOfNewLine(fileText, index); textString = fileText.Substring(index, endIndex - index); wordDictionary[keyString] = textString; //Debug.Log("Word added: " + keyString + " = " + textString); index = endIndex; } else { index = length; } break; } case '\r': case '\n': { index++; break; } default: { index = IndexOfNewLine(fileText, index); break; } } } PlayerPrefs.SetString("Language", path); LanguageChange?.Invoke(); }
public void Unsubscribe(LanguageChange lang) { OnLanguageChange -= lang; }
public void Subscribe(LanguageChange lang) { OnLanguageChange += lang; }