mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-07-14 18:15:56 -04:00
refactor(i18n): replace compiled .ts catalogs with direct .po imports
- Remove `lingui compile` / `i18n:compile` script — Vite and Metro LingUI plugins now compile `.po` files on the fly at dev/build time; no manual compile step needed
- Import `.po` files directly in `@sofa/i18n` (`./po/en.po` etc.) and add `po.d.ts` ambient module declaration so TypeScript accepts them
- Add `fallbackLocales: { default: "en" }` and `lineNumbers: false` to `lingui.config.ts`; prefix catalog paths with `<rootDir>` for correctness
- Derive `SupportedLocale` and `SUPPORTED_LOCALES` from `LOCALE_INFO` in `locales.ts` to eliminate the circular import between `index.ts` and `locales.ts`
- Update Crowdin config to use `project_id_env` instead of a hardcoded ID, drop `languages_mapping` (no longer needed), and add `preserve_hierarchy: true`
- Add a daily cron trigger (`0 6 * * *`) to the Crowdin GitHub Actions workflow and drop the now-redundant compile step from it
- Update docs and `AGENTS.md` to reflect that no compile step is required after `i18n:extract`
This commit is contained in:
@@ -24,7 +24,7 @@ The translation pipeline:
|
||||
1. React (web) and React Native (mobile) apps wrap UI strings in `<Trans>` components or `` msg`...` `` macros
|
||||
2. `bun run i18n:extract` scans the codebase and updates `en.po` with new strings
|
||||
3. Translations are added to each locale's `.po` file (e.g. `fr.po`, `de.po`)
|
||||
4. `bun run i18n:compile` compiles `.po` files into TypeScript for use at runtime
|
||||
4. The Vite and Metro plugins compile `.po` files on the fly at dev/build time
|
||||
5. Non-English locales are lazy-loaded on demand
|
||||
|
||||
## Contributing via Crowdin
|
||||
@@ -51,7 +51,7 @@ bun packages/i18n/scripts/claude.ts all --dry-run
|
||||
bun packages/i18n/scripts/claude.ts all --model opus
|
||||
```
|
||||
|
||||
The script only translates strings with empty `msgstr` — existing translations are never overwritten. It reads the locale list from [`lingui.config.ts`](https://github.com/jakejarvis/sofa/blob/main/lingui.config.ts) automatically and compiles catalogs after translating.
|
||||
The script only translates strings with empty `msgstr` — existing translations are never overwritten. It reads the locale list from [`lingui.config.ts`](https://github.com/jakejarvis/sofa/blob/main/lingui.config.ts) automatically.
|
||||
|
||||
<Callout type="info">
|
||||
Using this script really only makes sense if you have a [Claude Max
|
||||
@@ -64,7 +64,6 @@ The script only translates strings with empty `msgstr` — existing translations
|
||||
2. Run `bun run i18n:extract` — this creates a new `.po` file for the locale
|
||||
3. Translate the strings (via Crowdin, manually, or with `bun packages/i18n/scripts/claude.ts <locale>`)
|
||||
4. Add the locale to the `LOCALE_INFO` array in [`packages/i18n/src/locales.ts`](https://github.com/jakejarvis/sofa/blob/main/packages/i18n/src/locales.ts) with its native name
|
||||
5. Run `bun run i18n:compile`
|
||||
|
||||
## Translation guidelines
|
||||
|
||||
|
||||
Reference in New Issue
Block a user