vue-i18n-agent
v1.0.1
Published
Automated i18n workflow for Vue/Nuxt 3 powered by DeepSeek: Scan, Extract, Translate, and Refactor. | 基于 DeepSeek 的 Vue/Nuxt 3 国际化全流程自动化工具:一键扫描、提取、翻译与代码回填。
Downloads
240
Maintainers
Readme
vue-i18n-agent
Automated i18n workflow for Vue/Nuxt 3 powered by DeepSeek: Scan, Extract, Translate, and Refactor.
基于 DeepSeek 的 Vue/Nuxt 3 国际化全流程自动化工具:一键扫描、提取、翻译与代码回填。
📖 Languages
🇺🇸 English Documentation
Streamline your internationalization process for Vue 3 and Nuxt 3 projects. From scanning source code to generating language files and refactoring code, everything is automated with AI.
✨ Features
- 🔍 Auto Scan: Intelligently detects hardcoded Chinese text in
.vuefiles. - 🧹 Smart Extract: Filters comments and code, generating a clean list of text to translate.
- 🤖 AI Translate: Powered by DeepSeek AI, automatically generates semantic keys (snake_case) and translates to multiple languages (En/De).
- 📂 Auto Generate: Creates/Updates
locales/zh.json,en.json,de.json. - 🔄 Code Refactor: Automatically replaces hardcoded text with
$t('key')in both Templates and Scripts. - 🔧 Nuxt Support: Auto-injects
const { t } = useI18n()into<script setup>.
🚀 Quick Start (Recommended)
Run directly in your project root without installation:
npx vue-i18n-agentOr run with an API Key:
npx vue-i18n-agent --key sk-your-deepseek-key📦 Installation(Optional)
Install as a dev dependency:
npm install -D vue-i18n-agentAdd a script to your package.json:
{
"scripts": {
"i18n": "vue-i18n-agent"
}
}Run:
npm run i18nConfiguration
An API Key is required for DeepSeek translation. You can provide it in 3 ways:
- Interactive: Run the command, and paste the key when prompted.
- Environment Variable (Recommended): Create a .env file in your root directory:
DEEPSEEK_API_KEY=sk-your-deepseek-key- Command Line: Use the --key or -k flag.
🛡️ Safety
- The tool creates a .i18n_cache folder for intermediate files.
- Please commit your code to Git before running Step 5 (Refactor). Although the tool asks for confirmation, a backup is always recommended.
🇨🇳 中文说明
一键扫描、提取、翻译、回填。让 Nuxt 3 / Vue 3 项目的国际化迁移变得前所未有的简单。
✨ 功能特性
- 🔍 自动扫描: 智能识别
.vue文件中的中文硬编码。 - 🧹 智能提取: 过滤注释和代码,生成干净的待翻译清单。
- 🤖 AI 翻译: 内置 DeepSeek AI,自动生成语义化 Key 并翻译成多语言 (En/De)。
- 📂 自动生成: 自动创建/更新
locales/zh.json,en.json,de.json。 - 🔄 代码重构: 全自动将源码中的中文替换为
$t('user_login'),支持 Template 和 Script。 - 🔧 Nuxt 支持: 自动在
<script setup>中注入const { t } = useI18n()。
🚀 快速开始 (推荐)
无需安装,直接在你的项目根目录下运行:
npx vue-i18n-agent或者带上 API Key 运行:
npx vue-i18n-agent -k sk-你的DeepSeek密钥
📦 安装到项目 (可选)
如果想将工具安装到项目中,方便后续使用:
npm install -D vue-i18n-agent然后在 package.json 中添加脚本:
"scripts": {
"i18n": "vue-i18n-agent"
}运行:
npm run i18n⚙️ 配置API key
本工具需要 DeepSeek API Key 才能进行翻译。你有 3 种方式提供 Key:
- 交互式输入:直接运行命令,脚本会弹窗询问 Key。
- 环境变量 (推荐):在项目根目录创建 .env 文件:
DEEPSEEK_API_KEY=sk-你的DeepSeek密钥- 命令行参数:使用 --key 或 -k 参数。
🛡️ 安全提示
- 本工具会在项目根目录生成 .i18n_cache 文件夹用于存放临时数据。
- 在执行“代码重构 (Step 5)”之前,请务必确保你的代码已经 Git 提交。 虽然工具有确认提示,但备份总是好的!
