From 964a28573cc0f235ef21fc22c261b16819b55c74 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 23 Nov 2026 18:27:56 +0000 Subject: [PATCH] :books: Split translation guidance by locale Keep catalog and validation rules in the main memory. Move Catalan and Russian conventions into locale notes and drop historical coverage counts. AI-assisted-by: gpt-6.2-sol --- .serena/memories/frontend/translations.md | 83 +++----------------- .serena/memories/frontend/translations/ca.md | 5 ++ .serena/memories/frontend/translations/ru.md | 6 ++ 3 files changed, 22 insertions(+), 72 deletions(-) create mode 100644 .serena/memories/frontend/translations/ca.md create mode 100644 .serena/memories/frontend/translations/ru.md diff --git a/.serena/memories/frontend/translations.md b/.serena/memories/frontend/translations.md index ab6c4b1bde..40f0508fa2 100644 --- a/.serena/memories/frontend/translations.md +++ b/.serena/memories/frontend/translations.md @@ -1,77 +1,16 @@ -# Frontend Translations +# Frontend translations -PO-based UI i18n. Files: `frontend/translations/*.po`. `en.po` is the -source of truth (`msgid` = key, `msgstr` = English); `es.po` is a -high-coverage support reference, never the base. +- `frontend/translations/en.po` defines the keys and English text; `es.po` is a support reference, not the base. Add new keys to both in the same change. Locale conventions: `mem:frontend/translations/ca` and `mem:frontend/translations/ru`. -## Workflow +## Keys and catalog sync -- Canonicalize with `node ./scripts/translations.js sync -l ` from `frontend/`: sorts entries, syncs `#:` comments from `en`, deletes keys missing in `en`. -- `sync` never ADDS a key missing in the locale: it only syncs comments (for keys that already exist) and drops keys absent from `en`. A key added to `en` alone stays missing in `es` and its text silently falls back to English. Every new key is born in `en` AND `es` in the same change; compare the `msgid` sets to check (`comm -23 <(grep '^msgid ' en.po | sort -u) <(grep '^msgid ' es.po | sort -u)` must be empty). -- `sync` copies ALL comment flags from `en`, including `#, fuzzy`. Translated entries must NOT stay fuzzy: strip the flag after translating (mirror `es.po`, which keeps fuzzy only on genuinely untranslated entries). Fuzzy entries are excluded from `msgfmt --statistics` translated counts. -- Canonical files carry NO `#~` obsolete blocks (`en`/`es` have zero). Drop them; `sync` does not resurrect them. -- Definition of done: `msgfmt --check .po` exit 0, `msgfmt --statistics` shows 0 fuzzy, 0 untranslated, and the locale's `msgid` set is identical to `en.po`'s (no key missing, none extra). -- `rehash` scans `frontend/src` AND `common/src` for `(tr "key"` occurrences (any line counts, including `;;` comments) and refreshes `#:` refs in `en`, marking unreferenced keys `#, unused`. The refs in `en` are broadly stale, so a repo-wide `rehash` rewrites hundreds of lines (measured: ~487 on `en` alone): it is a maintenance action on its own, never a step to run inside a change that only adds or edits a key. -- Dynamic keys are invisible to `rehash`: eliminate them instead of - declaring them. Preference order: literal `(tr "key")` args only; - never put a branch inside `tr`, hoist it out (`(if cond (tr "a") (tr "b"))`); - resolve code→message maps with `case` returning literal calls; - key-forwarding components take pre-translated strings (callers translate - with literals). Only when no simple fix exists (open key sets sent by the - backend, large data-driven matrices like `shortcuts.*`) declare each key - with a `;; (tr "the.key")` comment next to the call site (grouped under - `;; Execution time translation strings:`), otherwise the next `rehash` - flags them `unused`. The declaration convention is legacy fallback, not - the default: never introduce new declarations where a hoist or - pre-translation works, and remove existing ones when fixing the call - site. Same for `:error/code "key"` data: prefer `:error/fn #(tr "key")`. Any non-literal first arg to `tr` is reported by the `:penpot/tr-dynamic` clj-kondo warning (hook in `.clj-kondo/hooks/i18n.clj`, registered for `app.util.i18n/tr` and `app.common.i18n/tr`) and forbidden by the `tr` docstring: only `(tr "literal" ...)` is statically resolvable. Translation keys must not contain spaces (use `-` or `.`). -- Shortcut command/section/subsection labels (`shortcuts.*`, including `shortcuts.section.*` and `shortcuts.subsection.*`) resolve through `:label` fns holding static `(tr "literal")` calls, executed at render time: commands carry `:label` on their definitions in the `app.main.data.*.shortcuts` namespaces, sections/subsections in static registries in `app.main.ui.shortcuts` next to `translation-keyname` (id lookup with raw-key fallback for stale custom ids). When adding, renaming, or removing commands/sections/subsections, add/update/remove the `:label`/registry entry; `rehash` sees the literals with no comment needed, and the exhaustiveness test fails otherwise. Exempt, untranslated by design: debug `:preview-frame` and colorpicker `:delete-stop` (no PO keys). +- Use feature-specific keys for feature vocabulary and `labels.*` for short labels shared across screens. Keep keys literal at `(tr "key")` call sites so `rehash` and the linter can see them. Branch outside `tr`, use a `case` with literal calls, or pass already translated text. Shortcut labels use literal calls in render-time `:label` functions; see `app.main.ui.shortcuts` and the command definitions. +- Only open sets that cannot be resolved statically should use the legacy `;; (tr "key")` declarations beside the call. Server-provided keys carry `#, backend`; don't remove or rename them or change their placeholder contract. Follow the existing marker and lint exception at that boundary. +- From `frontend/`, `node ./scripts/translations.js sync -l ` copies base comments and flags and drops keys absent from `en`; it does **not** add missing keys. It can restore `fuzzy` from `en`, so strip that flag from completed entries after the last sync. Drop `#~` obsolete entries rather than reviving them. Do not run a repo-wide `rehash` for a local string edit; it can rewrite unrelated references and `unused` flags. +- Keep placeholders, link targets, markup, escapes and key names intact. Validate each plural form against the call site and the locale header. A plural key with one regular `msgstr` loses runtime count selection; a single-form locale instead keeps `msgid_plural` and one count-bearing `msgstr[0]`. If English text is empty, resolve it from Spanish and source context rather than leaving the translation empty. -## Entry rules +## Verification by scope -- Placement: a key names the feature that renders it (`dashboard.import.*`, - `files-export-modal.*`, `jobs.*`); `labels.*` is the bucket for the short - generic words reused across screens (Accept, Cancel, Download…), never the - home of a feature's own vocabulary. Keep a feature's strings together: the - durable jobs write their progress stages as `jobs.progress.stage.*` and - their row statuses as `jobs.*`, not half in `labels.*`. -- Keys resolved dynamically from server-provided data carry a `#, backend` - flag (set it in `en`, `sync` copies it to the locales): do not remove or - rename these entries, and keep their `%s` placeholders (the backend only - sends the key). The code side keeps a `;; (tr "key")` marker for `rehash` - plus a `#_{:clj-kondo/ignore [:penpot/tr-dynamic]}` on the call site. -- New entries take `#:` refs from `en`; copy `#, unused`, never `#, fuzzy`. -- `en` keys with empty `msgstr` (or `#, fuzzy` + empty): translate from `es`/source context, never leave empty. -- Entries whose `en` uses `msgid_plural` need `msgstr[0]`/`msgstr[1]` (header: `nplurals=2; plural=n != 1`). Keep the `msgid_plural` line: a singular `msgstr` on a plural key silently breaks count selection at runtime (the app build reads 1-elem `msgstr` as singular). Exception: single-form locales (`nplurals=1`, e.g. `jpn_JP`, `ko`) keep ONE `msgstr[0]` that includes the count `%s` (build emits a plain string, runtime formats it with the count for every n); `check` compares it against the `en` plural form. -- `sync` re-adds `#, fuzzy` on EVERY run for entries fuzzy in `en`; re-strip after the last sync, never before it. -- Preserve verbatim: `%s`/`%d`, `{var}`/`{{...}}`, markdown `[text](%s)`, HTML tags, `\n` positions, brand names (Penpot), key names (Ctrl/Shift/Alt), technical terms (SVG, CSS, HSV, RGB). - -## Catalan (ca) conventions -- Normative IEC/Termcat Catalan. Address the user in VOSALTRES (2nd person plural): "Deseu", "Creeu", "Ja teniu un compte?". Buttons/menus use short imperatives ("Crea", "Mou", "Restaura"). -- Established glossary (reuse exactly, do not re-coin): layer=capa, board=tauler, stroke=traç, fill=Emplenat, blur=Difuminat, shadow=Ombra, clipboard=porta-retalls, delete=Elimina, rename=Canvia el nom, shortcut=drecera, grid=graella (keep "grid" where the file already does, e.g. grid-layout editing), plugins/extensions UI=extensions, layout=Disposició, gradient=Degradat, wireframing kept as loanword. -- Ela geminada uses the middle dot: Cancel·la, paral·lel, al·lega. -- ALL-CAPS source stays ALL-CAPS in Catalan; keep `$175`-style amounts in IEC format (`175 $/mes`) only where `es` already adapts. -- Shortcut/action names (`shortcuts.*`) are noun/infinitive labels, not sentences. Error strings are direct, no hedging. -- Same English source in different contexts may legitimately differ (verb "Copia" vs noun "Còpia"; "Desactivat" vs "Deshabilitada" agreeing with "drecera"). Normalize only true duplicates. - -## Russian (ru) conventions - -- Formal address with capital ВЫ ("Вы уверены…", "Вы собираетесь…"). Buttons/menus use infinitives ("Создать", "Удалить", "Дублировать"), never imperatives. -- Established glossary (reuse exactly, do not re-coin): layer=слой, board=доска (EN `board` is NEVER кадр — normalized in lote1: toolbar/viewer/shape-menu/header-menu/export-frames/undo/num-of-frames), path/draw tool=контур, stroke=обводка, fill=заливка, blur=размытие, shadow=тень, grid=сетка, clipboard=буфер обмена, shortcuts=сочетания клавиш (normalized in lote1: title/show-shortcuts/not-found), plugin=плагин, layout=макет (`labels.layout` fixed in lote1), gradient=градиент, token=токен, set=набор, theme=тема, file=файл, project=проект, team=команда, library=библиотека, component=компонент. -- No external RU style guide applies verbatim (Mozilla ru guide is marketing-only, GNOME glossary unmaintained, Adobe uses монтажная область for artboard but `ru.po` majority already says доска — keep доска for consistency). -- `words.ru.txt` `[function]` DELIBERATELY omits 1-letter words (в/с/к/о/у/а/и) and ending-colliding particles (на/по/не/ли/же/бы/его/их/те/или…): Russian inflects (проект→проекта, запросили=запрос+или), so listing them flags every inflected noun/verb. Never "complete" that list; put tripped valid words in `[ok]`. -- Never abbreviate т. д. / т. е. in `ru.po`: the lone т/д tokens poison the glue detector's frequency map and flag short words (тон→т+он). Write и так далее out. -- Tokens-domain glossary (lote2, reuse): alias=алиас, remap=переназначить, viewport=вьюпорт, set=набор, theme=тема, spread (shadow)=распространение, margins=внешние отступы, paddings=внутренние отступы, gaps=промежутки, type identifiers stay in English (Line Height, Font Size, innerShadow/dropShadow, none/Uppercase/Lowercase/Capitalize, thin/light/regular/bold/Italic). -- Editor-domain glossary (lote3, reuse): variant=вариант, property=свойство, guide=направляющая, board guide=направляющая доски, MCP server=MCP-сервер, size preset=пресет размера, border-radius section=скругление, path handler=маркер, canvas=холст, render=рендер/рендеринг, plugin (never extensión)=плагин. -- Avoid standalone те (those) in phrasing ("те же" → "такие же"): one lone те validates те+мы splits and flags every темы. Same poisoning class as т. д. -- `words.ru.txt` `[function]` also omits пока (dropped in lote4): with standalone за anywhere in the file, пока+за flags показа. Rare-typo detection loss accepted. -- Billing-domain glossary (lote4, reuse): plan names follow shipped `ru.po`, NOT es: Enterprise=Корпоративный, Professional=Профессиональный, Unlimited=Безлимитный, trial=пробный; subscription=подписка, storage=хранилище, seat editors=редакторы, viewer role=наблюдатель, amounts as `175 $/мес.` / `10 ГБ`; access token=токен доступа, MCP key=MCP-ключ (regenerate=перевыпустить), markdown `[text|target:self](%s)` kept verbatim. -- Closing-domain glossary (lote5, reuse): shortcut noun everywhere=сочетание (shortcuts section titles are noun/infinitive labels, never ярлыки); node=узел, segment=сегмент, measurements=размеры; WebGL unavailable flow uses гайд/руководство по неполадкам + рендеринг WebGL выключен/включён; `ru.po` reached 2275/2275 keys (100%) with 0 fuzzy, 0 untranslated per `msgfmt --statistics`. - -## QA before commit - -- Run `node ./scripts/translations.js check -l ` from `frontend/` (no default locale: pass `-l` explicitly): 0 errors required; review warnings by hand. Word lists live in `frontend/scripts/check-translations/words..txt` (`[elision]` `[function]` `[common]` `[ok]` `[brands]`); new valid words that trip the gate go to `[ok]`; `check --self-test` covers the detector rules. Without a catalog only the universal checks run. `#, fuzzy` entries are skipped (known-pending, owned elsewhere). -- Placeholder parity per entry (singular AND each plural form, also enforced by the script); verify `%s` against the `tr` call site when `en`/`es`/code disagree (a `%s` the code never passes renders literally; a dropped one swallows the argument). On `#, unused` keys the script only warns: never "fix" them by deleting placeholders or links, a reactivation may need them. -- Glued words (AI batches drop spaces at wrap boundaries): the script flags function-word splits (`del'equip`, `lapolítica`, `sinecessiteu`), `,/.`/`:` without following space, lowercase+Uppercase joins (`delPenpot`, `oCapitalize`) and `%s` glued to a word. -- Balanced `[]`/`()` in markdown links; no double spaces; no glued words around `·`; trailing spaces match the source. -- `git diff --stat` must touch only `frontend/translations/.po`. +- For a string change, verify the changed keys and placeholders in the catalogs you touched. New product keys belong in both `en.po` and `es.po`; don't expand the diff to fix unrelated coverage gaps. +- For a whole-locale pass, compare its active keys with `en.po`, check plural forms and placeholders, and require no missing, fuzzy or untranslated entries for a claim of full coverage. Use `msgfmt --check --statistics -o /dev/null .po` and, from `frontend/`, `node ./scripts/translations.js check -l `. The latter skips fuzzy entries and only runs universal checks when no word catalog exists; review warnings rather than treating silence as full coverage. +- When a valid word trips the glue detector, check `frontend/scripts/check-translations/words..txt` and prefer a targeted `[ok]` entry over broadening `[function]`. `node ./scripts/translations.js check --self-test` exercises the detector. For placeholder drift, trust the `tr` call site; don't remove placeholders from unused entries just to silence warnings. diff --git a/.serena/memories/frontend/translations/ca.md b/.serena/memories/frontend/translations/ca.md new file mode 100644 index 0000000000..8d29a9e1a7 --- /dev/null +++ b/.serena/memories/frontend/translations/ca.md @@ -0,0 +1,5 @@ +# Catalan UI conventions + +- Follow IEC and Termcat. Address the user in second-person plural in prose (`Deseu`, `Creeu`); use short imperatives in controls (`Crea`, `Mou`, `Restaura`). Shortcut names are actions, not sentences. +- Match existing Penpot vocabulary when it conflicts with a generic glossary. Keep `tauler` for board, `traç` for stroke, `drecera` for shortcut and `porta-retalls` for clipboard. Use `graella` for grid except where the existing grid-layout UI deliberately keeps `grid`. Read the neighboring entries in `ca.po` before normalizing apparent duplicates. +- Use the middle dot in ela geminada (`Cancel·la`); preserve all-caps source text when intended. An English word reused as a noun and a verb can legitimately have distinct translations (`Còpia` vs `Copia`). diff --git a/.serena/memories/frontend/translations/ru.md b/.serena/memories/frontend/translations/ru.md new file mode 100644 index 0000000000..d2ac62d434 --- /dev/null +++ b/.serena/memories/frontend/translations/ru.md @@ -0,0 +1,6 @@ +# Russian UI conventions + +- Use formal `Вы` in prose and infinitives in buttons and menus (`Создать`, `Удалить`), not imperatives. Use `доска` for board, not `кадр`; use `сочетание клавиш` for shortcut, not `ярлык`. Match shipped `ru.po` in the relevant domain, especially plan names and token terminology; don't normalize from Spanish. Keep token type identifiers in English when they represent literal values. +- `words.ru.txt` deliberately excludes one-letter words and particles that can look like inflected endings from `[function]`. Do not complete that list; put specific false positives in `[ok]`. `пока` is also excluded: together with `за` it misclassifies `показа`. +- Spell out `и так далее` and `то есть` rather than `т. д.` and `т. е.`; lone letters skew the glue detector. Avoid standalone `те` where an equivalent phrase works (`такие же` instead of `те же`); a lone `те` can make `темы` look like `те` + `мы`. +- Preserve Penpot-specific markup such as `[text|target:self](%s)`. Follow `ru.po` for billing notation and spacing (`175 $/мес.`, `10 ГБ`).