🌐 i18n MCP Server

🌐 i18n MCP Server

site icon
2025.04.16 0
TypeScript国际化管理翻译工具开发效率
i18n MCP Server 是一个强大的国际化(i18n)管理工具,旨在简化基于 JSON 的语言文件的翻译过程。它允许用户通过便捷的服务器接口,利用强大的语言模型直接从基础语言文件生成翻译。该工具特别适合与 Cursor IDE 配合使用,支持 stdio 传输协议,能够无缝集成到开发流程中。
View on GitHub

Overview

基本能力

产品定位

i18n MCP Server 是一个专注于国际化(i18n)管理的工具,旨在简化多语言项目的翻译流程,提高开发效率。

核心功能

  • 多语言支持:从单一基础语言文件自动生成多种语言的翻译。
  • 模型翻译:利用 Cursor 上的语言模型进行翻译,无需额外付费服务。
  • 高效工作流:无需手动复制或编辑 JSON 文件,通过请求即可获取翻译文件。
  • 开发者友好:设计简洁,易于集成到开发流程中。

适用场景

  • 需要快速生成多语言翻译的项目。
  • 希望减少手动翻译工作量的开发团队。
  • 需要保持 i18n 文件一致性和更新的项目。

工具列表

  • 基础语言文件读取:获取基础语言文件和支持的语言列表。
  • 翻译块获取:获取待翻译的文本块。
  • 翻译更新:更新内存缓存中的翻译。
  • 翻译保存:将翻译保存到语言特定的 JSON 文件中。

常见问题解答

  • 翻译中断:由于 Cursor 的 25 次工具调用限制,翻译流程可能会中断,需要手动恢复。
  • 翻译速度:生成单个语言的翻译比同时生成多个语言更快。
  • 模型选择:不同模型的响应时间和翻译效果可能有所不同。

使用教程

使用依赖

  1. 克隆仓库:
git clone
  1. 安装依赖:
pnpm install # 或 npm/yarn

安装教程

  1. 构建服务器:
pnpm run build
  1. 配置 Cursor IDE:
  2. 导航到 Cursor Settings / MCP,添加新的 MCP 服务器。
  3. 在打开的 JSON 中,包含服务器定义:
{
  "mcpServers": {
    "i18n-translation-server": {
      "command": "node",
      "args": ["<base-path>/i18n-mcp/dist/mcp_server.js"]
    }
  }
}
  • 替换 <base-path> 为编译服务器的绝对路径。

调试方式

  1. 运行 MCP 服务器后,使用 Cursor Agent 与服务器工具交互。
  2. 示例任务请求:
We are preparing the i18n files for a project and have a base language file. Using the following data, execute the proposed tasks to prepare the additional required languages.

Base JSON language file: <absolute path to the base language file>
Base language: <base language>
Supported languages: <comma-separated list of supported languages>

These are the tasks that we need to perform:

1. Clear the previous data
2. Read the base JSON language file
3. Get the next chunk
4. For each language in the supported languages, do the following subtasks:
   4.1. Translate all items in the chunk from the base language to the target language. Ensure that the order is preserved and that any i18n string parameters are respected.
   4.2. Update the translations for the language
5. Repeat from task 3 until the next chunk does not return any data.
6. After processing all chunks, save translations for each supported language.
  1. 生成的语言文件将保存在基础语言文件的同一文件夹中。

许可证

该项目遵循 AGPL-3.0 开源许可条款,请参阅 AGPL-3.0 了解完整条款。