@npm-questionpro/wick-ui-i18n
v2.28.0
Published
Auto-translation AST wrapper for Wick UI
Readme
wick-ui-i18n
Vite plugin — wraps JSX text in Wu* components with <WuTranslate>, rewrites translatable props to {wt("...")},
records wt() / useWt()() calls, and emits wick-ui-i18n.json.
Full docs and examples: Storybook → i18n/Overview
Quick start
// vite.config.ts
import wickI18n from '@npm-questionpro/wick-ui-i18n'
export default defineConfig({plugins: [react(), wickI18n()]})What it transforms
| Source | Output |
| ----------------------------------------- | --------------------------------------------- |
| <WuButton>Save</WuButton> | <WuTranslate __i18nKey="Save" /> |
| <WuInput Label="First name" /> | Label={wt("First name")} |
| <WuButton>{`${n} results`}</WuButton> | <><WuTranslate __i18nKey="results" />{n}</> |
| wt("Hello") | recorded in dictionary |
| wt(`Hello ${name}`) | `${wt("Hello")} ${name}` |
| useWt()("Hello") | recorded in dictionary |
| useWt()(`Hello ${name}`) | `${useWt()("Hello")} ${name}` |
Options
| Option | Default | Description |
| ------------------- | ----------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| components | [] | Extra components treated like Wu* |
| ignoreComponents | [] | Extra components never translated |
| translatableProps | ['Label','placeholder','title','aria-label','aria-placeholder'] | Props rewritten to wt() |
| dataLabelKeys | [] | Property names whose values are labels in mixed data files |
| dictionaryFiles | — | Globs (project files via Vite) or exact paths (anywhere, incl. node_modules via fs) |
| excludeFiles | — | Files skipped entirely |
| debug | false | Print extraction table at build |
Breaking changes
See BREAKING_CHANGES.md.
