MCPcopy Create free account
hub / github.com/PenguLoader/PenguLoader / App

Class App

loader/App.xaml.cs:8–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6namespace PenguLoader
7{
8 public partial class App : Application
9 {
10 protected override void OnStartup(StartupEventArgs e)
11 {
12 base.OnStartup(e);
13 SetLanguage(Config.Language);
14 }
15
16 public static event EventHandler LanguageChanged;
17 public static string Language
18 {
19 get => Config.Language;
20 set
21 {
22 if (value != Config.Language)
23 {
24 Config.Language = value;
25 SetLanguage(value);
26 LanguageChanged?.Invoke(null, EventArgs.Empty);
27 }
28 }
29 }
30
31 public static string[] Languages
32 {
33 get
34 {
35 var keys = LanguageMap.Keys;
36 var languages = new string[keys.Count];
37 keys.CopyTo(languages, 0);
38 return languages;
39 }
40 }
41
42 static readonly Dictionary<string, string> LanguageMap = new Dictionary<string, string>
43 {
44 { "English", "en-US.xaml" },
45 { "Tiếng Việt", "vi-VN.xaml" },
46 { "日本語", "ja-JP.xaml" },
47 { "中文", "zh-CN.xaml" },
48 { "Deutsch", "de-DE.xaml" },
49 { "Español", "es-ES.xaml" },
50 { "Français", "fr-FR.xaml"},
51 { "Português", "pt-BR.xaml" },
52 { "Русский", "ru-RU.xaml" },
53 { "Türkçe", "tr-TR.xaml" }
54 };
55
56 public static void SetLanguage(string lang)
57 {
58 if (!LanguageMap.ContainsKey(lang))
59 lang = "English";
60
61 var dict = new ResourceDictionary();
62 var file = LanguageMap[lang];
63 dict.Source = new Uri($"Languages/{file}", UriKind.Relative);
64
65 Current.Resources.MergedDictionaries.Add(dict);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected