diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 47cc794..f5b6d47 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -29,8 +29,6 @@ namespace Bloxstrap public static LaunchSettings LaunchSettings { get; private set; } = null!; - public static CultureInfo CurrentCulture { get; set; } = CultureInfo.InvariantCulture; - public static BuildMetadataAttribute BuildMetadata = Assembly.GetExecutingAssembly().GetCustomAttribute()!; public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2]; @@ -113,7 +111,7 @@ namespace Bloxstrap { const string LOG_IDENT = "App::OnStartup"; - CurrentCulture = Thread.CurrentThread.CurrentUICulture; + Locale.CurrentCulture = Thread.CurrentThread.CurrentUICulture; base.OnStartup(e); diff --git a/Bloxstrap/Locale.cs b/Bloxstrap/Locale.cs index 0d46530..a984ea5 100644 --- a/Bloxstrap/Locale.cs +++ b/Bloxstrap/Locale.cs @@ -6,6 +6,8 @@ namespace Bloxstrap { internal static class Locale { + public static CultureInfo CurrentCulture = CultureInfo.InvariantCulture; + public static readonly Dictionary SupportedLocales = new() { { "nil", Strings.Enums_Theme_Default }, // /shrug @@ -72,17 +74,29 @@ namespace Bloxstrap if (identifier == "nil") return; - App.CurrentCulture = new CultureInfo(identifier); + CurrentCulture = new CultureInfo(identifier); - CultureInfo.DefaultThreadCurrentUICulture = App.CurrentCulture; - Thread.CurrentThread.CurrentUICulture = App.CurrentCulture; + CultureInfo.DefaultThreadCurrentUICulture = CurrentCulture; + Thread.CurrentThread.CurrentUICulture = CurrentCulture; RoutedEventHandler? handler = null; if (identifier == "ar" || identifier == "he") - handler = new((window, _) => ((Window)window).FlowDirection = FlowDirection.RightToLeft); + { + handler = new((sender, _) => + { + var window = (Window)sender; + + window.FlowDirection = FlowDirection.RightToLeft; + + if (window.ContextMenu is not null) + window.ContextMenu.FlowDirection = FlowDirection.RightToLeft; + }); + } else if (identifier == "th") + { handler = new((window, _) => ((Window)window).FontFamily = new System.Windows.Media.FontFamily(new Uri("pack://application:,,,/Resources/Fonts/"), "./#Noto Sans Thai")); + } // https://supportcenter.devexpress.com/ticket/details/t905790/is-there-a-way-to-set-right-to-left-mode-in-wpf-for-the-whole-application if (handler is not null) diff --git a/Bloxstrap/Logger.cs b/Bloxstrap/Logger.cs index 093591e..9bea80a 100644 --- a/Bloxstrap/Logger.cs +++ b/Bloxstrap/Logger.cs @@ -97,7 +97,7 @@ WriteLine($"[{identifier}] {ex}"); - Thread.CurrentThread.CurrentUICulture = App.CurrentCulture; + Thread.CurrentThread.CurrentUICulture = Locale.CurrentCulture; } private async void WriteToLog(string message)