生成中文语言包

This commit is contained in:
ehkang
2022-03-19 12:46:23 +08:00
parent e9367f6b29
commit 55588c0e6e
19 changed files with 5505 additions and 9276 deletions

View File

@@ -191,40 +191,37 @@ namespace CleanMachineHMI
{
var appPath = System.Windows.Forms.Application.StartupPath.Split(new string[] { @"bin\Debug" }, StringSplitOptions.RemoveEmptyEntries)[0];
var filePath = appPath + $"Lang\\{GlobalHelper.LanguageCode}.json";
using (StreamReader sr = new StreamReader(filePath))
var str = File.ReadAllText(filePath);
var lstLanguage = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ThemeLanguage>>(str);
var tmpThemeLanguage = new Dictionary<string, string>();
lstLanguage.ForEach(item =>
{
var str = sr.ReadToEnd();
var lstLanguage = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ThemeLanguage>>(str);
//var tmpThemeLanguage = new List<ThemeLanguage>();
//lstLanguage.ForEach(item =>
//{
// var part = tmpThemeLanguage.FirstOrDefault(x => x.formCode == item.formCode && x.controlCode == item.controlCode);
// if (part == null)
// {
// tmpThemeLanguage.Add(item);
// }
// else
// {
// part.options.Add(item.controlName);
// }
//});
//var str1 = Newtonsoft.Json.JsonConvert.SerializeObject(tmpThemeLanguage);
//WriteFile(appPath + "\\Lang", filePath, str1);
var tmpThemeLanguage = new Dictionary<string, string>();
lstLanguage.ForEach(item =>
if (item.options != null && item.options.Count > 0)
{
if (item.options.Count > 0)
{
tmpThemeLanguage.Add(item.formCode + "|" + item.controlCode, string.Join(",", item.options));
}
else
{
tmpThemeLanguage.Add(item.formCode + "|" + item.controlCode, item.controlName);
}
});
ThemeLanguage = tmpThemeLanguage;
tmpThemeLanguage.Add(item.formCode + "|" + item.controlCode, string.Join(",", item.options));
}
else
{
tmpThemeLanguage.Add(item.formCode + "|" + item.controlCode, item.controlName);
}
});
ThemeLanguage = tmpThemeLanguage;
}
}
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<List<ThemeLanguage>>(str);
}
}
}