Show language names in theme settings

This commit is contained in:
2dust
2026-09-10 09:40:16 +08:00
parent 7be23d7ebc
commit 526cd6834d
5 changed files with 25 additions and 12 deletions

View File

@@ -489,17 +489,22 @@ public class Global
"localhost"
];
public static readonly List<LanguageOption> LanguageOptions =
[
new("zh-Hans", "简体中文"),
new("zh-Hant", "繁體中文"),
new("en", "English"),
new("fa", "فارسی"),
new("fr", "Français"),
new("ru", "Русский"),
new("hu", "Magyar"),
new("id", "Bahasa Indonesia"),
new("az", "Azərbaycan dili")
];
public static readonly List<string> Languages =
[
"zh-Hans",
"zh-Hant",
"en",
"fa",
"fr",
"ru",
"hu",
"id",
"az"
.. LanguageOptions.Select(t => t.Value)
];
public static readonly List<string> Alpns =

View File

@@ -0,0 +1,3 @@
namespace ServiceLib.Models.Dto;
public sealed record LanguageOption(string Value, string Display);

View File

@@ -1,3 +1,4 @@
using Avalonia.Data;
using v2rayN.Desktop.ViewModels;
namespace v2rayN.Desktop.Views;
@@ -14,7 +15,9 @@ public partial class ThemeSettingView : ReactiveUserControl<ThemeSettingViewMode
cmbCurrentTheme.ItemsSource = Utils.GetEnumNames<ETheme>();
cmbCurrentFontSize.ItemsSource = Enumerable.Range(Global.MinFontSize, Global.MinFontSizeCount).ToList();
cmbCurrentLanguage.ItemsSource = Global.Languages;
cmbCurrentLanguage.ItemsSource = Global.LanguageOptions;
cmbCurrentLanguage.DisplayMemberBinding = new Binding(nameof(LanguageOption.Display));
cmbCurrentLanguage.SelectedValueBinding = new Binding(nameof(LanguageOption.Value));
this.WhenActivated(disposables =>
{

View File

@@ -81,6 +81,8 @@
Grid.Column="1"
Width="120"
Margin="{StaticResource Margin8}"
DisplayMemberPath="Display"
SelectedValuePath="Value"
Style="{StaticResource DefComboBox}" />
</Grid>
</StackPanel>

View File

@@ -14,7 +14,7 @@ public partial class ThemeSettingView
cmbCurrentTheme.ItemsSource = Utils.GetEnumNames<ETheme>().Take(3).ToList();
cmbCurrentFontSize.ItemsSource = Enumerable.Range(Global.MinFontSize, Global.MinFontSizeCount).ToList();
cmbCurrentLanguage.ItemsSource = Global.Languages;
cmbCurrentLanguage.ItemsSource = Global.LanguageOptions;
this.WhenActivated(disposables =>
{
@@ -22,7 +22,7 @@ public partial class ThemeSettingView
this.OneWayBind(ViewModel, vm => vm.Swatches, v => v.cmbSwatches.ItemsSource).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSwatch, v => v.cmbSwatches.SelectedItem).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CurrentFontSize, v => v.cmbCurrentFontSize.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CurrentLanguage, v => v.cmbCurrentLanguage.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.CurrentLanguage, v => v.cmbCurrentLanguage.SelectedValue).DisposeWith(disposables);
});
}
}