Skip to content

Commit

Permalink
fix init ui lang
Browse files Browse the repository at this point in the history
  • Loading branch information
Q-Sharp committed Sep 29, 2024
1 parent c0155bd commit 1668364
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions RemnantSaveGuardian/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows;
using System.Windows.Markup;
Expand All @@ -21,10 +22,10 @@

namespace RemnantSaveGuardian
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App
{
// The.NET Generic Host provides dependency injection, configuration, logging, and other services.
// https://docs.microsoft.com/dotnet/core/extensions/generic-host
Expand Down Expand Up @@ -85,7 +86,7 @@ public static T GetService<T>()
/// </summary>
private async void OnStartup(object sender, StartupEventArgs e)
{
var culture = CultureInfo.CurrentCulture;
var culture = CultureInfo.GetCultureInfo(GetUserDefaultUILanguage());
var cultures = EnumerateSupportedCultures();
Current.Properties["langs"] = cultures;
if (!cultures.Contains(culture) && cultures.Contains(culture.Parent))
Expand All @@ -106,6 +107,9 @@ private async void OnStartup(object sender, StartupEventArgs e)
await _host.StartAsync();
}

[DllImport("Kernel32.dll", CharSet = CharSet.Auto)]
static extern ushort GetUserDefaultUILanguage();

private CultureInfo[] EnumerateSupportedCultures()
{
CultureInfo[] culture = CultureInfo.GetCultures(CultureTypes.AllCultures);
Expand Down

0 comments on commit 1668364

Please sign in to comment.