Repository navigation
Check plural branches, copies of English, the product name and banned words in the catalog check - #1015
Conversation
… words in the catalog check The catalog check now fails a translation whose plural lacks a branch its language needs (=1 standing in for one only where one holds nothing but 1), a translation identical to its English unless it has no letters of its own or its language lists it with why, a translation that drops "OpenSignup", and a word its glossary rules out. Each language's lists live in src/i18n/testing/language-rules.ts; today's Swedish passes as it is. Fixes #989. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016YZ9SUFKzikTU6ce5izv9U
Tophat: passedI tested 43c7112 locally, without starting the app: the PR changes only the catalog check (
Each break was undone before the next one, and There are no screenshots, since there is nothing on screen to show. This session: https://claude.ai/code/session_016YZ9SVUigEQJhq44SKdij5 Generated by Claude Code |
richshaw
left a comment
There was a problem hiding this comment.
Review: passed (round 1)
The catalog check now catches the four things the issue lists: a plural missing a category its language needs (with =1 standing in for one only where one holds no number but 1), a copy of the English (with a short sameAsEnglish list per language, which also fails a stale entry), a dropped "OpenSignup", and per-language banned patterns matched against the message's own text only. The rules run after the shape check succeeds, so compile in brokenRules never sees a message that failed to compile. Each rule has a fixture test that fails it once with the expected line, the real Swedish patterns have their own tests, and docs/translating.md and the translate skill are updated. Every item in the issue's "Done when" is done.
Blocking (0): none.
Optional (2):
src/i18n/testing/catalog-check.ts:373:pattern.exec(run)is stateful for a pattern with thegoryflag, so it would carrylastIndexfrom one run (or one message) into the next and miss matches. Today's patterns have neither flag. A line onBannedWord.patternsaying so, or usingrun.match(pattern), would stop a future language tripping on it.src/i18n/testing/catalog-check.ts:115: asameAsEnglishentry for a message a language doesn't have yet fails even where that language hasn't shipped, while the missing message itself only warns there. That seems right, since the list should only name messages that exist, but the failure text ("has no copy of its English") could say "doesn't have this message" for that case.
Earlier threads: none. Copilot couldn't review (quota used up).
Checks: CI green on 43c7112 (lint-type-test, e2e, CodeQL). The tophat passed on this SHA, broke the Swedish catalog once per rule and saw each line fire, and ran src/i18n and src/email tests on a local merge with current main. No runtime code: src/i18n/testing is imported only by tests. Nothing anyone using or hosting OpenSignup sees changes, so no UX gate and no CHANGELOG entry.
https://claude.ai/code/session_016YZ9ST3Q7iVX5PHd9zzLrd
Generated by Claude Code
Merge: not yet, back to fixOne gate failed on
Every other gate passed. CI was green on Once the conflict is resolved in the docs, this can come straight back to merge. https://claude.ai/code/session_016YZ9SSJKX7DDv7deP45mPR Generated by Claude Code |
…log-rules # Conflicts: # docs/translating.md
Conflict resolved in
|
Fixes #989.
The problem
Before this change, the catalog check (
src/i18n/testing/catalog-check.ts) let through four things that code can catch.docs/translating.mdlisted them under "What the checks miss", so only the reviewer could spot them:one/otherbreaks Polish, Russian and Arabic.The fix
Plural forms. Every
pluralin a translation must have a branch for each category thatIntl.PluralRules(language)lists. Plurals nested inside branches and tags count too.=1can stand in foroneonly when the language'soneholds no number but 1, checked withselecton 0, 21 and 101.Copies of English. A translation identical to its English fails, with two exceptions:
sameAsEnglish, with a reason.A key on that list whose translation isn't a copy also fails, so the list stays short.
The product name. If the English contains "OpenSignup", the translation must contain it too.
Banned words. Each language has a list of patterns. Each pattern records the glossary line it enforces, the namespaces it applies to (all when left out) and the reason. Patterns are matched against the message's own text, never a placeholder's or a tag's name.
Where the lists live. Each language's lists are in the new
src/i18n/testing/language-rules.ts(LANGUAGE_RULES), whichcheckCatalogsnow takes asrules. Swedish lists five messages that rightly match the English, each with a reason: the footer licence line, "Cookies", the two "Status" labels, and the "OpenSignup" home link. It bans three patterns:nias a whole word,din plats, and.... The other four identical messages have no letters of their own, such as{day} · {times}.Same output format. Each failure is one line in the check's existing
<language> <key>: <what's wrong>form. The rules apply in every language with a catalog, shipped or not, as the shape checks already do.Docs. In
docs/translating.md:=1can stand in forone.The
translateskill says what to do with a "the same as English" line.Decisions the issue didn't make
din platsapplies toparticipantandemail, not onlyparticipant. The glossary's settled item 1 comes from an email ("Visa eller ändra din plats" under "Plats: Aulan"), and participant emails are participant text. Today neither namespace contains it.niis matched as a whole word in any letters (\p{L}), case-insensitive. JavaScript's\bknows only a–z, so\bni\bwould match inside words like "åni".=1is also checked against 0, not only 21 and 101. French'soneholds 0, so=1can't stand in for it there.Tests
catalog-check.test.tsgains a fixture test for each rule:few/many, and a Swedish one withoutone;=1accepted for Swedish but not for Russian or French;nianddin platscaught, while another namespace, a longer word ("nivån") and a placeholder named{ni}are left alone.language-rules.test.tschecks Swedish's real patterns. They catch "Ni kan" and "Visa eller ändra din plats", and leave "nivå", "inni", "dina platser" and "Sparar…" alone.sv.jsonpasses. Taking "Cookies" off Swedish's list makescatalogs.test.tsfail withsv common.footer.cookies: the same as English; …, so the real-catalog run can fail. I put the entry back afterwards.pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test(242 files, 3447 tests).Generated by Claude Code