/// <summary> /// 获取Cookie的语言码 /// </summary> /// <returns></returns> public static string LangCode() { string result = WebCont.DEFAULT_LANG; HttpCookie langCookie = HttpContext.Current.Request.Cookies["PresentLang"]; if (langCookie != null) { result = CommonFuntion.StringDecoding(langCookie.Value); } return(result); }
/// <summary> /// 根据语言码获取多语言值 /// </summary> /// <param name="key"></param> /// <returns></returns> public static string Lang(string key) { Type resourceType = null; PropertyInfo p = null; switch (CommonFuntion.LangCode()) { case "cn": resourceType = typeof(Resources.cn); break; } p = resourceType.GetProperty(key, BindingFlags.NonPublic | BindingFlags.Static); if (p != null) { return(p.GetValue(null, null).ToString()); } else { return("null"); } }
/// <summary> /// View页面获取当前语言码扩展方法 /// </summary> /// <param name="htmlhelper"></param> /// <returns></returns> public static string LangCode(this HtmlHelper htmlhelper) { return(CommonFuntion.LangCode()); }