fix(i18n): plural forms for every text that counts

Findings, advisor reasons and a few UI texts put a count before a plural noun
without plural forms, so English and Italian read "1 frames are black". Each
such key is now a plural stem (.one/.other) whose count is its first argument;
findings and reasons, which travel as data, resolve through the new Loc.Text,
which picks the form from that argument (a fraction takes "other"), so stored
deep reports and project reasons keep their keys and arguments. Texts with two
or more counts (job log lines, "frames with a capture time: 12 of 300") read as
labels, which agree with no number. A single exposure change gets its own
finding instead of "1 exposure changes, typically 0 frames apart".

The converted and reworded keys leave the 36 other catalogs until they are
translated again; the dead plain Shell.JobBar.Ready goes too. `i18n check` now
fails on an English text that counts a noun without plural forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-12 10:13:46 +00:00
1 parent f7a7506fe7
commit 579ffd446d
242 files changed
+348 -2036

No files matched your search

@@ -31,14 +31,56 @@ public sealed partial class AdvisorLocalizationTests(TestContext context)
var keys = Keys(typeof(AdvisorKeys)).Concat(Keys(typeof(FindingKeys))).Concat(Keys(typeof(DeepFindingKeys)))
.Concat(english.Keys.Where(k => k.StartsWith(LogPrefix, StringComparison.Ordinal))).ToList();
Assert.Greater(keys.Count, 90);
var forms = 0;
foreach (var key in keys)
{
Assert.True(english.TryGetValue(key, out var en), $"English text missing for {key}");
Assert.True(italian.TryGetValue(key, out var it), $"Italian text missing for {key}");
Assert.SequenceEqual(Placeholders(en!), Placeholders(it!), key);
Assert.LessOrEqual(en!.Length, 200);
// A key that counts something is a plural stem (BRIEF §16) whose count is its first argument.
string[] names = english.ContainsKey(key) ? [key] : [key + ".one", key + ".other"];
if (names.Length == 2) Assert.Contains("0", Placeholders(english.GetValueOrDefault(key + ".other") ?? string.Empty), $"{key}.other counts with {{0}}");
foreach (var name in names)
{
Assert.True(english.TryGetValue(name, out var en), $"English text missing for {name}");
Assert.True(italian.TryGetValue(name, out var it), $"Italian text missing for {name}");
Assert.SequenceEqual(Placeholders(en!), Placeholders(it!), name);
Assert.LessOrEqual(en!.Length, 200);
forms++;
}
}
Assert.Equal(english.Count, keys.Count);
Assert.Equal(english.Count, forms);
}
[Test]
public void ACountOfOneReadsInTheSingularInBothLanguages()
{
Assert.Equal("1 frame is black (lens cap or missed exposure).", Loc.Text(DeepFindingKeys.BlackFrames, [1.0], English));
Assert.Equal("3 frames are black (lens cap or missed exposure).", Loc.Text(DeepFindingKeys.BlackFrames, [3.0], English));
Assert.Equal("1 fotogramma è nero (tappo sull'obiettivo o scatto mancato).", Loc.Text(DeepFindingKeys.BlackFrames, [1.0], Italian));
Assert.Equal("The lens changes once.", Loc.Text(FindingKeys.LensChanged, [1], English));
Assert.Equal("L'obiettivo cambia 2 volte.", Loc.Text(FindingKeys.LensChanged, [2], Italian));
Assert.Equal("2 exposure changes reached the pixels: each is spread over a smooth transition.", Loc.Text(AdvisorKeys.HolyGrailReceived, [2], English));
// Advisor windows are measured in tenths of a frame: a fraction takes the plural.
Assert.Equal("Flicker stays correlated over 1.5 frames: a 7-frame window spans four times that.", Loc.Text(AdvisorKeys.WindowCorrelation, [1.5, 7], English));
Assert.Equal("Flicker stays correlated over 1 frame: a 5-frame window spans four times that.", Loc.Text(AdvisorKeys.WindowCorrelation, [1.0, 5], English));
// Keys without a count read as before.
Assert.Equal("Clouds cover about 42% of the sky on average.", Loc.Text(DeepFindingKeys.Clouds, [42.0], English));
}
[Test]
public void ASingleExposureChangeHasNoSpacing()
{
var frames = Enumerable.Range(0, 20).Select(i => new LightFrame
{
Index = i,
CapturedAt = new DateTime(2026, 6, 1, 20, 0, 0, DateTimeKind.Utc).AddSeconds(10 * i),
ExposureTime = i < 12 ? 1.0 / 250 : 1.0 / 125,
FNumber = 8,
Iso = 100,
}).ToList();
var single = LightAnalyzer.Analyze(frames).Findings.Single(f => f.Key == FindingKeys.ExposureStep);
Assert.SequenceEqual([12], single.Frames);
Assert.Equal("One exposure change of -1.0 EV.", Loc.Text(single.Key, single.Arguments, English));
Assert.Equal("Un solo cambio di esposizione di -1,0 EV.", Loc.Text(single.Key, single.Arguments, Italian));
Assert.DoesNotContain(FindingKeys.ExposureSteps, LightAnalyzer.Analyze(frames).Findings.Select(f => f.Key));
}
[Test]
@@ -106,9 +148,8 @@ public sealed partial class AdvisorLocalizationTests(TestContext context)
{
foreach (var culture in new[] { English, Italian })
{
var format = Loc.Get(key, culture);
Assert.NotNull(format);
var text = Format(format!, culture, args);
var text = Loc.Text(key, args, culture);
Assert.False(text.Contains('⟦'), $"{key} has no {culture.Name} text");
Assert.False(text.Contains('{'), $"{key} left a placeholder: {text}");
}
return 1;