Titano: Library completion, remote editing, accessibility and RTL pass, remaining translations #3

Merged
Alby96 merged 117 commits from claude/keen-knuth-uhxv8w into main 2026-10-12 09:24:21 +02:00
3 changed files with 48 additions and 2 deletions
Showing only changes of commit baf3c6bddd - Show all commits

No files matched your search

@@ -56,4 +56,10 @@ public static class Formatting
/// <summary>Camera wall-clock date in the culture's short format.</summary>
public static string Date(DateTime wallClock) => wallClock.ToString("d", Loc.Culture);
/// <summary>
/// A path, address or fingerprint kept left to right inside right-to-left text (a Unicode left-to-right embedding),
/// so its separators and digits stay in place; it reads unchanged in left-to-right languages.
/// </summary>
public static string LeftToRight(string text) => "‪" + text + "‬";
}
@@ -0,0 +1,32 @@
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Threading;
namespace Titano.App.Infrastructure;
/// <summary>
/// A status line screen readers announce when it changes (a live region): <c>LiveRegion.Text</c> becomes the element's
/// accessible name and every later change raises <see cref="AutomationEvents.LiveRegionChanged"/>. The element's
/// <see cref="AutomationProperties.LiveSettingProperty"/> (Polite, or Assertive for errors) must be set as well.
/// </summary>
public static class LiveRegion
{
public static readonly DependencyProperty TextProperty = DependencyProperty.RegisterAttached(
"Text", typeof(string), typeof(LiveRegion), new PropertyMetadata(null, OnTextChanged));
public static string? GetText(DependencyObject element) => (string?)element.GetValue(TextProperty);
public static void SetText(DependencyObject element, string? value) => element.SetValue(TextProperty, value);
private static void OnTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is not FrameworkElement element) return;
AutomationProperties.SetName(element, (string?)e.NewValue ?? string.Empty);
// The first value arrives with the screen: only what changes while it is shown is announced, once layout has shown
// it (a status that appears with its text is still collapsed when the text arrives).
if (!element.IsLoaded || e.NewValue is null || !AutomationPeer.ListenerExists(AutomationEvents.LiveRegionChanged)) return;
element.Dispatcher.InvokeAsync(() => UIElementAutomationPeer.CreatePeerForElement(element)?.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged),
DispatcherPriority.Background);
}
}
+10 -2
View File
@@ -7,6 +7,15 @@ namespace Titano.App.Infrastructure;
/// <summary>Switches the UI language at run time without restart (BRIEF §16), mirroring right-to-left languages.</summary>
public static class UiLanguage
{
static UiLanguage()
{
// Windows created later (the main window at start, every dialog) take the reading direction when they load.
EventManager.RegisterClassHandler(typeof(Window), FrameworkElement.LoadedEvent, new RoutedEventHandler((sender, _) => ((Window)sender).FlowDirection = Direction));
}
/// <summary>The reading direction of the current language.</summary>
public static FlowDirection Direction => Loc.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
/// <summary>Applies <paramref name="code"/> (or the OS language when null) and returns the culture in use.</summary>
public static CultureInfo Apply(string? code)
{
@@ -25,8 +34,7 @@ public static class UiLanguage
Loc.SetCulture(culture);
if (Application.Current is { } app)
{
foreach (Window window in app.Windows)
window.FlowDirection = Loc.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
foreach (Window window in app.Windows) window.FlowDirection = Direction;
}
return culture;
}