diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index a565bfba..38ad169f 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -198,7 +198,11 @@ run as server jobs whose progress comes from the events. screens never set `FlowDirection` for the language. Photos, charts, numbers, paths and templates are left-to-right islands on the smallest element holding them; directional icons mirror by themselves (`IconData.IsDirectional`, overridden per subtree with `Bidi.IsDirectional`); left-to-right fragments inside a right-to-left sentence go - through `BidiText`. + through `BidiText`. Fields of a meta line are joined with `Loc.Separator`, never a literal " · ": in a + right-to-left language it holds right-to-left marks, so a number after a Latin field keeps to its own field. +- The language switches without restart: computed properties re-read through `LocalizedViewModel`, and a view model + that keeps texts in objects (chart series and legends, rows, cached sentences) makes them again in + `OnLanguageChanged`. - Radio buttons group by their parent panel. `GroupName` is shared by every window whose visual root is not known yet, so it is used only where the bindings are one-way (chips generated by item templates, the rail). - Content a control presents through its template from a dependency property other than `Content` is made a logical diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 580506a4..79f54524 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -118,6 +118,13 @@ commits follow Conventional Commits (release notes are generated from them by `T stayed disabled; the explicit dry run now cancels it. - Radio groups leaked between windows not shown yet (the Setup's capture overflowed the stack); screenshots of right-to-left windows were mirrored twice. +- Switching the language left texts kept by view models in the old language until their next change: the job bar, + the Jobs rows, the editor's chart legends and summaries, Auto chips and info line, the Archive figures and the + Import session table now follow at once. +- Right-to-left: in meta lines a number after a Latin field ("Canon EOS R5 · 2 h") joined the Latin run and split + its own field; fields are now separated with right-to-left marks. Desktop file sizes use the language's units. +- CI: a full artifact storage failed jobs whose checks had passed; uploads no longer fail a job, artifacts expire in + days, and screenshots reach their branch through the cache. - Release workflow: signing and the public-repository publish never ran (step conditions cannot read the step's own secrets); the publish job lacked the .NET SDK for `make-icon`; re-publishing an existing tag failed; the portable zip lacked `portable.txt`. diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index d6cdfe1e..6b37c378 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -237,3 +237,7 @@ One line per decision: date · decision · alternative · reason. | 2026-10-06 | Log download: reuse FileResponses.Serve (fixed-length, range-capable FileSlice) with the length listed at request time | Copy the log to a temp file first, or stream to EOF without a Content-Length | It reuses an existing facility, keeps Range resume working, has no extra I/O, and the response stays self-consistent while the logger keeps appending. | | 2026-10-06 | The regression test fills its server's log with about 2 MB up front, then logs one line about every 1 ms through the server's FileLoggerProvider only, on a LongRunning thread | A tight logging loop through ILoggerFactory (my first two versions) | The engine log sink is process-wide, so a console or file-lock flood stalled another test's job engine. The throttled version still reproduces the bug in 10 of 10 runs against the old endpoint. | | 2026-10-06 | Heartbeat test: count the claims the server answered with a DelegatingHandler, then wait for a later beat with a 30 s deadline | Keep the sleeps and widen the 400 ms window | It removes the timing assumption both ways (a false failure on a slow runner, and a false pass on the claim's own touch). It also proves no claim moved the beat. | +| 2026-10-11 | Fields of a meta line are joined with `Loc.Separator`: " · " in left-to-right languages, " · " between right-to-left marks in right-to-left ones (`Loc.SeparatorOf(culture)` for texts built in another language) | Unicode isolates (FSI/PDI) around each field, or a left-to-right island for every meta line | WPF's bidi predates the isolates; without a strong right-to-left character before it, a number after a Latin field ("Canon EOS R5 · 2 h") joins the Latin run (rule W7) and splits its own field; islands would read the fields in left-to-right order. | +| 2026-10-11 | `LocalizedViewModel.OnLanguageChanged` is the hook for texts kept in objects: the editor makes its tabs' charts, Auto chips, markers and info line again; Jobs refreshes rows, chips and the job bar; Archive reads again; Import rebuilds its session table and device list | Re-create every section after a language switch, or ask for a restart | BRIEF §16 switches language without restart; a running job's bar line and an open editor's legend otherwise stayed in the old language until their next change. | +| 2026-10-11 | Desktop sizes use the `Common.Size.*` formats, like the Setup and the Uploader | Hard-coded B, KB, MB, GB, TB, PB | Several languages write the units in their own script or words (КБ, bayt, كيلوبايت); every UI string is a resource. | +| 2026-10-11 | CI artifact uploads continue on error with short retention (test results 7 days, Windows programs 3); screenshots reach the screenshots job through the Actions cache | Keep failing jobs on a full artifact storage, or push the screenshots from the build job | A full storage quota failed jobs whose checks had passed; the cache has its own limit, and the build job keeps its read-only token. | diff --git a/src/Titano.App/Archive/ArchiveFigures.cs b/src/Titano.App/Archive/ArchiveFigures.cs index b254e772..0f2e1fff 100644 --- a/src/Titano.App/Archive/ArchiveFigures.cs +++ b/src/Titano.App/Archive/ArchiveFigures.cs @@ -52,7 +52,7 @@ public static class ArchiveFigures new(Formatting.Count(stats.Photos), Loc.Plural("Archive.Tile.Photos", stats.Photos)), new(Formatting.Count(stats.Sequences), Loc.Plural("Archive.Tile.Sequences", stats.Sequences)), new(Formatting.Bytes(stats.Bytes), Loc.L("Archive.Tile.Originals")), - new(Formatting.Count(cameras), Loc.Plural("Archive.Tile.Cameras", cameras) + " · " + Loc.Plural("Archive.Tile.Formats", stats.ByFormat.Count)), + new(Formatting.Count(cameras), Loc.Plural("Archive.Tile.Cameras", cameras) + Loc.Separator + Loc.Plural("Archive.Tile.Formats", stats.ByFormat.Count)), new(range, Loc.L("Archive.Tile.Pending", Formatting.Count(stats.Health.NotAnalyzed), Formatting.Count(stats.Health.Unverified))), ]; } diff --git a/src/Titano.App/Archive/ArchiveRowViewModels.cs b/src/Titano.App/Archive/ArchiveRowViewModels.cs index 0656c581..b1e23a81 100644 --- a/src/Titano.App/Archive/ArchiveRowViewModels.cs +++ b/src/Titano.App/Archive/ArchiveRowViewModels.cs @@ -35,7 +35,7 @@ public sealed class ArchiveTreeRowViewModel(ArchiveTreeNode node, ArchiveAvailab { get { - var text = Title + " · " + Detail; + var text = Title + Loc.Separator + Detail; return IsYear ? Loc.L(Loc.IsRightToLeft ? "Tooltips.Archive.YearRowRtl" : "Tooltips.Archive.YearRow", text) : text; } } @@ -72,7 +72,7 @@ public sealed class HealthLineViewModel(HealthLine line, ICommand? fix) : Observ public sealed class DuplicateRowViewModel(DuplicateRow row, ICommand open, ICommand reveal) : ObservableObject { public DuplicateRow Row { get; } = row; - public string Places => string.Join(" · ", Row.Places); + public string Places => string.Join(Loc.Separator, Row.Places); public ICommand OpenCommand { get; } = open; public ICommand RevealCommand { get; } = reveal; } diff --git a/src/Titano.App/Archive/ArchiveTree.cs b/src/Titano.App/Archive/ArchiveTree.cs index 23d287df..e7f2cf62 100644 --- a/src/Titano.App/Archive/ArchiveTree.cs +++ b/src/Titano.App/Archive/ArchiveTree.cs @@ -84,7 +84,7 @@ public sealed class ArchiveTree node.Add(new ArchiveTreeNode(TreeNodeKind.Sequence, s.Id.ToString("N"), 2) { Title = s.DisplayTitle, - Detail = Loc.Plural("Shell.Status.Photos", s.FrameCount) + " · " + Formatting.Bytes(s.TotalBytes), + Detail = Loc.Plural("Shell.Status.Photos", s.FrameCount) + Loc.Separator + Formatting.Bytes(s.TotalBytes), Sequence = s, }); } @@ -126,5 +126,5 @@ public sealed class ArchiveTree } private static string Summary(IReadOnlyCollection sequences) => - Loc.Plural("Shell.Status.Sequences", sequences.Count) + " · " + Formatting.Bytes(sequences.Sum(s => s.TotalBytes)); + Loc.Plural("Shell.Status.Sequences", sequences.Count) + Loc.Separator + Formatting.Bytes(sequences.Sum(s => s.TotalBytes)); } diff --git a/src/Titano.App/Archive/MassOperations.cs b/src/Titano.App/Archive/MassOperations.cs index f0b53e75..4bcb2d3b 100644 --- a/src/Titano.App/Archive/MassOperations.cs +++ b/src/Titano.App/Archive/MassOperations.cs @@ -98,7 +98,7 @@ public sealed record ArchiveSetFilter(string? Camera = null, StatusFilter Status } /// "Canon EOS R5 · Not analysed · sunset"; empty without a filter. - public string Describe() => string.Join(" · ", new[] + public string Describe() => string.Join(Loc.Separator, new[] { Camera ?? string.Empty, Status == StatusFilter.Any ? string.Empty : StatusLabel(Status), diff --git a/src/Titano.App/Archive/TrashDialogViewModel.cs b/src/Titano.App/Archive/TrashDialogViewModel.cs index 30bc0204..4f20e819 100644 --- a/src/Titano.App/Archive/TrashDialogViewModel.cs +++ b/src/Titano.App/Archive/TrashDialogViewModel.cs @@ -17,7 +17,7 @@ public sealed class TrashRowViewModel(TrashEntry entry, ICommand restore) public string Title => Entry.Title; /// "3,600 photos · 96.2 GB · 2026/2026-09-28 Canon EOS R5" (the folder left to right in every language). - public string Detail => string.Join(" · ", Loc.Plural("Shell.Status.Photos", Entry.Frames), Formatting.Bytes(Entry.Bytes), Formatting.LeftToRight(Entry.Folder)); + public string Detail => string.Join(Loc.Separator, Loc.Plural("Shell.Status.Photos", Entry.Frames), Formatting.Bytes(Entry.Bytes), Formatting.LeftToRight(Entry.Folder)); /// "Deleted 02/10/2026 18:04". public string DeletedText => Loc.L("Archive.Trash.Deleted", Formatting.Date(Entry.DeletedAt) + " " + Formatting.TimeOfDay(Entry.DeletedAt)); @@ -65,7 +65,7 @@ public sealed class TrashDialogViewModel : ArchiveDialogViewModel /// "3 sequences · 182 GB", or "The trash is empty". public string SummaryText => _rows.Count == 0 ? Loc.L("Archive.Trash.Empty") - : Loc.Plural("Shell.Status.Sequences", _rows.Count) + " · " + Formatting.Bytes(_rows.Sum(r => r.Entry.Bytes)); + : Loc.Plural("Shell.Status.Sequences", _rows.Count) + Loc.Separator + Formatting.Bytes(_rows.Sum(r => r.Entry.Bytes)); /// Reads the trash of the archive (off the UI thread). public async Task LoadAsync() diff --git a/src/Titano.App/Editor/EditorText.cs b/src/Titano.App/Editor/EditorText.cs index 85d1c72a..93b08ab4 100644 --- a/src/Titano.App/Editor/EditorText.cs +++ b/src/Titano.App/Editor/EditorText.cs @@ -14,7 +14,7 @@ namespace Titano.App.Editor; /// The editor's composed texts (header summary, shot data, preset card lines), in the current UI language. public static class EditorText { - private const string Separator = " · "; + private static string Separator => Loc.Separator; /// "3,600 frames · Canon EOS R5 · 2 s interval · 2 h 00 m · 3 warnings". public static string Summary(SequenceContent content, int warnings) diff --git a/src/Titano.App/Editor/EditorViewModel.cs b/src/Titano.App/Editor/EditorViewModel.cs index e2c80437..afaba5b2 100644 --- a/src/Titano.App/Editor/EditorViewModel.cs +++ b/src/Titano.App/Editor/EditorViewModel.cs @@ -814,6 +814,21 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable RequestPreview(immediate: true); } + /// + /// The UI language changed: what the tabs keep in objects (chart legends and summaries, the Auto chips of the + /// settings), the timeline markers and the preview's info line are made again in the new language. + /// + protected override void OnLanguageChanged() + { + if (!_disposed) + { + foreach (var tab in Tabs) tab.OnContentChanged(); + UpdateMarkers(); + UpdateInfo(); + } + base.OnLanguageChanged(); + } + /// The first failure of a run of failed saves (they are retried until one succeeds); Retry tries at once. private void OnSaveFailed(Exception ex) => Shell.ShowToast(new Toast { @@ -874,7 +889,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable { var settings = plan.Setup.Encoder.Settings; var position = plan.Setup.Plan.DurationSeconds * CurrentIndex / double.Max(1, FrameCount - 1); - InfoText = string.Join(" · ", EditorText.Position(CurrentIndex, FrameCount), + InfoText = string.Join(Loc.Separator, EditorText.Position(CurrentIndex, FrameCount), Loc.L("Editor.Preview.OutputTime", EditorText.Clock(position), EditorText.Clock(plan.Setup.Plan.DurationSeconds)), Loc.L("Editor.Preview.OutputSize", EditorText.Size(settings.Width, settings.Height))); } diff --git a/src/Titano.App/Editor/ExportTab.cs b/src/Titano.App/Editor/ExportTab.cs index 7ead2698..e762513d 100644 --- a/src/Titano.App/Editor/ExportTab.cs +++ b/src/Titano.App/Editor/ExportTab.cs @@ -381,7 +381,7 @@ public sealed class ExportTab : EditorTab /// "about 5 min · NVENC"; without this PC's encoder for a server sequence. public string? EstimatedTime => Estimated is { } plan - ? Loc.L("Editor.Export.About", Formatting.Duration(plan.Estimate.Time)) + (!Editor.IsRemote && plan.Setup.Encoder.Capability is { } c ? " · " + c.Name : string.Empty) + ? Loc.L("Editor.Export.About", Formatting.Duration(plan.Estimate.Time)) + (!Editor.IsRemote && plan.Setup.Encoder.Capability is { } c ? Loc.Separator + c.Name : string.Empty) : null; public string? ResultName => Editor.Plan?.FileName; diff --git a/src/Titano.App/Editor/ExposureTab.cs b/src/Titano.App/Editor/ExposureTab.cs index a715a743..eb99f0a1 100644 --- a/src/Titano.App/Editor/ExposureTab.cs +++ b/src/Titano.App/Editor/ExposureTab.cs @@ -187,6 +187,6 @@ public sealed class ExposureTab : EditorTab if (corrections.Report.Deflicker is { FlickerBefore: > 0 } d) parts.Add(Loc.L("Editor.Exposure.FlickerChange", double.Round((d.FlickerAfter / d.FlickerBefore - 1) * 100).ToString("+0;−0;0", Loc.Culture))); if (corrections.Report.MaxTargetStepEv is { } step) parts.Add(Loc.L("Editor.Exposure.MaxStep", step.ToString("0.00", Loc.Culture))); - return parts.Count == 0 ? null : string.Join(" · ", parts); + return parts.Count == 0 ? null : string.Join(Loc.Separator, parts); } } diff --git a/src/Titano.App/Editor/FramesTab.cs b/src/Titano.App/Editor/FramesTab.cs index a2025776..e01ea6fb 100644 --- a/src/Titano.App/Editor/FramesTab.cs +++ b/src/Titano.App/Editor/FramesTab.cs @@ -79,7 +79,7 @@ public sealed class FrameRow(FramesTab owner, Frame frame, int index) : Observab { if ((frame.Flags & flag) != 0) parts.Add(Loc.L("Editor.Frames.Flag." + flag)); } - return string.Join(" · ", parts); + return string.Join(Loc.Separator, parts); } } diff --git a/src/Titano.App/Editor/MotionTab.cs b/src/Titano.App/Editor/MotionTab.cs index 57f697e2..0861b9f5 100644 --- a/src/Titano.App/Editor/MotionTab.cs +++ b/src/Titano.App/Editor/MotionTab.cs @@ -78,7 +78,7 @@ public sealed class MotionTab : EditorTab Loc.L("Editor.Motion.CropValue", (shake.CropCost * 100).ToString("0.0", Loc.Culture)), }; if (shake.PanDetected) parts.Add(Loc.L("Editor.Motion.PanValue", shake.PanPxPerFrame.ToString("0.0", Loc.Culture))); - Summary = string.Join(" · ", parts); + Summary = string.Join(Loc.Separator, parts); } private static double[] Accumulate(double?[] shifts) diff --git a/src/Titano.App/Editor/SettingRows.cs b/src/Titano.App/Editor/SettingRows.cs index cae4b51a..bff6520e 100644 --- a/src/Titano.App/Editor/SettingRows.cs +++ b/src/Titano.App/Editor/SettingRows.cs @@ -187,7 +187,7 @@ public sealed class AutoSwitchRow : SettingRow var project = _session.Project; IsOn = _setting.Effective(project, _session.Content.Deep); IsAuto = _setting.IsAuto(project); - AutoText = Loc.L("Common.Auto") + " · " + Loc.L(IsOn ? "Editor.Value.On" : "Editor.Value.Off"); + AutoText = Loc.L("Common.Auto") + Loc.Separator + Loc.L(IsOn ? "Editor.Value.On" : "Editor.Value.Off"); AutoReason = Reason(_session, _setting); } } @@ -273,7 +273,7 @@ public sealed class AutoChoiceRow : AutoChoiceRow Selected = Options.FirstOrDefault(o => Equals(o.Value, value)); IsAuto = _setting.IsAuto(project); var auto = _setting.AutoValue(project, _session.Content.Deep); - AutoText = Loc.L("Common.Auto") + " · " + (Options.FirstOrDefault(o => Equals(o.Value, auto))?.Label ?? auto.ToString()); + AutoText = Loc.L("Common.Auto") + Loc.Separator + (Options.FirstOrDefault(o => Equals(o.Value, auto))?.Label ?? auto.ToString()); AutoReason = Reason(_session, _setting); NotApplicableReason = _notApplicable?.Invoke(project); } diff --git a/src/Titano.App/Import/CardActions.cs b/src/Titano.App/Import/CardActions.cs index c913763a..429ec86b 100644 --- a/src/Titano.App/Import/CardActions.cs +++ b/src/Titano.App/Import/CardActions.cs @@ -60,7 +60,7 @@ public sealed record CardActions(ImportDestinationKind Destination, bool IsKnown /// "4,812 verified on the card · 96.2 GB · 2 kept": the dry run in one line; empty before it ran. public string EraseText => Erase is null ? string.Empty - : string.Join(" · ", new[] + : string.Join(Loc.Separator, new[] { Loc.Plural("Import.Erase.Verified", DeleteCount), Formatting.Bytes(DeleteBytes), diff --git a/src/Titano.App/Import/CardPool.cs b/src/Titano.App/Import/CardPool.cs index 8acd0b65..89852850 100644 --- a/src/Titano.App/Import/CardPool.cs +++ b/src/Titano.App/Import/CardPool.cs @@ -95,7 +95,7 @@ public sealed record ImportSource(string Key, SourceKind Kind, CardDevice? Devic /// "Known card · 128 GB · 96.2 GB used · 4,812 photos": the entry's tooltip, with what its subtitle may have to cut /// (a drive's subtitle already says it has no DCIM). /// - public string ToolTip => Kind == SourceKind.Drive ? Subtitle : string.Join(" · ", new[] { StateText, Subtitle }.Where(t => t.Length > 0)); + public string ToolTip => Kind == SourceKind.Drive ? Subtitle : string.Join(Loc.Separator, new[] { StateText, Subtitle }.Where(t => t.Length > 0)); /// "Canon EOS R5 · 4,812 photos": the insertion toast's line; "not yet known to Titano" for a new card. public string ToastText @@ -106,7 +106,7 @@ public sealed record ImportSource(string Key, SourceKind Kind, CardDevice? Devic if ((CameraText(Card) is { Length: > 0 } known ? known : Contents?.Camera) is { } camera) parts.Add(camera); if (Contents is { } contents) parts.Add(Loc.Plural("Shell.Status.Photos", contents.Photos)); if (!IsKnown) parts.Add(Loc.L("Import.Toast.Unknown")); - return string.Join(" · ", parts); + return string.Join(Loc.Separator, parts); } } @@ -121,7 +121,7 @@ public sealed record ImportSource(string Key, SourceKind Kind, CardDevice? Devic var serial = Device?.SerialNumber ?? Card?.VolumeSerial; if (serial is { } s && Kind != SourceKind.Folder) parts.Add(Loc.L("Import.Device.Serial", BidiText.Ltr(SerialText(s)))); if (CameraText(Card) is { Length: > 0 } camera) parts.Add(Card?.CameraSerial is { Length: > 0 } body ? Loc.L("Import.Device.Body", camera, body) : camera); - return string.Join(" · ", parts); + return string.Join(Loc.Separator, parts); } } diff --git a/src/Titano.App/Import/ImportPlans.cs b/src/Titano.App/Import/ImportPlans.cs index a8c94da7..db3cb656 100644 --- a/src/Titano.App/Import/ImportPlans.cs +++ b/src/Titano.App/Import/ImportPlans.cs @@ -13,10 +13,10 @@ public sealed record PlanTotals(int Sessions, int Photos, int CopyCount, long Co public bool HasEnoughSpace => FreeAfter is not < 0; /// "3 sessions · 4,812 photos · 96.2 GB · about 12 min". - public string Text => SummaryText + " · " + Loc.L("Import.Plan.About", Formatting.Duration(Estimate)); + public string Text => SummaryText + Loc.Separator + Loc.L("Import.Plan.About", Formatting.Duration(Estimate)); /// "3 sessions · 4,812 photos · 96.2 GB": the plan without its time estimate. - public string SummaryText => string.Join(" · ", + public string SummaryText => string.Join(Loc.Separator, Loc.Plural("Import.Plan.Sessions", Sessions), Loc.Plural("Shell.Status.Photos", Photos), Formatting.Bytes(CopyBytes)); @@ -171,7 +171,7 @@ public static class ImportPlans foreach (var problem in plan.Problems) conflicts.Add(Loc.L("Import.Details.Unreadable", BidiText.Ltr(problem.RelativePath), problem.Message)); if (totals.Duplicates > 0) conflicts.Add(totals.DuplicatesText); if (!totals.HasEnoughSpace) conflicts.Add(totals.SpaceText); - var text = string.Join(" · ", new[] + var text = string.Join(Loc.Separator, new[] { Loc.Plural("Import.Details.Files", plan.FileCount), Loc.L("Import.Details.Copy", Formatting.Count(plan.CopyCount), Formatting.Bytes(plan.CopyBytes)), @@ -210,7 +210,7 @@ public static class ImportPlans var folder = FolderOf(paths[i]); shown.Add(i > 0 && folder == FolderOf(paths[i - 1]) ? paths[i][(folder.Length == 0 ? 0 : folder.Length + 1)..] : paths[i]); } - return Loc.L("Import.Names.Preview", string.Join(" · ", shown)); + return Loc.L("Import.Names.Preview", string.Join(Loc.Separator, shown)); } private static string FolderOf(string path) => path.LastIndexOf('/') is var slash and >= 0 ? path[..slash] : string.Empty; diff --git a/src/Titano.App/Import/ImportResultViewModel.cs b/src/Titano.App/Import/ImportResultViewModel.cs index 04f65e89..a1eb2b37 100644 --- a/src/Titano.App/Import/ImportResultViewModel.cs +++ b/src/Titano.App/Import/ImportResultViewModel.cs @@ -83,7 +83,7 @@ public sealed class ImportResultViewModel : LocalizedViewModel : Loc.L("Import.Result.Partial", Formatting.Count(Outcome.Imported), Formatting.Count(Outcome.Failures.Count)); /// "12 skipped · 3 already there", or empty. - public string DetailText => string.Join(" · ", new[] + public string DetailText => string.Join(Loc.Separator, new[] { Outcome.Skipped > 0 ? Loc.Plural("Import.Result.Skipped", Outcome.Skipped) : string.Empty, Outcome.Duplicates > 0 ? Loc.Plural("Import.Result.AlreadyThere", Outcome.Duplicates) : string.Empty, diff --git a/src/Titano.App/Infrastructure/Formatting.cs b/src/Titano.App/Infrastructure/Formatting.cs index 60fd23b0..de0db20f 100644 --- a/src/Titano.App/Infrastructure/Formatting.cs +++ b/src/Titano.App/Infrastructure/Formatting.cs @@ -5,7 +5,8 @@ namespace Titano.App.Infrastructure; /// Culture-aware number, size and duration formatting for the UI. public static class Formatting { - private static readonly string[] ByteUnits = ["B", "KB", "MB", "GB", "TB", "PB"]; + /// Localized "{0} KB" formats from bytes to petabytes (BRIEF §16: sizes follow the language, "96,2 Go"). + private static readonly string[] ByteUnits = ["Common.Size.B", "Common.Size.KB", "Common.Size.MB", "Common.Size.GB", "Common.Size.TB", "Common.Size.PB"]; /// 1,536 → "1.5 KB" (decimal units, as Explorer shows for drives). public static string Bytes(long bytes) @@ -18,7 +19,7 @@ public static class Formatting unit++; } var format = unit == 0 || value >= 100 ? "0" : "0.#"; - return value.ToString(format, Loc.Culture) + " " + ByteUnits[unit]; + return Loc.L(ByteUnits[unit], value.ToString(format, Loc.Culture)); } public static string Count(long n) => n.ToString("N0", Loc.Culture); diff --git a/src/Titano.App/Jobs/JobText.cs b/src/Titano.App/Jobs/JobText.cs index 72da9fa3..28f259ef 100644 --- a/src/Titano.App/Jobs/JobText.cs +++ b/src/Titano.App/Jobs/JobText.cs @@ -75,6 +75,6 @@ public static class JobText if (Counter(entry.Done, entry.Total) is { Length: > 0 } counter) parts.Add(counter); if (Speed(entry.Job.Kind, entry.ItemsPerSecond) is { Length: > 0 } speed) parts.Add(speed); if (entry.Eta is { } eta) parts.Add(Loc.L("Jobs.Bar.Left", Formatting.Duration(eta))); - return string.Join(" · ", parts); + return string.Join(Loc.Separator, parts); } } diff --git a/src/Titano.App/Library/SequenceItem.cs b/src/Titano.App/Library/SequenceItem.cs index 8c785c1c..3256faff 100644 --- a/src/Titano.App/Library/SequenceItem.cs +++ b/src/Titano.App/Library/SequenceItem.cs @@ -80,7 +80,7 @@ public sealed class SequenceItem : ObservableObject public string Camera => PathTemplate.CameraName(_sequence.CameraMake, _sequence.CameraModel); /// Card line: count · camera · span. - public string Subtitle => string.Join(" · ", new[] { FramesText, Camera, SpanText }.Where(s => s.Length > 0)); + public string Subtitle => string.Join(Loc.Separator, new[] { FramesText, Camera, SpanText }.Where(s => s.Length > 0)); public string FramesText => Formatting.Count(_sequence.FrameCount); diff --git a/src/Titano.App/Sections/AboutViewModel.cs b/src/Titano.App/Sections/AboutViewModel.cs index 1ed7fe2f..4ebf51d5 100644 --- a/src/Titano.App/Sections/AboutViewModel.cs +++ b/src/Titano.App/Sections/AboutViewModel.cs @@ -46,7 +46,7 @@ public sealed class AboutViewModel : SectionViewModel /// File version and processor architecture. public string Build => - (typeof(App).Assembly.GetCustomAttribute()?.Version ?? Version) + " · " + RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant(); + (typeof(App).Assembly.GetCustomAttribute()?.Version ?? Version) + Loc.Separator + RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant(); public string Runtime => RuntimeInformation.FrameworkDescription; diff --git a/src/Titano.App/Sections/ArchiveViewModel.cs b/src/Titano.App/Sections/ArchiveViewModel.cs index 53db943f..a2d11016 100644 --- a/src/Titano.App/Sections/ArchiveViewModel.cs +++ b/src/Titano.App/Sections/ArchiveViewModel.cs @@ -223,12 +223,12 @@ public sealed class ArchiveViewModel : SectionViewModel var text = selected.Count == 0 || selected.Any(n => n.Kind == TreeNodeKind.Archive) ? Loc.Plural("Archive.Set.All", set.Count) : set.Count == 1 ? set[0].DisplayTitle : Loc.Plural("Shell.Status.Sequences", set.Count); - return _filter.IsEmpty ? text : text + " · " + _filter.Describe(); + return _filter.IsEmpty ? text : text + Loc.Separator + _filter.Describe(); } } /// The set button's accessible name: what it is and the set it shows. - public string SetFilterName => Loc.L("Archive.Set.Filter") + " · " + SetText; + public string SetFilterName => Loc.L("Archive.Set.Filter") + Loc.Separator + SetText; /// Camera, status and tag on top of the tree selection. public ArchiveSetFilter Filter @@ -426,6 +426,13 @@ public sealed class ArchiveViewModel : SectionViewModel Orphans = OrphanRows(orphans, locations); } + /// The UI language changed: the figures, tree and health rows are read again in the new language. + protected override void OnLanguageChanged() + { + if (_loaded) _ = LoadAsync(); + base.OnLanguageChanged(); + } + public override void Dispose() { _reloadDelay.Stop(); diff --git a/src/Titano.App/Sections/ImportViewModel.cs b/src/Titano.App/Sections/ImportViewModel.cs index b1766d3e..763091c5 100644 --- a/src/Titano.App/Sections/ImportViewModel.cs +++ b/src/Titano.App/Sections/ImportViewModel.cs @@ -306,7 +306,7 @@ public sealed class ImportViewModel : SectionViewModel public string ServerName => Services.Server.ServerName ?? Loc.L("Import.Destination.NotConnected"); /// "Server · Studio NAS": the Server choice as screen readers announce it. - public string ServerChoiceName => Loc.L("Import.Destination.Server") + " · " + ServerName; + public string ServerChoiceName => Loc.L("Import.Destination.Server") + Loc.Separator + ServerName; public string ServerToolTip => CanUseServer ? Loc.L("Tooltips.Import.Server") : Loc.L("Import.Blocked.NoServer"); @@ -664,6 +664,14 @@ public sealed class ImportViewModel : SectionViewModel /// Shows an import that stopped with , without running it (capture). public void ShowFailed(Exception error) => Fail(ImportFailures.Import(error, SourceTitle), error.Message); + /// The UI language changed: the session table and the device list say it again in the new language. + protected override void OnLanguageChanged() + { + ApplyPlan(); + if (_loaded) _ = RefreshSourcesAsync(); + base.OnLanguageChanged(); + } + public override void Dispose() { _planDelay.Stop(); @@ -801,7 +809,7 @@ public sealed class ImportViewModel : SectionViewModel try { if ((await db.MediaCards.ListImportsAsync(card.Id, 1)).FirstOrDefault() is { } last) - text = string.Join(" · ", new[] { text, Loc.L("Import.Device.LastImport", Formatting.Date(last.ImportedAt)) }.Where(t => t.Length > 0)); + text = string.Join(Loc.Separator, new[] { text, Loc.L("Import.Device.LastImport", Formatting.Date(last.ImportedAt)) }.Where(t => t.Length > 0)); } catch (DatabaseException ex) { @@ -1325,7 +1333,7 @@ public sealed class ImportViewModel : SectionViewModel : Loc.L("Import.Progress.Bytes", Formatting.Bytes(done), Formatting.Bytes(total)), }; if (eta is { } left) parts.Add(Loc.L("Jobs.Bar.Left", Formatting.Duration(left))); - ProgressText = string.Join(" · ", parts); + ProgressText = string.Join(Loc.Separator, parts); } private void Finish(ImportPlan plan, ImportOutcome outcome) diff --git a/src/Titano.App/Sections/JobsViewModel.cs b/src/Titano.App/Sections/JobsViewModel.cs index 393f156f..d5ebb1f5 100644 --- a/src/Titano.App/Sections/JobsViewModel.cs +++ b/src/Titano.App/Sections/JobsViewModel.cs @@ -169,6 +169,15 @@ public sealed class JobsViewModel : SectionViewModel base.Dispose(); } + /// The UI language changed: the rows, the filter chips and the job bar say it again in the new language. + protected override void OnLanguageChanged() + { + foreach (var row in _rows.Values) row.Refresh(); + foreach (var chip in Chips) chip.Refresh(); + UpdateShell(); + base.OnLanguageChanged(); + } + /// Reads the job list again from the first page (after jobs were written outside the engine). public Task ReloadAsync() { diff --git a/src/Titano.App/Sections/LibraryViewModel.cs b/src/Titano.App/Sections/LibraryViewModel.cs index 690613fd..9b680bdc 100644 --- a/src/Titano.App/Sections/LibraryViewModel.cs +++ b/src/Titano.App/Sections/LibraryViewModel.cs @@ -469,7 +469,7 @@ public sealed class LibraryViewModel : SectionViewModel get { var chosen = SelectedItems().ToList(); - return Loc.Plural("Shell.Status.Photos", chosen.Sum(i => (long)i.Sequence.FrameCount)) + " · " + Formatting.Bytes(chosen.Sum(i => i.Sequence.TotalBytes)); + return Loc.Plural("Shell.Status.Photos", chosen.Sum(i => (long)i.Sequence.FrameCount)) + Loc.Separator + Formatting.Bytes(chosen.Sum(i => i.Sequence.TotalBytes)); } } diff --git a/src/Titano.App/Sections/ServerViewModel.cs b/src/Titano.App/Sections/ServerViewModel.cs index 8e7b3f54..093dbf4d 100644 --- a/src/Titano.App/Sections/ServerViewModel.cs +++ b/src/Titano.App/Sections/ServerViewModel.cs @@ -104,7 +104,7 @@ public sealed class ServerViewModel : SectionViewModel if (!IsConnected || Session.Flow.Info is not { } info) return null; var parts = new List { info.Name, Loc.L("Server.Version", info.Version) }; if (Session.Flow.Latency is { } latency) parts.Add(Loc.L("Server.Latency", Math.Max(1, (int)Math.Round(latency.TotalMilliseconds)))); - return string.Join(" · ", parts); + return string.Join(Loc.Separator, parts); } } diff --git a/src/Titano.App/Sections/SettingsViewModel.cs b/src/Titano.App/Sections/SettingsViewModel.cs index 0e1661ab..45299c80 100644 --- a/src/Titano.App/Sections/SettingsViewModel.cs +++ b/src/Titano.App/Sections/SettingsViewModel.cs @@ -589,7 +589,7 @@ public sealed class SettingsViewModel : SectionViewModel Encoders.Clear(); foreach (var row in rows) Encoders.Add(new EncoderRowViewModel(row)); var hardware = rows.Count(r => r.Hardware); - AdapterText = string.Join(" · ", new[] { adapter, Loc.Plural("Settings.Rendering.EncoderCount", rows.Count(r => r.Source == EncoderSource.MediaFoundation)) } + AdapterText = string.Join(Loc.Separator, new[] { adapter, Loc.Plural("Settings.Rendering.EncoderCount", rows.Count(r => r.Source == EncoderSource.MediaFoundation)) } .Where(s => !string.IsNullOrEmpty(s))); Log.Info("settings", $"{rows.Count} encoder(s), {hardware} hardware"); } diff --git a/src/Titano.App/Server/SyncText.cs b/src/Titano.App/Server/SyncText.cs index 03b604ad..bbd435dc 100644 --- a/src/Titano.App/Server/SyncText.cs +++ b/src/Titano.App/Server/SyncText.cs @@ -300,5 +300,5 @@ public static class SyncText private static string Shorten(string text) => text.Length <= 40 ? text : string.Concat(text.AsSpan(0, 39), "…"); - private static string Join(params string[] parts) => string.Join(" · ", parts); + private static string Join(params string[] parts) => string.Join(Loc.Separator, parts); } diff --git a/src/Titano.App/Settings/EncoderUse.cs b/src/Titano.App/Settings/EncoderUse.cs index 0ea94f22..7e1b461c 100644 --- a/src/Titano.App/Settings/EncoderUse.cs +++ b/src/Titano.App/Settings/EncoderUse.cs @@ -23,7 +23,7 @@ public sealed record EncoderRow(string Codec, string Name, string? Vendor, Encod public bool CanSelfTest => Source != EncoderSource.BuiltInAnimation; /// "NVIDIA · NVIDIA HEVC Encoder MFT" unless the name already carries the vendor. - public string DisplayName => Vendor is { } vendor && !Name.Contains(vendor, StringComparison.OrdinalIgnoreCase) ? vendor + " · " + Name : Name; + public string DisplayName => Vendor is { } vendor && !Name.Contains(vendor, StringComparison.OrdinalIgnoreCase) ? vendor + Loc.Separator + Name : Name; } /// What the encoders of this PC are for: the built-in presets each one serves and what a render node offers. @@ -38,7 +38,7 @@ public static class EncoderUse ]; /// "4K archive · 4K HEVC · …" for the Used for column (every codec of this PC has built-in presets). - public static string Text(EncoderRow row) => string.Join(" · ", Presets(row)); + public static string Text(EncoderRow row) => string.Join(Loc.Separator, Presets(row)); /// /// The Media Foundation encoders a render node on this PC offers the server: the software ones, and the hardware ones @@ -49,5 +49,5 @@ public static class EncoderUse /// "HEVC · H.264 · AV1": the codecs of , each once; null when there are none. public static string? Codecs(IEnumerable encoders) => - encoders.Select(e => e.Codec).Distinct(StringComparer.Ordinal).ToList() is { Count: > 0 } codecs ? string.Join(" · ", codecs) : null; + encoders.Select(e => e.Codec).Distinct(StringComparer.Ordinal).ToList() is { Count: > 0 } codecs ? string.Join(Loc.Separator, codecs) : null; } diff --git a/src/Titano.Core/Localization/Loc.cs b/src/Titano.Core/Localization/Loc.cs index feb4352c..a233085e 100644 --- a/src/Titano.Core/Localization/Loc.cs +++ b/src/Titano.Core/Localization/Loc.cs @@ -25,6 +25,16 @@ public static class Loc /// Text direction of the current culture. public static bool IsRightToLeft => _culture.TextInfo.IsRightToLeft; + /// + /// Separator of the fields of a meta line ("3,600 · Canon EOS R5 · 2 h 00 min"). In a right-to-left language it sits + /// between right-to-left marks, so a number after a Latin field stays in its own field instead of joining the Latin + /// run (Unicode bidi rule W7) and the fields read from the right. + /// + public static string Separator => SeparatorOf(_culture); + + /// of , for texts built in a language other than the UI's. + public static string SeparatorOf(CultureInfo culture) => culture.TextInfo.IsRightToLeft ? "‏ · ‏" : " · "; + public static void SetCulture(CultureInfo culture) { ArgumentNullException.ThrowIfNull(culture); diff --git a/src/Titano.Ui/Mvvm/ObservableObject.cs b/src/Titano.Ui/Mvvm/ObservableObject.cs index 3257d5fb..74abe182 100644 --- a/src/Titano.Ui/Mvvm/ObservableObject.cs +++ b/src/Titano.Ui/Mvvm/ObservableObject.cs @@ -35,5 +35,11 @@ public abstract class LocalizedViewModel : ObservableObject, IDisposable GC.SuppressFinalize(this); } - private void OnCultureChanged(object? sender, EventArgs e) => OnAllPropertiesChanged(); + private void OnCultureChanged(object? sender, EventArgs e) => OnLanguageChanged(); + + /// + /// The UI language changed: every property is read again. A view model that keeps texts in objects (chart series + /// and legends, rows, cached sentences) builds them again here, then calls the base. + /// + protected virtual void OnLanguageChanged() => OnAllPropertiesChanged(); } diff --git a/src/Titano.Ui/Visuals/BarChart.cs b/src/Titano.Ui/Visuals/BarChart.cs index 0aef8541..5bf16cd7 100644 --- a/src/Titano.Ui/Visuals/BarChart.cs +++ b/src/Titano.Ui/Visuals/BarChart.cs @@ -152,7 +152,7 @@ public sealed class BarChart : DrawingElement private static string DefaultFormat(double value) => value.ToString("N0", Loc.Culture); - private string ReadoutText(ChartItem item) => item.ToolTip ?? item.Label + " · " + (item.ValueText ?? Format(item.Value)); + private string ReadoutText(ChartItem item) => item.ToolTip ?? item.Label + Loc.Separator + (item.ValueText ?? Format(item.Value)); private double ScaleMaximum(IReadOnlyList items) { diff --git a/src/Titano.Ui/Visuals/HeatmapStrip.cs b/src/Titano.Ui/Visuals/HeatmapStrip.cs index fcd5fd19..2896f57a 100644 --- a/src/Titano.Ui/Visuals/HeatmapStrip.cs +++ b/src/Titano.Ui/Visuals/HeatmapStrip.cs @@ -249,6 +249,6 @@ public sealed class HeatmapStrip : DrawingElement if (data.ToolTips is { } tips && column < tips.Count && !string.IsNullOrEmpty(tips[column])) return tips[column]!; var value = column < data.Values.Count ? data.Values[column] : double.NaN; var columnLabel = ColumnLabels is { } labels && column < labels.Count ? " " + labels[column] : string.Empty; - return data.Label + columnLabel + (double.IsFinite(value) ? " · " + Format(value) : string.Empty); + return data.Label + columnLabel + (double.IsFinite(value) ? Loc.Separator + Format(value) : string.Empty); } } diff --git a/src/Titano.Ui/Visuals/StackedBar.cs b/src/Titano.Ui/Visuals/StackedBar.cs index 61ac7f78..22dfc4ce 100644 --- a/src/Titano.Ui/Visuals/StackedBar.cs +++ b/src/Titano.Ui/Visuals/StackedBar.cs @@ -200,6 +200,6 @@ public sealed class StackedBar : DrawingElement if (item.ToolTip is not null) return item.ToolTip; var total = Total(items); var share = Share(total > 0 ? Math.Max(0, item.Value) / total : 0); - return item.Label + " · " + (item.ValueText is null ? share : item.ValueText + " · " + share); + return item.Label + Loc.Separator + (item.ValueText is null ? share : item.ValueText + Loc.Separator + share); } } diff --git a/src/Titano.Ui/Visuals/TimelineBands.cs b/src/Titano.Ui/Visuals/TimelineBands.cs index e565cde3..734db3dc 100644 --- a/src/Titano.Ui/Visuals/TimelineBands.cs +++ b/src/Titano.Ui/Visuals/TimelineBands.cs @@ -277,6 +277,6 @@ public sealed class TimelineBands : DrawingElement var value = slot < row.Values.Count ? row.Values[slot] : double.NaN; var caption = SlotLabels is { } labels && slot < labels.Count ? " " + labels[slot] : string.Empty; var format = ValueFormatter ?? (v => v.ToString("N0", Loc.Culture)); - return row.Label + caption + (double.IsFinite(value) ? " · " + format(value) : string.Empty); + return row.Label + caption + (double.IsFinite(value) ? Loc.Separator + format(value) : string.Empty); } } diff --git a/src/Titano.Uploader/Shell/Converters.cs b/src/Titano.Uploader/Shell/Converters.cs index 841e65fb..e1acdcce 100644 --- a/src/Titano.Uploader/Shell/Converters.cs +++ b/src/Titano.Uploader/Shell/Converters.cs @@ -78,8 +78,8 @@ public sealed class QueueRowNameConverter : IMultiValueConverter public object Convert(object?[] values, Type targetType, object? parameter, CultureInfo culture) { if (values is not [string file, UploadItemState state, UploadFailure failure, var detail, ..]) return string.Empty; - var name = file + " · " + UploadStateTextConverter.Text(state); - return state == UploadItemState.Failed && FailureTextConverter.Describe(failure, detail as string) is { } reason ? name + " · " + reason : name; + var name = file + Loc.Separator + UploadStateTextConverter.Text(state); + return state == UploadItemState.Failed && FailureTextConverter.Describe(failure, detail as string) is { } reason ? name + Loc.Separator + reason : name; } public object[] ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture) => throw new NotSupportedException(); diff --git a/src/Titano.Uploader/Shell/MainViewModel.cs b/src/Titano.Uploader/Shell/MainViewModel.cs index d7a24f4d..8e217c1e 100644 --- a/src/Titano.Uploader/Shell/MainViewModel.cs +++ b/src/Titano.Uploader/Shell/MainViewModel.cs @@ -290,7 +290,7 @@ public sealed class MainViewModel : LocalizedViewModel } /// Tray hover text. - public string TrayText => Loc.L("Uploader.App.Title") + (HasItems ? " · " + QueueText : string.Empty); + public string TrayText => Loc.L("Uploader.App.Title") + (HasItems ? Loc.Separator + QueueText : string.Empty); // ---------------- Watch folders ---------------- diff --git a/src/Titano.Uploader/Shell/WatchFolderViewModel.cs b/src/Titano.Uploader/Shell/WatchFolderViewModel.cs index b1f8c1d3..71baeb0b 100644 --- a/src/Titano.Uploader/Shell/WatchFolderViewModel.cs +++ b/src/Titano.Uploader/Shell/WatchFolderViewModel.cs @@ -64,7 +64,7 @@ public sealed class WatchFolderViewModel : ObservableObject public string IntervalText => Loc.L("Uploader.Watch.Interval", Interval(IntervalSeconds)); /// The full path (the chip may shorten it), then the folder's state and interval. - public string ToolTip => LeftToRight(Path) + " · " + (IsAvailable == false ? Loc.L("Tooltips.Uploader.WatchFolderMissing", Interval(IntervalSeconds)) + public string ToolTip => LeftToRight(Path) + Loc.Separator + (IsAvailable == false ? Loc.L("Tooltips.Uploader.WatchFolderMissing", Interval(IntervalSeconds)) : IsNetwork ? Loc.L("Tooltips.Uploader.WatchFolderNetwork", Interval(IntervalSeconds)) : Loc.L("Tooltips.Uploader.WatchFolder", Interval(IntervalSeconds))); diff --git a/src/Titano.Uploader/Text/UploaderText.cs b/src/Titano.Uploader/Text/UploaderText.cs index a3cc01cb..dc3e76fb 100644 --- a/src/Titano.Uploader/Text/UploaderText.cs +++ b/src/Titano.Uploader/Text/UploaderText.cs @@ -20,8 +20,6 @@ public enum QueueActivity /// public static class UploaderText { - private const string Separator = " · "; - /// Localized "{0} KB" formats from bytes to petabytes (BRIEF §16: sizes follow the language, "96,2 Go"). private static readonly string[] SizeFormats = ["Common.Size.B", "Common.Size.KB", "Common.Size.MB", "Common.Size.GB", "Common.Size.TB", "Common.Size.PB"]; @@ -86,11 +84,11 @@ public static class UploaderText parts.Add(L("Uploader.Queue.Done", culture)); break; } - return string.Join(Separator, parts); + return string.Join(Loc.SeparatorOf(culture), parts); } /// "2,214 of 4,812 sent · 2,201 verified by the server · 0 retries" (failures have their own link, ). - public static string ProgressLine(QueueSummary summary, CultureInfo culture) => string.Join(Separator, + public static string ProgressLine(QueueSummary summary, CultureInfo culture) => string.Join(Loc.SeparatorOf(culture), L("Uploader.Progress.Sent", culture, summary.Sent, summary.Files), L("Uploader.Progress.Verified", culture, summary.Verified), Plural("Uploader.Progress.Retries", summary.Retries, culture)); diff --git a/tests/Titano.App.Tests/Archive/ArchiveLogicTests.cs b/tests/Titano.App.Tests/Archive/ArchiveLogicTests.cs index cda498ce..540d6ae7 100644 --- a/tests/Titano.App.Tests/Archive/ArchiveLogicTests.cs +++ b/tests/Titano.App.Tests/Archive/ArchiveLogicTests.cs @@ -258,7 +258,8 @@ public sealed class ArchiveLogicTests try { Loc.SetCulture(CultureInfo.GetCultureInfo("he")); - Assert.Equal(Loc.L("Tooltips.Archive.YearRowRtl", "2026 · " + year.Detail), year.RowToolTip, "the arrow keys of a mirrored tree"); + Assert.Equal(Loc.L("Tooltips.Archive.YearRowRtl", "2026" + Loc.Separator + year.Detail), year.RowToolTip, "the arrow keys of a mirrored tree"); + Assert.Contains("‏", year.RowToolTip, "right-to-left marks keep the year and its figures apart"); } finally { diff --git a/tests/Titano.App.Tests/Archive/ArchiveScreenSmokeTests.cs b/tests/Titano.App.Tests/Archive/ArchiveScreenSmokeTests.cs index 18af3c60..5376d444 100644 --- a/tests/Titano.App.Tests/Archive/ArchiveScreenSmokeTests.cs +++ b/tests/Titano.App.Tests/Archive/ArchiveScreenSmokeTests.cs @@ -126,7 +126,7 @@ public sealed class ArchiveScreenSmokeTests await ArchiveScenes.ShowAsync(app.Shell, "overview"); Assert.Equal(12.ToString("N0", Loc.Culture), archive.MonthLabels[^1], "Arabic month names have no initials: the columns are numbered"); var year = archive.TreeRows[1]; - Assert.Equal(Loc.L("Tooltips.Archive.YearRowRtl", year.Title + " · " + year.Detail), year.RowToolTip, "the tooltip names the mirrored arrow keys"); + Assert.Equal(Loc.L("Tooltips.Archive.YearRowRtl", year.Title + Loc.Separator + year.Detail), year.RowToolTip, "the tooltip names the mirrored arrow keys"); await app.ExpectAsync("archive-overview-ar"); // The dialogs' templates exist once they are laid out: render first, then look inside. diff --git a/tests/Titano.App.Tests/Editor/EditorSmokeTests.cs b/tests/Titano.App.Tests/Editor/EditorSmokeTests.cs index 137b5ef2..672877b4 100644 --- a/tests/Titano.App.Tests/Editor/EditorSmokeTests.cs +++ b/tests/Titano.App.Tests/Editor/EditorSmokeTests.cs @@ -142,6 +142,21 @@ public sealed class EditorSmokeTests Assert.Equal(editor.Session.Content.SourceWidth, ((BitmapSource)editor.PreviewImage!).PixelWidth, "1:1 shows source pixels"); editor.ZoomMode = PreviewZoomMode.Fit; + // A language switch makes again what the tabs keep in objects: the chart legend and the Auto chips follow at once. + var chip = editor.Exposure.Rows.OfType().First(); + var english = chip.AutoText; + UiLanguage.Apply("it"); + try + { + Assert.True(editor.Exposure.Legend.Any(i => i.Text == "luminanza misurata"), "the legend follows the language"); + Assert.Equal(Loc.L("Common.Auto") + Loc.Separator + Loc.L(chip.IsOn ? "Editor.Value.On" : "Editor.Value.Off"), chip.AutoText); + Assert.NotEqual(english, chip.AutoText); + } + finally + { + UiLanguage.Apply("en"); + } + // An edit through the session is undone and redone (Ctrl+Z / Ctrl+Y run the same commands). ThemeManager.Apply(AppTheme.Dark); var before = editor.Session.Project.Exposure.ExposureOffsetEv; diff --git a/tests/Titano.App.Tests/Jobs/JobsScreenSmokeTests.cs b/tests/Titano.App.Tests/Jobs/JobsScreenSmokeTests.cs index 5b6b615e..863cb4e2 100644 --- a/tests/Titano.App.Tests/Jobs/JobsScreenSmokeTests.cs +++ b/tests/Titano.App.Tests/Jobs/JobsScreenSmokeTests.cs @@ -3,6 +3,7 @@ using System.Windows.Automation; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; +using Titano.App.Infrastructure; using Titano.App.Jobs; using Titano.App.Sections; using Titano.App.Shell; @@ -70,6 +71,20 @@ public sealed class JobsScreenSmokeTests } var actionColumns = rows.Select(r => Left(Descendants(r.Item).Last())).ToList(); Assert.True(actionColumns.Max() - actionColumns.Min() < 1, "the actions column starts at the same x in every row"); + + // A language switch reaches the job bar at once, not at the job's next progress report. + var bar = shell.JobText; + Assert.True(shell.IsJobActive, "the sample runs a job"); + UiLanguage.Apply("it"); + try + { + Assert.NotEqual(bar, shell.JobText, "the job bar follows the language"); + } + finally + { + UiLanguage.Apply("en"); + } + Assert.Equal(bar, shell.JobText); }); private static TextBlock Text(ScreenSmokeTests.SampleApp app, string text) => app.FindAll().First(t => t.Text == text && t.IsVisible); diff --git a/tests/Titano.Core.Tests/Localization/LocTests.cs b/tests/Titano.Core.Tests/Localization/LocTests.cs new file mode 100644 index 00000000..e778b111 --- /dev/null +++ b/tests/Titano.Core.Tests/Localization/LocTests.cs @@ -0,0 +1,33 @@ +using System.Globalization; +using Titano.Core.Localization; +using Titano.Testing; + +namespace Titano.Core.Tests.Localization; + +/// Switches the process-wide UI language, so nothing else runs meanwhile. +[Serial] +public sealed class LocTests +{ + [Test] + public void FieldSeparatorHoldsRightToLeftMarksOnlyInRightToLeftLanguages() + { + var before = Loc.Culture; + try + { + Loc.SetCulture(CultureInfo.GetCultureInfo("en")); + Assert.Equal(" · ", Loc.Separator); + Loc.SetCulture(CultureInfo.GetCultureInfo("it")); + Assert.Equal(" · ", Loc.Separator); + foreach (var culture in new[] { "ar", "he" }) + { + Loc.SetCulture(CultureInfo.GetCultureInfo(culture)); + // A strong right-to-left character on each side: a number after a Latin field stays in its own field. + Assert.Equal("‏ · ‏", Loc.Separator); + } + } + finally + { + Loc.SetCulture(before); + } + } +}