首页演练场案例展示应用文档博客
    • 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. v6
    Creation:2025-09-22Last update:2025-09-22
    将此文档参考到您的 AI 助手
    ChatGPT
    Claude
    DeepSeek
    Google AI mode
    Gemini
    Perplexity
    Mistral
    Grok

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

    此文档已过期,基础版本已在以下日期更新 2025年9月23日.

    前往英文文档

    版本历史

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

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

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

      文档的 GitHub 链接
      Copy

      复制文档 Markdown 到剪贴板

      新版 Intlayer v6 - 新特性介绍

      欢迎使用 Intlayer v6!本次发布重点提升了性能、开发者体验和可靠性。以下是主要亮点,包括迁移说明和可复制粘贴的示例。

      亮点

      • 新命令:npx intlayer content test 用于检测缺失的翻译
      • 新增全局 autoFill 选项,用于自动生成缺失的翻译
      • 填充命令默认跳过已有翻译:npx intlayer fill
      • VS Code 扩展:新增 Intlayer 活动栏(搜索和词典)、工具栏/上下文操作、自动显示、填充/测试命令
      • 通过 Promise 并行化实现构建速度提升 10 倍
      • 远程词典缓存,避免应用启动时重复获取
      • 改进日志记录:设置 log.mode: 'verbose' 以检查行为
      • 更严格的验证,防止词典问题导致应用崩溃
      • 使用 build.importMode = 'live' 和 pnpm intlayer live 实现与 CMS 的实时更新
      • 修复:Vue.js 集成、Lynx 适配器、Windows 上的可视化编辑器

      新功能:测试缺失的翻译

      快速审核项目,找出缺失的键/语言。

      bash
      复制代码

      复制代码到剪贴板

      npx intlayer content test

      输出:

      bash
      复制代码

      复制代码到剪贴板

      pnpm intlayer content test缺失的翻译: - blog-data       - 日语 (ja)、韩语 (ko)、中文 (zh)、德语 (de)、意大利语 (it) - src/components/BlogPage/blogData.content.ts - demo-page       - 法语 (fr)、意大利语 (it)                                         - src/components/DemoPage/demo.content.ts - locale-switcher - 意大利语 (it)、葡萄牙语 (pt)                                       - src/components/LocaleSwitcher/localeSwitcher.content.ts语言环境:英语 (en)、俄语 (ru)、日语 (ja)、法语 (fr)、韩语 (ko)、中文 (zh)、西班牙语 (es)、德语 (de)、阿拉伯语 (ar)、意大利语 (it)、英式英语 (en-GB)、葡萄牙语 (pt)、印地语 (hi)必需语言环境:英语 (en)缺少的语言环境:日语 (ja)、韩语 (ko)、中文 (zh)、德语 (de)、意大利语 (it)、法语 (fr)、葡萄牙语 (pt)缺少的必需语言环境:-缺少的语言环境总数:7缺少的必需语言环境总数:0

      查看更多 CLI 选项请参阅文档:CLI 参考 → “测试缺失的翻译”。以及 测试 指南。


      新功能:全局 autoFill 自动补全缺失翻译

      现在您可以全局启用 autoFill,任何缺失翻译的字典都会自动补全。

      intlayer.config.ts
      复制代码

      复制代码到剪贴板

      import { type IntlayerConfig, Locales } from "intlayer";const config: IntlayerConfig = {  internationalization: {    locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],    defaultLocale: Locales.ENGLISH,    requiredLocales: [Locales.ENGLISH, Locales.FRENCH],  },  content: {    // 为所有词典自动生成缺失的翻译    autoFill: "./{{fileName}}.content.ts",    //    // autoFill: "/messages/{{locale}}/{{key}}/{{fileName}}.content.json",    //    // autoFill: true, // 自动为所有词典生成缺失的翻译,类似使用 "./{{fileName}}.content.json"    //    // autoFill: {    //   en: "./{{fileName}}.en.content.json",    //   fr: "./{{fileName}}.fr.content.json",    //   es: "./{{fileName}}.es.content.json",    // },  },};export default config;

      您仍然可以使用内容文件中的 autoFill 字段对每个字典进行微调。完整参考请见 doc/autoFill 和 doc/dictionary/content_file。


      填充命令:更安全的默认设置

      填充命令现在默认只填充缺失的翻译,跳过已有内容。

      bash
      复制代码

      复制代码到剪贴板

      npx intlayer fill
      bash
      复制代码

      复制代码到剪贴板

      受影响的字典键处理:access-key-creation-form-schema, doc-search-metadata, doc-search-page  - [access-key-creation-form-schema]      字典没有文件路径。跳过。  - [access-key-creation-form-schema]      正在处理内容声明:src/components/Dashboard/ProjectForm/AccessKey/useAccessKeyCreationFormSchema.content.ts  - [access-key-creation-form-schema]      无需填充的语言 - 跳过字典  - [doc-search-metadata]                  字典没有文件路径。跳过。  - [doc-search-metadata]                  正在处理内容声明:src/app/[locale]/(docs)/doc/search/metadata.content.ts  - [doc-search-metadata]                  无需填充的语言环境 - 跳过字典  - [doc-search-page]                      字典没有文件路径。跳过。  - [doc-search-page]                      正在处理内容声明:src/app/[locale]/(docs)/doc/search/page.content.ts  - [doc-search-page]                     [俄语 (ru)]                   正在准备将字典从英语 (en) 翻译为俄语 (ru)[intlayer]  已对 src/app/[locale]/(docs)/doc/search/page.content.ts 应用 Prettier 格式化  - [doc-search-page]                      内容声明已写入 src/app/[locale]/(docs)/doc/search/page.content.ts

      CI 示例可在 CI/CD 中查看。


      更新的 VS Code 扩展

      该扩展现在在活动栏中包含了一个专用的 Intlayer 选项卡,并带来了多个工作流改进:

      • Intlayer 活动栏包含两个视图:
        • 搜索网页视图 (intlayer.searchBar),用于实时字典/内容搜索
        • 字典树 (intlayer.dictionaries),列出环境、字典和贡献文件
      • 字典视图上的工具栏:构建、拉取、推送、填充、刷新、测试、创建字典文件
      • 上下文菜单:字典上的拉取/推送;文件上的填充
      • 自动显示:在适用时,当前编辑器文件会在词典树中高亮显示
      • 命令面板新增命令:填充词典和测试词典

      详情请参见官方 VS Code 扩展文档。


      性能提升:快 10 倍

      • 本地和远程词典并行解析
      • 远程词典缓存,避免应用启动时重复获取
      bash
      复制代码

      复制代码到剪贴板

      npx intlayer build

      输出:

      bash
      复制代码

      复制代码到剪贴板

      [intlayer]  准备 Intlayer (v6.0.1)[intlayer]  词典:[intlayer]  ✓ 本地内容:163/163[intlayer]  ✓ 远程内容:100/100[intlayer]   - access-key-creation-form             [local: ✔ built] [distant: ✔ imported][intlayer]   - access-key-creation-form-schema      [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - access-key-form                      [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - ai-ab-testing-section                                 [远程: ✔ 导入完成][intlayer]   - application-not-running-view         [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - application-template-message         [本地: ✔ 构建完成] [远程: ✔ 获取完成][intlayer]   - aside-navigation                     [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - ask-reset-password                   [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - ask-reset-password-schema            [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - 自动完成部分               [本地: ✔ 构建完成] [远程: ✔ 获取完成][intlayer]   - 可用技术部分               [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - 博客数据                  [本地: ✔ 构建完成][intlayer]   - 博客元数据                [本地: ✔ 构建完成][intlayer]   - 博客导航列表              [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - 博客页面                  [远程: ✔ 获取完成][intlayer]   - 博客搜索元数据            [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - 博客搜索页面              [本地: ✔ 构建完成] [远程: ✔ 导入完成]...[intlayer]  内容已加载  (总计: 8401毫秒 - 本地: 4050毫秒 - 远程: 4222毫秒)

      日志改进

      日志系统已得到改进,能够提供有关构建和运行时转换过程中发生情况的更详细信息。

      启用详细日志以更好地了解构建和运行时转换过程中发生的情况。
      intlayer.config.ts
      复制代码

      复制代码到剪贴板

      export default {  log: {    mode: "verbose", // 选项: "default" | "verbose" | "disabled"  },};

      有关所有日志选项,请参见配置。


      更强的验证

      字典处理现在执行更强健的验证。当字典处理失败时,Intlayer 会避免破坏您的应用程序,并显示可操作的错误信息。


      使用 CMS 的实时更新(生产安全)

      在生产环境中提供实时内容更新(例如,编辑更新),无需重新构建您的应用程序。

      1. 启用实时导入模式:
      intlayer.config.ts
      复制代码

      复制代码到剪贴板

      import { type IntlayerConfig } from "intlayer";const config: IntlayerConfig = {  build: {    importMode: "live", // "static" | "dynamic" | "live"  },  editor: {    liveSync: true, // 启用服务器端实时同步  },};export default config;
      1. 运行您的应用程序并实时处理并行执行:
      bash
      复制代码

      复制代码到剪贴板

      npx intlayer live --with 'vite preview'

      注意:

      • 只有标记为使用实时模式的字典会被实时获取。其他字典则经过性能优化。
      • 如果无法访问实时 API,则回退到动态导入。

      请参阅CMS 和实时同步和配置以获取完整指南。


      迁移说明

      • 移除:dictionaryOutput(之前为 i18next 或 next-intl)。此功能将在未来版本中以可插拔适配器形式回归。请从配置中删除该字段。
      • 相关移除:i18nextResourcesDir(详见 doc/configuration 更新日志)。
      • 推荐使用新的全局选项 content.autoFill 来大规模生成缺失的翻译。
      • 使用 npx intlayer content test 来检测 PR 中缺失的翻译。
      • 若需详细诊断,请设置 log.mode = 'verbose'。

      修复

      • Vue.js 集成稳定性提升
      • Lynx 适配器改进
      • Windows 上的可视化编辑器

      有用的链接

      • CLI 参考
      • 自动填充
      • 配置
      • 内容文件参考
      • 官方 VS Code 扩展
      • CMS 与实时同步
      v7
      基准测试
      Alt+→

      在此页面

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

        npx intlayer content test
        pnpm intlayer content test缺失的翻译: - blog-data       - 日语 (ja)、韩语 (ko)、中文 (zh)、德语 (de)、意大利语 (it) - src/components/BlogPage/blogData.content.ts - demo-page       - 法语 (fr)、意大利语 (it)                                         - src/components/DemoPage/demo.content.ts - locale-switcher - 意大利语 (it)、葡萄牙语 (pt)                                       - src/components/LocaleSwitcher/localeSwitcher.content.ts语言环境:英语 (en)、俄语 (ru)、日语 (ja)、法语 (fr)、韩语 (ko)、中文 (zh)、西班牙语 (es)、德语 (de)、阿拉伯语 (ar)、意大利语 (it)、英式英语 (en-GB)、葡萄牙语 (pt)、印地语 (hi)必需语言环境:英语 (en)缺少的语言环境:日语 (ja)、韩语 (ko)、中文 (zh)、德语 (de)、意大利语 (it)、法语 (fr)、葡萄牙语 (pt)缺少的必需语言环境:-缺少的语言环境总数:7缺少的必需语言环境总数:0
        import { type IntlayerConfig, Locales } from "intlayer";const config: IntlayerConfig = {  internationalization: {    locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],    defaultLocale: Locales.ENGLISH,    requiredLocales: [Locales.ENGLISH, Locales.FRENCH],  },  content: {    // 为所有词典自动生成缺失的翻译    autoFill: "./{{fileName}}.content.ts",    //    // autoFill: "/messages/{{locale}}/{{key}}/{{fileName}}.content.json",    //    // autoFill: true, // 自动为所有词典生成缺失的翻译,类似使用 "./{{fileName}}.content.json"    //    // autoFill: {    //   en: "./{{fileName}}.en.content.json",    //   fr: "./{{fileName}}.fr.content.json",    //   es: "./{{fileName}}.es.content.json",    // },  },};export default config;
        npx intlayer fill
        受影响的字典键处理:access-key-creation-form-schema, doc-search-metadata, doc-search-page  - [access-key-creation-form-schema]      字典没有文件路径。跳过。  - [access-key-creation-form-schema]      正在处理内容声明:src/components/Dashboard/ProjectForm/AccessKey/useAccessKeyCreationFormSchema.content.ts  - [access-key-creation-form-schema]      无需填充的语言 - 跳过字典  - [doc-search-metadata]                  字典没有文件路径。跳过。  - [doc-search-metadata]                  正在处理内容声明:src/app/[locale]/(docs)/doc/search/metadata.content.ts  - [doc-search-metadata]                  无需填充的语言环境 - 跳过字典  - [doc-search-page]                      字典没有文件路径。跳过。  - [doc-search-page]                      正在处理内容声明:src/app/[locale]/(docs)/doc/search/page.content.ts  - [doc-search-page]                     [俄语 (ru)]                   正在准备将字典从英语 (en) 翻译为俄语 (ru)[intlayer]  已对 src/app/[locale]/(docs)/doc/search/page.content.ts 应用 Prettier 格式化  - [doc-search-page]                      内容声明已写入 src/app/[locale]/(docs)/doc/search/page.content.ts
        npx intlayer build
        [intlayer]  准备 Intlayer (v6.0.1)[intlayer]  词典:[intlayer]  ✓ 本地内容:163/163[intlayer]  ✓ 远程内容:100/100[intlayer]   - access-key-creation-form             [local: ✔ built] [distant: ✔ imported][intlayer]   - access-key-creation-form-schema      [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - access-key-form                      [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - ai-ab-testing-section                                 [远程: ✔ 导入完成][intlayer]   - application-not-running-view         [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - application-template-message         [本地: ✔ 构建完成] [远程: ✔ 获取完成][intlayer]   - aside-navigation                     [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - ask-reset-password                   [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - ask-reset-password-schema            [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - 自动完成部分               [本地: ✔ 构建完成] [远程: ✔ 获取完成][intlayer]   - 可用技术部分               [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - 博客数据                  [本地: ✔ 构建完成][intlayer]   - 博客元数据                [本地: ✔ 构建完成][intlayer]   - 博客导航列表              [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - 博客页面                  [远程: ✔ 获取完成][intlayer]   - 博客搜索元数据            [本地: ✔ 构建完成] [远程: ✔ 导入完成][intlayer]   - 博客搜索页面              [本地: ✔ 构建完成] [远程: ✔ 导入完成]...[intlayer]  内容已加载  (总计: 8401毫秒 - 本地: 4050毫秒 - 远程: 4222毫秒)
        export default {  log: {    mode: "verbose", // 选项: "default" | "verbose" | "disabled"  },};
        import { type IntlayerConfig } from "intlayer";const config: IntlayerConfig = {  build: {    importMode: "live", // "static" | "dynamic" | "live"  },  editor: {    liveSync: true, // 启用服务器端实时同步  },};export default config;
        npx intlayer live --with 'vite preview'