20250314 中英文切换
This commit is contained in:
@@ -4,11 +4,13 @@ using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using static FineUIPro.Web.CQMS.Performance.Performance;
|
||||
@@ -1299,5 +1301,64 @@ namespace FineUIPro.Web
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 中英文切换
|
||||
/// <summary>
|
||||
/// 语言国际化
|
||||
/// </summary>
|
||||
protected override void InitializeCulture()
|
||||
{
|
||||
string https = ConfigurationManager.AppSettings["Https"];
|
||||
if (Request.Cookies["SelectLan"] != null)
|
||||
{
|
||||
HttpCookie lanCookie = Request.Cookies["SelectLan"];
|
||||
|
||||
//从Session或Cookie里面读取
|
||||
string language = lanCookie["lan"];
|
||||
|
||||
//当前线程的语言采用哪种语言(比如zh,en等)
|
||||
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language);
|
||||
//决定各种数据类型是如何组织,如数字与日期
|
||||
Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(language);
|
||||
}
|
||||
else
|
||||
{
|
||||
HttpCookie lanCookie = new HttpCookie("SelectLan");
|
||||
//默认为中文
|
||||
lanCookie["lan"] = "zh-CN";
|
||||
lanCookie.Expires = DateTime.Now.AddDays(1);
|
||||
if (https == "true")
|
||||
{
|
||||
lanCookie.Secure = true;
|
||||
}
|
||||
Response.Cookies.Add(lanCookie);
|
||||
}
|
||||
}
|
||||
|
||||
#region 获取语言
|
||||
/// <summary>
|
||||
/// 获取语言
|
||||
/// </summary>
|
||||
public string GetLanguage
|
||||
{
|
||||
get
|
||||
{
|
||||
string lan = "zh-CN";
|
||||
if (Request.Cookies["SelectLan"] != null)
|
||||
{
|
||||
HttpCookie lanCookie = Request.Cookies["SelectLan"];
|
||||
if (lanCookie["lan"] != null)
|
||||
{
|
||||
if (lanCookie["lan"] == "en-US")
|
||||
{
|
||||
lan = "en-US";
|
||||
}
|
||||
}
|
||||
}
|
||||
return lan;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user