Skip to content
Toolkit

ADR-0085 — A sentence with emphasis inside it is one key

Status: Accepted · Date: 2026-08-29 · Track: 005-i18n, phase 02

Context

Twenty-three counted strings were left behind by twelve extraction slices for one reason: they are halves of a sentence that runs through a tag.

You have <strong>${amount}</strong> available for withdrawal…
Start something <em>new.</em>
Set <code>APP_URL</code>, <code>APP_KEY</code>, and <code>QUEUE_DRIVER</code>…

t() cannot carry them. Each is one sentence to a reader and two JSX text nodes to the parser, and the two obvious moves are both wrong:

  • Split at the tag. t('referrals.withdraw.lead') + the amount + t('referrals.withdraw.tail') hands a translator two fragments and freezes English word order — the emphasised part cannot move, which in many languages is exactly what has to happen. This track has forbidden the interpolated fragment from its first slice; a fragment either side of a <strong> is the same defect with markup between the halves.
  • Drop the markup. The emphasis is not decoration here: it is what makes the amount findable in the sentence.

So the strings stayed hardcoded, and every slice that met one recorded it as "no mechanism". The mechanism is not a slice's call to make, which is why it is an ADR.

Decision

A sentence with markup inside it is one key, rendered by react-i18next's <Trans>.

<Trans
  i18nKey="referrals.withdraw.available"
  values={{ amount: `$${stats.available_for_withdraw.toFixed(2)}` }}
  components={{ strong: <strong /> }}
/>
"referrals.withdraw.available":
  "You have <strong>{{amount}}</strong> available for withdrawal. Commissions become available 30 days after being earned."

The rules that make it safe:

  1. i18nKey is a literal, always. Same reason t() keys are: a key nobody can check is a key that reaches the user verbatim.
  2. The catalogue holds the whole sentence, with named tags. Not <0> / <1> index tags — a translator moving a phrase should not have to count elements, and an index that shifts when the JSX changes is a silent re-emphasis. The tag name is the element it stands for: strong, em, code.
  3. components maps those names to empty elements, never to elements with text of their own. Text inside a components element is text outside the catalogue.
  4. A value that is formatting stays formatting. The amount above is toFixed(2) at the call site, interpolated as a value; money, dates and byte sizes remain the standing Intl item, which phase 04's language settles.
  5. <Trans> is for markup inside a sentence, not for reaching a component. A whole sentence with no tag stays t().

Trans is re-exported from apps/web/src/i18n.ts so a surface reaches for it through the same door as useTranslation.

Gate

Rule 3 of check-i18n-coverage.mjs is widened to read <Trans i18nKey="…"> under the same test as a t() argument. It had counted a <Trans> element as a translated call site since it was written but never looked at its key — the one sentence shape carrying markup was the one shape whose key nothing checked. Watched failing on all three broken shapes (missing key, computed key, no key) in .station/jobs/005-i18n/evidence/phase-02-trans-gate-2026-08-29.md.

What the gate cannot see is that the catalogue's tag names match the call site's components map: a mismatch drops the tag silently, leaving a sentence that reads correctly and has lost its emphasis. That is pinned in apps/web/src/i18n.trans.test.tsx, on the first sentence to use the mechanism.

Consequences

  • The twenty-three stranded strings are now extractable, one surface per PR as every other slice: ReferralsPage (this one), the dashboard's four SecHead splits and its paste headline, link statistics' five, the image optimizer's and OG images' <code> chip sentences, and the editor canvas's empty state.
  • PageHeader's title + accent word is the same sentence split across two props rather than two nodes. <Trans> answers it only once the component takes one node instead of two; until then it is the same open item.
  • The counter treats a <Trans> element as one call site and sees no JSX text inside a self-closing one, so a slice that converts a split sentence lowers the ratchet by the number of fragments it had — two, here (135 → 133).

Source: docs/decisions/0085-a-sentence-with-emphasis-inside-it-is-one-key.md

Library