.agents/skills/lingui-workflow/SKILL.md
Guide daily Lingui command workflow for Next.js and React projects. Use when teams need clear extract/translate/compile/manifest routines, troubleshooting steps, and command semantics for i18n catalogs.
npx skillsauth add adonis0123/adonis-skills lingui-workflowInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
当此 skill 被激活时,先输出以下命令速查表,再回应用户问题:
| 命令 | 作用摘要 | 可用参数 |
| ----------------- | ---------------------------------------------- | ------------------------------------------------- |
| i18n:extract | 提取源码文案到 po | — |
| i18n:translate | 统计缺失翻译 | --fill-source, --strict |
| i18n:check | 严格翻译检查,缺失即报错退出 | — |
| i18n:compile | 编译 po → mjs,自动执行 i18n:manifest | — |
| i18n:manifest | 基于已有 mjs 生成 catalog-manifest.ts | — |
| i18n:sync | 当前仅等价 i18n:extract | — |
| i18n:bootstrap | 一次执行 extract + compile(+manifest) | — |
| i18n | 组合入口;默认 extract + translate | --compile, --fill-source, --no-translate, --strict |
这个 skill 面向“已经完成 Lingui 接入后的日常使用”,帮助你稳定执行 i18n 命令链路并快速排障。
如果你需要的是“初始化/脚手架接入”,请使用 lingui-next-init,不要混用职责。
Before using this skill, confirm your project already has Lingui runtime setup:
scripts/i18n/* exists (at least index.ts, cli.ts, manifest.ts).["@lingui/swc-plugin", {}].src/locales/** catalogs and src/i18n/catalog-manifest.ts flow are already wired.推荐最短日常流程(新增/修改文案):
pnpm --filter @your/web run i18n:extract
pnpm --filter @your/web run i18n:translate
pnpm --filter @your/web run i18n:compile
高频补充命令:
pnpm --filter @your/web run i18n:bootstrappnpm --filter @your/web run i18n:manifestpnpm --filter @your/web run i18n -- --compilepnpm --filter @your/web run i18n:check| 命令 | 作用摘要 | 可用参数 |
| --- | --- | --- |
| i18n:extract | 提取源码文案到 po | — |
| i18n:translate | 统计缺失翻译 | --fill-source, --strict |
| i18n:check | 严格翻译检查,缺失即报错退出 | — |
| i18n:compile | 编译 po 到 mjs,并自动执行 i18n:manifest | — |
| i18n:manifest | 基于现有 mjs 生成 catalog-manifest.ts | — |
| i18n:sync | 当前仅等价 i18n:extract | — |
| i18n:bootstrap | 一次执行 extract + compile(+manifest) | — |
| i18n | 组合入口;默认 extract + translate,加 --compile 才会编译 | --compile, --fill-source, --no-translate, --strict |
详细输入/输出/副作用请看 references/i18n-commands.md。
When command semantics change, docs must be updated in the same change set.
Trigger files:
apps/web/scripts/i18n/index.tsapps/web/scripts/i18n/manifest.tsapps/web/scripts/i18n/cli.tspackages/i18n/src/lingui-config.tsRequired doc sync:
references/i18n-commands.mdreferences/workflow-daily.md (if execution sequence changed)references/maintenance-playbook.md (if maintenance workflow changed)i18n 默认会 compile。
实际:默认不会,必须显式传 --compile。
i18n:sync 是全量同步命令。
实际:当前实现仅执行 extract。
i18n:manifest 可替代 i18n:compile。
实际:manifest 依赖已有 .mjs,不会自行生成编译产物。
只在 [lang]/layout.tsx 做初始化就够了。
实际:在 Next App Router / RSC 下,服务端 page.tsx 也应在使用 t 或生成 metadata 前初始化 locale。
遇到以下错误时按顺序检查:
Lingui: Attempted to call a translation function without setting a locale
initLingui(locale) 是否执行了 i18n.activate(locale)。layout.tsx 与服务端 page.tsx 是否都调用了 initPageLingui(params)(或等价逻辑)。useLingui/Trans,避免依赖全局 @lingui/core/macro t 的初始化时序。i18n:compile 后的 manifest 是否包含对应 entry + locale loader。extract -> translate -> compile。translate 输出缺失项为预期状态(已补翻或接受占位)。build 脚本含 compile gate)。.gitignore 已忽略编译产物 web/src/locales/**/*.js|*.mjs(及兼容路径)。references/i18n-commands.mdreferences/workflow-daily.mdreferences/maintenance-playbook.mdapps/web/scripts/i18n/index.tsapps/web/scripts/i18n/manifest.tstools
Use when the user's pain is "adding/removing one more X means editing N files" and X is a recurring variant kind: popup, banner, modal, ad slot, payment method, AI model/tool, form field type, connector, sub-site, command, menu item, agent, extension point, or data source. Use when they want to design, refactor, review, name, or explain a pluggable mechanism using registry, interface/trait contract, runtime core, and convention folders; mention pluginize, pluggable, plugin architecture, extension point, registry pattern, or extensibility. Use when explaining the first-principles rationale, DDD/SOLID/OCP mapping, or industry analogies behind that structure. Use for cross-stack mapping to VSCode contributes, Webpack/Vite plugins, Rust/Tauri connectors, Python entry_points, or cargo features. Skip one variant's internals/styles/hooks/copy/bugs, and skip register/registry meaning DI container, user signup, or package registry.
development
Use BEFORE heavier workflow skills when route choice matters. Route creative work without a design doc/spec to Brainstorm; destructive or hard-to-reverse work to Discuss; unresolved decisions, Plan/Full fan-out, ship checks, unclear bugs, and fresh-eyes fix-then-re-review need this gate. Skip single-line read-only lookups, pure typo/formatting edits, trivial safe one-line fixes, and clearly safe named-skill requests. Outputs Route, Runtime skill, Fallback alias, and Execution path.
development
Cross-agent code review handoff and review-fix-re-review loop with persistent packet artifacts. Requires a git repo because packet addressing uses git rev-parse --show-toplevel. Use when the user asks for an independent, read-only second pair of eyes on a diff/branch/PR another agent or teammate implemented; asks to verify reviewer feedback before fixing; says a fix is done and wants scoped re-review; asks to continue the latest review packet; or asks for first-principles, DDD, high-cohesion/low-coupling review. Persists each loop under $repo_root/.review-handoff/active/ so agents can resume without copy-paste. Do NOT use for ordinary implementation, generic staged-change review, review-comment copy editing, non-git folders/zips/tarballs/temp dirs, or when the user names a different review skill.
testing
Enforces 'decide then plan' discipline - the pre-planning decision gate. Use when the user asks for a plan or starts a change while key decisions are unresolved: architecture tradeoffs, data flow, public interfaces, unclear requirements, multi-module scope, or roughly 5+ files affected. Also triggers when the user explicitly wants to discuss, compare options, or review architecture before committing. Core job: reduce incorrect-execution cost by confirming decisions before producing executable plans.