diff --git a/src/Leo.Wpf.App/App.xaml.cs b/src/Leo.Wpf.App/App.xaml.cs index 0dfef9e..6ebdcde 100644 --- a/src/Leo.Wpf.App/App.xaml.cs +++ b/src/Leo.Wpf.App/App.xaml.cs @@ -20,6 +20,13 @@ public partial class App : Application { private readonly IHost _host; +#if DEBUG + static App() + { + CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + } +#endif + public App() { _host = Host.CreateDefaultBuilder() @@ -76,9 +83,6 @@ protected override async void OnStartup(StartupEventArgs e) private void LoadApplicationResources() { var cultureInfo = CultureInfo.CurrentUICulture; -#if DEBUG - cultureInfo = CultureInfo.GetCultureInfo("en-US"); -#endif while (!string.IsNullOrEmpty(cultureInfo.Name)) { var uri = $"Resources/{cultureInfo.Name}/Localization.xaml"; diff --git a/src/Leo.Wpf.App/Infrastructure/Constants/Constants.Genders.cs b/src/Leo.Wpf.App/Infrastructure/Constants/Constants.Genders.cs index e19b588..019469f 100644 --- a/src/Leo.Wpf.App/Infrastructure/Constants/Constants.Genders.cs +++ b/src/Leo.Wpf.App/Infrastructure/Constants/Constants.Genders.cs @@ -1,13 +1,37 @@ -namespace Leo.Wpf.App.Infrastructure +using System.Globalization; + +namespace Leo.Wpf.App.Infrastructure { public partial class Constants { public static Dictionary Genders = new() { - // i18n - {"Unkonw", "未知" }, - {"Male", "男" }, - {"Female", "女" }, + {"Unkonw", GetString("Unkonw") }, + {"Male", GetString("Male") }, + {"Female", GetString("Female") }, }; + + // TODO i18n + private static string GetString(string key) + { + var enUS = new Dictionary() + { + {"Unkonw", "Unkonw" }, + {"Male", "Male" }, + {"Female", "Female" }, + }; + var zhCN = new Dictionary() + { + {"Unkonw", "未知" }, + {"Male", "男" }, + {"Female", "女" }, + }; + + if (CultureInfo.CurrentUICulture.Name.Contains("zh")) + { + return zhCN[key]; + } + return enUS[key]; + } } } diff --git a/src/Leo.Wpf.App/ViewModels/FindCustomerViewModel.cs b/src/Leo.Wpf.App/ViewModels/FindCustomerViewModel.cs index f8b201f..6560a97 100644 --- a/src/Leo.Wpf.App/ViewModels/FindCustomerViewModel.cs +++ b/src/Leo.Wpf.App/ViewModels/FindCustomerViewModel.cs @@ -6,6 +6,7 @@ using Leo.Wpf.App.Messages; using System.Collections.ObjectModel; using System.ComponentModel; +using System.Globalization; using System.Windows.Data; namespace Leo.Wpf.App.ViewModels @@ -40,6 +41,24 @@ public FindCustomerViewModel( AllCustomersView = CollectionViewSource.GetDefaultView(AllCustomers); _ = LoadAllCustomersAsync(); + + // TODO i18n + if (CultureInfo.CurrentUICulture.Name.Contains("zh")) + { + SearchFields = new() { + { "name", "姓名" }, + { "phone", "手机" }, + { "card", "卡号" }, + }; + } + else + { + SearchFields = new() { + { "name", "Name" }, + { "phone", "Phone" }, + { "card", "CardNo" }, + }; + } } public ObservableCollection AllCustomers { get; set; } = [];