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
56
57
using Misc;
using MultiLayout.UiModule;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
namespace FLY.Thick.Base.UI.OnInit
{
public class OnInitLanguage : IOnInit
{
ParamDictionary paramDictionary;
public OnInitLanguage(ParamDictionary paramDictionary, int lv=0)
{
this.paramDictionary = paramDictionary;
Level = lv;
UpdateCulture();
}
public int Level { get; }
public void OnInit()
{
paramDictionary.ValueChanged += ParamDictionary_ValueChanged;
}
private void ParamDictionary_ValueChanged(object sender, ParamDictionaryValueChangedEventArgs e)
{
if (e.Key == ParamDistItemKeys.Language)
{
UpdateCulture();
}
}
private void UpdateCulture()
{
CultureInfo info;
string language = paramDictionary.GetValue(ParamDistItemKeys.Language, "zh-CN");
if (language == "en-US")
{
info = new CultureInfo(language);
}
else
{
info = new CultureInfo("zh-CN");
}
Thread.CurrentThread.CurrentCulture = info;
Thread.CurrentThread.CurrentUICulture = info;
}
}
}