asp.netprivate 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的值
}
}
asp.net中的多語言使用
80酷酷网 80kuku.com