/// <summary> /// 获取语言项 /// </summary> /// <param name="key"></param> /// <param name="lang"></param> /// <returns></returns> public string Get(Languages lang, LanguagePackageKey key) { if (_languagePack[lang].TryGetValue(((int)key).ToString(), out var outStr)) { return(outStr); } throw new ArgumentNullException(nameof(key), $"({lang}->{key})不包含当前语言的配置项!"); }
/// <summary> /// 添加默认语言 /// </summary> /// <param name="key"></param> /// <param name="langList"></param> public void Add(LanguagePackageKey key, IDictionary <Languages, string> langList) { var keyStr = ((int)key).ToString(); foreach (var pair in langList) { AddOne(pair.Key, keyStr, pair.Value); } }
/// <summary> /// 添加默认语言 /// </summary> /// <param name="key"></param> /// <param name="langs"></param> public void Add(LanguagePackageKey key, IDictionary <Languages, string> langs) { String keyStr = ((int)key).ToString(); foreach (KeyValuePair <Languages, string> pair in langs) { this.AddOne(pair.Key, keyStr, pair.Value); } }
/// <summary> /// 获取语言项 /// </summary> /// <param name="key"></param> /// <param name="lang"></param> /// <returns></returns> public string Get(Languages lang, LanguagePackageKey key) { string outStr = null; if (this._languagePack[lang].TryGetValue(((int)key).ToString(), out outStr)) { return(outStr); } throw new ArgumentNullException("key", String.Format("({0}->{1})不包含当前语言的配置项!", lang, key)); }
/// <summary> /// 添加默认语言 /// </summary> /// <param name="key"></param> /// <param name="langs"></param> public void Add(LanguagePackageKey key, IDictionary<Languages, string> langs) { String keyStr = ((int)key).ToString(); string packKeyStr; foreach (KeyValuePair<Languages, string> pair in langs) { packKeyStr = String.Concat(keyStr, ">", ((int)pair.Key).ToString()); if(languagePack.ContainsKey(packKeyStr)) break; languagePack.Add(packKeyStr , pair.Value); } }
/// <summary> /// 添加默认语言 /// </summary> /// <param name="key"></param> /// <param name="langs"></param> public void Add(LanguagePackageKey key, IDictionary <Languages, string> langs) { String keyStr = ((int)key).ToString(); string packKeyStr; foreach (KeyValuePair <Languages, string> pair in langs) { packKeyStr = String.Concat(keyStr, ">", ((int)pair.Key).ToString()); if (languagePack.ContainsKey(packKeyStr)) { break; } languagePack.Add(packKeyStr, pair.Value); } }
/// <summary> /// 获取语言项 /// </summary> /// <param name="key"></param> /// <param name="lang"></param> /// <returns></returns> public string Get(LanguagePackageKey key, Languages lang) { string dictKey = String.Concat( ((int)key).ToString(CultureInfo.InvariantCulture), ">", ((int)lang).ToString(CultureInfo.InvariantCulture)); string outStr = null; if (languagePack.TryGetValue(dictKey, out outStr)) { return(outStr); } throw new ArgumentNullException("key", String.Format("({0}->{1})不包含当前语言的配置项!", lang.ToString(), key.ToString())); }
/// <summary> /// 获取值 /// </summary> /// <param name="key"></param> /// <returns></returns> public String Get(LanguagePackageKey key) { return lang.Get(key, Cms.Context.CurrentSite.Language); }
/// <summary> /// 获取值 /// </summary> /// <param name="key"></param> /// <returns></returns> public String Get(LanguagePackageKey key) { return(_lang.Get(Cms.Context.UserLanguage, key)); }
/// <summary> /// 获取语言项 /// </summary> /// <param name="key"></param> /// <param name="lang"></param> /// <returns></returns> public string Get(LanguagePackageKey key, Languages lang) { string dictKey = String.Concat( ((int)key).ToString(CultureInfo.InvariantCulture), ">", ((int)lang).ToString(CultureInfo.InvariantCulture)); string outStr = null; if (languagePack.TryGetValue(dictKey, out outStr)) { return outStr; } throw new ArgumentNullException("key", String.Format("({0}->{1})不包含当前语言的配置项!", lang.ToString(), key.ToString())); }
/// <summary> /// 获取值 /// </summary> /// <param name="key"></param> /// <returns></returns> public String Get(LanguagePackageKey key) { return(lang.Get(key, Cms.Context.CurrentSite.Language)); }