List <TextLocalization> LoadInTSVtoText(string filename) { List <TextLocalization> TextList = new List <TextLocalization>(); TextAsset LocalizationText = Resources.Load <TextAsset>(filename); string[] data = LocalizationText.text.Split(new char[] { '\n' }); for (int i = 1; i < data.Length - 1; i++) { string[] row = data[i].Split(new char[] { '\t' }); TextLocalization t = new TextLocalization(); t.id = row[0]; t.EN = row[1]; t.DE = row[2]; TextList.Add(t); } Debug.Log("Loaded List"); return(TextList); }
// public void SwitchLanguage(string newLanguage) // { // // if (string.Compare(PlayerPrefs.GetString("Language"), newLanguage) != 0) // AudioManager.Instance.Play("Select2"); // TextLocalization.ChangeLanguage(newLanguage); // UnselectButton(); // } // public void SwitchLanguageToEnglish() // { // AudioManager.Instance.Play("Select1"); // TextLocalization.ChangeLanguage("English"); // UnselectButton(); // } // public void SwitchLanguageToVietnamese() // { // AudioManager.Instance.Play("Select1"); // TextLocalization.ChangeLanguage("Vietnamese"); // UnselectButton(); // } // public void SwitchLanguageToFrench() // { // AudioManager.Instance.Play("Select1"); // TextLocalization.ChangeLanguage("French"); // UnselectButton(); // } // Change the language public static void ChangeLanguage(string l) { AudioManager.Instance.Play("Select2"); // Change language in the preference PlayerPrefs.SetString("Language", l); TextLocalization.UpdateAllText(); }
public void OnLocalize() { if (string.IsNullOrEmpty(key)) { key = label.text; } if (!string.IsNullOrEmpty(key)) { value = TextLocalization.Get(key); } }
void SwitchText() { TextLocalization textL = new TextLocalization(); foreach (TextLocalization t in textLocalizations) { if (t.id == id) { textL = t; } } text.text = (string)textL.GetType().GetField(PlayerPrefs.GetString("language")).GetValue(textL); }
public static void SetupBirthdayPanel(BirthdayChildPanel bdPanel) { Transform panel = bdPanel.transform.GetChild(0); GameObject btnContainer = SetupButtons(bdPanel, panel); TextLocalization txtLoc = panel.Find("Title").GetComponentInChildren <TextLocalization>(); txtLoc.key = "witchy_PlannedParenthood_BirthdayPanelTitle"; txtLoc.UpdateText(); GameObject boyWrapper = SetupBoyPanel(bdPanel, panel); GameObject girlWrapper = SetupGirlPanel(bdPanel, panel, boyWrapper); int descIndex = bdPanel.descriptionText.transform.GetSiblingIndex(); boyWrapper.transform.SetSiblingIndex(descIndex + 1); girlWrapper.transform.SetSiblingIndex(descIndex + 2); btnContainer.transform.SetSiblingIndex(descIndex + 3); }
private void Awake() { var syslang = Application.systemLanguage; var isLangAvailable = false; TextLocalization.Init(); foreach (var item in TextLocalization.AvailableLanguages) { if (item == syslang.ToString()) { isLangAvailable = true; break; } } if (isLangAvailable) { SelectLanguage(syslang.ToString()); } else { SelectLanguage("English"); } }
public void RemoveText(TextLocalization t) { _localizableTexts.Remove(t); }
public void Addtext(TextLocalization t) { _localizableTexts.Add(t); }
public void SelectLanguage(string aName) { TextLocalization.SelectLanguage(aName); }
/***** LANGUAGE FUNCTIONS *****/ public void SwitchLanguage(string newLanguage) { TextLocalization.ChangeLanguage(newLanguage); }
public override void OnInspectorGUI() { serializedObject.Update(); GUILayout.Space(6f); EditorGUIUtility.labelWidth = 80f; GUILayout.BeginHorizontal(); // Key not found in the localization file -- draw it as a text field SerializedProperty sp = serializedObject.FindProperty("key"); EditorGUILayout.PropertyField(sp, new GUIContent("Key")); string myKey = sp.stringValue; bool isPresent = (mKeys != null) && mKeys.Contains(myKey); GUI.color = isPresent ? Color.green : Color.red; GUILayout.BeginVertical(GUILayout.Width(22f)); GUILayout.Space(2f); GUILayout.Label(isPresent ? "\u2714" : "\u2718", "TL SelectionButtonNew", GUILayout.Height(20f)); GUILayout.EndVertical(); GUI.color = Color.white; GUILayout.EndHorizontal(); if (isPresent) { if (DrawHeader("Preview")) { GUILayout.BeginHorizontal(); EditorGUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(10f)); GUILayout.BeginVertical(); GUILayout.Space(2f); string[] keys = TextLocalization.AvailableLanguages; string[] values = TextLocalization.GetAll(myKey); if (keys != null && values != null) { for (int i = 0; i < keys.Length; ++i) { GUILayout.BeginHorizontal(); GUILayout.Label(keys[i], GUILayout.Width(70f)); if (GUILayout.Button(values[i], "AS TextArea", GUILayout.MinWidth(80f), GUILayout.MaxWidth(Screen.width - 110f))) { (target as TextLocalize).value = values[i]; GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; } GUILayout.EndHorizontal(); } } else { GUILayout.Label("No preview available"); } GUILayout.Space(3f); GUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); GUILayout.Space(3f); GUILayout.EndHorizontal(); GUILayout.Space(3f); } } else if (mKeys != null && !string.IsNullOrEmpty(myKey)) { GUILayout.BeginHorizontal(); GUILayout.Space(80f); GUILayout.BeginVertical(); GUI.backgroundColor = new Color(1f, 1f, 1f, 0.35f); int matches = 0; for (int i = 0; i < mKeys.Count; ++i) { if (mKeys[i].StartsWith(myKey, System.StringComparison.OrdinalIgnoreCase) || mKeys[i].Contains(myKey)) { if (GUILayout.Button(mKeys[i] + " \u25B2", "CN CountBadge")) { sp.stringValue = mKeys[i]; GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; } if (++matches == 8) { GUILayout.Label("...and more"); break; } } } GUI.backgroundColor = Color.white; GUILayout.EndVertical(); GUILayout.Space(22f); GUILayout.EndHorizontal(); } serializedObject.ApplyModifiedProperties(); }
void OnEnable() { TextLocalization.Init(); mKeys = TextLocalization.Keys; mKeys.Sort(delegate(string left, string right) { return(System.String.Compare(left, right, System.StringComparison.Ordinal)); }); }