private void InitLocalization() { LangCode currentLanguage = (LangCode)PlayerPrefs.GetInt(LanguageKey, (int)LangCode.EN); L10n.LoadLanguage(currentLanguage); L10n.LanguageLoaded += OnLanguageLoaded; }
private void OnGUI() { LangCode langCode = (LangCode)EditorGUILayout.EnumPopup(CurrentLanguage); SetLanguage(langCode); EditorGUILayout.BeginVertical(); Dictionary <string, string> newValues = new Dictionary <string, string>(); List <string> deletedKeys = new List <string>(); foreach (var localization in _localizations) { EditorGUILayout.BeginHorizontal(); string key = EditorGUILayout.TextField(localization.Key); string value = EditorGUILayout.TextField(localization.Value); newValues.Add(key, value); if (GUILayout.Button("X")) { deletedKeys.Add(localization.Key); } EditorGUILayout.EndHorizontal(); } _localizations = newValues; foreach (var deletedKey in deletedKeys) { if (_localizations.ContainsKey(deletedKey)) { _localizations.Remove(deletedKey); } } if (GUILayout.Button("Add value")) { if (!_localizations.ContainsKey("")) { _localizations.Add("", ""); } } if (GUILayout.Button("Save")) { L10n.CurrentLanguage.SetValues(_localizations); L10n.SaveCurrentLanguage(); } EditorGUILayout.EndVertical(); }
private void SetLanguage(LangCode langCode) { if (CurrentLanguage == langCode) { return; } CurrentLanguage = langCode; EditorPrefs.SetInt(LocalizationKey, (int)CurrentLanguage); _localizations.Clear(); L10n.LoadLanguage(CurrentLanguage); _localizations = L10n.CurrentLanguage.GetValues(); }
public void SetFinnish() { L10n.LoadLanguage(LangCode.FI); }
public void SetEnglish() { L10n.LoadLanguage(LangCode.EN); }