resx翻译mcp
A. 模型上下文协议(MCP) 服务器,使AI助手能够阅读和编辑。网 .resx 高效地翻译文件,而无需将原始XML加载到上下文中。
特性
| 工具 | 说明 |
|---|---|
get_translations | 检索每个语言变体中给定键的所有翻译(.resx, .en-US.resx, .pl-PL.resx,…)在同一目录中。 |
upsert_translation | 添加新密钥或更新特定密钥中的现有密钥 .resx 文件。每次写入后,文件会自动按字母顺序重新排序。 |
运作原理
.resx 文件在。NET项目遵循命名约定:
Language.resx ← default / fallback
Language.en-US.resx ← English (US)
Language.pl-PL.resx ← Polish
Language.de-DE.resx ← German当你打电话的时候 get_translations 随着 基本文件 路径(Language.resx)服务器扫描目录中所有匹配的语言文件,并在单个响应中返回该键的每个翻译。
当你打电话的时候 upsert_translation,你指向一个 特定的 语言文件(例如。 Language.en-US.resx),提供键和值,服务器插入或更新条目,然后按字母顺序对整个文件进行排序。
安装
npx(无需安装)
npx resx-translations-mcp来源
# Clone the repository
git clone https://github.com/DarrenStasiak/resx-translations-mcp.git
cd resx-translations-mcp
# Install dependencies
npm install
# Build
npm run build配置
将服务器添加到MCP客户端配置中。
克劳德桌面/克劳德代码
使用npx(推荐):
{
"mcpServers": {
"resx": {
"command": "npx",
"args": ["resx-translations-mcp"]
}
}
}或者使用本地克隆:
{
"mcpServers": {
"resx": {
"command": "node",
"args": ["/absolute/path/to/resx-translations-mcp/dist/index.js"]
}
}
}VS代码(副驾驶/MCP扩展)
增添 .vscode/mcp.json:
使用npx(推荐):
{
"servers": {
"resx": {
"command": "npx",
"args": ["resx-translations-mcp"]
}
}
}或者使用本地克隆:
{
"servers": {
"resx": {
"command": "node",
"args": ["/absolute/path/to/resx-translations-mcp/dist/index.js"]
}
}
}工具参考
get_translations
检索给定密钥的所有翻译。
参数:
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
basePath | string | 是 | 到基的路径(默认) .resx 文件,例如。 src/Translations/Language.resx |
key | string | 是 | 要查找的翻译键 |
示例响应:
{
"key": "BUTTON_SAVE",
"translations": {
"default": "Zapisz",
"en-US": "Save",
"de-DE": "Speichern"
}
}如果特定语言文件中不存在密钥,则返回该语言 "[NOT_FOUND]". 如果在任何文件中都找不到密钥,则会返回一条描述性消息。
______________________________________________________________________
upsert_translation
添加或更新翻译条目。
参数:
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
filePath | string | 是 | 特定路径 .resx 文件,例如。 src/Translations/Language.en-US.resx |
key | string | 是 | 翻译键 |
value | string | 是 | 翻译值 |
文件自动 按字母顺序排序 每次写作后按键。
发展
# Watch mode
npm run dev
# Single build
npm run build