626ad445d4
通过系统环境维护单位及语言开关,并调整相关页面和接口以使用当前配置。
47 lines
1.4 KiB
C#
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; }
|
|
}
|
|
}
|
|
}
|