public void OnValidate() { if (UI != null) { UI.text = LocalizationManager.GetLocalizedValue(key); } }
void Start() { m_Link = LocalizationManager.Instance; text = GetComponent <Text>(); keyText = text.text; text.text = m_Link.GetLocalizedValue(keyText); }
private IEnumerator Start() { default_font = UI.font; thsarabunnew = Resources.Load <Font>("Fonts/THSarabunNew"); while (!LocalizationManager.IsReady) { yield return(null); } if (string.IsNullOrEmpty(value)) { var txt = LocalizationManager.GetLocalizedValue(key); UI.text = txt; if (LocalizationManager.lang == SystemLanguage.Thai) { UI.font = thsarabunnew; } else { UI.font = default_font; } } else { UI.text = value; } }
private bool IsKeyDefined(string key) { for (int i = 0; i < Values.Length; i++) { if (LocalizationManager.GetLocalizedValue(key, (LocalizedLanguage)System.Enum.GetValues(typeof(LocalizedLanguage)).GetValue(i)) != null) { return(true); } } return(false); }
void Update() { if (string.IsNullOrEmpty(value)) { var txt = LocalizationManager.GetLocalizedValue(key); UI.text = txt; } else { UI.text = value; } }
public static void Open(string key) { TextLocalizerEditWindow window = CreateInstance <TextLocalizerEditWindow>(); window.titleContent = new GUIContent("Localizer Window"); window.ShowUtility(); IsOpen = true; Key = key; for (int i = 0; i < Values.Length; i++) { Values[i] = LocalizationManager.GetLocalizedValue(key, (LocalizedLanguage)System.Enum.GetValues(typeof(LocalizedLanguage)).GetValue(i)); } }
private IEnumerator Start() { while (!LocalizationManager.IsReady) { yield return(null); } if (string.IsNullOrEmpty(value)) { var txt = LocalizationManager.GetLocalizedValue(key); UI.text = txt; } else { UI.text = value; } }
void Update() { if (string.IsNullOrEmpty(value)) { var txt = LocalizationManager.GetLocalizedValue(key); UI.text = txt; if (LocalizationManager.lang == SystemLanguage.Thai) { UI.font = thsarabunnew; } else { UI.font = default_font; } } else { UI.text = value; } }
public void OnGUI() { EditorGUI.BeginChangeCheck(); Key = EditorGUILayout.TextField("Key: ", Key); if (EditorGUI.EndChangeCheck()) { for (int i = 0; i < Values.Length; i++) { Values[i] = LocalizationManager.GetLocalizedValue(Key, (LocalizedLanguage)System.Enum.GetValues(typeof(LocalizedLanguage)).GetValue(i)); } } EditorGUILayout.BeginVertical(); for (int i = 0; i < Values.Length; i++) { EditorGUILayout.LabelField(System.Enum.GetName(typeof(LocalizedLanguage), i) + " Value: ", GUILayout.MaxWidth(100)); EditorStyles.textArea.wordWrap = true; Values[i] = EditorGUILayout.TextArea(Values[i], EditorStyles.textArea, GUILayout.Height(100), GUILayout.Width(400)); } EditorGUILayout.EndVertical(); if (GUILayout.Button("Add / Edit")) { if (IsKeyDefined(Key)) { LocalizationManager.Replace(Key, Values); } else { LocalizationManager.Add(Key, Values); } Selection.activeGameObject.GetComponent <Localize>().SetKey(Key); } minSize = new Vector2(460, 500); maxSize = minSize; }
private void SetTextValue(int languageIndex, bool editMode = false) { RTLTextMeshPro RTLTextMeshPro = GetComponent <RTLTextMeshPro>(); if (RTLTextMeshPro == null) { return; } LocalizedLanguage currenctLanguage = (LocalizedLanguage)languageIndex; if (!string.IsNullOrEmpty(LocalizedString.key)) { string value; if (editMode) { value = LocalizationManager.GetLocalizedValue(LocalizedString.key, currenctLanguage); } else { value = LocalizedString.value; } if (!string.IsNullOrEmpty(value)) { if (!IsContainsAtSign) { value = value.Replace("@", System.Environment.NewLine); } RTLTextMeshPro.text = value; } } SetOtherSettings(RTLTextMeshPro, currenctLanguage); //Re-Fix RTLTextMeshPro.UpdateText(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); position.width -= 34; position.height = 18; Rect valueRect = new Rect(position); valueRect.x += 15; valueRect.y += 20; valueRect.width -= 15; Rect foldButtonRectRect = new Rect(position); foldButtonRectRect.width = 15; dropdown = EditorGUI.Foldout(foldButtonRectRect, dropdown, ""); position.x += 15; position.width -= 15; SerializedProperty key = property.FindPropertyRelative("key"); key.stringValue = EditorGUI.TextField(position, key.stringValue); position.x += position.width + 2; position.width = 17; position.height = 17; Texture searchIcon = (Texture)Resources.Load("Localization/search"); GUIContent searchContent = new GUIContent(searchIcon); if (GUI.Button(position, searchContent)) { if (!TextLocalizerSearchWindow.IsOpen) { TextLocalizerSearchWindow.Open(); } } position.x += position.width + 2; Texture addIcon = (Texture)Resources.Load("Localization/add"); GUIContent addContent = new GUIContent(addIcon); if (GUI.Button(position, addContent)) { if (!TextLocalizerEditWindow.IsOpen) { TextLocalizerEditWindow.Open(key.stringValue); } } if (dropdown) { for (int i = 0; i < System.Enum.GetNames(typeof(LocalizedLanguage)).Length; i++) { var value = LocalizationManager.GetLocalizedValue(key.stringValue, (LocalizedLanguage)System.Enum.GetValues(typeof(LocalizedLanguage)).GetValue(i)); GUIStyle style = GUI.skin.box; height = style.CalcHeight(new GUIContent(value), valueRect.width); valueRect.height = height; valueRect.width += 21; valueRect.y = 20 * (i + 2) + 5; EditorGUI.LabelField(valueRect, value, EditorStyles.wordWrappedLabel); } } EditorGUI.EndProperty(); }