translation agent broke plural rules double-applying them and the catalog build failed
Covers translation agents double-applying plural rules: assign ownership to one stage and make it idempotent. Use it when catalogs show doubly-pluralized strings. Not for single-application rule bugs.
Fix the translation agent double-applying plural rules
TL;DR
The agent pluralizes strings that are already pluralized, so make pluralization idempotent or apply it once. Double application turns 2 items into 2 itemses style garbage. Check whether the string is already in plural form before applying rules, or restructure so only one stage owns pluralization.
The error
Translation agent: catalog build failed, double pluralization detected
"2 items" became "2 itemses" in the outputFix it
Step 1: Find the two pluralization stages
grep -rn "plural" scripts/translate-agent.js | head -10Expected: You see where plural rules apply twice.
Step 2: Decide which stage owns pluralization
node -e "console.log('one stage applies rules, the other passes strings through untouched')"Expected: Ownership is explicit.
Step 3: Make the rule application idempotent
node -e "console.log('pattern: only apply when the string lacks plural markers already')"Expected: Running twice is now harmless.
Step 4: Rebuild the catalog and spot-check plurals
node scripts/build-catalog.js | tail -2Expected: Plurals render correctly.
When to use this
- A translation agent applies plural rules twice
- Catalog shows doubly-pluralized strings
When NOT to use this
- Plurals are wrong once, that is a rule bug not a double application
- The double application is in your app code, fix it there
Tool and version compatibility
- Agent pipelines with separate transform stages
- Idempotent string transforms
Variant phrasings
double application across agent and TMS
Same fix. Agree on which side pluralizes, the other side passes through.
only some strings double-pluralize
Those go through both stages. Trace one string end to end to find the overlap.
Why it happens
Pipelines grow stages over time, and two stages each assume they own pluralization. Neither checks whether the work is done, so strings passing through both get the rules applied twice.
Edge cases
- Idempotency checks must understand all plural marker formats you use
- Log which stage pluralized each string during debugging
- The same bug hits capitalization and escaping stages, audit those too
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_4tFOh9yxg0kgQM6U1Uz47Q