e30bb4b1b7
为页面、菜单及提示接入中英文资源,保留业务值和导出中文标题,以支持用户切换界面语言。
42 lines
1.5 KiB
C#
42 lines
1.5 KiB
C#
using BLL;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Web;
|
|
|
|
namespace FineUIPro.Web
|
|
{
|
|
public class UiResources : IHttpHandler
|
|
{
|
|
private static readonly IDictionary<string, string[]> Modules = JsonConvert.DeserializeObject<Dictionary<string, string[]>>(
|
|
File.ReadAllText(HttpContext.Current.Server.MapPath("~/App_GlobalResources/UiModules.json")));
|
|
|
|
public static bool HasModule(string module)
|
|
{
|
|
return Modules.ContainsKey(module);
|
|
}
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
UiLanguage.Apply();
|
|
string module = context.Request.QueryString["module"] ?? "Common";
|
|
string[] keys;
|
|
if (!Modules.TryGetValue(module, out keys))
|
|
{
|
|
context.Response.StatusCode = 400;
|
|
return;
|
|
}
|
|
context.Response.ContentType = "application/javascript";
|
|
context.Response.ContentEncoding = Encoding.UTF8;
|
|
context.Response.Cache.SetCacheability(HttpCacheability.Private);
|
|
context.Response.Cache.SetNoStore();
|
|
context.Response.Write("window.SGGLI18nResources=" + JsonConvert.SerializeObject(UiText.ClientResources(keys),
|
|
new JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeHtml }) + ";");
|
|
}
|
|
|
|
public bool IsReusable { get { return true; } }
|
|
}
|
|
}
|