Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix init ui lang #283

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -77,7 +78,7 @@
public static T GetService<T>()
where T : class
{
return _host.Services.GetService(typeof(T)) as T;

Check warning on line 81 in RemnantSaveGuardian/App.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference return.
}

/// <summary>
Expand All @@ -85,7 +86,7 @@
/// </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 @@
await _host.StartAsync();
}

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

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