forked from Planshit/Tai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocalizationTest.cs
More file actions
55 lines (48 loc) · 1.66 KB
/
LocalizationTest.cs
File metadata and controls
55 lines (48 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Globalization;
using System.Resources;
using System.Threading;
namespace LocalizationTest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Tai 本地化测试程序");
Console.WriteLine("==================");
// 测试中文
Console.WriteLine("\n测试中文 (zh-CN):");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-CN");
TestLocalization();
// 测试英文
Console.WriteLine("\n测试英文 (en-US):");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
TestLocalization();
Console.WriteLine("\n按任意键退出...");
Console.ReadKey();
}
static void TestLocalization()
{
try
{
var resourceManager = new ResourceManager("UI.Properties.Resources", typeof(Program).Assembly);
var testKeys = new[]
{
"Navigation_Overview",
"Settings_Title",
"Website_Title",
"Message_Loading"
};
foreach (var key in testKeys)
{
var value = resourceManager.GetString(key, Thread.CurrentThread.CurrentUICulture);
Console.WriteLine($"{key}: {value}");
}
}
catch (Exception ex)
{
Console.WriteLine($"错误: {ex.Message}");
}
}
}
}