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; } } }
public static Sprite TranslateImg(string relativeName) { Sprite sp = ResUtil.LoadSprite($"Sprite/Localization/{relativeName}_{SavedLanguage}"); if (sp == null) { Debug.LogWarning($"Sprite/Localization/{relativeName}_{SavedLanguage}图片不存在"); } return(sp); }
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); }
private static Texture2D TranslateImgSpecific(string relativeName, XIHLanguage lag) { return(ResUtil.LoadSprite($"Sprite/Localization/{relativeName}_{lag}")?.texture); }