首页演练场案例展示应用文档博客
    • English英语
      EN
    • русский俄语
      RU
    • 日本語日语
      JA
    • français法语
      FR
    • 한국어韩语
      KO
    • 中文中文
      ZH
    • español西班牙语
      ES
    • Deutsch德语
      DE
    • العربية阿拉伯语
      AR
    • italiano意大利语
      IT
    • British English英国英语
      EN-GB
    • português葡萄牙语
      PT
    • हिन्दी印地语
      HI
    • Türkçe土耳其语
      TR
    • polski波兰语
      PL
    • Indonesia印度尼西亚语
      ID
    • Tiếng Việt越南语
      VI
    • українська乌克兰语
      UK
    /
    按框架筛选文档
    Alt+←
    为什么Intlayer?
    开始
    概念
    • Intlayer如何工作
    • 配置
    • TestFillBuildWatchExtractLoginPushPullConfigurationListVersionEditorLiveDebugDoc ReviewDoc TranslateSDK
    • 可视化编辑器
    • CMS
    • CI/CD集成
    • 翻译复数枚举条件性别插入文件嵌套MarkdownHTML函数获取
    • 每个语言环境的文件
    • 编译器
    • 自动填充
    • 测试
    • 打包优化
    环境
    • Next.js 14和应用路由器
      Next.js 15
      Next.js 无 locale URL
      Next.js和页面路由器
      编译器
    • Tanstack Start Solid
    • Astro和React
      Astro和Svelte
      Astro和Vue
      Astro和Solid
      Astro和Preact
      Astro和Lit
      Astro和Vanilla JS
    • React Router v7
      React Router v7 (fs-routes)
      Compiler
    • Nuxt和Vue
    • Vite和Solid
    • SvelteKit
    • Vite和Preact
    • Vite和Vanilla JS
    • Vite和Lit
    • Angular 19 (Webpack)
      Analog
    • React CRA
    • React Native和Expo
    • Express.js
      NestJS
      Fastify
      Hono
      Adonis
    • Lynx和React
    Plugins
    • JSON
    • gettext (.po)
    VS Code扩展
    代理
    • MCP服务器
    • 代理技能
    发布
    • v8
    • v7
    • v6
    基准测试
    • Next.js
    • TanStack
    • Vue
    • Solid
    • Svelte
    博客
    问问题
    1. Documentation
    2. 概念
    3. CLI
    4. Fill
    Creation:2024-08-11Last update:2025-11-22
    将此文档参考到您的 AI 助手
    ChatGPT
    Claude
    DeepSeek
    Google AI mode
    Gemini
    Perplexity
    Mistral
    Grok

    使用您最喜欢的AI助手总结文档,并引用此页面和AI提供商

    此页面的内容已使用 AI 翻译。

    查看英文原文的最新版本
    编辑此文档

    如果您有改善此文档的想法,请随时通过在GitHub上提交拉取请求来贡献。

    文档的 GitHub 链接
    Copy

    复制文档 Markdown 到剪贴板

    填充 / 审核 / 翻译字典

    bash
    复制代码

    复制代码到剪贴板

    npx intlayer fill

    此命令会分析您的内容声明文件,查找潜在问题,例如缺失的翻译、结构不一致或类型不匹配。如果发现任何问题,intlayer fill 将建议或应用更新,以保持您的字典一致且完整。

    关键要点:

    • 将大型 JSON 文件拆分为块,以保持在 AI 模型的上下文窗口限制内。
    • 如果输出格式不正确,会重试翻译。
    • 结合应用程序和文件特定的上下文以提高翻译准确性。
    • 通过不覆盖现有翻译来保留它们。
    • 使用队列系统并行处理文件、块和语言环境以提高速度。

    别名:

    • npx intlayer dictionaries fill
    • npx intlayer dictionary fill
    • npx intlayer dic fill

    输出示例:

    bash
    复制代码

    复制代码到剪贴板

    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 默认启用)

    示例:

    bash
    复制代码

    复制代码到剪贴板

    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/ 目录下所有内容声明文件的内容从英语翻译为法语和西班牙语。

    Test
    Build
    Alt+→

    在此页面

      讨论是匿名的,并会定期审查以解决常见问题。欢迎分享功能想法、对文档的反馈或任何与 Intlayer 相关的内容, 我们会利用这些意见来制定路线图并改进产品。

      npx intlayer 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
      npx intlayer fill --file src/home/*.content.ts --source-locale en --output-locales fr es --model gpt-3.5-turbo