Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
Arabic reads right to left, in Filee and in Setup
KnifeLemon121121f1fc6e
diff --git a/docs/ADDING-A-LANGUAGE.md b/docs/ADDING-A-LANGUAGE.mdindex b96dc5b7..6ede4daa 100644--- a/docs/ADDING-A-LANGUAGE.md+++ b/docs/ADDING-A-LANGUAGE.md@@ -4,14 +4,16 @@The file is a flat list of `"key": "text"` pairs.2. Translate the values. Keep `{0}`, `{1}` placeholders — a test checks they match English.Keep the text short where English is short (buttons, donut labels).-3. Register the language in `LocalizationService.Languages`- (`src/Filee.App/Services/LocalizationService.cs`) with its native name, e.g. `("ja", "日本語")`.- If the OS culture should pick it automatically, extend `LocalizationService.Resolve`.+3. Register the language in `AppLanguages.All` (`src/Filee.App/Services/AppLanguages.cs`) with its native name,+ e.g. `("ja", "日本語")`; the order there is the order of the language pickers. Setup (`src/Filee.Setup`) offers it+ too. If the OS culture should pick it automatically, extend `LocalizationService.Resolve`.4. `LocalizationTests.Languages` automatically checks every registered language for key and placeholder parity.5. If the script needs another font, add a static Noto font to `build/fetch-fonts.ps1`- and to the font list in `ThemeService` (variable fonts are not supported by Avalonia).- Keep the app's left-to-right layout in every language. Arabic text still uses bidirectional shaping;- custom-drawn controls must shape text in the UI culture's direction, as `DonutMenu` does.+ and to the font list in `SoftPalette.FontFamilies` (variable fonts are not supported by Avalonia).+ A language written right to left (Arabic) mirrors every window by itself (`SoftPalette.ApplyFlowDirection`).+ Pictures and drawings that must not mirror (the donut, the crop canvas, animated images, logos) set+ `FlowDirection="LeftToRight"` on themselves; custom-drawn text is shaped in the UI culture's direction, as+ `DonutMenu` does.6. Run `dotnet test` and look at the screenshots in `tests/Filee.App.Tests/bin/.../screenshots`(add your language to `RenderTests.Pages` to render a few pages).diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex 26659103..39cb3272 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -128,8 +128,10 @@ Bump `AppSettings.CurrentSchemaVersion` and add a step to `SettingsMigrations` w- `LocalizationService` loads `Assets/i18n/<lang>.json` into `Application.Resources`; XAML uses`{DynamicResource key}`, so switching language updates the UI live.-- `ThemeService` writes the accent colour, corner radii, fonts and Fluent's `SystemAccentColor*` into- application resources. Light/dark surface colours are theme dictionaries in `Styles/Soft.axaml`; a user's+- `ThemeService` writes the accent colour, corner radii, fonts, the reading direction and Fluent's+ `SystemAccentColor*` into application resources. Arabic reads right to left: `Styles/Soft.axaml`'s Window style+ takes `FlowDirection` from that resource, so every window mirrors; the donut, the crop canvas and animated images+ stay left to right. Light/dark surface colours are theme dictionaries in `Styles/Soft.axaml`; a user's`theme.json` (`CustomTheme`, see [CUSTOM-THEMES.md](CUSTOM-THEMES.md)) overrides them with theme dictionaries inapplication resources, which are searched first.diff --git a/src/Filee.App/Controls/AnimatedImage.cs b/src/Filee.App/Controls/AnimatedImage.csindex 219f9837..391d105f 100644--- a/src/Filee.App/Controls/AnimatedImage.cs+++ b/src/Filee.App/Controls/AnimatedImage.cs@@ -93,7 +93,12 @@ public sealed class AnimatedImage : Control/// <summary>Pixel size of the picture.</summary>public PixelSize PixelSize => _decoder is null ? default : new PixelSize(_decoder.Width, _decoder.Height);- public AnimatedImage() => Clock = () => _stopwatch.Elapsed;+ public AnimatedImage()+ {+ Clock = () => _stopwatch.Elapsed;+ // Screenshots and demos are never mirrored, also in a right-to-left UI.+ FlowDirection = FlowDirection.LeftToRight;+ }protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e){diff --git a/src/Filee.App/Controls/CropCanvas.cs b/src/Filee.App/Controls/CropCanvas.csindex 1ec71590..a9eb51d5 100644--- a/src/Filee.App/Controls/CropCanvas.cs+++ b/src/Filee.App/Controls/CropCanvas.cs@@ -81,6 +81,9 @@ public sealed class CropCanvas : ControlAffectsRender<CropCanvas>(SourceImageProperty, NormalizedCropRectProperty, AspectRatioProperty);}+ // The picture is never mirrored, also in a right-to-left UI.+ public CropCanvas() => FlowDirection = FlowDirection.LeftToRight;+public void ResetCrop(){NormalizedCropRect = new Rect(0, 0, 1, 1);diff --git a/src/Filee.App/Controls/DonutMenu.cs b/src/Filee.App/Controls/DonutMenu.csindex 0f4cc816..c8a092ce 100644--- a/src/Filee.App/Controls/DonutMenu.cs+++ b/src/Filee.App/Controls/DonutMenu.cs@@ -138,6 +138,9 @@ public sealed partial class DonutMenu : Controlpublic DonutMenu(){+ // A circle reads the same either way: slices keep their clockwise order in Arabic too, their labels are+ // shaped right to left (TextDirection).+ FlowDirection = FlowDirection.LeftToRight;ClipToBounds = false;Cursor = new Cursor(StandardCursorType.Hand);}diff --git a/src/Filee.App/Services/LocalizationService.cs b/src/Filee.App/Services/LocalizationService.csindex 5b9013a6..47771f13 100644--- a/src/Filee.App/Services/LocalizationService.cs+++ b/src/Filee.App/Services/LocalizationService.cs@@ -79,6 +79,13 @@ public sealed class LocalizationService : ILocalizerLanguageChanged?.Invoke(this, EventArgs.Empty);}+ /// <summary>+ /// Left-to-right <paramref name="text"/> inside a sentence of the UI language: in Arabic a list like ".jpg, .png"+ /// keeps its dots in front (left-to-right marks around it). Unchanged in left-to-right languages.+ /// </summary>+ public static string LeftToRight(string text) =>+ CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft ? "\u200E" + text + "\u200E" : text;+/// <summary>Maps "auto" / a culture name to one of the shipped languages.</summary>public static string Resolve(string setting){diff --git a/src/Filee.App/Services/SoftPalette.cs b/src/Filee.App/Services/SoftPalette.csindex 5a037222..6854ba42 100644--- a/src/Filee.App/Services/SoftPalette.cs+++ b/src/Filee.App/Services/SoftPalette.cs@@ -1,7 +1,8 @@// The resources behind Filee's look that are computed rather than written in Styles/Soft.axaml: the accent colour-// with its shades, the corner radii and the UI font order. ThemeService applies them with the user's choices; the+// with its shades, the corner radii, the UI font order and the reading direction. ThemeService applies them with the user's choices; the// installer (src/Filee.Setup links this file) applies the defaults, so Setup looks like the app.+using System.Globalization;using Avalonia;using Avalonia.Controls;using Avalonia.Media;@@ -86,6 +87,36 @@ internal static class SoftPalettereturn $"Segoe UI, Nirmala UI, {string.Join(", ", cjk.Select(f => f.System))}, sans-serif";}+ /// <summary>The resource Soft.axaml's Window style takes <see cref="Visual.FlowDirection"/> from.</summary>+ public const string FlowDirectionKey = "AppFlowDirection";++ /// <summary>"→" between a name and what it becomes, "←" in a right-to-left language (arrows don't mirror).</summary>+ public const string ForwardArrowKey = "AppForwardArrow";++ /// <summary>+ /// Arabic reads right to left: every window mirrors its layout (Soft.axaml's Window style). Controls that draw a+ /// picture or a circle (the donut, the crop canvas, animated images) keep left to right themselves.+ /// </summary>+ public static void ApplyFlowDirection(IResourceDictionary res, string language)+ {+ var rightToLeft = IsRightToLeft(language);+ res[FlowDirectionKey] = rightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;+ res[ForwardArrowKey] = rightToLeft ? "←" : "→";+ }++ /// <summary>True for a language written right to left.</summary>+ public static bool IsRightToLeft(string language)+ {+ try+ {+ return CultureInfo.GetCultureInfo(language).TextInfo.IsRightToLeft;+ }+ catch (CultureNotFoundException)+ {+ return false;+ }+ }+/// <summary>The UI font for <paramref name="language"/>.</summary>public static FontFamily FontFamilyFor(string language) => FontFamily.Parse(FontFamilies(language));diff --git a/src/Filee.App/Services/ThemeService.cs b/src/Filee.App/Services/ThemeService.csindex 2ac2dd08..6c340179 100644--- a/src/Filee.App/Services/ThemeService.cs+++ b/src/Filee.App/Services/ThemeService.cs@@ -1,4 +1,4 @@-// Applies ThemeSettings (light/dark, accent colour, corner radius, font order, reduced motion) and the user's+// Applies ThemeSettings (light/dark, accent colour, corner radius, font order and reading direction, reduced motion) and the user's// theme.json colours at runtime by writing resources into Application.Resources. All styles reference these with// DynamicResource.@@ -51,6 +51,7 @@ public sealed class ThemeService(IPlatformServices platform)SoftPalette.ApplyAccent(res, Color.TryParse(theme.Accent, out var parsed) ? parsed : Color.Parse(SoftPalette.DefaultAccent));SoftPalette.ApplyCornerRadius(res, theme.CornerRadius);res["AppFontFamily"] = SoftPalette.FontFamilyFor(language);+ SoftPalette.ApplyFlowDirection(res, language);// Application.Resources is searched before the styles, so these theme dictionaries win over Soft.axaml's.ApplyCustom(res, ThemeVariant.Light, custom?.Light);diff --git a/src/Filee.App/Styles/Soft.axaml b/src/Filee.App/Styles/Soft.axamlindex add41e68..a993b378 100644--- a/src/Filee.App/Styles/Soft.axaml+++ b/src/Filee.App/Styles/Soft.axaml@@ -65,6 +65,16 @@<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" /><Setter Property="FontFamily" Value="{DynamicResource AppFontFamily}" /><Setter Property="FontSize" Value="14" />+ <!-- Right to left for Arabic (SoftPalette.ApplyFlowDirection). -->+ <Setter Property="FlowDirection" Value="{DynamicResource AppFlowDirection}" />+ </Style>+ <!-- Pictures, logos and icons look the same in Arabic; only chevrons that point along the line (class "reading")+ turn with it. -->+ <Style Selector="Image, PathIcon">+ <Setter Property="FlowDirection" Value="LeftToRight" />+ </Style>+ <Style Selector="PathIcon.reading">+ <Setter Property="FlowDirection" Value="{DynamicResource AppFlowDirection}" /></Style><Style Selector="TextBlock.h1">diff --git a/src/Filee.App/Styles/TagEditor.axaml b/src/Filee.App/Styles/TagEditor.axamlindex 8c919f8f..45880cb1 100644--- a/src/Filee.App/Styles/TagEditor.axaml+++ b/src/Filee.App/Styles/TagEditor.axaml@@ -39,7 +39,8 @@AutomationProperties.Name="{Binding Text}" AutomationProperties.HelpText="{Binding ToolTip}"><StackPanel Orientation="Horizontal" Spacing="3"><PathIcon Classes="tagchip-flag" Data="{StaticResource Icon.Alert}" IsVisible="{Binding IsWarning}" />- <TextBlock Classes="tagchip-text" Text="{Binding Text}" />+ <!-- Extensions, name patterns and app names read left to right, also in Arabic (else "*.jpg" shows as "jpg.*"). -->+ <TextBlock Classes="tagchip-text" Text="{Binding Text}" FlowDirection="LeftToRight" /><Button Classes="tagchip-remove" Focusable="False" ToolTip.Tip="{DynamicResource tags.remove}"><PathIcon Width="8" Height="8" Data="{StaticResource Icon.Close}" /></Button>@@ -64,7 +65,8 @@<DockPanel><TextBlock DockPanel.Dock="Right" Classes="caption tag-suggestion-note" Text="{Binding Note}"Margin="12,0,0,0" VerticalAlignment="Center" />- <TextBlock DockPanel.Dock="Left" Text="{Binding Text}" FontWeight="SemiBold" MinWidth="64" VerticalAlignment="Center" />+ <TextBlock DockPanel.Dock="Left" Text="{Binding Text}" FontWeight="SemiBold" MinWidth="64" VerticalAlignment="Center"+ FlowDirection="LeftToRight" /><TextBlock Classes="caption" Text="{Binding Detail}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" /></DockPanel></DataTemplate>diff --git a/src/Filee.App/ViewModels/Pages/ExtensionTagsViewModel.cs b/src/Filee.App/ViewModels/Pages/ExtensionTagsViewModel.csindex 0436f39e..4029ce8d 100644--- a/src/Filee.App/ViewModels/Pages/ExtensionTagsViewModel.cs+++ b/src/Filee.App/ViewModels/Pages/ExtensionTagsViewModel.cs@@ -4,6 +4,7 @@using CommunityToolkit.Mvvm.ComponentModel;using CommunityToolkit.Mvvm.Input;using Filee.App.Controls;+using Filee.App.Services;using Filee.Core.Formats;using Filee.Core.Localization;using Filee.Core.Profiles;@@ -62,7 +63,7 @@ public sealed partial class ExtensionTagsViewModel : ObservableObject}if (_profile.Extensions.Contains(extension, StringComparer.OrdinalIgnoreCase)){- InputError = _loc.Format("toolbar.ext_duplicate", "." + extension);+ InputError = _loc.Format("toolbar.ext_duplicate", LocalizationService.LeftToRight("." + extension));return;}_profile.Extensions.Add(extension);@@ -116,10 +117,11 @@ public sealed partial class ExtensionTagsViewModel : ObservableObjectforeach (var group in claimed.GroupBy(c => c.Owner)){var key = IndexOf(group.Key) < myIndex ? "toolbar.ext_claimed_first" : "toolbar.ext_claimed_later";- notes.Add(new ExtensionNote(_loc.Format(key, string.Join(", ", group.Select(c => c.Text)), _loc.DisplayName(group.Key)), true));+ notes.Add(new ExtensionNote(_loc.Format(key, LocalizationService.LeftToRight(string.Join(", ", group.Select(c => c.Text))),+ _loc.DisplayName(group.Key)), true));}if (unknown.Count > 0)- notes.Add(new ExtensionNote(_loc.Format("toolbar.ext_unknown", string.Join(", ", unknown)), false));+ notes.Add(new ExtensionNote(_loc.Format("toolbar.ext_unknown", LocalizationService.LeftToRight(string.Join(", ", unknown))), false));Tags = chips;Notes = notes;diff --git a/src/Filee.App/Views/Pages/AboutPage.axaml b/src/Filee.App/Views/Pages/AboutPage.axamlindex 3b476cd1..4d6614c6 100644--- a/src/Filee.App/Views/Pages/AboutPage.axaml+++ b/src/Filee.App/Views/Pages/AboutPage.axaml@@ -72,7 +72,8 @@<Border Classes="card"><StackPanel Spacing="8"><TextBlock Classes="h2" Text="{DynamicResource about.notices}" />- <c:MarkdownView Markdown="{Binding Notices}" SkipTitle="True" />+ <!-- The notices are in English: left to right in every language. -->+ <c:MarkdownView Markdown="{Binding Notices}" SkipTitle="True" FlowDirection="LeftToRight" /></StackPanel></Border></StackPanel>diff --git a/src/Filee.App/Views/Pages/HomePage.axaml b/src/Filee.App/Views/Pages/HomePage.axamlindex ebdc6017..332ca778 100644--- a/src/Filee.App/Views/Pages/HomePage.axaml+++ b/src/Filee.App/Views/Pages/HomePage.axaml@@ -126,7 +126,7 @@</Button><Button Classes="ghost" Command="{Binding ToggleFailuresCommand}" Padding="6,4" HorizontalAlignment="Left"><StackPanel Orientation="Horizontal" Spacing="6">- <PathIcon Classes="chevron" Classes.open="{Binding ShowFailures}" Width="12" Height="12"+ <PathIcon Classes="chevron reading" Classes.open="{Binding ShowFailures}" Width="12" Height="12"Data="{StaticResource Icon.ChevronRight}" /><TextBlock Classes="caption danger" Text="{Binding FailureSummary}" /></StackPanel>diff --git a/src/Filee.App/Views/Pages/ToolbarPage.axaml b/src/Filee.App/Views/Pages/ToolbarPage.axamlindex 8a049929..8cef6102 100644--- a/src/Filee.App/Views/Pages/ToolbarPage.axaml+++ b/src/Filee.App/Views/Pages/ToolbarPage.axaml@@ -263,7 +263,7 @@<ToggleButton DockPanel.Dock="Left" Classes="expander" IsChecked="{Binding IsExpanded}"ToolTip.Tip="{DynamicResource toolbar.mixed_expand}"AutomationProperties.Name="{Binding Name}">- <PathIcon Data="{StaticResource Icon.ChevronRight}" />+ <PathIcon Classes="reading" Data="{StaticResource Icon.ChevronRight}" /></ToggleButton><TextBlock DockPanel.Dock="Right" Classes="caption" Text="{Binding Count}" VerticalAlignment="Center" /><CheckBox Content="{Binding Name}" IsChecked="{Binding State, Mode=OneWay}"diff --git a/src/Filee.App/Views/Pages/WatchFoldersPage.axaml b/src/Filee.App/Views/Pages/WatchFoldersPage.axamlindex 3ed77f68..279b37fc 100644--- a/src/Filee.App/Views/Pages/WatchFoldersPage.axaml+++ b/src/Filee.App/Views/Pages/WatchFoldersPage.axaml@@ -77,7 +77,7 @@<!-- Optional: which files, and how converted files are named. Empty fields change nothing. --><Button Classes="ghost" Command="{Binding ToggleOptionsCommand}" Padding="6,4" HorizontalAlignment="Left"><StackPanel Orientation="Horizontal" Spacing="6">- <PathIcon Classes="chevron" Classes.open="{Binding ShowOptions}" Width="12" Height="12" Data="{StaticResource Icon.ChevronRight}" />+ <PathIcon Classes="chevron reading" Classes.open="{Binding ShowOptions}" Width="12" Height="12" Data="{StaticResource Icon.ChevronRight}" /><TextBlock Text="{DynamicResource watch.options}" /></StackPanel></Button>@@ -138,7 +138,7 @@</DockPanel><Button Classes="ghost" Command="{Binding ToggleResultFailuresCommand}" Padding="6,4" HorizontalAlignment="Left" IsVisible="{Binding HasResultFailures}"><StackPanel Orientation="Horizontal" Spacing="6">- <PathIcon Classes="chevron" Classes.open="{Binding ShowResultFailures}" Width="12" Height="12" Data="{StaticResource Icon.ChevronRight}" />+ <PathIcon Classes="chevron reading" Classes.open="{Binding ShowResultFailures}" Width="12" Height="12" Data="{StaticResource Icon.ChevronRight}" /><TextBlock Classes="caption danger" Text="{Binding ResultFailuresLabel}" /></StackPanel></Button>diff --git a/src/Filee.App/Views/RenameToolWindow.axaml b/src/Filee.App/Views/RenameToolWindow.axamlindex eb40ed90..892b52e1 100644--- a/src/Filee.App/Views/RenameToolWindow.axaml+++ b/src/Filee.App/Views/RenameToolWindow.axaml@@ -124,7 +124,7 @@<Panel><Grid ColumnDefinitions="*,Auto,*" IsVisible="{Binding ShowArrow}"><TextBox Text="{Binding Find}" PlaceholderText="{Binding FindPlaceholder}" />- <TextBlock Grid.Column="1" Classes="muted" Text="→" Margin="8,0" VerticalAlignment="Center" />+ <TextBlock Grid.Column="1" Classes="muted" Text="{DynamicResource AppForwardArrow}" Margin="8,0" VerticalAlignment="Center" /><TextBox Grid.Column="2" Text="{Binding Replace}" PlaceholderText="{Binding ReplacePlaceholder}" /></Grid><TextBox Text="{Binding Find}" PlaceholderText="{Binding FindPlaceholder}" IsVisible="{Binding ShowFindOnly}" />@@ -153,7 +153,7 @@<DataTemplate x:DataType="vm:RenamePreview"><Grid ColumnDefinitions="*,Auto,*" Margin="0,2"><TextBlock Classes="caption" Text="{Binding Before}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" />- <TextBlock Grid.Column="1" Classes="muted" Text="→" Margin="8,0" />+ <TextBlock Grid.Column="1" Classes="muted" Text="{DynamicResource AppForwardArrow}" Margin="8,0" /><TextBlock Grid.Column="2" FontWeight="SemiBold" Text="{Binding After}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" /></Grid></DataTemplate>@@ -162,7 +162,7 @@<TextBlock Classes="caption" Text="{DynamicResource watch.rename_try}" Margin="0,4,0,0" /><Grid ColumnDefinitions="*,Auto,*"><TextBox Text="{Binding CustomName}" PlaceholderText="{DynamicResource watch.rename_try_placeholder}" />- <TextBlock Grid.Column="1" Classes="muted" Text="→" Margin="8,0" VerticalAlignment="Center" />+ <TextBlock Grid.Column="1" Classes="muted" Text="{DynamicResource AppForwardArrow}" Margin="8,0" VerticalAlignment="Center" /><SelectableTextBlock Grid.Column="2" FontWeight="SemiBold" Text="{Binding CustomResult}" VerticalAlignment="Center" TextWrapping="Wrap" /></Grid></StackPanel>diff --git a/src/Filee.App/Views/SponsorWindow.axaml b/src/Filee.App/Views/SponsorWindow.axamlindex b49617b3..07792200 100644--- a/src/Filee.App/Views/SponsorWindow.axaml+++ b/src/Filee.App/Views/SponsorWindow.axaml@@ -39,7 +39,7 @@Background="{Binding Color}"><PathIcon Width="19" Height="19" Data="{Binding Icon}" Foreground="White" /></Border>- <PathIcon DockPanel.Dock="Right" Width="12" Height="12" Opacity="0.55"+ <PathIcon DockPanel.Dock="Right" Classes="reading" Width="12" Height="12" Opacity="0.55"Data="{StaticResource Icon.ChevronRight}" VerticalAlignment="Center" /><StackPanel VerticalAlignment="Center" Spacing="1"><TextBlock Text="{Binding Name}" FontWeight="SemiBold" />diff --git a/src/Filee.App/Views/WhatsNewWindow.axaml b/src/Filee.App/Views/WhatsNewWindow.axamlindex 9245273b..6acef122 100644--- a/src/Filee.App/Views/WhatsNewWindow.axaml+++ b/src/Filee.App/Views/WhatsNewWindow.axaml@@ -30,7 +30,7 @@<!-- The whole width of the card (560 - 2 × 12 margin - 2 × 20 padding), 16:9 --><c:SlideShow x:Name="Slides" MediaWidth="496" MediaHeight="279" />- <!-- Previous on the left (hidden on the first slide), Next / Get started on the right -->+ <!-- Previous on the left (hidden on the first slide), Next / Get started on the right; mirrored in Arabic --><Grid ColumnDefinitions="*,*" Margin="0,18,0,0"><Button x:Name="PreviousButton" HorizontalAlignment="Left" MinWidth="96" HorizontalContentAlignment="Center"Content="{DynamicResource whats_new.previous}" Click="OnPrevious" />diff --git a/src/Filee.App/Views/WhatsNewWindow.axaml.cs b/src/Filee.App/Views/WhatsNewWindow.axaml.csindex a0aa58d9..0ead33c1 100644--- a/src/Filee.App/Views/WhatsNewWindow.axaml.cs+++ b/src/Filee.App/Views/WhatsNewWindow.axaml.cs@@ -1,6 +1,7 @@using Avalonia.Controls;using Avalonia.Input;using Avalonia.Interactivity;+using Avalonia.Media;using Filee.App.Controls;using Filee.App.Services;using Filee.Core.Localization;@@ -77,14 +78,16 @@ public partial class WhatsNewWindow : Windowbase.OnKeyDown(e);if (e.Handled)return;+ // The arrow pointing the way the text reads goes on: Left in Arabic, where Next sits on the left.+ var rightToLeft = FlowDirection == FlowDirection.RightToLeft;switch (e.Key){- case Key.Left:- Slides.Previous();+ case Key.Left or Key.Right when (e.Key == Key.Right) != rightToLeft:+ Slides.Next();e.Handled = true;break;- case Key.Right:- Slides.Next();+ case Key.Left or Key.Right:+ Slides.Previous();e.Handled = true;break;case Key.Escape:diff --git a/src/Filee.Setup/App.axaml.cs b/src/Filee.Setup/App.axaml.csindex 3dcd5c65..3e084c21 100644--- a/src/Filee.Setup/App.axaml.cs+++ b/src/Filee.Setup/App.axaml.cs@@ -34,7 +34,10 @@ public sealed class App : Applicationbase.OnFrameworkInitializationCompleted();}- /// <summary>Filee's look in <paramref name="texts"/>' language: default accent, radius, Windows' fonts in the language's order; texts as resources.</summary>+ /// <summary>+ /// Filee's look in <paramref name="texts"/>' language: default accent, radius, Windows' fonts in the language's+ /// order, its reading direction; texts as resources.+ /// </summary>internal static void ApplyLook(Application app, SetupTexts texts){var res = app.Resources;@@ -43,6 +46,7 @@ public sealed class App : Applicationvoid Apply(){res["AppFontFamily"] = FontFamily.Parse(SoftPalette.SystemFontFamilies(texts.Language));+ SoftPalette.ApplyFlowDirection(res, texts.Language);texts.Publish(res);}Apply();diff --git a/src/Filee.Setup/Controls/DonutLogo.cs b/src/Filee.Setup/Controls/DonutLogo.csindex 35da26b5..2aabd2bd 100644--- a/src/Filee.Setup/Controls/DonutLogo.cs+++ b/src/Filee.Setup/Controls/DonutLogo.cs@@ -44,6 +44,8 @@ public sealed class DonutLogo : Controlpublic DonutLogo(){+ // The logo is never mirrored, also in Arabic.+ FlowDirection = FlowDirection.LeftToRight;_progress = SetupMotion.Enabled ? 0 : 1;_loop = new FrameLoop(this, elapsed =>{diff --git a/tests/Filee.App.Tests/DonutFlipTests.cs b/tests/Filee.App.Tests/DonutFlipTests.csindex 09156fc1..76ee2408 100644--- a/tests/Filee.App.Tests/DonutFlipTests.cs+++ b/tests/Filee.App.Tests/DonutFlipTests.cs@@ -491,6 +491,7 @@ public class DonutFlipTests[InlineData("ko", false)][InlineData("ja", true)][InlineData("ru", false)]+ [InlineData("ar", true)]public void The_flip_key_is_recorded_and_checked_in_the_shortcut_settings(string language, bool dark) =>With(animations: false, back: null, language: language, test: () =>{@@ -589,6 +590,7 @@ public class DonutFlipTests[InlineData("zh-CN", false)][InlineData("ja", false)][InlineData("ru", false)]+ [InlineData("ar", true)]public void The_back_face_renders(string language, bool dark) => With(animations: true, back: null, () =>{var theme = AppHost.Get<ThemeService>();@@ -641,6 +643,7 @@ public class DonutFlipTests[InlineData("zh-CN", false)][InlineData("ja", false)][InlineData("ru", false)]+ [InlineData("ar", true)]public void The_editor_switches_between_the_front_and_the_back(string language, bool dark) => With(animations: false, back: null, () =>{var theme = AppHost.Get<ThemeService>();diff --git a/tests/Filee.App.Tests/LocalizationResourceTests.cs b/tests/Filee.App.Tests/LocalizationResourceTests.csindex d0f614de..87f3a359 100644--- a/tests/Filee.App.Tests/LocalizationResourceTests.cs+++ b/tests/Filee.App.Tests/LocalizationResourceTests.cs@@ -30,7 +30,7 @@ public class LocalizationResourceTests}[AvaloniaFact]- public void Switching_to_arabic_keeps_navigation_and_page_in_the_same_positions()+ public void Arabic_mirrors_the_main_window_and_english_brings_it_back(){TestServices.EnsureInitialized("en");using var model = new MainWindowViewModel(AppHost.Services, AppHost.Get<ILocalizer>(), AppHost.Get<UpdateService>());@@ -42,20 +42,26 @@ public class LocalizationResourceTestsRenderTests.Pump();var navigation = window.GetVisualDescendants().OfType<ListBox>().Single(l => l.Classes.Contains("nav"));var page = window.FindControl<ScrollViewer>("PageScroller")!;- var navigationPosition = navigation.TranslatePoint(default, window);- var pagePosition = page.TranslatePoint(default, window);- Assert.True(pagePosition!.Value.X > navigationPosition!.Value.X);+ double Left(Visual visual) => new Rect(visual.Bounds.Size).TransformToAABB(visual.TransformToVisual(window)!.Value).Left;+ double Center(Visual visual) =>+ new Rect(visual.Bounds.Size).TransformToAABB(visual.TransformToVisual(window)!.Value).Center.X;+ Assert.Equal(FlowDirection.LeftToRight, window.FlowDirection);+ Assert.True(Center(navigation) < Center(page));+ var englishNavigationLeft = Left(navigation);++ TestServices.EnsureInitialized("ar");+ RenderTests.Pump();+ Assert.Equal(FlowDirection.RightToLeft, window.FlowDirection);+ Assert.Equal(FlowDirection.RightToLeft, page.FlowDirection);+ // The sidebar moves to the right edge, the page to its left.+ Assert.True(Center(navigation) > Center(page));+ Assert.Equal(window.Bounds.Width - englishNavigationLeft, Left(navigation) + navigation.Bounds.Width, 1);+ Assert.Equal("عام", AppHost.Get<ILocalizer>()["general.title"]);- foreach (var language in new[] { "ar", "en", "ar" })- {- TestServices.EnsureInitialized(language);- RenderTests.Pump();- // Fonts may change the header's natural height; the sidebar must remain on the same side.- Assert.Equal(navigationPosition!.Value.X, navigation.TranslatePoint(default, window)!.Value.X);- Assert.Equal(pagePosition, page.TranslatePoint(default, window));- Assert.Equal(FlowDirection.LeftToRight, window.FlowDirection);- Assert.Equal(language == "ar" ? "عام" : "General", AppHost.Get<ILocalizer>()["general.title"]);- }+ TestServices.EnsureInitialized("en");+ RenderTests.Pump();+ Assert.Equal(FlowDirection.LeftToRight, window.FlowDirection);+ Assert.Equal(englishNavigationLeft, Left(navigation), 1);}finally{@@ -65,25 +71,24 @@ public class LocalizationResourceTests}[AvaloniaFact]- public void Arabic_translates_existing_and_new_windows_without_mirroring_the_layout()+ public void Arabic_windows_read_right_to_left_but_pictures_and_the_donut_do_not_mirror(){- TestServices.EnsureInitialized("en");- var window = new Window { Content = new TextBlock() };+ TestServices.EnsureInitialized("ar");+ var canvas = new CropCanvas();+ var donut = new DonutMenu();+ var picture = new AnimatedImage();+ var window = new Window { Content = new StackPanel { Children = { new TextBlock(), canvas, donut, picture } } };window.Show();try{- Assert.Equal(FlowDirection.LeftToRight, window.FlowDirection);- TestServices.EnsureInitialized("ar");- Assert.Equal(FlowDirection.LeftToRight, window.FlowDirection);- Assert.Equal(FlowDirection.LeftToRight, ((TextBlock)window.Content).FlowDirection);+ Assert.Equal(FlowDirection.RightToLeft, window.FlowDirection);+ Assert.Equal(FlowDirection.RightToLeft, ((StackPanel)window.Content).Children[0].FlowDirection);+ Assert.Equal(FlowDirection.LeftToRight, canvas.FlowDirection);+ Assert.Equal(FlowDirection.LeftToRight, donut.FlowDirection);+ Assert.Equal(FlowDirection.LeftToRight, picture.FlowDirection);Assert.True(Application.Current!.TryGetResource("general.language", null, out var value));Assert.Equal("اللغة", value);- var canvas = new CropCanvas();- var dialog = new Window { Content = canvas };- dialog.Show();- Assert.Equal(FlowDirection.LeftToRight, dialog.FlowDirection);- Assert.Equal(FlowDirection.LeftToRight, canvas.FlowDirection);- dialog.Close();+TestServices.EnsureInitialized("en");Assert.Equal(FlowDirection.LeftToRight, window.FlowDirection);}diff --git a/tests/Filee.App.Tests/LocalizationTests.cs b/tests/Filee.App.Tests/LocalizationTests.csindex df195f0d..905d886c 100644--- a/tests/Filee.App.Tests/LocalizationTests.cs+++ b/tests/Filee.App.Tests/LocalizationTests.cs@@ -23,16 +23,14 @@ public partial class LocalizationTestspublic static TheoryData<string> Languages => new(LocalizationService.Languages.Where(l => l.Code != "en").Select(l => l.Code));- [Theory]- [InlineData("ar")]- [InlineData("AR")]- [InlineData("ar-IQ")]- [InlineData("ar-SA")]- public void Arabic_is_offered_under_its_own_name_and_accepts_regional_cultures(string culture)+ [Fact]+ public void Arabic_is_offered_under_its_own_name_and_reads_right_to_left(){Assert.Contains(("ar", "العربية"), LocalizationService.Languages);- Assert.Equal("ar", LocalizationService.Resolve(culture));- Assert.Contains("fonts:Filee#Noto Sans Arabic", ThemeService.FontFamilies(culture));+ Assert.Equal("ar", LocalizationService.Resolve("AR"));+ Assert.Contains("fonts:Filee#Noto Sans Arabic", ThemeService.FontFamilies("ar"));+ Assert.True(SoftPalette.IsRightToLeft("ar"));+ Assert.All(LocalizationService.Languages.Where(l => l.Code != "ar"), l => Assert.False(SoftPalette.IsRightToLeft(l.Code)));}[Theory]diff --git a/tests/Filee.App.Tests/RenderTests.cs b/tests/Filee.App.Tests/RenderTests.csindex 4b9031fd..4f3aba0f 100644--- a/tests/Filee.App.Tests/RenderTests.cs+++ b/tests/Filee.App.Tests/RenderTests.cs@@ -106,6 +106,7 @@ public class RenderTests[InlineData("ja")][InlineData("ko")][InlineData("ru")]+ [InlineData("ar")]public void Watch_folders_page_renders_a_rule(string language){TestServices.EnsureInitialized(language);@@ -203,6 +204,7 @@ public class RenderTests[InlineData("ja")][InlineData("ko")][InlineData("ru")]+ [InlineData("ar")]public void Watch_folder_options_rename_and_filter_with_a_preview(string language){TestServices.EnsureInitialized(language);@@ -293,6 +295,7 @@ public class RenderTests[InlineData("ja")][InlineData("ko")][InlineData("ru")]+ [InlineData("ar")]public void Home_page_lists_failed_files_with_a_retry_button(string language){TestServices.EnsureInitialized(language);@@ -344,6 +347,7 @@ public class RenderTests[InlineData("pl")][InlineData("hi")][InlineData("ru")]+ [InlineData("ar")]public void Home_page_search_finds_old_conversions_in_a_long_history(string language){TestServices.EnsureInitialized(language);@@ -498,6 +502,7 @@ public class RenderTests[InlineData("ko")][InlineData("hi")][InlineData("ru")]+ [InlineData("ar")]public void Reset_to_default_sits_beside_delete_for_a_built_in_profile_only(string language){TestServices.EnsureInitialized(language);@@ -588,6 +593,7 @@ public class RenderTests[InlineData("en")][InlineData("zh-CN")][InlineData("ru")]+ [InlineData("ar")]public void The_rotate_and_flip_groups_fan_out_names_that_fit(string language){TestServices.EnsureInitialized(language);@@ -636,6 +642,7 @@ public class RenderTests[InlineData("ko")][InlineData("en")][InlineData("ru")]+ [InlineData("ar")]public void A_group_slice_fans_out_its_presets(string language){TestServices.EnsureInitialized(language);@@ -814,6 +821,7 @@ public class RenderTests[AvaloniaTheory][InlineData("ko", "JPG 3개")][InlineData("ru", "3 × JPG")]+ [InlineData("ar", "3 × JPG")]public void Donut_toolbar_renders_for_images(string language, string title){TestServices.EnsureInitialized(language);@@ -849,6 +857,7 @@ public class RenderTests[InlineData("ja")][InlineData("ko")][InlineData("ru")]+ [InlineData("ar")]public void Sponsor_window_renders(string language){TestServices.EnsureInitialized(language);@@ -904,6 +913,7 @@ public class RenderTests[InlineData("ja")][InlineData("ko")][InlineData("ru")]+ [InlineData("ar")]public void First_run_engine_setup_renders(string language){TestServices.EnsureInitialized(language);@@ -1214,6 +1224,7 @@ public class RenderTests[InlineData("ja")][InlineData("ko")][InlineData("ru")]+ [InlineData("ar")]public void Sidebar_shows_the_version_and_a_new_release(string language){TestServices.EnsureInitialized(language);@@ -1304,6 +1315,7 @@ public class RenderTests[InlineData("en", true)][InlineData("ko", true)][InlineData("ru", false)]+ [InlineData("ar", true)]public void Toolbar_extension_editor_renders(string language, bool dark){var photos = new ToolbarProfile@@ -1383,6 +1395,7 @@ public class RenderTests[InlineData("zh-CN", false)][InlineData("ko", true)][InlineData("ru", false)]+ [InlineData("ar", true)]public void Preset_editor_shows_media_and_archive_options(string language, bool dark){TestServices.EnsureInitialized(language);@@ -1466,6 +1479,7 @@ public class RenderTests[InlineData("ko")][InlineData("zh-CN")][InlineData("ru")]+ [InlineData("ar")]public void Preset_editor_shows_tracing_options(string language){TestServices.EnsureInitialized(language);@@ -1511,6 +1525,7 @@ public class RenderTests[InlineData("ko")][InlineData("zh-CN")][InlineData("ru")]+ [InlineData("ar")]public void Preset_editor_offers_markdown_without_pictures(string language){TestServices.EnsureInitialized(language);@@ -1720,6 +1735,7 @@ public class RenderTests[InlineData("ja")][InlineData("ko")][InlineData("ru")]+ [InlineData("ar")]public void Excluded_apps_render_as_tags(string language){TestServices.EnsureInitialized(language);@@ -1750,6 +1766,7 @@ public class RenderTests[InlineData("ko")][InlineData("zh-CN")][InlineData("ru")]+ [InlineData("ar")]public void Close_dialog_renders(string language){TestServices.EnsureInitialized(language);@@ -1766,6 +1783,7 @@ public class RenderTests[InlineData("ko")][InlineData("zh-CN")][InlineData("ru")]+ [InlineData("ar")]public void Format_request_notice_renders(string language){TestServices.EnsureInitialized(language);diff --git a/tests/Filee.App.Tests/WhatsNewTests.cs b/tests/Filee.App.Tests/WhatsNewTests.csindex 5d3eface..b9e95d93 100644--- a/tests/Filee.App.Tests/WhatsNewTests.cs+++ b/tests/Filee.App.Tests/WhatsNewTests.cs@@ -2,6 +2,7 @@// background start), the window's buttons and keys, and screenshots of the window.using System.Text.Json;+using Avalonia;using Avalonia.Controls;using Avalonia.Headless;using Avalonia.Headless.XUnit;@@ -332,6 +333,29 @@ public class WhatsNewTests}}+ [AvaloniaFact]+ public void In_arabic_left_goes_on_and_next_sits_on_the_left()+ {+ var window = Open("ar");+ try+ {+ Assert.Equal(Avalonia.Media.FlowDirection.RightToLeft, window.FlowDirection);+ Press(window, Key.Left);+ Press(window, Key.Left);+ Assert.Equal(2, window.SlideShow.Index);+ Press(window, Key.Right);+ Assert.Equal(1, window.SlideShow.Index);+ var previous = Named(window, "PreviousButton");+ var next = Named(window, "PrimaryButton");+ Assert.True(next.TranslatePoint(default, window)!.Value.X < previous.TranslatePoint(default, window)!.Value.X);+ }+ finally+ {+ window.Close();+ TestServices.EnsureInitialized("en");+ }+ }+[AvaloniaFact]public void The_close_button_closes_from_any_slide(){diff --git a/tests/Filee.Setup.Tests/SetupWindowTests.cs b/tests/Filee.Setup.Tests/SetupWindowTests.csindex 1bd01a8e..97ef3f52 100644--- a/tests/Filee.Setup.Tests/SetupWindowTests.cs+++ b/tests/Filee.Setup.Tests/SetupWindowTests.cs@@ -126,7 +126,7 @@ public class SetupWindowTeststry{app.RequestedThemeVariant = ThemeVariant.Dark;- foreach (var language in new[] { "en", "ko", "ru" })+ foreach (var language in new[] { "en", "ko", "ru", "ar" }){var (model, _, runner) = Model(language);var window = Show(model);@@ -157,7 +157,7 @@ public class SetupWindowTests[AvaloniaFact]public async Task Updates_and_failures_render(){- foreach (var language in new[] { "en", "ko", "ru" })+ foreach (var language in new[] { "en", "ko", "ru", "ar" }){var (model, texts, runner) = Model(language, update: true);var window = Show(model);@@ -178,7 +178,7 @@ public class SetupWindowTests[AvaloniaFact]public async Task Uninstall_renders_and_keeps_the_settings_by_default(){- foreach (var language in new[] { "en", "ko", "ru", "zh-CN" })+ foreach (var language in new[] { "en", "ko", "ru", "zh-CN", "ar" }){var (model, _, runner) = Model(language, uninstall: true);var window = Show(model);