static public int GetLanguages_s(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif System.String a1; checkType(l, 1, out a1); var ret = LocalizationImporter.GetLanguages(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
public static bool KeyExist(string key) { var languages = LocalizationImporter.GetLanguages(key); var selected = (int)Instance.selectedLanguage; return(languages.Count > 0 && Instance.selectedLanguage >= 0 && selected < languages.Count); }
public static string Get(string key, Language language) { var languages = LocalizationImporter.GetLanguages(key); var selected = (int)language; if (languages.Count > 0 && selected >= 0 && selected < languages.Count) { var currentString = languages[selected]; if (string.IsNullOrEmpty(currentString) || LocalizationImporter.IsLineBreak(currentString)) { Debug.LogWarning("Could not find key " + key + " for current language " + language + ". Falling back to " + Instance.fallbackLanguage + " with " + languages[(int)Instance.fallbackLanguage]); selected = (int)Instance.fallbackLanguage; currentString = languages[selected]; } #if ARABSUPPORT_ENABLED if (selected == (int)Language.Arabic) { return(ArabicSupport.ArabicFixer.Fix(currentString, instance.showTashkeel, instance.useHinduNumbers)); } #endif return(currentString); } return(string.Format(KeyNotFound, key)); }
public override void OnInspectorGUI() { EditorGUI.BeginChangeCheck(); serializedObject.Update(); SerializedProperty iterator = serializedObject.GetIterator(); LocalizedText text = target as LocalizedText; if (text != null) { if (this.zhString != text.GetText()) { this.zhString = text.GetText(); } text.SerializeZhText(this.zhString); } for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false) { if (iterator.name == "m_zhText") { EditorGUILayout.LabelField("zhText", iterator.stringValue, new GUILayoutOption[0]); } else if (iterator.name == "m_key") { EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]); string key = iterator.stringValue; string localizedString = LocalizationImporter.GetLanguages(key); if (string.IsNullOrEmpty(zhString)) { zhString = localizedString; } EditorGUILayout.LabelField("中文", localizedString, new GUILayoutOption[0]); if (!string.IsNullOrEmpty(zhString) && zhString != localizedString) { DrawValuesAutoComplete(iterator, zhString); } } } serializedObject.ApplyModifiedProperties(); if (EditorGUI.EndChangeCheck()) { if (text != null) { text.OnLocalize(); } } }
public void OnLocalize() { #if UNITY_EDITOR var flags = m_text != null ? m_text.hideFlags : HideFlags.None; if (m_text != null) { m_text.hideFlags = HideFlags.DontSave; } #endif SetText(LocalizationImporter.GetLanguages(m_key)); #if UNITY_EDITOR if (m_text != null) { m_text.hideFlags = flags; } #endif }
private bool KeyHasValueForLanguage(string key, Locale language) { return(!string.IsNullOrWhiteSpace(LocalizationImporter.GetLanguages(key).ElementAtOrDefault((int)language))); }