File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using System . Diagnostics ;
2+ using System . Globalization ;
23using System . Runtime . Versioning ;
34using Avalonia ;
45using Avalonia . Controls . ApplicationLifetimes ;
@@ -81,6 +82,7 @@ public override async void OnFrameworkInitializationCompleted()
8182 _serviceProvider = host . Services ;
8283 var settingService = Services . GetRequiredService < AppSettingService > ( ) ;
8384 RequestedThemeVariant = settingService . AppTheme . ToThemeVariant ( ) ;
85+ SetAppLanguage ( settingService . AppLanguageCode ) ;
8486
8587 if ( ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop )
8688 {
@@ -105,6 +107,13 @@ public override async void OnFrameworkInitializationCompleted()
105107 await _host . RunAsync ( ) ;
106108 }
107109
110+ private static void SetAppLanguage ( string languageCode )
111+ {
112+ var cultureInfo = CultureInfo . GetCultureInfo ( languageCode ) ;
113+ CultureInfo . CurrentUICulture = cultureInfo ;
114+ CultureInfo . DefaultThreadCurrentUICulture = cultureInfo ;
115+ }
116+
108117 private static HostApplicationBuilder CreateHostBuilder ( )
109118 {
110119 var settings = new HostApplicationBuilderSettings
You can’t perform that action at this time.
0 commit comments