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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "td-octopus",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "I18N tool",
5
5
  "author": "Anthony Li",
6
6
  "bin": {
@@ -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())
@@ -28,6 +28,7 @@ const PROJECT_CONFIG = {
28
28
  resourcePath: [
29
29
  "./src/constants/locale"
30
30
  ],
31
+ reservedKey: ["template", "case"]
31
32
  },
32
33
  langMap: {
33
34
  ['en-US']: 'en',