Ejemplo n.º 1
0
 public static void RegisterLocale(AvailableLocale n)
 {
     if (_langs == null)
     {
         _langs = new HashSet <AvailableLocale>();
     }
     _langs.Add(n);
 }
Ejemplo n.º 2
0
        private static void SetLocale(AvailableLocale localeConst)
        {
            string locale = GetCultureString(localeConst);

            _localeInfo = new CultureInfo(locale);

            Utils.LoadAsset <TextAsset>(localeConst.jsonFile, SetLocale);
        }
Ejemplo n.º 3
0
 private Locale(AvailableLocale defaultLocale)
 {
     DefaultLocale = defaultLocale;
     if (_instance != null)
     {
         throw new Exception("there can be only one");
     }
     _instance = this;
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 private static string GetCultureString(AvailableLocale locale)
 {
     return(LOCALE_TO_CULTURE.Replace(locale.lang, "$1-$2"));
 }