实现本地化多语言
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/// <summary>
/// Summary description for PageBase
/// </summary>
public class PageBase: System.Web.UI.Page
{
public PageBase()
{
//
// TODO: Add constructor logic here
//
}
#region 实现本地化多语言
protected override void InitializeCulture()
{
base.InitializeCulture();
string languagePreference = (string)Session["LanguagePreference"];
if (string.IsNullOrEmpty(languagePreference) || (languagePreference.ToLower() == "auto"))
{
languagePreference = "zh-CN";
}
this.UICulture = languagePreference;
this.Culture = languagePreference;
//System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CreateSpecificCulture(languagePreference);
//System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(languagePreference);
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo(languagePreference);
System.Threading.Thread.CurrentThread.CurrentUICulture = culture;
System.Threading.Thread.CurrentThread.CurrentCulture = culture;
}
#endregion
}