td-octopus 0.0.9 → 0.0.10
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 +2 -1
- package/package.json +1 -1
- package/src/extract/extract.js +8 -0
- package/src/utils/const.js +1 -0
package/README.md
CHANGED
|
@@ -47,7 +47,8 @@ copyright 2022 同盾
|
|
|
47
47
|
"defaultTranslateKeyApi": "Pinyin", // 默认生成的JSON key 使用拼音前5个
|
|
48
48
|
"importI18N": "import I18N from 'src/utils/I18N';",
|
|
49
49
|
"include": [], // 需要翻译的目录&也可以命令行输入参数
|
|
50
|
-
"exclude": [] // 过滤目录&文件
|
|
50
|
+
"exclude": [], // 过滤目录&文件
|
|
51
|
+
"reservedKey": ["template", "case"] // js关键词以及I18N内置方法不能作为目录名,会统一添加td作为前缀
|
|
51
52
|
}
|
|
52
53
|
```
|
|
53
54
|

|
package/package.json
CHANGED
package/src/extract/extract.js
CHANGED
|
@@ -261,6 +261,14 @@ function extractAll({ dirPath, prefix }) {
|
|
|
261
261
|
currentFilename = obj.fileName;
|
|
262
262
|
targetStrs = obj.targetStrs;
|
|
263
263
|
console.log(`${currentFilename} 替换中...`);
|
|
264
|
+
// 对一些特殊文件名进行优化,要不然会出现一些意想不到的bug
|
|
265
|
+
if(obj.key) {
|
|
266
|
+
const [fileName] = obj.key.split('.') || []
|
|
267
|
+
|
|
268
|
+
if(CONFIG['reservedKey'] && CONFIG['reservedKey'].some(i => i.toLocaleLowerCase() === fileName)) {
|
|
269
|
+
obj.key = 'td' + obj.key;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
264
272
|
return replaceAndUpdate(currentFilename, obj.target, `I18N.${obj.key}`, false, obj.needWrite, proType);
|
|
265
273
|
});
|
|
266
274
|
}, Promise.resolve())
|