Skip to content

VSCode 集成

更喜欢观看视频?

为了提升直接在代码编辑器中管理消息的工作流程,你可以使用一个支持 next-intl 的 VSCode 扩展。

以下这些扩展已知支持 next-intl

  1. i18n Ally
  2. Loccy
  3. Sherlock

i18n Ally

亮点:

  • 消息提取
  • 内联注释
  • 内联消息编辑
  • 机器翻译

设置:

  1. 安装 i18n Ally
  2. 通过工作区设置在项目中配置该扩展
.vscode/settings.json
"i18n-ally.localesPaths": ["./path/to/your/messages"], // 例如 "./messages"
"i18n-ally.keystyle": "nested"

更多内容请参阅 i18n Ally 文档

Loccy

亮点:

  • 消息提取
  • 内联注释
  • 内联消息编辑
  • AI增强功能,用于消息创建、机器翻译等(付费)

设置:

  1. 安装 Loccy,它会自动检测你的 i18n 配置
  2. 若需高级配置,可在命令面板运行 Loccy: Create Config File

更多信息请见 Loccy 官网

Sherlock

亮点:

  • 消息提取
  • 内联注释
  • 内联消息编辑

设置:

  1. 安装 Sherlock VS Code 扩展
  2. 通过 project.inlang/settings.json 在项目中配置该扩展:
project.inlang/settings.json
{
  "$schema": "https://inlang.com/schema/project-settings",
  "sourceLanguageTag": "en",
  "languageTags": ["en", "de"],
  "modules": [
    "https://cdn.jsdelivr.net/npm/@inlang/plugin-next-intl@latest/dist/index.js"
  ],
  "plugin.inlang.nextIntl": {
    "pathPattern": "./messages/{languageTag}.json"
  }
}

更多内容请参阅 inlang 文档