Ejemplo n.º 1
0
        private void InitLocalization()
        {
            LangCode currentLanguage = (LangCode)PlayerPrefs.GetInt(LanguageKey, (int)LangCode.EN);

            L10n.LoadLanguage(currentLanguage);
            L10n.LanguageLoaded += OnLanguageLoaded;
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
 public void SetFinnish()
 {
     L10n.LoadLanguage(LangCode.FI);
 }
Ejemplo n.º 5
0
 public void SetEnglish()
 {
     L10n.LoadLanguage(LangCode.EN);
 }