* 重构多语翻译类
This commit is contained in:
parent
5f09fe5626
commit
7af419a5c0
@ -24,69 +24,6 @@ using System.Globalization;
|
|||||||
|
|
||||||
namespace Sunny.UI
|
namespace Sunny.UI
|
||||||
{
|
{
|
||||||
public static class CultureInfos
|
|
||||||
{
|
|
||||||
//语言文件对应ID网址
|
|
||||||
//https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms912047(v=winembedded.10)?redirectedfrom=MSDN
|
|
||||||
//ID语言 ID语言
|
|
||||||
//1025 阿拉伯语
|
|
||||||
//1041 日语
|
|
||||||
//1028 繁体中文
|
|
||||||
//1042 朝鲜语
|
|
||||||
//1029 捷克语
|
|
||||||
//1043 荷兰语
|
|
||||||
//1030 丹麦语
|
|
||||||
//1044 挪威语
|
|
||||||
//1031 德语
|
|
||||||
//1045 波兰语
|
|
||||||
//1032 希腊语
|
|
||||||
//1046 葡萄牙语 - 巴西
|
|
||||||
//1033 英语
|
|
||||||
//1049 俄语
|
|
||||||
//1034 西班牙语
|
|
||||||
//1053 瑞典语
|
|
||||||
//1035 芬兰语
|
|
||||||
//1054 泰语
|
|
||||||
//1036 法语
|
|
||||||
//1055 土耳其语
|
|
||||||
//1037 希伯来语
|
|
||||||
//2052 简体中文
|
|
||||||
//1038 匈牙利语
|
|
||||||
//2070 葡萄牙语
|
|
||||||
//1040 意大利语
|
|
||||||
//3076 汉语 - 香港
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 2052 简体中文
|
|
||||||
/// </summary>
|
|
||||||
public const int LCID_zh_CN = 2052;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 1028 繁体中文
|
|
||||||
/// </summary>
|
|
||||||
public const int LCID_zh_TW = 1028;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 1033 英语
|
|
||||||
/// </summary>
|
|
||||||
public const int LCID_en_US = 1033;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 2052 简体中文
|
|
||||||
/// </summary>
|
|
||||||
public static readonly CultureInfo zh_CN = CultureInfo.GetCultureInfo(LCID_zh_CN);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 1028 繁体中文
|
|
||||||
/// </summary>
|
|
||||||
public static readonly CultureInfo zh_TW = CultureInfo.GetCultureInfo(LCID_zh_TW);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 1033 英语
|
|
||||||
/// </summary>
|
|
||||||
public static readonly CultureInfo en_US = CultureInfo.GetCultureInfo(LCID_en_US);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class zh_CN_Resources : UIBuiltInResources
|
public class zh_CN_Resources : UIBuiltInResources
|
||||||
{
|
{
|
||||||
public override CultureInfo CultureInfo => CultureInfos.zh_CN;
|
public override CultureInfo CultureInfo => CultureInfos.zh_CN;
|
67
SunnyUI/Style/UCultureInfo.cs
Normal file
67
SunnyUI/Style/UCultureInfo.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace Sunny.UI
|
||||||
|
{
|
||||||
|
public static class CultureInfos
|
||||||
|
{
|
||||||
|
//语言文件对应ID网址
|
||||||
|
//https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms912047(v=winembedded.10)?redirectedfrom=MSDN
|
||||||
|
//ID语言 ID语言
|
||||||
|
//1025 阿拉伯语
|
||||||
|
//1041 日语
|
||||||
|
//1028 繁体中文
|
||||||
|
//1042 朝鲜语
|
||||||
|
//1029 捷克语
|
||||||
|
//1043 荷兰语
|
||||||
|
//1030 丹麦语
|
||||||
|
//1044 挪威语
|
||||||
|
//1031 德语
|
||||||
|
//1045 波兰语
|
||||||
|
//1032 希腊语
|
||||||
|
//1046 葡萄牙语 - 巴西
|
||||||
|
//1033 英语
|
||||||
|
//1049 俄语
|
||||||
|
//1034 西班牙语
|
||||||
|
//1053 瑞典语
|
||||||
|
//1035 芬兰语
|
||||||
|
//1054 泰语
|
||||||
|
//1036 法语
|
||||||
|
//1055 土耳其语
|
||||||
|
//1037 希伯来语
|
||||||
|
//2052 简体中文
|
||||||
|
//1038 匈牙利语
|
||||||
|
//2070 葡萄牙语
|
||||||
|
//1040 意大利语
|
||||||
|
//3076 汉语 - 香港
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 2052 简体中文
|
||||||
|
/// </summary>
|
||||||
|
public const int LCID_zh_CN = 2052;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 1028 繁体中文
|
||||||
|
/// </summary>
|
||||||
|
public const int LCID_zh_TW = 1028;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 1033 英语
|
||||||
|
/// </summary>
|
||||||
|
public const int LCID_en_US = 1033;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 2052 简体中文
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CultureInfo zh_CN = CultureInfo.GetCultureInfo(LCID_zh_CN);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 1028 繁体中文
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CultureInfo zh_TW = CultureInfo.GetCultureInfo(LCID_zh_TW);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 1033 英语
|
||||||
|
/// </summary>
|
||||||
|
public static readonly CultureInfo en_US = CultureInfo.GetCultureInfo(LCID_en_US);
|
||||||
|
}
|
||||||
|
}
|
@ -54,16 +54,74 @@ namespace Sunny.UI
|
|||||||
|
|
||||||
public static class TranslateHelper
|
public static class TranslateHelper
|
||||||
{
|
{
|
||||||
private static List<string> Ingores =
|
private static List<string> Ignores =
|
||||||
[
|
[
|
||||||
"UIContextMenuStrip",
|
"UIContextMenuStrip",
|
||||||
"UIStyleManager",
|
"UIStyleManager",
|
||||||
"UILogo",
|
"UILogo",
|
||||||
"UIPagination",
|
"UIPagination",
|
||||||
"UIMiniPagination"
|
"UIMiniPagination",
|
||||||
|
"UIAnalogMeter",
|
||||||
|
"UIBattery",
|
||||||
|
"UICalendar",
|
||||||
|
"UIColorPicker",
|
||||||
|
"UIComboBox",
|
||||||
|
"UIComboDataGridView",
|
||||||
|
"UIComboTreeView",
|
||||||
|
"UIDataGridViewFooter",
|
||||||
|
"UIDatePicker",
|
||||||
|
"UIDateTimePicker",
|
||||||
|
"UIDigitalLabel",
|
||||||
|
"UIDoubleUpDown",
|
||||||
|
"UIEdit",
|
||||||
|
"UIFlowLayoutPanel",
|
||||||
|
"UIGifAvatar",
|
||||||
|
"UIHorScrollBar",
|
||||||
|
"UIHorScrollBarEx",
|
||||||
|
"UIImageListBox",
|
||||||
|
"UIIntegerUpDown",
|
||||||
|
"UIIPTextBox",
|
||||||
|
"UILedBulb",
|
||||||
|
"UILedStopwatch",
|
||||||
|
"UILight",
|
||||||
|
"UIListBox",
|
||||||
|
"UIListBoxEx",
|
||||||
|
"UIMillisecondTimer",
|
||||||
|
"UINavMenu",
|
||||||
|
"UINumPadTextBox",
|
||||||
|
"UIPipe",
|
||||||
|
"UIProgressIndicator",
|
||||||
|
"UIProcessBar",
|
||||||
|
"UIRichTextBox",
|
||||||
|
"UIRoundMeter",
|
||||||
|
"UIRoundProcess",
|
||||||
|
"UIRuler",
|
||||||
|
"UIScrollBar",
|
||||||
|
"UISignal",
|
||||||
|
"UISplitContainer",
|
||||||
|
"UITabControl",
|
||||||
|
"UITabControlMenu",
|
||||||
|
"UITableLayoutPanel",
|
||||||
|
"UITextBox",
|
||||||
|
"UIThermometer",
|
||||||
|
"UITimePicker",
|
||||||
|
"UIToolTip",
|
||||||
|
"UITrackBar",
|
||||||
|
"UITransfer",
|
||||||
|
"UITransparentPanel",
|
||||||
|
"UITreeView",
|
||||||
|
"UIValve",
|
||||||
|
"UIVerificationCode",
|
||||||
|
"UIVerScrollBarEx",
|
||||||
|
"UIWaitingBar",
|
||||||
|
"UIBarChart",
|
||||||
|
"UIChart",
|
||||||
|
"UIDoughnutChart",
|
||||||
|
"UILineChart",
|
||||||
|
"UIPieChart"
|
||||||
];
|
];
|
||||||
|
|
||||||
private static List<string> Needs =
|
private static List<string> Includes =
|
||||||
[
|
[
|
||||||
"System.Windows.Forms.ToolStripMenuItem"
|
"System.Windows.Forms.ToolStripMenuItem"
|
||||||
];
|
];
|
||||||
@ -134,9 +192,9 @@ namespace Sunny.UI
|
|||||||
string name = items[2].Replace(";", "");
|
string name = items[2].Replace(";", "");
|
||||||
string classname = items[1];
|
string classname = items[1];
|
||||||
|
|
||||||
if (Ingores.Contains(classname)) continue;
|
if (Ignores.Contains(classname)) continue;
|
||||||
|
|
||||||
if (classname.SplitLast(".").StartsWith("UI") || Needs.Contains(classname))
|
if (classname.SplitLast(".").StartsWith("UI") || Includes.Contains(classname))
|
||||||
{
|
{
|
||||||
ctrladds.TryGetValue("this." + name, out string parent);
|
ctrladds.TryGetValue("this." + name, out string parent);
|
||||||
if (parent.IsValid())
|
if (parent.IsValid())
|
||||||
@ -279,12 +337,14 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Load(Form form) => Current.LoadResources(form);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 实体对象
|
/// 实体对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static TConfig current;
|
private static TConfig current;
|
||||||
|
|
||||||
public void Load(Form form)
|
private void LoadResources(Form form)
|
||||||
{
|
{
|
||||||
if (!UIStyles.MultiLanguageSupport) return;
|
if (!UIStyles.MultiLanguageSupport) return;
|
||||||
if (!(form is UIBaseForm || form is UIPage)) return;
|
if (!(form is UIBaseForm || form is UIPage)) return;
|
||||||
@ -339,7 +399,7 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ConcurrentDictionary<string, Ident> InitIdents<T>(T config)
|
private ConcurrentDictionary<string, Ident> InitIdents<T>(T config)
|
||||||
{
|
{
|
||||||
ConcurrentDictionary<string, Ident> concurrentDictionary = new ConcurrentDictionary<string, Ident>();
|
ConcurrentDictionary<string, Ident> concurrentDictionary = new ConcurrentDictionary<string, Ident>();
|
||||||
foreach (PropertyInfo needProperty in config.GetType().GetNeedProperties())
|
foreach (PropertyInfo needProperty in config.GetType().GetNeedProperties())
|
||||||
@ -381,7 +441,7 @@ namespace Sunny.UI
|
|||||||
return concurrentDictionary;
|
return concurrentDictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void LoadConfigValue<T>(T config, ConcurrentDictionary<string, Ident> idents)
|
private void LoadConfigValue<T>(T config, ConcurrentDictionary<string, Ident> idents)
|
||||||
{
|
{
|
||||||
foreach (PropertyInfo needProperty in config.GetType().GetNeedProperties())
|
foreach (PropertyInfo needProperty in config.GetType().GetNeedProperties())
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user