日期:2011-10-29  浏览次数:20677 次

private ResourceManager MultiLang = new ResourceManager("Demo.Languages.test", Assembly.GetExecutingAssembly());
//Web站台名.放置多語方的目錄.要使用的語言包(會自動根據進程的語言狀態選擇test.zh-tw.resx,test.zh-cn.resx,test.en-us.resx,......)

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
if (Session["Language"] == null)
{
if (Request.Cookies["Lan"] != null)
{
Session["Language"] = Request.Cookies["Lan"].Value; //暫存當前用戶所選擇的語言
}
else
{
Session["Language"] = "en-us";
}
}
this.ci = new CultureInfo(Session["Language"].ToString());
Thread.CurrentThread.CurrentUICulture = this.ci;
txtA.Text = MultiLang.GetString("txtA"); //在語言包中設置的txtA的值
}
}