Files
Chronos/tests/Titano.Tools.Tests/I18nCommandTests.cs
T
Claude 082ff1e3eb fix(i18n): tallies of participles read as labels
Texts that count with participles or adjectives still put a bare number in
front of a word that agrees with it in Italian, so one failure read "1 non
riuscite": the import result and its Done toast, the archive health line and
the thumbnail and import job log lines. They now read as labels in English and
Italian ("Copied: 40 · failed: 1"), like the scan and verify log lines; their
old translations leave the other 36 catalogs until the next translation pass.
The uploader's progress keeps the mockup's English and uses labels in Italian,
and the admin dashboard's upload total no longer agrees with the number.

`i18n check` now also fails on an English text that tallies two or more counts
with participles or adjectives. A single "{0} failed" is left alone, since the
placeholder there is as often a name or a size as a count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
2026-10-12 11:09:17 +00:00

60 lines
4.2 KiB
C#

using Titano.Testing;
using Titano.Tools.Commands;
namespace Titano.Tools.Tests;
/// <summary><c>i18n check</c> flags an English text that counts something without plural forms (BRIEF §16).</summary>
public sealed class I18nCommandTests
{
[Test]
public void ANumberInFrontOfACountedNounNeedsPluralForms()
{
Assert.Equal("frames", I18nCommand.CountedNoun("Advisor.Finding.BlackFrames", "{0} frames are black (lens cap or missed exposure)."));
Assert.Equal("gaps", I18nCommand.CountedNoun("Advisor.Reason.Timing.SparseGaps", "{0} short gaps, but motion is unmeasured or fast."));
Assert.Equal("changes", I18nCommand.CountedNoun("Advisor.Finding.StepsNotReceived", "{0} logged exposure changes never reached the pixels."));
Assert.Equal("times", I18nCommand.CountedNoun("Advisor.Finding.LensChanged", "The lens changes {0} times."));
Assert.Equal("sequences", I18nCommand.CountedNoun("Errors.Analysis.Failed", "{0} of {1} sequences could not be analysed; see the job log."));
Assert.Equal("jobs", I18nCommand.CountedNoun("Shell.JobBar.Ready", "Ready · {0:N0} jobs queued"));
Assert.Equal("cores", I18nCommand.CountedNoun("Settings.Rendering.Cores", "of {0} logical cores"));
}
[Test]
public void PluralFormsBoundsLabelsAndUnitsCountNothing()
{
Assert.Null(I18nCommand.CountedNoun("Advisor.Finding.BlackFrames.other", "{0} frames are black (lens cap or missed exposure)."));
Assert.Null(I18nCommand.CountedNoun("Advisor.Finding.BlackFrames.one", "{0} frame is black (lens cap or missed exposure)."));
Assert.Null(I18nCommand.CountedNoun("Server.Error.WeakPassword", "Use at least {0} characters."));
Assert.Null(I18nCommand.CountedNoun("Library.Views.Error.Long", "At most {0} characters, no control characters."));
Assert.Null(I18nCommand.CountedNoun("Archive.Retag.Invalid", "Each tag has 1 to {0} characters."));
Assert.Null(I18nCommand.CountedNoun("Archive.Log.ScanDone", "Folders: {0}, indexed: {1}, adopted: {2}, removed: {3}"));
Assert.Null(I18nCommand.CountedNoun("Advisor.Reason.Window.Period.other", "Flicker repeats every {0} frames: a {1}-frame window averages four cycles."));
Assert.Null(I18nCommand.CountedNoun("Advisor.Reason.Timing.Regular", "Steady {0} s interval (jitter {1} s): each photo becomes one video frame."));
Assert.Null(I18nCommand.CountedNoun("Tooltips.Editor.Remote", "Changes are saved on {0} and analyses and renders run there"));
Assert.Null(I18nCommand.CountedNoun("Advisor.Reason.Transition.Single", "A single exposure step: a {0}-frame transition keeps the change gentle."));
}
[Test]
public void ATallyOfParticiplesNeedsLabels()
{
// Italian reads "1 copiate · 1 non riuscite": the participle agrees with the number in front of it.
Assert.Equal("copied", I18nCommand.CountedTally("Import.Result.Partial", "{0} copied · {1} failed"));
Assert.Equal("missing", I18nCommand.CountedTally("Archive.Health.Damaged", "{0} missing · {1} damaged"));
Assert.Equal("made", I18nCommand.CountedTally("Archive.Log.ImagesDone", "{0}: {1} made, {2} reused, {3} unreadable"));
Assert.Equal("copied", I18nCommand.CountedTally("Archive.Log.ImportDone", "{0:N0} copied, {1:N0} skipped, {2:N0} failed."));
}
[Test]
public void LabelsNamesAndSizesAreNoTally()
{
Assert.Null(I18nCommand.CountedTally("Import.Result.Partial", "Copied: {0} · failed: {1}"));
Assert.Null(I18nCommand.CountedTally("Archive.Log.ImagesDone", "{0}: made {1}, reused {2}, unreadable {3}"));
Assert.Null(I18nCommand.CountedTally("Archive.Log.ScanDone", "Folders: {0}, indexed: {1}, adopted: {2}, removed: {3}"));
// A single participle after a placeholder is as often a name or a size as a count.
Assert.Null(I18nCommand.CountedTally("Export.Log.Failed", "{0} failed: {1}"));
Assert.Null(I18nCommand.CountedTally("Library.Queued", "{0} queued · {1}"));
Assert.Null(I18nCommand.CountedTally("Import.Plan.SpaceMissing", "{0} missing"));
Assert.Null(I18nCommand.CountedTally("Settings.Storage.Usage", "{0} used · {1} free"));
Assert.Null(I18nCommand.CountedTally("Import.Result.Skipped.other", "{0:N0} copied, {1:N0} skipped"));
}
}