From 1a45dc8df882e58e4280849541e4f3be94f0edb9 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz <42140194+IsaacMarovitz@users.noreply.github.com> Date: Sat, 13 Jan 2024 00:42:42 +0000 Subject: [PATCH] Ava UI: RTL Language Support (#5619) * Add Hebrew locale files to ItemGroups * Align all windows RTL for testing This should be controlled with a binding that selects the appropriate layout based on current language * Update FlowDirection as Locale changes * Fix Settings NavigationViewItem FlowDirection * Fix remaining text * Fix input menu directionality * Fix RTL not rendering * Fix rebase errors --- src/Ryujinx.Ava/Common/Locale/LocaleManager.cs | 14 ++++++++++++++ src/Ryujinx.Ava/Ryujinx.Ava.csproj | 2 ++ .../UI/Controls/ApplicationListView.axaml | 16 ++++++++-------- src/Ryujinx.Ava/UI/Renderer/RendererHost.axaml | 9 +++++---- .../UI/Views/Input/ControllerInputView.axaml | 3 ++- .../UI/Views/Main/MainStatusBarView.axaml | 12 ++++++------ .../User/UserProfileImageSelectorView.axaml | 4 ++-- .../UI/Views/User/UserRecovererView.axaml | 4 ++-- src/Ryujinx.Ava/UI/Windows/AboutWindow.axaml | 2 +- src/Ryujinx.Ava/UI/Windows/AmiiboWindow.axaml | 2 +- src/Ryujinx.Ava/UI/Windows/MainWindow.axaml | 6 +++--- src/Ryujinx.Ava/UI/Windows/SettingsWindow.axaml | 3 +++ src/Ryujinx.Ava/UI/Windows/StyleableWindow.cs | 10 ++++++++++ .../UI/Windows/TitleUpdateWindow.axaml | 2 +- 14 files changed, 60 insertions(+), 29 deletions(-) diff --git a/src/Ryujinx.Ava/Common/Locale/LocaleManager.cs b/src/Ryujinx.Ava/Common/Locale/LocaleManager.cs index 64f3a7e8..0e613838 100644 --- a/src/Ryujinx.Ava/Common/Locale/LocaleManager.cs +++ b/src/Ryujinx.Ava/Common/Locale/LocaleManager.cs @@ -16,8 +16,10 @@ namespace Ryujinx.Ava.Common.Locale private readonly Dictionary _localeStrings; private Dictionary _localeDefaultStrings; private readonly ConcurrentDictionary _dynamicValues; + private string _localeLanguageCode; public static LocaleManager Instance { get; } = new(); + public event Action LocaleChanged; public LocaleManager() { @@ -104,6 +106,15 @@ namespace Ryujinx.Ava.Common.Locale } } + public bool IsRTL() + { + return _localeLanguageCode switch + { + "he_IL" => true, + _ => false + }; + } + public string UpdateAndGetDynamicValue(LocaleKeys key, params object[] values) { _dynamicValues[key] = values; @@ -124,6 +135,9 @@ namespace Ryujinx.Ava.Common.Locale { this[item.Key] = item.Value; } + + _localeLanguageCode = languageCode; + LocaleChanged?.Invoke(); } private static Dictionary LoadJsonLanguage(string languageCode = DefaultLanguageCode) diff --git a/src/Ryujinx.Ava/Ryujinx.Ava.csproj b/src/Ryujinx.Ava/Ryujinx.Ava.csproj index 054a5c7f..b6d37a2f 100644 --- a/src/Ryujinx.Ava/Ryujinx.Ava.csproj +++ b/src/Ryujinx.Ava/Ryujinx.Ava.csproj @@ -119,6 +119,7 @@ + @@ -143,6 +144,7 @@ + diff --git a/src/Ryujinx.Ava/UI/Controls/ApplicationListView.axaml b/src/Ryujinx.Ava/UI/Controls/ApplicationListView.axaml index 9004f751..fecf0888 100644 --- a/src/Ryujinx.Ava/UI/Controls/ApplicationListView.axaml +++ b/src/Ryujinx.Ava/UI/Controls/ApplicationListView.axaml @@ -86,17 +86,17 @@ HorizontalAlignment="Stretch" FontWeight="Bold" Text="{Binding TitleName}" - TextAlignment="Left" + TextAlignment="Start" TextWrapping="Wrap" /> @@ -110,12 +110,12 @@ - \ No newline at end of file + diff --git a/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml b/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml index d636873a..99f2b6b6 100644 --- a/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml +++ b/src/Ryujinx.Ava/UI/Views/Input/ControllerInputView.axaml @@ -101,7 +101,7 @@ HorizontalAlignment="Stretch" VerticalAlignment="Center" SelectedIndex="0" - ItemsSource="{Binding ProfilesList}" + ItemsSource="{Binding ProfilesList}" Text="{Binding ProfileName, Mode=TwoWay}" /> diff --git a/src/Ryujinx.Ava/UI/Windows/AmiiboWindow.axaml b/src/Ryujinx.Ava/UI/Windows/AmiiboWindow.axaml index caf7c1f3..c587aa87 100644 --- a/src/Ryujinx.Ava/UI/Windows/AmiiboWindow.axaml +++ b/src/Ryujinx.Ava/UI/Windows/AmiiboWindow.axaml @@ -72,4 +72,4 @@ Click="CancelButton_Click" /> - \ No newline at end of file + diff --git a/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml b/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml index 0d9a5949..4def7c28 100644 --- a/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml +++ b/src/Ryujinx.Ava/UI/Windows/MainWindow.axaml @@ -158,7 +158,7 @@ FontWeight="Bold" IsVisible="{Binding ShowLoadProgress}" Text="{Binding LoadHeading}" - TextAlignment="Left" + TextAlignment="Start" TextWrapping="Wrap" MaxWidth="500" /> @@ -202,4 +202,4 @@ Grid.Row="2" /> - \ No newline at end of file + diff --git a/src/Ryujinx.Ava/UI/Windows/SettingsWindow.axaml b/src/Ryujinx.Ava/UI/Windows/SettingsWindow.axaml index a0a75f61..40cac90d 100644 --- a/src/Ryujinx.Ava/UI/Windows/SettingsWindow.axaml +++ b/src/Ryujinx.Ava/UI/Windows/SettingsWindow.axaml @@ -101,6 +101,9 @@ + - \ No newline at end of file +