Skip to content

Check plural branches, copies of English, the product name and banned words in the catalog check - #1015

Merged
richshaw merged 3 commits into
mainfrom
claude/issue-989-catalog-rules
Nov 16, 2026
Merged

richshaw merged 3 commits into
mainfrom
claude/issue-989-catalog-rules

Conversation

@richshaw

Copy link
Copy Markdown
Owner

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.md listed them under "What the checks miss", so only the reviewer could spot them:

  • a plural without a branch its language needs. A copy of English's one/other breaks Polish, Russian and Arabic.
  • a message left in English
  • a translation that drops "OpenSignup"
  • a word the glossary rules out, such as ni, din plats or "..."

The fix

  • Plural forms. Every plural in a translation must have a branch for each category that Intl.PluralRules(language) lists. Plurals nested inside branches and tags count too. =1 can stand in for one only when the language's one holds no number but 1, checked with select on 0, 21 and 101.

  • Copies of English. A translation identical to its English fails, with two exceptions:

    • it has no letters outside its placeholders and tags (only the compiled message's own text counts);
    • its language lists it in 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), which checkCatalogs now takes as rules. 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: ni as 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:

    • "What the catalog check catches" gains the four rules.
    • "What the checks miss" drops the two items now caught and adds what's still missed: English left in part of a message, and glossary words with no pattern.
    • The Plurals section explains when =1 can stand in for one.
    • The Swedish Style section points to the banned list.
    • "Adding a language" says to give the new language an entry.

    The translate skill says what to do with a "the same as English" line.

Decisions the issue didn't make

  • din plats applies to participant and email, not only participant. 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.
  • ni is matched as a whole word in any letters (\p{L}), case-insensitive. JavaScript's \b knows only a–z, so \bni\b would match inside words like "åni".
  • =1 is also checked against 0, not only 21 and 101. French's one holds 0, so =1 can't stand in for it there.
  • No CHANGELOG entry. Nothing changes for anyone using or hosting OpenSignup.

Tests

  • catalog-check.test.ts gains a fixture test for each rule:
    • a Polish plural without few/many, and a Swedish one without one;
    • =1 accepted for Swedish but not for Russian or French;
    • a copy of the English failing, passing once listed, and passing when it has no letters;
    • a list entry that isn't a copy;
    • a dropped "OpenSignup";
    • ni and din plats caught, while another namespace, a longer word ("nivån") and a placeholder named {ni} are left alone.
  • language-rules.test.ts checks Swedish's real patterns. They catch "Ni kan" and "Visa eller ändra din plats", and leave "nivå", "inni", "dina platser" and "Sparar…" alone.
  • Today's sv.json passes. Taking "Cookies" off Swedish's list makes catalogs.test.ts fail with sv common.footer.cookies: the same as English; …, so the real-catalog run can fail. I put the entry back afterwards.
  • Ran and passed: pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test (242 files, 3447 tests).

Generated by Claude Code

… 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
@richshaw richshaw added the pipeline:working A session is working on it right now label Nov 16, 2026 — with Claude
@richshaw
richshaw requested a balanced review from Copilot November 16, 2026 17:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@richshaw richshaw added pipeline:tophat pipeline:working A session is working on it right now and removed pipeline:working A session is working on it right now labels Nov 16, 2026 — with Claude

Copy link
Copy Markdown
Owner Author

Tophat: passed

I tested 43c7112 locally, without starting the app: the PR changes only the catalog check (src/i18n/testing/, which only tests import), its tests, docs/translating.md and the translate skill. No page, email or API response changes, so I ran the affected tests and broke the Swedish catalog on purpose to see each new rule fire.

Check Result What I saw
Nothing at runtime imports the check ✅ The only importers of src/i18n/testing are *.test.ts files and the module itself
vitest run src/i18n on the head ✅ 19 files, 483 passed (plus 1 expected fail)
The same on a local merge with current main (3f906a8, after #1010 changed the catalogs) ✅ Merged without conflict (docs/translating.md auto-merged). src/i18n + src/email: 26 files, 555 passed. typecheck, knip, eslint on src/i18n/testing and prettier on the changed files are clean
Plural missing a branch (dropped one from participant.signupView.closedBanner.keepsYours) ✅ fails {count, plural} has no one branch, which sv needs (it has one, other)
Copy of English (participant.signupPage.title set to its English) ✅ fails the same as English; translate it, or list it in sameAsEnglish in src/i18n/testing/language-rules.ts with why
Product name dropped (organizer.dashboard.noWorkspace.title, "OpenSignup" → "Appen") ✅ fails drops "OpenSignup", the product's name, which stays as it is
Banned ni ("Ni kan …" prefixed to a participant message) ✅ fails has "Ni", which the glossary rules out: du, never ni (Style: Tone)
Banned ... (appended to a participant message) ✅ fails has "...", which the glossary rules out: an ellipsis is one character, … (Style: Punctuation)

Each break was undone before the next one, and sv.json was left untouched.

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 richshaw added pipeline:review pipeline:working A session is working on it right now and removed pipeline:tophat pipeline:working A session is working on it right now labels Nov 16, 2026 — with Claude

@richshaw richshaw left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the g or y flag, so it would carry lastIndex from one run (or one message) into the next and miss matches. Today's patterns have neither flag. A line on BannedWord.pattern saying so, or using run.match(pattern), would stop a future language tripping on it.
  • src/i18n/testing/catalog-check.ts:115: a sameAsEnglish entry 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

@richshaw richshaw added pipeline:merge and removed pipeline:review pipeline:working A session is working on it right now labels Nov 16, 2026 — with Claude
@richshaw richshaw added the pipeline:working A session is working on it right now label Nov 16, 2026 — with Claude

Copy link
Copy Markdown
Owner Author

Merge: not yet, back to fix

One gate failed on ed9569c:

Every other gate passed. CI was green on ed9569c. The review (verdict=pass gate=auto) and the tophat (result=pass) cover this code, because the only commit since 43c7112 is a merge from main, with no runtime hunks. There are no open threads.

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

@richshaw richshaw added pipeline:fix pipeline:working A session is working on it right now and removed pipeline:merge pipeline:working A session is working on it right now labels Nov 16, 2026 — with Claude
…log-rules

# Conflicts:
#	docs/translating.md

Copy link
Copy Markdown
Owner Author

Conflict resolved in 4918f8f

  • Merged main (Run the translation tests for every language with a catalog #935 at ba54e25). The only conflict was "Adding a language" in docs/translating.md, which Run the translation tests for every language with a catalog #935 restructured. I kept main's version and put back this PR's one sentence in its "Write its glossary" step: give the language an entry in LANGUAGE_RULES.
  • No runtime code was involved. The PR has no commits of its own since 43c7112, which the review and tophat passed.
  • After the merge, these ran and passed: pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test (243 files, 3463 tests). src/i18n covers the new catalog rules against main's catalogs.

Once CI is green this goes straight back to merge.

https://claude.ai/code/session_016YZ9SSJKX7DDv7deP45mPR


Generated by Claude Code

@richshaw richshaw added pipeline:merge pipeline:working A session is working on it right now and removed pipeline:fix pipeline:working A session is working on it right now labels Nov 16, 2026 — with Claude
@richshaw
richshaw merged commit be771ff into main Nov 16, 2026
5 checks passed
@richshaw
richshaw deleted the claude/issue-989-catalog-rules branch November 16, 2026 19:54
@richshaw richshaw removed pipeline:merge pipeline:working A session is working on it right now labels Nov 16, 2026 — with Claude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The catalog check doesn't check plural forms, copies of the English, the product name or the glossary's banned words

3 participants