auto-i18n-plugin-core 1.1.5 → 1.1.7
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +18 -2
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/readme-en.md +19 -0
- package/readme.md +42 -25
package/package.json
CHANGED
package/readme-en.md
CHANGED
|
@@ -35,6 +35,13 @@ pnpm run preview // Don't select React, contains too much English text
|
|
|
35
35
|
- **Build Tools**: Fully compatible with Webpack, Vite, and Rollup 🚀
|
|
36
36
|
- **Translation Services**: Default support for **Youdao** and **Google** translation, plus custom translators
|
|
37
37
|
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## ❓ Common Issues
|
|
41
|
+
|
|
42
|
+
[Documentation](https://juejin.cn/post/7483435518526062626).
|
|
43
|
+
|
|
44
|
+
|
|
38
45
|
---
|
|
39
46
|
|
|
40
47
|
## 🌟 Quick Start 🚀
|
|
@@ -341,6 +348,7 @@ import '../lang/index.js' // 📍 Must be imported on the first line of the entr
|
|
|
341
348
|
| deepScan | boolean | ❌ | `false` | Experimental: Whether to perform deep string scanning |
|
|
342
349
|
| commonTranslateKey | string | ❌ | `''` | General translation key |
|
|
343
350
|
| insertFileExtensions | string[] | ❌ | `[]` | List of file extensions to insert translation code into |
|
|
351
|
+
| isClear | boolean | ❌ | `false` | Whether to clear content not in context (clear source language key-value pairs not in context) |
|
|
344
352
|
|
|
345
353
|
---
|
|
346
354
|
|
|
@@ -463,6 +471,17 @@ Original authors: wenps, xu-code, Caleb-Xu, Winfans
|
|
|
463
471
|
|
|
464
472
|
## Changelog
|
|
465
473
|
|
|
474
|
+
|
|
475
|
+
### v1.1.6 (Recommended Version)
|
|
476
|
+
|
|
477
|
+
- Fixed issue where clearing whitespace before/after template strings caused mismatch between JSON and translation functions
|
|
478
|
+
- Fixed issue where Chinese brackets in interpolation caused interpolation to fail
|
|
479
|
+
- Added configuration cleanup functionality
|
|
480
|
+
|
|
481
|
+
### v1.1.5 (Recommended Version)
|
|
482
|
+
|
|
483
|
+
- Added support for interpolation translation
|
|
484
|
+
|
|
466
485
|
### v1.1.4 (Recommended Version)
|
|
467
486
|
|
|
468
487
|
- Fixed template string processing exception in exclude functions
|
package/readme.md
CHANGED
|
@@ -39,6 +39,12 @@ tips:有道翻译需要用户自己去申请有道的翻译服务,demo里面
|
|
|
39
39
|
|
|
40
40
|
---
|
|
41
41
|
|
|
42
|
+
## ❓ 常见问题
|
|
43
|
+
|
|
44
|
+
[问题文档](https://juejin.cn/post/7483435518526062626)。
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
42
48
|
## 🌟 快速开始 🚀
|
|
43
49
|
|
|
44
50
|
### 1️⃣ 安装插件 📦
|
|
@@ -121,11 +127,11 @@ export default {
|
|
|
121
127
|
|
|
122
128
|
```js
|
|
123
129
|
window.langMap = {
|
|
124
|
-
|
|
125
|
-
|
|
130
|
+
en: {
|
|
131
|
+
zccsau6: 'hello'
|
|
126
132
|
},
|
|
127
133
|
'zh-cn': {
|
|
128
|
-
|
|
134
|
+
zccsau6: '你好'
|
|
129
135
|
}
|
|
130
136
|
}
|
|
131
137
|
```
|
|
@@ -331,28 +337,29 @@ import '../lang/index.js' // 📍 必须在入口文件中第一行引入,文
|
|
|
331
337
|
|
|
332
338
|
## ⚙️ 配置参数说明
|
|
333
339
|
|
|
334
|
-
| 参数 | 类型 | 必选 | 默认值 | 描述
|
|
335
|
-
| -------------------- | ---------- | ---- | ------------------------ |
|
|
336
|
-
| enabled | boolean | ❌ | `true` | 是否触发翻译。
|
|
337
|
-
| translateType | string | ❌ | `full-auto` | 翻译状态,默认有两种可选`full-auto` 和 `semi-auto` 。
|
|
338
|
-
| translateKey | string | ✅ | `$t` | 翻译调用函数名称,例如`$t` 表示翻译调用时的函数名
|
|
339
|
-
| excludedCall | string[] | ❌ | `['$i8n', 'require', …]` | 标记不会被翻译的函数调用列表
|
|
340
|
-
| excludedPattern | RegExp[] | ❌ | `[/\.\w+$/]` | 用于标记排除不翻译的字符串模式,例如文件路径中的文件后缀
|
|
341
|
-
| excludedPath | string[] | ❌ | `['node_modules']` | 指定需要排除翻译的文件夹路径,例如默认会跳过`node_modules`
|
|
342
|
-
| includePath | RegExp[] | ❌ | `[/src\//]` | 指定只翻译某些目录路径(白名单),默认为`src`
|
|
343
|
-
| globalPath | string | ❌ | `'./lang'` | 翻译文件配置生成路径
|
|
344
|
-
| distPath | string | ✅ | `''` | 打包后生成的文件位置路径
|
|
345
|
-
| distKey | string | ✅ | `'index'` | 打包后生成的翻译主文件名称
|
|
346
|
-
| namespace | string | ✅ | `lang` | 项目命名空间,用于区分不同项目的翻译配置
|
|
347
|
-
| originLang | string | ✅ | `'zh-cn'` | 源语言,翻译以此语言为基础
|
|
348
|
-
| targetLangList | string[] | ✅ | `['en']` | 目标语言列表,支持配置多个语言
|
|
349
|
-
| buildToDist | boolean | ❌ | `false` | 是否在构建结束后将最新的翻译文件打包到主包中,默认不打包
|
|
350
|
-
| translator | Translator | ❌ | `GoogleTranslator` | 翻译器实例
|
|
351
|
-
| translatorOption | object | ❌ | `{}` | 翻译器的配置项,优先级低于`translator`
|
|
352
|
-
| rewriteConfig | boolean | ❌ | `true` | 插件每次运行时是否重写配置文件
|
|
353
|
-
| deepScan | boolean | ❌ | `false` | 实验性属性,表示是否进行深层扫描字符串
|
|
354
|
-
| commonTranslateKey | string | ❌ | `''` | 通用翻译key
|
|
355
|
-
| insertFileExtensions | string[] | ❌ | `[]` | 要插入翻译代码的文件扩展名列表
|
|
340
|
+
| 参数 | 类型 | 必选 | 默认值 | 描述 |
|
|
341
|
+
| -------------------- | ---------- | ---- | ------------------------ | ------------------------------------------------------------------ |
|
|
342
|
+
| enabled | boolean | ❌ | `true` | 是否触发翻译。 |
|
|
343
|
+
| translateType | string | ❌ | `full-auto` | 翻译状态,默认有两种可选`full-auto` 和 `semi-auto` 。 |
|
|
344
|
+
| translateKey | string | ✅ | `$t` | 翻译调用函数名称,例如`$t` 表示翻译调用时的函数名 |
|
|
345
|
+
| excludedCall | string[] | ❌ | `['$i8n', 'require', …]` | 标记不会被翻译的函数调用列表 |
|
|
346
|
+
| excludedPattern | RegExp[] | ❌ | `[/\.\w+$/]` | 用于标记排除不翻译的字符串模式,例如文件路径中的文件后缀 |
|
|
347
|
+
| excludedPath | string[] | ❌ | `['node_modules']` | 指定需要排除翻译的文件夹路径,例如默认会跳过`node_modules` |
|
|
348
|
+
| includePath | RegExp[] | ❌ | `[/src\//]` | 指定只翻译某些目录路径(白名单),默认为`src` |
|
|
349
|
+
| globalPath | string | ❌ | `'./lang'` | 翻译文件配置生成路径 |
|
|
350
|
+
| distPath | string | ✅ | `''` | 打包后生成的文件位置路径 |
|
|
351
|
+
| distKey | string | ✅ | `'index'` | 打包后生成的翻译主文件名称 |
|
|
352
|
+
| namespace | string | ✅ | `lang` | 项目命名空间,用于区分不同项目的翻译配置 |
|
|
353
|
+
| originLang | string | ✅ | `'zh-cn'` | 源语言,翻译以此语言为基础 |
|
|
354
|
+
| targetLangList | string[] | ✅ | `['en']` | 目标语言列表,支持配置多个语言 |
|
|
355
|
+
| buildToDist | boolean | ❌ | `false` | 是否在构建结束后将最新的翻译文件打包到主包中,默认不打包 |
|
|
356
|
+
| translator | Translator | ❌ | `GoogleTranslator` | 翻译器实例 |
|
|
357
|
+
| translatorOption | object | ❌ | `{}` | 翻译器的配置项,优先级低于`translator` |
|
|
358
|
+
| rewriteConfig | boolean | ❌ | `true` | 插件每次运行时是否重写配置文件 |
|
|
359
|
+
| deepScan | boolean | ❌ | `false` | 实验性属性,表示是否进行深层扫描字符串 |
|
|
360
|
+
| commonTranslateKey | string | ❌ | `''` | 通用翻译key |
|
|
361
|
+
| insertFileExtensions | string[] | ❌ | `[]` | 要插入翻译代码的文件扩展名列表 |
|
|
362
|
+
| isClear | boolean | ❌ | `false` | 是否清除已经不在上下文中的内容(清除项目中不再使用到的源语言键值对) |
|
|
356
363
|
|
|
357
364
|
---
|
|
358
365
|
|
|
@@ -477,6 +484,16 @@ const HelloWorld: React.FC<HelloWorldProps> = ({ name = 'World' }) => {
|
|
|
477
484
|
|
|
478
485
|
## 更新日志
|
|
479
486
|
|
|
487
|
+
### v1.1.6 (推荐版本)
|
|
488
|
+
|
|
489
|
+
- 修复模板字符串前后空格清空导致 JSON 对应不上翻译函数的问题
|
|
490
|
+
- 修复插值中文括号导致插值失效的问题
|
|
491
|
+
- 新增清理配置功能
|
|
492
|
+
|
|
493
|
+
### v1.1.5 (推荐版本)
|
|
494
|
+
|
|
495
|
+
- 支持插值翻译
|
|
496
|
+
|
|
480
497
|
### v1.1.4 (推荐版本)
|
|
481
498
|
|
|
482
499
|
- 修复排除函数处理模版字符串异常问题
|