diff --git a/i18n/en/Editor.resx b/i18n/en/Editor.resx index 836a85e7..8c4cc113 100644 --- a/i18n/en/Editor.resx +++ b/i18n/en/Editor.resx @@ -159,6 +159,7 @@ Path smoothing Stabilise {0}: {1} → {2}invariant + {0}: {1} ← {2}invariant; right-to-left languages: the arrow points from the old value to the new one {0} setting changed {0} settings changed Nothing to change diff --git a/src/Titano.App/Editor/EditorText.cs b/src/Titano.App/Editor/EditorText.cs index d7d6376e..85d1c72a 100644 --- a/src/Titano.App/Editor/EditorText.cs +++ b/src/Titano.App/Editor/EditorText.cs @@ -196,6 +196,14 @@ public static class EditorText _ => parameter, }; + /// + /// "Deflicker window: 21 frames → 41 frames", one line of the Optimise toast. Bidi never mirrors an arrow, so a + /// right-to-left language reads it from its own resource, the arrow pointing from the old value to the new one. + /// + public static string Change(SettingChange change) => + Loc.L(Loc.IsRightToLeft ? "Editor.Optimise.ChangeRtl" : "Editor.Optimise.Change", ParameterLabel(change.Parameter), Value(change.Parameter, change.Before), + Value(change.Parameter, change.After)); + /// A value of an advisor parameter as its control shows it (the "what changed" toast of Optimise). public static string Value(string parameter, object? value) => (parameter, value) switch { diff --git a/src/Titano.App/Editor/EditorViewModel.cs b/src/Titano.App/Editor/EditorViewModel.cs index adfb5ad5..e2c80437 100644 --- a/src/Titano.App/Editor/EditorViewModel.cs +++ b/src/Titano.App/Editor/EditorViewModel.cs @@ -819,6 +819,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable { Title = Loc.L("Editor.Save.Failed"), Message = ex.Message, + IsError = true, ActionText = Loc.L("Editor.Save.Retry"), ActionToolTip = Loc.L("Tooltips.Editor.Save.Retry"), ActionCommand = new RelayCommand(() => _ = Session.FlushAsync()), @@ -893,9 +894,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable Shell.Notify(Loc.L("Editor.Optimise.Nothing")); return; } - var lines = changes.Select(c => Loc.L("Editor.Optimise.Change", EditorText.ParameterLabel(c.Parameter), EditorText.Value(c.Parameter, c.Before), - EditorText.Value(c.Parameter, c.After))); - Shell.Notify(Loc.Plural("Editor.Optimise.Done", changes.Count), string.Join(Environment.NewLine, lines)); + Shell.Notify(Loc.Plural("Editor.Optimise.Done", changes.Count), string.Join(Environment.NewLine, changes.Select(EditorText.Change))); } private async Task AnalyseAsync() @@ -957,6 +956,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable { Title = Loc.L("Editor.ServerJob.Ended", JobText.Kind(job.Kind), Loc.L("Jobs.State." + job.State), server), Message = job.Error ?? job.TargetLabel ?? Title, + IsError = job.State == JobState.Failed, ActionText = Loc.L("Jobs.Action.Retry"), ActionToolTip = Loc.L("Tooltips.Editor.ServerJob.Retry", server), ActionCommand = new AsyncRelayCommand(() => Session.Source.RetryJobAsync(job.Id, CancellationToken.None), () => !_disposed), diff --git a/tests/Titano.App.Tests/Editor/EditorTextTests.cs b/tests/Titano.App.Tests/Editor/EditorTextTests.cs index cf5df466..166be194 100644 --- a/tests/Titano.App.Tests/Editor/EditorTextTests.cs +++ b/tests/Titano.App.Tests/Editor/EditorTextTests.cs @@ -1,3 +1,4 @@ +using System.Globalization; using Titano.App.Editor; using Titano.Core.Advice; using Titano.Core.Imaging; @@ -36,6 +37,24 @@ public sealed class EditorTextTests Assert.Equal("3 frames", EditorText.Value(AdvisorParameters.Excluded, new[] { 1, 2, 3 })); } + [Test] + public void AnOptimiseLinePointsFromTheOldValueToTheNewOneInEitherReadingDirection() + { + var change = new SettingChange(AdvisorParameters.DeflickerWindow, 21, 41, "reason", []); + Assert.Equal("Deflicker window: 21 frames → 41 frames", EditorText.Change(change)); + try + { + Loc.SetCulture(CultureInfo.GetCultureInfo("ar")); + Assert.Equal(Loc.L("Editor.Optimise.ChangeRtl", Loc.L("Editor.Exposure.Window"), Loc.Plural("Editor.Value.Frames", 21), Loc.Plural("Editor.Value.Frames", 41)), + EditorText.Change(change), "Arabic reads the old value first, from the right"); + Assert.Contains("←", EditorText.Change(change)); + } + finally + { + Loc.SetCulture(CultureInfo.GetCultureInfo("en")); + } + } + [Test] public void CropMarginsKeepAtLeastATenthOfTheFrame() {