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
This commit is contained in:
84 files changed
+76
-162
No files matched your search
@@ -77,7 +77,7 @@ public sealed class ImportResultViewModel : LocalizedViewModel
|
||||
public ICommand EjectCommand { get; }
|
||||
public ICommand OpenLibraryCommand { get; }
|
||||
|
||||
/// <summary>"4,812 copied and verified", "4,800 copied · 12 failed".</summary>
|
||||
/// <summary>"4,812 copied and verified", "Copied: 4,800 · failed: 12".</summary>
|
||||
public string ResultText => Outcome.IsComplete
|
||||
? Loc.Plural(Outcome.Verified ? "Import.Result.Verified" : "Import.Result.Copied", Outcome.Imported)
|
||||
: Loc.L("Import.Result.Partial", Formatting.Count(Outcome.Imported), Formatting.Count(Outcome.Failures.Count));
|
||||
|
||||
@@ -56,6 +56,8 @@ internal sealed partial class I18nCommand : ICommand
|
||||
errors.Add($"en: {key} is empty");
|
||||
if (CountedNoun(key, entry.Value) is { } noun)
|
||||
errors.Add($"en: {key} counts {noun} but is not a plural stem: write {key}.one and {key}.other with the count as {{0}}, or a label (\"Frames: {{0}}\")");
|
||||
if (CountedTally(key, entry.Value) is { } word)
|
||||
errors.Add($"en: {key} puts counts before \"{word}\", which agrees with the number in other languages: write labels (\"Copied: {{0}}, failed: {{1}}\")");
|
||||
}
|
||||
|
||||
foreach (var (culture, strings) in catalog.Cultures)
|
||||
@@ -141,6 +143,20 @@ internal sealed partial class I18nCommand : ICommand
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The first word of a tally that counts with participles or adjectives ("{0} copied · {1} failed", "{1} made, {2}
|
||||
/// reused"): Italian, Polish or Russian inflect those words for the number ("1 copiata", "3 copiate"), so the tally
|
||||
/// reads "1 copiate" unless it is written as labels ("Copied: {0} · failed: {1}"). Only a list of two or more counts
|
||||
/// is a tally: before a single "failed" or "missing" the placeholder is as often a name ("Import of {0} failed") or a
|
||||
/// size ("{0} missing") as a count. Null when the value holds no such tally.
|
||||
/// </summary>
|
||||
internal static string? CountedTally(string key, string value)
|
||||
{
|
||||
if (PluralSuffix().IsMatch(key[(key.LastIndexOf('.') + 1)..])) return null;
|
||||
var items = CountedTallyRegex().Matches(value);
|
||||
return items.Count >= 2 ? items[0].Groups["word"].Value : null;
|
||||
}
|
||||
|
||||
/// <summary>The English <c>other</c> form when <paramref name="key"/> is a plural form of an English plural key.</summary>
|
||||
private static Entry? PluralStem(string key, Dictionary<string, Entry> en)
|
||||
{
|
||||
@@ -316,6 +332,14 @@ internal sealed partial class I18nCommand : ICommand
|
||||
+ @"keyframes|encoders|errors|problems|duplicates|locks|packs|flags|lines|months|years|previews|settings|versions|workers|stars|rows|chunks)\b")]
|
||||
private static partial Regex CountedNounRegex();
|
||||
|
||||
/// <summary>One item of a tally: a placeholder that starts the text or follows a list separator, then a participle or
|
||||
/// adjective that ends the item.</summary>
|
||||
[GeneratedRegex(@"(?<=^|[,;:·(]\s*)\{\d+(?:[,:][^}]*)?\}\s+(?<word>copied|skipped|failed|made|reused|missing|damaged|unreadable|deleted|kept|"
|
||||
+ @"moved|removed|added|indexed|adopted|checked|intact|hashed|verified|imported|exported|rendered|renamed|uploaded|downloaded|sent|"
|
||||
+ @"received|created|updated|changed|restored|trashed|merged|found|lost|broken|corrupt|undecodable|unchanged|cancelled|done|finished|"
|
||||
+ @"queued|running|waiting|pending|selected|linked|synced|compacted|flagged|marked)(?=\s*(?:$|[,;·.)]))")]
|
||||
private static partial Regex CountedTallyRegex();
|
||||
|
||||
internal sealed record Entry(string File, string Value, string? Comment);
|
||||
|
||||
internal sealed class Catalog
|
||||
|
||||
Reference in new issue
Block a user