Skip to content

Free, open-source Windows optimization tool for performance, privacy, and simplicity.

feat: add RTL FlowDirection support

fatDuck1f22ee4c484d
diff --git a/optimizerDuck/Services/Configuration/LanguageManager.cs b/optimizerDuck/Services/Configuration/LanguageManager.cs
index d820718..1a5a52c 100644
--- a/optimizerDuck/Services/Configuration/LanguageManager.cs
+++ b/optimizerDuck/Services/Configuration/LanguageManager.cs
@@ -1,12 +1,15 @@
+using System.ComponentModel;
using System.Globalization;
+using System.Windows;
using optimizerDuck.Resources.Languages;
namespace optimizerDuck.Services.Configuration;
/// <summary>
/// Provides localization and culture management for the application.
+/// Implements <see cref="INotifyPropertyChanged" /> so UI bindings (e.g., FlowDirection) update on culture change.
/// </summary>
-public class Loc
+public class Loc : INotifyPropertyChanged
{
/// <summary>
/// Gets the singleton instance of the localization manager.
@@ -18,6 +21,17 @@ public class Loc
/// </summary>
public static CultureInfo CurrentCulture => Translations.Culture;
+ /// <summary>
+ /// Gets whether the current culture uses a right-to-left writing system.
+ /// </summary>
+ public bool IsRtl => Translations.Culture.TextInfo.IsRightToLeft;
+
+ /// <summary>
+ /// Gets the <see cref="FlowDirection" /> corresponding to the current culture.
+ /// Returns <see cref="FlowDirection.RightToLeft" /> for RTL languages, otherwise <see cref="FlowDirection.LeftToRight" />.
+ /// </summary>
+ public FlowDirection Direction => IsRtl ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
+
/// <summary>
/// Gets the localized string for the specified key.
/// </summary>
@@ -33,5 +47,19 @@ public class Loc
public void ChangeCulture(CultureInfo culture)
{
Translations.Culture = culture;
+ OnPropertyChanged(nameof(IsRtl));
+ OnPropertyChanged(nameof(Direction));
+ }
+
+ /// <inheritdoc />
+ public event PropertyChangedEventHandler? PropertyChanged;
+
+ /// <summary>
+ /// Raises the <see cref="PropertyChanged" /> event.
+ /// </summary>
+ /// <param name="propertyName">The name of the property that changed.</param>
+ protected virtual void OnPropertyChanged(string propertyName)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
diff --git a/optimizerDuck/UI/Windows/MainWindow.xaml b/optimizerDuck/UI/Windows/MainWindow.xaml
index ab7f671..e434222 100644
--- a/optimizerDuck/UI/Windows/MainWindow.xaml
+++ b/optimizerDuck/UI/Windows/MainWindow.xaml
@@ -5,6 +5,7 @@
xmlns:controls="clr-namespace:optimizerDuck.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:extensions="clr-namespace:optimizerDuck.Common.Extensions"
+ xmlns:config="clr-namespace:optimizerDuck.Services.Configuration"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pages="clr-namespace:optimizerDuck.UI.Pages"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
@@ -26,7 +27,7 @@
WindowCornerPreference="Round"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
- <Grid>
+ <Grid FlowDirection="{Binding Direction, Source={x:Static config:Loc.Instance}}">
<ui:NavigationView
x:Name="RootNavigation"
Margin="0"