Added system language detection

This commit is contained in:
2026-02-12 11:07:36 +01:00
parent dec9ab6874
commit ba9c16e4c4
4 changed files with 28 additions and 9 deletions

View File

@@ -1,9 +1,7 @@
using System;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Markup.Xaml;
using Avalonia.Markup.Xaml.Styling;
namespace StarterNG.Views;
@@ -19,6 +17,12 @@ public partial class Settings : UserControl
CabTextureResolutionSlider_OnValueChanged(null, null);
shaderResolutionSlider_OnValueChanged(null, null);
};
ChangeLanguageCb.SelectedIndex = App.Loc.CurrentLanguage switch
{
"Polski" => 0,
_ => 1
};
}
private void TextureResolutionSlider_OnValueChanged(object? sender, RangeBaseValueChangedEventArgs e)
@@ -50,7 +54,9 @@ public partial class Settings : UserControl
private void LanguageComboBox_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
{
if (sender is not ComboBox { SelectedItem: ComboBoxItem item }) return;
if (!item.IsKeyboardFocusWithin) return;
var lang = item.Content?.ToString();
if (string.IsNullOrEmpty(lang)) return;
@@ -69,6 +75,6 @@ public partial class Settings : UserControl
}
App.Current.Resources.MergedDictionaries.Add(langDict);
App.Loc.SetLanguage(langDict);
App.Loc.SetLanguage(langDict, lang);
}
}