使用您最喜欢的AI助手总结文档,并引用此页面和AI提供商
此页面的内容已使用 AI 翻译。
查看英文原文的最新版本如果您有改善此文档的想法,请随时通过在GitHub上提交拉取请求来贡献。
文档的 GitHub 链接复制文档 Markdown 到剪贴板
填充 / 审核 / 翻译字典
复制代码到剪贴板
npx intlayer fill此命令会分析您的内容声明文件,查找潜在问题,例如缺失的翻译、结构不一致或类型不匹配。如果发现任何问题,intlayer fill 将建议或应用更新,以保持您的字典一致且完整。
关键要点:
- 将大型 JSON 文件拆分为块,以保持在 AI 模型的上下文窗口限制内。
- 如果输出格式不正确,会重试翻译。
- 结合应用程序和文件特定的上下文以提高翻译准确性。
- 通过不覆盖现有翻译来保留它们。
- 使用队列系统并行处理文件、块和语言环境以提高速度。
别名:
npx intlayer dictionaries fillnpx intlayer dictionary fillnpx intlayer dic fill
输出示例:
复制代码到剪贴板
npx intlayer fillPreparing Intlayer (v7.5.14)Done 76ms@intlayer/ai found - Run process locallyProvider: (default) - Model: (default) - API Key: ✓Affected dictionary keys for processing: app, comp-test, hello-world, lang-switcher - [comp-test] No locales to fill, Skipping comp-test.content.json - [app] Processing app.content.tsx - [app] Filling missing metadata for app.content.tsx - [hello-world] Processing test.content.ts - [hello-world] [French (fr)] Preparing test.content.ts - [hello-world] [Spanish (es)] Preparing test.content.ts - [lang-switcher] Processing langSwitcher.content.ts - [lang-switcher] Filling missing metadata for langSwitcher.content.ts - [hello-world] Translation completed successfully for test.content.ts - [lang-switcher] [Spanish (es)] Preparing langSwitcher.content.ts - [app] [French (fr)] Preparing app.content.tsx - [app] [Spanish (es)] Preparing app.content.tsx - [hello-world] Content declaration written to test.content.ts - [app] Translation completed successfully for app.content.tsx - [app] Content declaration written to app.content.tsx - [lang-switcher] Translation completed successfully for langSwitcher.content.ts - [lang-switcher] Content declaration written to langSwitcher.content.ts参数:
文件列表选项:
-f, --file [files...]:要审核的特定内容声明文件列表。如果未提供,将审核根据您的配置文件设置发现的所有*.content.{ts,js,mjs,cjs,tsx,jsx,json}文件。示例:
npx intlayer dictionary fill -f src/home/app.content.ts-k, --keys [keys...]:基于键过滤字典。如果未提供,将审核所有字典。示例:
npx intlayer dictionary fill -k key1 key2--key [keys...]:基于键过滤字典(--keys 的别名)。示例:
npx intlayer dictionary fill --key key1 key2--excluded-keys [excludedKeys...]:基于键过滤排除字典。如果未提供,将审核所有字典。示例:
npx intlayer dictionary fill --excluded-keys key1 key2--excluded-key [excludedKeys...]:基于键过滤排除字典(--excluded-keys 的别名)。示例:
npx intlayer dictionary fill --excluded-key key1 key2--path-filter [pathFilters...]:基于文件路径的 glob 模式过滤字典。示例:
npx intlayer dictionary fill --path-filter "src/home/**"
条目输出选项:
--source-locale [sourceLocale]:要翻译的源语言区域。如果未指定,将使用配置中的默认语言区域。--output-locales [outputLocales...]:目标翻译语言区域。如果未指定,将使用配置中的所有语言区域,除了源语言区域。--mode [mode]:翻译模式:complete(完整)、review(审核)。默认是complete。complete会填充所有缺失内容,review会填充缺失内容并审核已有的键。
Git 选项:
--git-diff:仅对包含从基准(默认origin/main)到当前分支(默认HEAD)的变更的字典执行操作。--git-diff-base:指定 git diff 的基准引用(默认origin/main)。--git-diff-current:指定 git diff 的当前引用(默认HEAD)。--uncommitted:包含未提交的更改。--unpushed:包含未推送的更改。--untracked:包含未跟踪的文件。示例:
npx intlayer doc translate --git-diff --git-diff-base origin/main --git-diff-current HEAD示例:
npx intlayer doc translate --uncommitted --unpushed --untracked
AI 选项:
--model [model]:用于翻译的 AI 模型(例如,gpt-3.5-turbo)。--provider [provider]:用于翻译的 AI 提供商。--temperature [temperature]:AI 模型的温度设置。--api-key [apiKey]:为 AI 服务提供您自己的 API 密钥。--custom-prompt [prompt]:为您的翻译指令提供自定义提示。--application-context [applicationContext]:为 AI 翻译提供额外的上下文。示例:
npx intlayer fill --model gpt-3.5-turbo --provider openai --temperature 0.5 --api-key sk-1234567890 --application-context "我的应用是一个猫咪商店"
环境变量选项:
--env:指定环境(例如,development,production)。--env-file [envFile]:提供自定义环境文件以加载变量。示例:
npx intlayer fill --env-file .env.production.local示例:
npx intlayer fill --env production
配置选项:
--base-dir:指定项目的基础目录。示例:
npx intlayer fill --base-dir ./src--no-cache:禁用缓存。示例:
npx intlayer build --no-cache
准备选项:
--build:在推送之前构建字典以确保内容是最新的。设置为 true 将强制构建,false 将跳过构建,undefined 将允许使用构建缓存。--skip-metadata:跳过为字典填写缺失的元数据(描述、标题、标签)。
日志选项:
--verbose:启用详细日志以便调试。(CLI 默认启用)
示例:
复制代码到剪贴板
npx intlayer fill --file src/home/*.content.ts --source-locale en --output-locales fr es --model gpt-3.5-turbo该命令将使用 GPT-3.5 Turbo 模型,将 src/home/ 目录下所有内容声明文件的内容从英语翻译为法语和西班牙语。