Files
fusion/i18next.config.ts
gsxdsm 9072d71306 feat(i18n): add @fusion/i18n package, catalogs, and i18next-cli tooling (U2)
Create the @fusion/i18n package as the authored source-of-truth: shared
i18next config (namespace split, script-aware zh-CN/zh-TW fallback, plural
setup), en base catalogs, and a generated CLI static-import map so the
terminal surface is drop-in for new locales. Add the i18next-cli workflow
(extract/sync/types/status/lint) wired as root i18n:* scripts, install the
i18next stack into dashboard + CLI, strip @fusion/i18n from the published CLI
manifest, gitignore the generated dashboard catalog tree, and add a changeset.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-03 08:00:31 -07:00

47 lines
1.5 KiB
TypeScript

import {
defineConfig,
recommendedAcceptedAttributes,
recommendedAcceptedTags,
} from "i18next-cli";
/**
* i18next-cli workflow config for the whole monorepo.
*
* - `extract` pulls t()/<Trans> keys from the dashboard and CLI source into the
* authored `en` catalogs under @fusion/i18n.
* - `sync` propagates the `en` key structure to the four other locales.
* - `types` regenerates key types from the `en` catalogs.
* - `status` reports per-locale completion (CI gate).
* - `lint` flags hardcoded user-facing strings (primary guardrail).
*
* Namespaces are routed by the `ns:` prefix in keys / `useTranslation(ns)` in
* source, not by file path. `common` is the default namespace.
*/
export default defineConfig({
locales: ["en", "zh-CN", "zh-TW", "fr", "es"],
extract: {
input: [
"packages/dashboard/app/**/*.{ts,tsx}",
"packages/cli/src/**/*.{ts,tsx}",
"!**/__tests__/**",
"!**/*.test.*",
],
output: "packages/i18n/locales/{{language}}/{{namespace}}.json",
primaryLanguage: "en",
defaultNS: "common",
keySeparator: ".",
nsSeparator: ":",
// Untranslated secondary-locale keys stay empty so `status` can measure
// real completion; the active locale falls back to `en` at runtime.
defaultValue: "",
},
types: {
input: ["packages/i18n/locales/en/*.json"],
output: "packages/i18n/src/i18next-resources.d.ts",
},
lint: {
acceptedTags: recommendedAcceptedTags,
acceptedAttributes: recommendedAcceptedAttributes,
},
});