From ab6f8874c56db69033f5f7ec64145581837d4e21 Mon Sep 17 00:00:00 2001 From: dev Date: Tue, 24 May 2022 09:58:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B7=BB=E5=8A=A0=E6=96=B0?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E7=9A=84=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CleanMachineHMI/Program.cs | 3 --- CleanMachineHMI/Utils/GlobalHelper.cs | 28 +++++++++++++-------------- CleanMachineHMI/Utils/frmUtil.cs | 14 ++++++++------ 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/CleanMachineHMI/Program.cs b/CleanMachineHMI/Program.cs index 5aaf19b..fc2c7e3 100644 --- a/CleanMachineHMI/Program.cs +++ b/CleanMachineHMI/Program.cs @@ -27,9 +27,6 @@ namespace CleanMachineHMI Application.EnableVisualStyles(); //frmUtil.DB2Json();//语言字典从数据库转json Global.LoadTheme(); -#if DEBUG - Global.LoadzhCN(); -#endif Application.SetCompatibleTextRenderingDefault(false); Global.LoadAllFormData(); Application.Run(Global.LoginForm); diff --git a/CleanMachineHMI/Utils/GlobalHelper.cs b/CleanMachineHMI/Utils/GlobalHelper.cs index 146322b..1b5ec68 100644 --- a/CleanMachineHMI/Utils/GlobalHelper.cs +++ b/CleanMachineHMI/Utils/GlobalHelper.cs @@ -335,20 +335,20 @@ namespace CleanMachineHMI } } - public static void LoadzhCN() - { - if (Utils.frmUtil.znCNLang == null || Utils.frmUtil.znCNLang.Count == 0) - { - var appPath = System.Windows.Forms.Application.StartupPath.Split(new string[] { @"bin\Debug" }, StringSplitOptions.RemoveEmptyEntries)[0]; - var filePath = appPath + $"Lang\\zh-CN.json"; - if (!File.Exists(filePath)) - { - return; - } - var str = File.ReadAllText(filePath); - Utils.frmUtil.znCNLang = Newtonsoft.Json.JsonConvert.DeserializeObject>(str); + //public static void LoadzhCN() + //{ + // if (Utils.frmUtil.znCNLang == null || Utils.frmUtil.znCNLang.Count == 0) + // { + // var appPath = System.Windows.Forms.Application.StartupPath.Split(new string[] { @"bin\Debug" }, StringSplitOptions.RemoveEmptyEntries)[0]; + // var filePath = appPath + $"Lang\\zh-CN.json"; + // if (!File.Exists(filePath)) + // { + // return; + // } + // var str = File.ReadAllText(filePath); + // Utils.frmUtil.znCNLang = Newtonsoft.Json.JsonConvert.DeserializeObject>(str); - } - } + // } + //} } } diff --git a/CleanMachineHMI/Utils/frmUtil.cs b/CleanMachineHMI/Utils/frmUtil.cs index 8a60dea..be5723d 100644 --- a/CleanMachineHMI/Utils/frmUtil.cs +++ b/CleanMachineHMI/Utils/frmUtil.cs @@ -21,7 +21,10 @@ namespace CleanMachineHMI.Utils /// public static class frmUtil { - public static List znCNLang = new List(); + /// + /// 新增的翻译 + /// + public static List _newlyLang = new List(); /// /// 给一个字符串进行MD5加密 @@ -351,20 +354,19 @@ namespace CleanMachineHMI.Utils return; } var codes = key.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries); - - if (znCNLang.Any(x => x.formCode == codes[0] && x.controlCode == codes[1])) + if (Global.ThemeLanguage.ContainsKey(key)) { return; } - znCNLang.Add(new ThemeLanguage + _newlyLang.Add(new ThemeLanguage { formCode = codes[0], controlCode = codes[1], controlName = string.IsNullOrEmpty(options) ? name : null, options = string.IsNullOrEmpty(options) ? null : options.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList(), }); - var str1 = Newtonsoft.Json.JsonConvert.SerializeObject(znCNLang); - WriteLangFile("zh-CN.json", str1); + var str1 = Newtonsoft.Json.JsonConvert.SerializeObject(_newlyLang); + WriteLangFile("newly.json", str1); } }