public static void RegisterLocale(AvailableLocale n) { if (_langs == null) { _langs = new HashSet <AvailableLocale>(); } _langs.Add(n); }
private static void SetLocale(AvailableLocale localeConst) { string locale = GetCultureString(localeConst); _localeInfo = new CultureInfo(locale); Utils.LoadAsset <TextAsset>(localeConst.jsonFile, SetLocale); }
private Locale(AvailableLocale defaultLocale) { DefaultLocale = defaultLocale; if (_instance != null) { throw new Exception("there can be only one"); } _instance = this; }
public static Locale <T> Init(string lang, Dictionary <string, string> cache = null) { AvailableLocale l = StringToLocale(lang); if (_instance == null) { _instance = new Locale <T>(l); } if (cache != null) { _messages = cache; } else if (_messages == null) { _messages = new Dictionary <string, string>(); } SetLocale(l); return(_instance); }
private static string GetCultureString(AvailableLocale locale) { return(LOCALE_TO_CULTURE.Replace(locale.lang, "$1-$2")); }