Beispiel #1
0
        private static LanguageSetting getCoreLang(String langStr)
        {
            Dictionary <String, LanguageSetting> langlist;

            langLocaleAll.TryGetValue(langStr, out langlist);

            if (langlist == null)
            {
                langlist = new Dictionary <String, LanguageSetting>();
                logger.Error("no language: " + langStr);
            }

            String          configName = "core";
            LanguageSetting ret;

            langlist.TryGetValue(configName, out ret);
            if (ret == null)
            {
                ret = LanguageSetting.NewNull();
                logger.Error("no language config: " + langStr + " => " + configName);
            }
            return(ret);
        }
Beispiel #2
0
        private static Dictionary <String, LanguageSetting> getLangList(String path)
        {
            String[] files = Directory.GetFiles(path);

            Dictionary <String, LanguageSetting> results = new Dictionary <String, LanguageSetting>();

            foreach (String file in files)
            {
                if (Path.GetExtension(file) != ".config")
                {
                    continue;
                }

                String fileName = Path.GetFileNameWithoutExtension(file);

                Dictionary <String, String> _lang = cfgHelper.Read(file, '=');
                LanguageSetting             lbl   = new LanguageSetting(fileName, _lang);

                results.Add(fileName, lbl);
            }

            return(results);
        }
Beispiel #3
0
        /// <summary>
        /// 根据 app 的类型 t 获取某 key 的语言值
        /// </summary>
        /// <param name="t">app 的类型</param>
        /// <param name="key">语言 key</param>
        /// <returns></returns>
        public static String get(Type t, String key)
        {
            LanguageSetting ls = lang.getByApp(t);

            return(ls == null ? null : ls.get(key));
        }