npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@wginit/mcp-vue-i18n

v1.0.0

Published

Vue i18n 工具

Readme

mcp-vue-i18n

自动抽取 Vue2 项目中的中文文案,生成拼音 key(无下划线),写入多语言文件(按 namespace 分组),并可将源码替换为 $t('namespace.key')的 MCP 服务工具

功能概览

  • 抽取 Vue2 SFC 与普通 JS 文件中的中文文案
  • 生成无下划线拼音 key,冲突自动去重
  • 写入多语言文件:zh-CN.jsonen.json(按 namespace 分组写入)
  • 预览/应用源码替换,将中文替换为 $t(key),并生成补丁以便回滚
  • MCP 工具与命令行工具双形态,便于在 IDE/代理 和脚手架中集成

运行环境

  • Node.js >= 20

作为 MCP Server 使用

在客户端(如 Cursor)的 mcp.json 注册该服务(示例):

{
    "mcpServers": {
        "mcp-vue-i18n": {
            "command": "npx",
            "args": ["-y", "@wginit/mcp-vue-i18n@latest"]
        }
    }
}

服务启动后提供以下工具(tools)与一个提示(prompt):

工具:extract_i18n(只写 locales)

  • 入参:
    • root: 项目根目录(必填)
    • output: 多语言输出目录(必填),例如 ./src/locales
    • namespace: 命名空间(必填),如 projectA
    • include: 相对 root 的扫描目录(可选,默认 src
  • 行为:扫描 include 下的 .vue.js,抽取中文,生成 key,写入 zh-CN.jsonen.json

工具:preview_i18n(仅预览差异,不落盘)

  • 入参:
    • root: 项目根目录(必填)
    • namespace: 命名空间(必填)
    • include: 相对 root 的扫描目录(可选,默认 src
  • 行为:生成将中文替换为 $t(key) 的 diff 预览列表(不修改源码)。

工具:apply_i18n(写 locales 并替换源码)

  • 入参:
    • root: 项目根目录(必填)
    • output: 多语言输出目录(必填)
    • namespace: 命名空间(必填)
    • include: 相对 root 的扫描目录(可选,默认 src
  • 行为:写入 zh-CN.jsonen.json,并将源码中的中文替换为 $t(key);补丁保存至 root/.mcp-i18n-patches

工具:rollback_i18n(回滚上次替换)

  • 入参:
    • root: 项目根目录(必填)
  • 行为:尝试使用 git checkout -- <file> 回滚已替换的文件;需在 Git 管控下使用。

提示:generate_i18n_key

  • 输入:text(原始中文)
  • 输出:推荐的无下划线拼音 key 和英文翻译建议

可选参数:--include(默认 src),控制扫描范围;内部会忽略 node_modules

多语言文件输出规范

  • 生成或追加写入:
    • <output>/zh-CN.json
    • <output>/en.json
  • 使用「点号」路径按命名空间写入,例如:
    • key 为 projectA.home.title,则会写入:
      • zh-CN.json 中的 { "projectA": { "home": { "title": "首页" }}}
      • en.json 中的 { "projectA": { "home": { "title": "TRANSLATION_首页" }}}

源码替换与回滚

  • apply 模式会尝试将模板与脚本中的中文替换为 $t('namespace.key')
  • 生成的补丁保存于:<root>/.mcp-i18n-patches
  • 回滚依赖 Git:rollback 工具会对补丁涉及的文件执行 git checkout -- <file>

注意与建议

  • 建议先 preview,确认替换效果后再 apply
  • 对非常复杂的模板/脚本场景,可能需要人工复核
  • 英文翻译默认占位(TRANSLATION_中文),可对接翻译 API 自行扩展