Merge branch 'fix/app-fixes': localized error toasts, plural counts, archive and import view-model fixes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
303 files changed
+968
-2234
No files matched your search
@@ -54,6 +54,10 @@ internal sealed partial class I18nCommand : ICommand
|
||||
errors.Add($"en: {key} is {entry.Value.Length} chars (budget {limit})");
|
||||
if (string.IsNullOrWhiteSpace(entry.Value))
|
||||
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)
|
||||
@@ -124,6 +128,35 @@ internal sealed partial class I18nCommand : ICommand
|
||||
warnings.Add($"{culture}: {key} is {translated.Value.Length} chars (soft budget {limit})");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The noun a plain (non-plural) English value counts with a number in front of it ("{0} frames", "{0} short gaps"):
|
||||
/// such a key reads "1 frames", and Italian or Slavic forms cannot follow the number either (BRIEF §16). Bounds the code
|
||||
/// sets ("at most {0} characters") and labels ("Frames: {0}") count nothing; null when the value counts nothing.
|
||||
/// </summary>
|
||||
internal static string? CountedNoun(string key, string value)
|
||||
{
|
||||
if (PluralSuffix().IsMatch(key[(key.LastIndexOf('.') + 1)..])) return null;
|
||||
foreach (Match m in CountedNounRegex().Matches(value))
|
||||
{
|
||||
if (!m.Groups["bound"].Success) return m.Groups["noun"].Value;
|
||||
}
|
||||
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)
|
||||
{
|
||||
@@ -292,6 +325,21 @@ internal sealed partial class I18nCommand : ICommand
|
||||
[GeneratedRegex(@"^(one|few|many|other)$")]
|
||||
private static partial Regex PluralSuffix();
|
||||
|
||||
/// <summary>A placeholder, up to two describing words that are not function words, then a noun the product counts.</summary>
|
||||
[GeneratedRegex(@"(?<bound>\b(?i:at least|at most|up to|to)\s+)?\{\d+(?:[,:][^}]*)?\}(?:\s+(?!(?:and|or|of|the|a|an|to|on|in|at|by|for|with|from|is|are|was|were)\b)[a-z]+){0,2}?\s+"
|
||||
+ @"(?<noun>frames|photos|sequences|files|folders|exports|renders|jobs|times|gaps|sessions|changes|steps|warnings|cores|days|hours|minutes|"
|
||||
+ @"items|cards|tags|users|accounts|nodes|presets|characters|originals|copies|groups|issues|cameras|lenses|uploads|downloads|transfers|"
|
||||
+ @"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