添加完成国际化触发器

This commit is contained in:
2025-01-09 15:09:34 +08:00
parent c19b32cae3
commit 8fea1ef63f
4 changed files with 395 additions and 596 deletions
+30 -15
View File
@@ -4,10 +4,12 @@ using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Web;
using System.Web.UI;
using AspNet = System.Web.UI.WebControls;
@@ -44,6 +46,32 @@ namespace FineUIPro.Web
#region OnInit
/// <summary>
/// 初始化多语言资源
/// </summary>
protected override void InitializeCulture()
{
HttpCookie langCookie = Request.Cookies["Language"];
// 默认为中文
var langName = "zh-CN";
if (langCookie != null)
{
// 简单的转换:zh_CN -> zh-CN
langName = langCookie.Value.Replace("_", "-");
if (langName == "en")
{
langName = "en-US";
}
}
// 设置语言
var cultureInfo = CultureInfo.CreateSpecificCulture(langName);
Thread.CurrentThread.CurrentCulture = cultureInfo;
Thread.CurrentThread.CurrentUICulture = cultureInfo;
base.InitializeCulture();
}
protected override void OnInit(EventArgs e)
{
string url = HttpContext.Current.Request.Path;
@@ -93,21 +121,6 @@ namespace FineUIPro.Web
}
}
HttpCookie langCookie = Request.Cookies["Language"];
if (langCookie != null)
{
string langValue = langCookie.Value;
try
{
// 是否为内置语言
pm.Language = (Language)Enum.Parse(typeof(Language), langValue, true);
}
catch (Exception)
{
pm.CustomLanguage = langValue;
}
}
// 1. 仅显示基础版示例, 2. 基础版
// 上述两种情况都要禁用EnableAnimation、DisplayMode、MobileAdaption
bool showOnlyBase = false;
@@ -206,6 +219,8 @@ namespace FineUIPro.Web
//}
}
/// <summary>
/// UNLOAD事件,发生在页面装载顺序的最后。
/// 在这里处理的是DBLIST,数据库连接字典。