Lingui
When to Use
Adding/modifying translations.
Rules
- •React:
<Trans>Label</Trans>ort\Text`(viauseLingui()from@lingui/react/macro`) - •Non-React:
msg\Text`(via@lingui/macro`) - •Catalogues:
packages/i18n/locales/<locale>/messages.po - •Commands:
npm run lingui:extract→ edit.po→npm run lingui:compile - •Never use:
useTranslate, old i18n helpers
Workflow
- •Identify context: React component/hook →
<Trans>/t\...`, Domain →msg`...`` - •Detect old system:
useTranslate(), old helpers, anti-patterns - •Propose Lingui API: React JSX →
<Trans>, React logic →t\...`, Domain →msg`...`` - •Migration plan: replace old calls, structure messages, imports (see
references/patterns.md) - •Catalogue update: extract → edit
.po→ compile - •Verification: display in fr/en/de, no fallback, no old API residue, key consistency
Output
- •i18n Context
- •Old Implementation Analysis
- •Proposed Lingui Strategy
- •Migration / Addition Plan
- •Catalogue Update
- •Functional Verification
Guardrails
- •Never reintroduce old API
- •Never mix Lingui + old system
- •Always use correct imports:
@lingui/react/macro,@lingui/react,@lingui/macro - •Respect existing patterns in component