From 0315053c0a16cc6ec8fb1206c498824f858f071c Mon Sep 17 00:00:00 2001 From: DB p Date: Sun, 20 Nov 2022 15:14:43 +0900 Subject: [PATCH] Fix CultureInfo Reflect Preview/Flow --- Flow.Launcher/ViewModel/MainViewModel.cs | 6 ++++-- Flow.Launcher/ViewModel/SettingWindowViewModel.cs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index dc8121c5a..dea85fd65 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -23,6 +23,7 @@ using ISavable = Flow.Launcher.Plugin.ISavable; using System.IO; using System.Collections.Specialized; using CommunityToolkit.Mvvm.Input; +using System.Globalization; namespace Flow.Launcher.ViewModel { @@ -326,6 +327,7 @@ namespace Flow.Launcher.ViewModel public string ClockText { get; private set; } public string DateText { get; private set; } + public CultureInfo cultureInfo => new CultureInfo(Settings.Language); private async Task RegisterClockAndDateUpdateAsync() { var timer = new PeriodicTimer(TimeSpan.FromSeconds(1)); @@ -333,9 +335,9 @@ namespace Flow.Launcher.ViewModel while (await timer.WaitForNextTickAsync().ConfigureAwait(false)) { if (Settings.UseClock) - ClockText = DateTime.Now.ToString(Settings.TimeFormat); + ClockText = DateTime.Now.ToString(Settings.TimeFormat, cultureInfo); if (Settings.UseDate) - DateText = DateTime.Now.ToString(Settings.DateFormat); + DateText = DateTime.Now.ToString(Settings.DateFormat, cultureInfo); } } public ResultsViewModel Results { get; private set; } diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 78c82bee6..60ce25a0f 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -55,6 +55,7 @@ namespace Flow.Launcher.ViewModel case nameof(Settings.TimeFormat): OnPropertyChanged(nameof(ClockText)); break; + } }; } @@ -80,6 +81,7 @@ namespace Flow.Launcher.ViewModel } } + public CultureInfo cultureInfo => new CultureInfo(Settings.Language); public bool StartFlowLauncherOnSystemStartup { get => Settings.StartFlowLauncherOnSystemStartup; @@ -500,9 +502,9 @@ namespace Flow.Launcher.ViewModel set { Settings.DateFormat = value; } } - public string ClockText => DateTime.Now.ToString(TimeFormat); + public string ClockText => DateTime.Now.ToString(TimeFormat, cultureInfo); - public string DateText => DateTime.Now.ToString(DateFormat); + public string DateText => DateTime.Now.ToString(DateFormat, cultureInfo); public double WindowWidthSize