td-octopus 0.1.12 → 0.1.13
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/package.json +1 -1
- package/src/check/index.js +7 -6
- package/src/utils/syncLang.js +3 -3
package/package.json
CHANGED
package/src/check/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @Author: 郑泳健
|
|
4
4
|
* @Date: 2024-12-12 15:00:24
|
|
5
5
|
* @LastEditors: 郑泳健
|
|
6
|
-
* @LastEditTime: 2025-09-09
|
|
6
|
+
* @LastEditTime: 2025-09-09 17:09:27
|
|
7
7
|
*/
|
|
8
8
|
const path = require('path')
|
|
9
9
|
const fs = require('fs')
|
|
@@ -72,14 +72,14 @@ function main() {
|
|
|
72
72
|
return
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
if (!fs.existsSync(path.resolve(process.cwd(), '
|
|
75
|
+
if (!fs.existsSync(path.resolve(process.cwd(), 'public/.octopus'))) {
|
|
76
76
|
spinner.succeed(`查询完毕,共计丢失${lostKey.length}个,请在lostI18N.js中查看`);
|
|
77
|
-
spinner.warn('请将原始项目的.octopus复制到当前项目
|
|
77
|
+
spinner.warn('请将原始项目的.octopus复制到当前项目public目录下,会帮你自助将缺失的key补充上去');
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
const zhFrom = syncLang('zh-CN', path.resolve(process.cwd(), '
|
|
82
|
-
const enFrom = syncLang('en-US', path.resolve(process.cwd(), '
|
|
80
|
+
spinner.start(`查询完毕,共计丢失${lostKey.length}个,开始同步开始`);
|
|
81
|
+
const zhFrom = syncLang('zh-CN', path.resolve(process.cwd(), 'public/.octopus'))
|
|
82
|
+
const enFrom = syncLang('en-US', path.resolve(process.cwd(), 'public/.octopus'))
|
|
83
83
|
const zhFromFlat = flatObject(zhFrom);
|
|
84
84
|
const enFromFlat = flatObject(enFrom);
|
|
85
85
|
|
|
@@ -102,6 +102,7 @@ function main() {
|
|
|
102
102
|
|
|
103
103
|
rewriteFiles(getFileKeyValueList(zhCNResult), 'zh-CN');
|
|
104
104
|
rewriteFiles(getFileKeyValueList(enCNResult), 'en-US');
|
|
105
|
+
spinner.succeed(`同步完成`);
|
|
105
106
|
})()
|
|
106
107
|
}
|
|
107
108
|
|
package/src/utils/syncLang.js
CHANGED
|
@@ -2,14 +2,14 @@ const fs = require('fs')
|
|
|
2
2
|
const { otpPath } = require('./translate');
|
|
3
3
|
const { getLangData } = require('../extract/getLangData')
|
|
4
4
|
|
|
5
|
-
module.exports = (lang) => {
|
|
5
|
+
module.exports = (lang, basePath = otpPath) => {
|
|
6
6
|
try {
|
|
7
|
-
const list = fs.readdirSync(
|
|
7
|
+
const list = fs.readdirSync(basePath + '/' + lang);
|
|
8
8
|
let langMap = {};
|
|
9
9
|
list.forEach((i) => {
|
|
10
10
|
const suffixCheck = ['.js', '.ts', '.jsx', 'tsx'].some(it => i.endsWith(it));
|
|
11
11
|
if (suffixCheck && !['index.js', 'index.jsx', 'index.ts', 'index.tsx'].includes(i)) {
|
|
12
|
-
const json = getLangData(`${
|
|
12
|
+
const json = getLangData(`${basePath}/${lang}/${i}`)
|
|
13
13
|
const key = i.split('.')[0];
|
|
14
14
|
|
|
15
15
|
langMap[key] = json;
|