diff --git a/i18n/en/About.resx b/i18n/en/About.resx index 37466cd9..fe6b0d73 100644 --- a/i18n/en/About.resx +++ b/i18n/en/About.resx @@ -27,6 +27,7 @@ Download failed Downloading {0:P0} Check failed + Downloading… Download not verified Titano {0} downloaded Show file diff --git a/i18n/en/Jobs.resx b/i18n/en/Jobs.resx index b8ab8847..9e6c4cd8 100644 --- a/i18n/en/Jobs.resx +++ b/i18n/en/Jobs.resx @@ -56,6 +56,7 @@ Pause all Rendering settings {0} · {1} + {0}: {1}invariant Search target or kind {0} fps {0}/s diff --git a/i18n/en/Server.resx b/i18n/en/Server.resx index 341cfbb2..378cdb93 100644 --- a/i18n/en/Server.resx +++ b/i18n/en/Server.resx @@ -182,6 +182,7 @@ {0} uploads queued{0} count {0} received{0} percent Not compared · retrying + {0}: {1}invariant This PC's settings savedlong Search Show file diff --git a/i18n/it/About.it.resx b/i18n/it/About.it.resx index c290af5d..86977362 100644 --- a/i18n/it/About.it.resx +++ b/i18n/it/About.it.resx @@ -27,6 +27,7 @@ Download non riuscito Download in corso {0:P0} Verifica non riuscita + Download in corso… Download non verificato Titano {0} scaricato Mostra file diff --git a/i18n/it/Jobs.it.resx b/i18n/it/Jobs.it.resx index ec6f193b..4524e528 100644 --- a/i18n/it/Jobs.it.resx +++ b/i18n/it/Jobs.it.resx @@ -56,6 +56,7 @@ Sospendi tutte Impostazioni di rendering {0} · {1} + {0}: {1} Cerca oggetto o tipo {0} fps {0}/s diff --git a/i18n/it/Server.it.resx b/i18n/it/Server.it.resx index 148043a7..14baa2bc 100644 --- a/i18n/it/Server.it.resx +++ b/i18n/it/Server.it.resx @@ -179,6 +179,7 @@ {0} caricamenti in coda {0} ricevuto Confronto fallito · riprovo + {0}: {1} Impostazioni di questo PC salvate Cerca Mostra file diff --git a/src/Titano.App/Infrastructure/LiveRegion.cs b/src/Titano.App/Infrastructure/LiveRegion.cs index 3bfdf6e2..c9129e1f 100644 --- a/src/Titano.App/Infrastructure/LiveRegion.cs +++ b/src/Titano.App/Infrastructure/LiveRegion.cs @@ -1,7 +1,9 @@ +using System.Globalization; using System.Windows; using System.Windows.Automation; using System.Windows.Automation.Peers; using System.Windows.Threading; +using Titano.Core.Localization; namespace Titano.App.Infrastructure; @@ -15,6 +17,13 @@ public static class LiveRegion public static readonly DependencyProperty TextProperty = DependencyProperty.RegisterAttached( "Text", typeof(string), typeof(LiveRegion), new PropertyMetadata(null, OnTextChanged)); + /// + /// The data and language the last text came from: a recycled list row showing another item, or every status + /// relabelled by a language switch, is not news. + /// + private static readonly DependencyProperty SourceProperty = DependencyProperty.RegisterAttached( + "Source", typeof(Origin), typeof(LiveRegion), new PropertyMetadata(null)); + public static string? GetText(DependencyObject element) => (string?)element.GetValue(TextProperty); public static void SetText(DependencyObject element, string? value) => element.SetValue(TextProperty, value); @@ -23,10 +32,15 @@ public static class LiveRegion { if (d is not FrameworkElement element) return; AutomationProperties.SetName(element, (string?)e.NewValue ?? string.Empty); + var origin = new Origin(element.DataContext, Loc.Culture); + var sameSource = element.GetValue(SourceProperty) is Origin last && ReferenceEquals(last.Data, origin.Data) && last.Culture.Equals(origin.Culture); + element.SetValue(SourceProperty, origin); // 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; + if (!sameSource || !element.IsLoaded || e.NewValue is null || !AutomationPeer.ListenerExists(AutomationEvents.LiveRegionChanged)) return; element.Dispatcher.InvokeAsync(() => UIElementAutomationPeer.CreatePeerForElement(element)?.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged), DispatcherPriority.Background); } + + private sealed record Origin(object? Data, CultureInfo Culture); } diff --git a/src/Titano.App/Jobs/JobRowViewModel.cs b/src/Titano.App/Jobs/JobRowViewModel.cs index 5f9a5e2e..6893f915 100644 --- a/src/Titano.App/Jobs/JobRowViewModel.cs +++ b/src/Titano.App/Jobs/JobRowViewModel.cs @@ -53,6 +53,9 @@ public sealed class JobRowViewModel : ObservableObject public string StateText => JobText.State(_entry); + /// "Render · Harbour sunset: done · 3:00": what a screen reader announces when the state changes (not progress). + public string StateAnnouncement => Loc.L("Jobs.Row.State", AccessibleName, StateText); + /// Glyph and colour of the state (paired with the word, never colour alone). public StatusKind StateKind => _entry.State switch { @@ -131,6 +134,7 @@ public sealed class JobRowViewModel : ObservableObject OnPropertyChanged(nameof(LeftText)); OnPropertyChanged(nameof(WhereText)); OnPropertyChanged(nameof(StateText)); + OnPropertyChanged(nameof(StateAnnouncement)); if (_isExpanded) OnPropertyChanged(nameof(LogText)); } diff --git a/src/Titano.App/Sections/AboutView.xaml b/src/Titano.App/Sections/AboutView.xaml index bf79c9a9..ac29b3b4 100644 --- a/src/Titano.App/Sections/AboutView.xaml +++ b/src/Titano.App/Sections/AboutView.xaml @@ -58,7 +58,7 @@ + AutomationProperties.LiveSetting="Polite" infra:LiveRegion.Text="{Binding UpdateAnnouncement}" />