mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-05-21 12:53:18 +12:00
Move LoadLanguage to Utils
This commit is contained in:
parent
83760c6a0a
commit
3fe99bb5e2
|
@ -36,7 +36,7 @@ namespace ModAssistant
|
|||
System.Net.ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
|
||||
|
||||
// Load localisation languages
|
||||
LoadLanguage(CultureInfo.CurrentCulture.Name);
|
||||
Utils.LoadLanguage(CultureInfo.CurrentCulture.Name);
|
||||
|
||||
// Uncomment the next line to debug localisation
|
||||
// LoadLanguage("en-DEBUG");
|
||||
|
@ -142,7 +142,7 @@ namespace ModAssistant
|
|||
}
|
||||
else
|
||||
{
|
||||
LoadLanguage(args[1]);
|
||||
Utils.LoadLanguage(args[1]);
|
||||
}
|
||||
|
||||
args = Shift(args, 2);
|
||||
|
@ -213,29 +213,5 @@ namespace ModAssistant
|
|||
e.Handled = true;
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
||||
private ResourceDictionary LanguagesDict
|
||||
{
|
||||
get
|
||||
{
|
||||
return Resources.MergedDictionaries[1];
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadLanguage(string culture)
|
||||
{
|
||||
try
|
||||
{
|
||||
LanguagesDict.Source = new Uri($"Localisation/{culture}.xaml", UriKind.Relative);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
if (culture.Contains("-"))
|
||||
{
|
||||
LoadLanguage(culture.Split('-').First());
|
||||
}
|
||||
// Can't load language file
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -439,5 +439,29 @@ namespace ModAssistant
|
|||
ShowMessageBoxDelegate caller = new ShowMessageBoxDelegate(ShowMessageBox);
|
||||
caller.BeginInvoke(Message, null, null, null);
|
||||
}
|
||||
|
||||
private static ResourceDictionary LanguagesDict
|
||||
{
|
||||
get
|
||||
{
|
||||
return Application.Current.Resources.MergedDictionaries[1];
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadLanguage(string culture)
|
||||
{
|
||||
try
|
||||
{
|
||||
LanguagesDict.Source = new Uri($"Localisation/{culture}.xaml", UriKind.Relative);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
if (culture.Contains("-"))
|
||||
{
|
||||
LoadLanguage(culture.Split('-').First());
|
||||
}
|
||||
// Can't load language file
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue