2026-11-02 11:16:43 +08:00
|
|
|
using BLL;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Web;
|
|
|
|
|
|
|
|
|
|
namespace FineUIPro.Web
|
|
|
|
|
{
|
|
|
|
|
public static class UiLanguage
|
|
|
|
|
{
|
2026-11-07 15:22:32 +08:00
|
|
|
public static bool IsEnabled
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var context = HttpContext.Current;
|
|
|
|
|
if (context.Items["MultiLanguageEnabled"] == null)
|
|
|
|
|
{
|
|
|
|
|
context.Items["MultiLanguageEnabled"] = SysConstSetService.IsMultiLanguageEnabled;
|
|
|
|
|
}
|
|
|
|
|
return (bool)context.Items["MultiLanguageEnabled"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-02 11:16:43 +08:00
|
|
|
public static string Resolve(string current, string legacy)
|
|
|
|
|
{
|
|
|
|
|
string value = current ?? legacy;
|
|
|
|
|
return string.Equals(value, "en", StringComparison.OrdinalIgnoreCase) ? "en" : "zh_CN";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string Current
|
|
|
|
|
{
|
2026-11-07 15:22:32 +08:00
|
|
|
get { return IsEnabled ? Resolve(HttpContext.Current.Request.Cookies["Language_Pro"]?.Value, HttpContext.Current.Request.Cookies["Language"]?.Value) : "zh_CN"; }
|
2026-11-02 11:16:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Apply()
|
|
|
|
|
{
|
|
|
|
|
// 只改变界面语言,保留现有数字、日期解析和数据库传输约定。
|
|
|
|
|
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(Current == "en" ? "en-US" : "zh-CN");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Language ControlLanguage
|
|
|
|
|
{
|
|
|
|
|
get { return Current == "en" ? Language.EN : Language.ZH_CN; }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|