t9n-cli 0.1.0

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.
Files changed (2) hide show
  1. package/README.md +48 -0
  2. package/package.json +31 -0
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # t9n-cli
2
+
3
+ AI 驱动的 JSON 翻译命令行工具,懂代码,更懂你。
4
+
5
+ ## 核心特性
6
+ - **变量保护 (Variable Guard)**:自动识别并保护 `{name}`、`%s`、`{{count}}` 等代码变量,确保翻译后变量不损坏。
7
+ - **语境感知 (Context Aware)**:支持提供翻译背景描述(如:这是一个金融应用),让 AI 翻译语境更精准。
8
+ - **增量更新 (Diff Mode)**:仅翻译缺失或已修改的 Key,极大节省 AI 消耗和处理时间。
9
+ - **代码扫描 (Scanner)**:自动扫描源代码中的 `t()` 或 `dict.key` 调用,找出尚未录入字典的文案。
10
+ - **多语言支持**:全面支持 23 种以上主流语言的并发翻译。
11
+
12
+ ## 安装
13
+ ```bash
14
+ npm install -g t9n-cli
15
+ ```
16
+
17
+ ## 快速上手
18
+ 1. **初始化**项目配置:
19
+ ```bash
20
+ t9n init
21
+ ```
22
+ 2. **身份认证** (从 [t9n.dev/settings](https://t9n.dev/settings) 获取 API Key):
23
+ ```bash
24
+ t9n auth <your-api-key>
25
+ ```
26
+ 3. **翻译单个文件**:
27
+ ```bash
28
+ t9n translate en.json -t zh-CN,ja,fr
29
+ ```
30
+ 4. **增量更新文件夹**:
31
+ ```bash
32
+ t9n diff ./locales -s en -t zh-CN,ja
33
+ ```
34
+ 5. **扫描代码缺失 Key**:
35
+ ```bash
36
+ t9n scan ./src -d ./locales/en.json
37
+ ```
38
+
39
+ ## 命令列表
40
+ - `auth [key]`:配置 API Key。
41
+ - `init`:在当前目录初始化 `t9n.config.json`。
42
+ - `translate <files...>`:翻译指定的 JSON 文件。
43
+ - `diff <folder>`:对整个文件夹下的语言包进行增量对比并更新。
44
+ - `scan [folder]`:扫描代码中未在字典中定义的翻译 Key。
45
+ - `status`:查看当前账户套餐级别和剩余额度。
46
+
47
+ ## 开源协议
48
+ MIT
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "t9n-cli",
3
+ "version": "0.1.0",
4
+ "description": "T9N Translation CLI Tool",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "t9n": "dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "dictionaries",
12
+ "README.md"
13
+ ],
14
+ "scripts": {
15
+ "dev": "tsx index.ts",
16
+ "prebuild": "node scripts/sync-assets.js",
17
+ "build": "tsc"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "chalk": "^5.3.0",
24
+ "commander": "^12.1.0",
25
+ "ora": "^8.1.1"
26
+ },
27
+ "devDependencies": {
28
+ "tsx": "^4.21.0",
29
+ "typescript": "^5.0.0"
30
+ }
31
+ }