Next.js国际化工具服务器

为Next.js App Router提供国际化(i18n)支持的MCP服务器,包含组件转换、翻译键检测、ICU语法验证和项目脚手架等功能。

  • by demartini
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 demartini/next-intl-mcp-server

使用说明

next-intl-mcp-server

MCP server for next-intl — i18n tooling for Next.js App Router.

目录

关于

next-intl-mcp-server 为MCP兼容的AI客户端提供深入、确定的知识 下一个intl --Next.js应用路由器的领先i18n库。

该服务器不依赖样板或期望人工智能推断API的正确使用,而是提供了专门的构建工具来转换组件、检测区域设置文件之间的不一致性、验证ICU语法和脚手架完成项目设置-无论是否使用基于URL-的路由。

(back to top)

特性

  • 🔄 转换要使用的任何组件 next-intl 只需一个电话
  • 🌍 检测跨区域设置文件的丢失或过时的翻译键
  • ✅ 部署前验证ICU消息语法
  • 🏗️ 为两种布线模式构建完整的项目设置
  • 📚 组件、ICU语法和设置的内置参考指南
  • 🤖 用于审查、翻译和审计工作流程的结构化提示模板
  • 🔒 完全本地执行——在stdio上运行,无需网络调用
  • ⚡ 无需安装,可立即通过 npx

(back to top)

工具

next_intl_internalize

将Next.js TSX组件转换为完全国际化的版本。它检测组件类型(server-async, client,或 shared),提取所有硬编码字符串(包括JSX内容、可访问性属性和元数据),注入适当的API(getTranslations 或 useTranslations),并为每个目标语言环境返回转换后的源代码和即用型消息JSON。

Use next_intl_internalize on this component with targetLocales ["en", "pt"]:

export default async function HeroSection() {
  return (
    <section>
      <h1>Welcome to our platform</h1>
      <button aria-label="Start for free">Get started</button>
    </section>
  );
}

next_intl_sync_locales

将多个区域设置JSON文件与参考区域设置进行比较,并报告丢失的键、多余或过时的条目,以及每个区域设置的建议补丁。补丁是一个最小的JSON结构,包含 [TODO:locale] 占位符,准备合并。

Use next_intl_sync_locales with referenceLocale "en" and these locales:
{
  "en": "<contents of messages/en.json>",
  "pt": "<contents of messages/pt.json>"
}

next_intl_validate_icu

使用大括号深度解析器跨区域设置文件验证ICU消息语法。它检测不平衡的牙套,需要缺失 other 类别在 plural 或 select 块、未闭合的富格文本标签和无效的密钥命名。

Use next_intl_validate_icu with the content of my messages/pt.json before I deploy.

next_intl_scaffold

生成完整 next-intl Next.js应用路由器项目的样板。支持两种路由模式:

  • locale-prefix --URL中包含的区域设置(/en/about).生成 routing.ts, navigation.ts, request.ts, proxy.ts, next.config.ts, app/[locale]/layout.tsx,以及启动器消息目录。
  • none --URL中没有区域设置,非常适合管理面板和SPA。通过以下方式解析区域设置 cookie, header,或 domain,并且可选地包括 switchLocale 服务器操作。
Scaffold a next-intl project with locales ["en", "pt", "es"],
defaultLocale "en", routing "none", localeSource "cookie".

(back to top)

资源

您的AI客户端随时都可以使用内置的参考指南,无需额外的提示。

URI 描述
next-intl://guide/component-patterns API选择指南、组件示例和常见缺陷
next-intl://guide/icu-syntax 完整的ICU参考:插值、复数、选择、序号、日期/数字、富文本
next-intl://guide/setup 带有文件结构和路由模式比较的设置指南

提示

结构化提示模板,旨在指导多步骤工作流程。

review_i18n_completeness

为组件生成结构化审查。它识别硬编码字符串,验证API的正确使用,检查是否丢失 NextIntlClientProvider,并返回一个清单以及国际化代码和消息JSON。

Review this component for i18n completeness.

translate_messages

创建保留ICU语法的翻译提示。它只转换值,保持键不变,保留占位符({name}, {count, plural, …})以及富格文本标签(<link>…</link>),并为每种语言应用正确的复数规则。

Translate messages/en.json to "pt,es,fr" preserving all ICU placeholders.

audit_locale_file

为区域设置文件构建完整的审核提示。它检查ICU语法,验证密钥命名约定,检测未翻译的值,并标记可疑的占位符——返回一个具有严重性级别的结构化报告。

Audit messages/pt-BR.json and report all issues with severity.

配置

您可以使用任何MCP客户端与下一个intl MCP服务器进行交互。下面是最受欢迎的客户端的设置说明。

克劳德代码

添加到您的项目 .mcp.json 对于全团队共享:

{
  "mcpServers": {
    "next-intl": {
      "command": "npx",
      "args": ["-y", "next-intl-mcp-server"]
    }
  }
}

或者通过CLI全局添加:

claude mcp add next-intl -- npx -y next-intl-mcp-server

验证 claude mcp list.

请参阅 克劳德代码MCP文档 了解更多详情。

光标

添加 .cursor/mcp.json:

{
  "mcpServers": {
    "next-intl": {
      "command": "npx",
      "args": ["-y", "next-intl-mcp-server"]
    }
  }
}

在游标设置中启用服务器。绿色指示灯确认激活。

请参阅 光标MCP文档 了解更多详情。

VS Code

添加 .vscode/mcp.json:

{
  "servers": {
    "next-intl": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "next-intl-mcp-server"]
    }
  }
}

打开文件并单击 开始 在服务器条目旁边。

请参阅 VS代码MCP文档 了解更多详情。

法典

添加 ~/.codex/config.toml:

[mcp_servers.next-intl]
command = "npx"
args = ["-y", "next-intl-mcp-server"]

重新启动Codex以加载服务器。

请参阅 食品法典委员会MCP文件 了解更多详情。

(back to top)

贡献

如果你想贡献,请查看我们的 贡献指南 并打开一个 问题 或 拉取请求.

(back to top)

更新日志

看 更新日志 以获得完整且人类可读的变化历史。

(back to top)

许可证

根据MIT许可证分发。看 许可证 了解详情。

(back to top)