Files
SGGL_SHJ/SGGL/FineUIPro.Web/common/UiLanguage.cs
T
lpf 626ad445d4 feat: 支持系统单位和多语言配置
通过系统环境维护单位及语言开关,并调整相关页面和接口以使用当前配置。
2026-11-07 15:22:32 +08:00

47 lines
1.4 KiB
C#

using BLL;
using System;
using System.Globalization;
using System.Threading;
using System.Web;
namespace FineUIPro.Web
{
public static class UiLanguage
{
public static bool IsEnabled
{
get
{
var context = HttpContext.Current;
if (context.Items["MultiLanguageEnabled"] == null)
{
context.Items["MultiLanguageEnabled"] = SysConstSetService.IsMultiLanguageEnabled;
}
return (bool)context.Items["MultiLanguageEnabled"];
}
}
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
{
get { return IsEnabled ? Resolve(HttpContext.Current.Request.Cookies["Language_Pro"]?.Value, HttpContext.Current.Request.Cookies["Language"]?.Value) : "zh_CN"; }
}
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; }
}
}
}