diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index 4568e92f3..91bcfdf5a 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -17,6 +17,7 @@ namespace Flow.Launcher.Core.Resource public class Internationalization { public Settings Settings { get; set; } + public CultureInfo CurrentCulture { get; private set; } private const string Folder = "Languages"; private const string DefaultFile = "en.xaml"; private const string Extension = ".xaml"; @@ -62,6 +63,7 @@ namespace Flow.Launcher.Core.Resource { LoadLanguage(AvailableLanguages.English); _oldResources.Clear(); + CurrentCulture = new CultureInfo("en"); } public void ChangeLanguage(string languageCode) @@ -96,9 +98,12 @@ namespace Flow.Launcher.Core.Resource { LoadLanguage(language); } - Settings.Language = language.LanguageCode; CultureInfo.CurrentCulture = new CultureInfo(language.LanguageCode); CultureInfo.CurrentUICulture = CultureInfo.CurrentCulture; + CurrentCulture = CultureInfo.CurrentCulture; + + // Raise event after this.CurrentCulture is set + Settings.Language = language.LanguageCode; _ = Task.Run(() => { UpdatePluginMetadataTranslations(); diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 109cfc81e..5be065429 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -65,16 +65,10 @@ namespace Flow.Launcher.ViewModel Settings = settings; Settings.PropertyChanged += (_, args) => { - if (args.PropertyName == nameof(Settings.WindowSize)) - { - } switch (args.PropertyName) { case nameof(Settings.WindowSize): OnPropertyChanged(nameof(MainWindowWidth)); break; - case nameof(Settings.Language): - Culture = new CultureInfo(Settings.Language); - break; } }; @@ -106,8 +100,6 @@ namespace Flow.Launcher.ViewModel RegisterClockAndDateUpdateAsync(); SetOpenResultModifiers(); - - Culture = new CultureInfo(Settings.Language); } private void RegisterViewUpdate() @@ -343,7 +335,7 @@ namespace Flow.Launcher.ViewModel public Settings Settings { get; } public string ClockText { get; private set; } public string DateText { get; private set; } - public CultureInfo Culture { get; set; } + public CultureInfo Culture => InternationalizationManager.Instance.CurrentCulture; private async Task RegisterClockAndDateUpdateAsync() { diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index c51e3e421..f31e838fa 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -56,14 +56,12 @@ namespace Flow.Launcher.ViewModel OnPropertyChanged(nameof(ClockText)); break; case nameof(Settings.Language): - Culture = new CultureInfo(Settings.Language); OnPropertyChanged(nameof(ClockText)); OnPropertyChanged(nameof(DateText)); break; } }; - Culture = new CultureInfo(Settings.Language); } public Settings Settings { get; set; } @@ -87,7 +85,7 @@ namespace Flow.Launcher.ViewModel } } - public CultureInfo Culture { get; private set; } + public CultureInfo Culture => InternationalizationManager.Instance.CurrentCulture; public bool StartFlowLauncherOnSystemStartup {