编程语言

img hiyaolee

asp.net中的多語言使用

发表于2004/10/6 19:33:00  763人阅读

分类: C# And ASP.NET

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的值
       }
}

阅读全文
0 0

相关文章推荐

img
取 消
img