Beispiel #1
0
 private static void Init()
 {
     wordsAllDics.Clear();
     foreach (var val in Enum.GetNames(typeof(XIHLanguage)))
     {
         Enum.TryParse(val, out XIHLanguage lge);
         if (lge == XIHLanguage.none)
         {
             continue;
         }
         LanguageCfg cfg = ResUtil.LoadScriptableObject <LanguageCfg>($"Config/Localization/{val}");
         if (cfg == null)
         {
             Debug.LogError($"File Not Exits in Config/Localization/{val}");
             continue;
         }
         if (cfg.keyWords == null)
         {
             continue;
         }
         foreach (var kw in cfg.keyWords)
         {
             if (!wordsAllDics.ContainsKey(kw.key))
             {
                 wordsAllDics[kw.key] = new Dictionary <XIHLanguage, string>();
             }
             wordsAllDics[kw.key][lge] = kw.word;
         }
     }
 }
Beispiel #2
0
        public static void SetLanguage(XIHLanguage language)
        {
            if (SavedLanguage == language && wordsDics.Count > 0)
            {
                return;
            }
            PlayerPrefs.SetInt("FATTY_LANGUAGE", (int)language);
            PlayerPrefs.Save();
            SavedLanguage = language;
            LanguageCfg cfg = ResUtil.LoadScriptableObject <LanguageCfg>($"Config/Localization/{SavedLanguage}");

            if (cfg == null)
            {
                Debug.LogError($"File Not Exits in Config/Localization/{SavedLanguage}");
                return;
            }
            wordsDics.Clear();
            foreach (var kw in cfg.keyWords)
            {
                wordsDics[kw.key] = kw.word;
            }
            LanugeChanged?.Invoke(SavedLanguage);
        }