vue-auto-i18n-zlp 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: zhouliping
|
|
3
|
+
* @Date: 2026-01-20 17:36:37
|
|
4
|
+
* @LastEditors: Please set LastEditors
|
|
5
|
+
* @LastEditTime: 2026-01-21 11:23:15
|
|
6
|
+
* @Description:
|
|
7
|
+
* @FilePath: \学习\auto-i18n-cli\README.md
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
# Vue/Nuxt 3 自动化国际化工具 (DeepSeek 版)
|
|
11
|
+
|
|
12
|
+
> 一键扫描、提取、翻译、回填。让 Nuxt 3 / Vue 3 项目的国际化迁移变得前所未有的简单。
|
|
13
|
+
|
|
14
|
+
## ✨ 功能特性
|
|
15
|
+
|
|
16
|
+
- 🔍 **自动扫描**: 智能识别 `.vue` 文件中的中文硬编码。
|
|
17
|
+
- 🧹 **智能提取**: 过滤注释和代码,生成干净的待翻译清单。
|
|
18
|
+
- 🤖 **AI 翻译**: 内置 DeepSeek AI,自动生成语义化 Key 并翻译成多语言 (En/De)。
|
|
19
|
+
- 📂 **自动生成**: 自动创建/更新 `locales/zh.json`, `en.json`, `de.json`。
|
|
20
|
+
- 🔄 **代码重构**: 全自动将源码中的中文替换为 `$t('user_login')`,支持 Template 和 Script。
|
|
21
|
+
- 🔧 **Nuxt 支持**: 自动在 `<script setup>` 中注入 `const { t } = useI18n()`。
|
|
22
|
+
|
|
23
|
+
## 🚀 快速开始 (推荐)
|
|
24
|
+
|
|
25
|
+
无需安装,直接在你的项目根目录下运行:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npx vue-auto-i18n-zlp
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
或者带上 API Key 运行:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx vue-auto-i18n-zlp -k sk-你的DeepSeek密钥
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 📦 安装到项目 (可选)
|
|
39
|
+
|
|
40
|
+
如果想将工具安装到项目中,方便后续使用:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install -D vue-auto-i18n-zlp
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
然后在 package.json 中添加脚本:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
"scripts": {
|
|
50
|
+
"i18n": "vue-auto-i18n-zlp"
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
运行:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm run i18n
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## ⚙️ 配置API key
|
|
61
|
+
|
|
62
|
+
本工具需要 DeepSeek API Key 才能进行翻译。你有 3 种方式提供 Key:
|
|
63
|
+
|
|
64
|
+
1. 交互式输入:直接运行命令,脚本会弹窗询问 Key。
|
|
65
|
+
2. 环境变量 (推荐):在项目根目录创建 .env 文件:
|
|
66
|
+
|
|
67
|
+
```ini
|
|
68
|
+
DEEPSEEK_API_KEY=sk-你的DeepSeek密钥
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
3. 命令行参数:使用 --key 或 -k 参数。
|
|
72
|
+
|
|
73
|
+
## 🛡️ 安全提示
|
|
74
|
+
|
|
75
|
+
- 本工具会在项目根目录生成 .i18n_cache 文件夹用于存放临时数据。
|
|
76
|
+
- 在执行“代码重构 (Step 5)”之前,请务必确保你的代码已经 Git 提交。 虽然工具有确认提示,但备份总是好的!
|
|
77
|
+
|
|
78
|
+
## 📄 License
|
|
79
|
+
ISC
|