# Translating Step 1 to Zero Trust

Step 1 speaks English, Dutch, French, German, Spanish, Hindi and Arabic. The extension follows
the language chosen in its settings (or set by IT with the `language` policy); "Automatic", the
default, uses the browser's own language. When the browser's language is not one of these,
English is shown together with a menu to choose one. The consoles do the same with a menu in
their header (remembered per browser), and the company's emails use the language chosen in the
hosted console's Settings.

The translations were made by Claude in October 2026 and still need checking by native
speakers, Hindi and Arabic first. Security warnings and privacy promises matter most.

## How it works

- **The English text is the key.** Code writes `t('This site is blocked')`; the table for the
  chosen language maps that English text to its translation. A text without a translation shows
  in English, never as a blank.
- **Tables per area and language** in `src/i18n/<area>/<lang>.js`, so each part loads only what
  it can show:

  | Area | What | Loaded by |
  | --- | --- | --- |
  | `page` | setup wizard, popup, report, warning page, safe preview | the page, chosen language only (`src/pages/language.js`) |
  | `runtime` | dialogs and banners on websites, notifications, the problem report | the service worker, which hands the chosen language's texts to the content scripts (`src/content/text.js`) |
  | `console` | offline console and hosted company console | both consoles, all languages inside (`console/language.js`) |
  | `email` | alert and confirmation emails | the Supabase functions (`supabase/functions/_shared/email-language.js`) |

  Which files belong to an area is worked out by following imports from its entry files
  (`scripts/i18n.mjs`).

## Rules for code

1. **Whole sentences, plain literals.** `t('{n} computers need attention', { n })`, never
   `t(\`${n} computers…\`)` or pieces glued together: other languages order words differently.
   The first argument of `t()` must be a quoted string so the tools can find it.
2. **Placeholders** are `{name}` and get their value from the second argument. Translations must
   keep the same placeholders (a test checks).
3. **Singular and plural:** `tn(count, '{n} app', '{n} apps')`.
4. **Texts stored or passed around before they are shown** (labels in a table, findings saved by
   the server): mark them `tKey('…')` where they are written and call `t(value)` where they are
   shown. Translate when drawing, not when a module loads: the language is set just before.
5. **HTML:** `data-i18n` on an element whose whole content is one text (no child elements inside),
   `data-i18n-attr="placeholder aria-label title"` for attributes.
6. **Content scripts** (classic scripts) use `Step1Text.t()` / `Step1Text.tn()` and wait for
   `Step1Text.ready` before drawing.
7. **Stays English:** the product name, app and company names, codes such as IBAN and BSN, the
   report and export formats (JSON, CSV column names) and log entries' stored values, and emails
   to the advisor (`leads.js`).
8. **Right-to-left (Arabic):** pages get `dir="rtl"` automatically. Use logical CSS:
   `margin-inline-start` instead of `margin-left`, `padding-inline`, `text-align: start`,
   `border-inline-start`, `inset-inline-start`.

## Fonts

Latin text uses Roboto (Roboto Mono for addresses and codes); Arabic, Hindi and any other script
use Noto (Noto Sans Arabic, Noto Sans Devanagari, Noto Sans). The browser picks per character, so
Latin words inside Arabic or Hindi text are Roboto too. The fonts are stored with the product in
`vendor/fonts/` (SIL Open Font License 1.1) and never loaded from a font service: the pages
load `vendor/fonts/fonts.css`, the consoles carry the fonts inside their single file, and dialogs
on websites add them with `src/content/fonts.js`. Use `var(--font-sans)` / `var(--font-mono)` in
CSS. `npm run vendor:fonts` copies them again after upgrading the @fontsource-variable packages.

## Changing or adding text

1. Change the English text in the code.
2. `npm run i18n -- sync` adds the new text to every table (empty) and removes texts no longer
   used.
3. Fill in the empty translations (`npm run i18n -- missing nl` lists them per language). Many at
   once: write them to a JSON file outside the repository, shaped
   `{ "<area>": { "<lang>": { "<English>": "<translation>" } } }`, and run
   `npm run i18n -- fill <file>`. It fills only empty entries and says which it left alone and why;
   to change a translation that is already there, edit the table itself.
   The `step1-translator` agent (`.claude/agents/`) does all of this.
4. `npm test` fails while a translation is missing, a placeholder differs or a text is stale.
