From 2325844bd436335a956469406919c7447f714198 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 16 Oct 2025 20:33:43 -0400 Subject: [PATCH] Slight cleanup to main window language handling --- MPF.UI/Windows/MainWindow.xaml | 2 +- MPF.UI/Windows/MainWindow.xaml.cs | 20 ++++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/MPF.UI/Windows/MainWindow.xaml b/MPF.UI/Windows/MainWindow.xaml index f09665e0..8ef70b20 100644 --- a/MPF.UI/Windows/MainWindow.xaml +++ b/MPF.UI/Windows/MainWindow.xaml @@ -118,7 +118,7 @@ Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" Foreground="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" Template="{DynamicResource CustomMenuItemTemplate}"> - diff --git a/MPF.UI/Windows/MainWindow.xaml.cs b/MPF.UI/Windows/MainWindow.xaml.cs index 46bfc047..4d855ea5 100644 --- a/MPF.UI/Windows/MainWindow.xaml.cs +++ b/MPF.UI/Windows/MainWindow.xaml.cs @@ -575,8 +575,8 @@ namespace MPF.UI.Windows /// private void LanguageMenuItemClick(object sender, RoutedEventArgs e) { - var clickedItem = (MenuItem)sender; // Don't do anything if language is already checked and being unchecked + var clickedItem = (MenuItem)sender; if (!clickedItem.IsChecked) { clickedItem.IsChecked = true; @@ -594,20 +594,12 @@ namespace MPF.UI.Windows // Change UI language to selected item string lang = clickedItem.Header.ToString() ?? ""; var dictionary = new ResourceDictionary(); - switch (lang) + dictionary.Source = lang switch { - case "ENG": - // Change UI language to English - dictionary.Source = new Uri("../Resources/Strings.xaml", UriKind.Relative); - break; - case "한국어": - // Change UI language to Korean - dictionary.Source = new Uri("../Resources/Strings.ko.xaml", UriKind.Relative); - break; - default: - dictionary.Source = new Uri("../Resources/Strings.xaml", UriKind.Relative); - break; - } + "ENG" => new Uri("../Resources/Strings.xaml", UriKind.Relative), + "한국어" => new Uri("../Resources/Strings.ko.xaml", UriKind.Relative), + _ => new Uri("../Resources/Strings.xaml", UriKind.Relative), + }; Application.Current.Resources.MergedDictionaries.Add(dictionary); // Update the labels that don't get updated automatically