Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

3.2 KB
Raw Blame

description: "User-visible text in new UI, and every menu and navigation label, renders through t() so it is translated into every interface language." paths: - "apps/web/src//*.tsx" - "apps/web/src//.ts" globs: "apps/web/src/**/.tsx,apps/web/src/**/*.ts" alwaysApply: false

Translate user-visible text

The app is shown in the person's interface language (their own, else their team's, else their browser's, else English). A hard-coded string stays English for everyone.

  • Render user-visible text with t('<namespace>.<key>') from @app/lib/i18n, and add the English text to apps/web/src/lib/i18n/locales/en/<namespace>.ts. This covers every menu, navigation, and command label, and all text in new UI: new components, pages, dialogs, settings, toasts, empty states, placeholders, and aria-labels. A literal label on a menu item fails CI (ast-grep tsx-menu-label-translated).
  • Inside an existing surface that isn't translated yet (most page content, the slides, canvas, spreadsheet, and database editors), match the surface: translate all of it or none, so a page never mixes languages.
  • Change only the English. The periodic translation update (the update-translations skill) translates new and changed messages, which show in English until then; bun run i18n:status lists them. Translating in the same change is fine: follow src/lib/i18n/glossary.md and run bun run i18n:status --accept <language> for each language you finish.
  • Use {{name}} placeholders for interpolated values (t('nav.goTo', { label })), never string concatenation, since word order differs by language. Pass numbers as numbers: t writes them for the interface locale (1.234 in German).
  • A message whose wording depends on a number is plural: write the English as { one: 'Moved {{count}} item', other: 'Moved {{count}} items' } and call t(key, { count }); the types require count. Make it plural even when the English doesn't change ({ other: '{{count}} selected' }), because other languages do. Don't split one sentence into singular and plural keys chosen by the count; one plural message covers every number.
  • Format dates and numbers on a translated surface with formatLocale() from @app/lib/i18n (Intl.DateTimeFormat(formatLocale(), …)), never a missing or hard-coded locale, so they match the interface language. Leave untranslated surfaces and anything sent elsewhere (emails, exports, agent prompts) on their current locale; switch a surface's dates when you translate it.
  • Call t where the label renders (JSX, a memo, a hotkey description: () => t(...), a getter get label() { return t(...) } in a module-level config) so it updates when the language changes. Never store a translated string in a module constant or in persisted state.
  • Keep ids, persistence keys, and anything compared in logic in English; only the displayed text is translated.
  • Size menus so long labels (German, Finnish) and CJK text fit: give menu content a minimum width and let it grow (min-w-* with a max-w-* cap) rather than a fixed w-*, and keep truncate on the label as the last resort.

Check: bun run test -- src/lib/i18n passes, and just test-i18n-browser passes when a menu's width or a translation changed.