ztxkutils 2.10.66-30 → 2.10.66-31
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 +112 -112
- package/zti18n-cli/bin/index.js +3 -3
- package/zti18n-cli/index.js +23 -23
- package/zti18n-cli/src/command/collect.js +353 -353
- package/zti18n-cli/src/command/convert.js +17 -17
- package/zti18n-cli/src/command/convert2.js +35 -35
- package/zti18n-cli/src/command/initFileConf.js +133 -133
- package/zti18n-cli/src/command/publish.js +24 -24
- package/zti18n-cli/src/conf/BaseConf.js +21 -21
- package/zti18n-cli/src/conf/FileConf.js +116 -116
- package/zti18n-cli/src/index.js +75 -75
- package/zti18n-cli/src/translate/google.js +87 -87
- package/zti18n-cli/src/utils/isChinese.js +3 -3
- package/zti18n-cli/src/utils/log.js +8 -8
- package/zti18n-cli/src/utils/mergeOptions.js +45 -45
- package/zti18n-cli/src/utils/reactOptions.js +73 -73
- package/zti18n-cli/src/utils/vueOptions.js +69 -69
- package/zti18n-core/index.js +1 -1
- package/zti18n-core/src/index.js +5 -5
- package/zti18n-core/src/plugin/reactIntlToReactIntlUniversal.js +224 -224
- package/zti18n-core/src/plugin/reactIntlUniversalToDi18n.js +64 -64
- package/zti18n-core/src/transform/defaultPkMap.js +79 -79
- package/zti18n-core/src/transform/transformHtml.js +271 -271
- package/zti18n-core/src/transform/transformJs.js +489 -489
- package/zti18n-core/src/transform/transformPug.js +272 -272
- package/zti18n-core/src/transform/transformReactIntlToReactIntlUniversal.js +96 -96
- package/zti18n-core/src/transform/transformReactIntlUniveralToDi18n.js +90 -90
- package/zti18n-core/src/transform/transformToDi18n.js +22 -22
- package/zti18n-core/src/transform/transformTs.js +41 -41
- package/zti18n-core/src/transform/transformVue.js +126 -126
- package/zti18n-core/src/transform/transformZeroToDi18n.js +105 -105
- package/zti18n-core/src/translate/google.js +6 -6
- package/zti18n-core/src/utils/constants.js +3 -3
- package/zti18n-core/src/utils/getIgnoreLines.js +14 -14
- package/zti18n-core/src/utils/isChinese.js +3 -3
- package/zti18n-core/src/utils/log.js +8 -8
- package/dist/dataModel-1fbaff40.js +0 -24
- package/dist/dataModel-6c68c88f.js +0 -26
- package/dist/dataModel-914b6226.js +0 -26
- package/dist/dataModel-b3629ef3.js +0 -26
- package/dist/reqUrl-22b880a4.js +0 -82
- package/dist/request-1e442d5d.js +0 -2982
- package/dist/request-4c29d6de.js +0 -2977
- package/dist/request-80d1ac80.js +0 -2992
- package/dist/request-986d7090.js +0 -2923
- package/dist/request-c0970aae.js +0 -2917
- package/dist/request-d1972b41.js +0 -2992
- package/dist/request-d8d72b87.js +0 -2982
- package/dist/request-f600ad7a.js +0 -2992
- package/dist/tools-16a7fb45.js +0 -2446
- package/dist/validate-18e52490.js +0 -249
- package/dist/validate-21164759.js +0 -260
- package/dist/validate-21b58a69.js +0 -260
- package/dist/validate-2de5a28f.js +0 -260
- package/dist/validate-ab47ebe9.js +0 -260
@@ -1,126 +1,126 @@
|
|
1
|
-
const compiler = require('vue-template-compiler');
|
2
|
-
const transformJs = require('./transformJs');
|
3
|
-
const transformPug = require('./transformPug');
|
4
|
-
const transformHtml = require('./transformHtml');
|
5
|
-
|
6
|
-
function openTag(sfcBlock) {
|
7
|
-
const { type, lang, src, scoped, module, attrs } = sfcBlock;
|
8
|
-
|
9
|
-
let tag = `<${type}`;
|
10
|
-
if (lang) tag += ` lang="${lang}"`;
|
11
|
-
if (src) tag += ` src="${src}"`;
|
12
|
-
if (scoped) tag += ' scoped';
|
13
|
-
if (module) {
|
14
|
-
if (typeof module === 'string') tag += ` module="${module}"`;
|
15
|
-
else tag += ' module';
|
16
|
-
}
|
17
|
-
for (let k in attrs) {
|
18
|
-
if (!['type', 'lang', 'src', 'scoped', 'module'].includes(k)) {
|
19
|
-
tag += ` ${k}="${attrs[k]}"`;
|
20
|
-
}
|
21
|
-
}
|
22
|
-
tag += '>';
|
23
|
-
|
24
|
-
return tag;
|
25
|
-
}
|
26
|
-
|
27
|
-
function closeTag(sfcBlock) {
|
28
|
-
return '</' + sfcBlock.type + '>';
|
29
|
-
}
|
30
|
-
|
31
|
-
function combineVue(template, script, sytles, customBlocks) {
|
32
|
-
return [template, script, ...sytles, ...customBlocks]
|
33
|
-
.map((sfc) =>
|
34
|
-
sfc ? `${openTag(sfc)}\n${sfc.content.trim()}\n${closeTag(sfc)}\n` : ''
|
35
|
-
)
|
36
|
-
.join('\n');
|
37
|
-
}
|
38
|
-
|
39
|
-
module.exports = function transformVue(source, localeInfo = {}, options = {}) {
|
40
|
-
const { allTranslated = {}, allUpdated = {}, allUsedKeys = [] } = localeInfo;
|
41
|
-
|
42
|
-
const {
|
43
|
-
primaryRegx = /[\u4e00-\u9fa5]/,
|
44
|
-
i18nObject = 'intl',
|
45
|
-
i18nMethod = '$t',
|
46
|
-
importCode = "import { intl } from 'di18n-vue';",
|
47
|
-
babelPresets = [],
|
48
|
-
babelPlugins = [],
|
49
|
-
ignoreComponents = [],
|
50
|
-
ignoreMethods = [],
|
51
|
-
pkMap = {},
|
52
|
-
} = options;
|
53
|
-
|
54
|
-
const sfc = compiler.parseComponent(source, {
|
55
|
-
pad: 'space',
|
56
|
-
deindent: false,
|
57
|
-
});
|
58
|
-
|
59
|
-
const { template, script, styles, customBlocks } = sfc;
|
60
|
-
let hasTouch = false;
|
61
|
-
|
62
|
-
if (template) {
|
63
|
-
const templateType = (template.lang || 'html').toLowerCase();
|
64
|
-
|
65
|
-
// transform template
|
66
|
-
if (['html', 'pug'].includes(templateType)) {
|
67
|
-
const transform = templateType === 'html' ? transformHtml : transformPug;
|
68
|
-
|
69
|
-
const ret = transform(
|
70
|
-
template.content,
|
71
|
-
{
|
72
|
-
allTranslated,
|
73
|
-
allUpdated,
|
74
|
-
allUsedKeys,
|
75
|
-
},
|
76
|
-
{
|
77
|
-
primaryRegx,
|
78
|
-
i18nObject: '',
|
79
|
-
i18nMethod,
|
80
|
-
importCode: '',
|
81
|
-
babelPresets,
|
82
|
-
babelPlugins,
|
83
|
-
ignoreComponents,
|
84
|
-
ignoreMethods,
|
85
|
-
pkMap,
|
86
|
-
}
|
87
|
-
);
|
88
|
-
|
89
|
-
template.content = ret.source;
|
90
|
-
hasTouch = ret.hasTouch;
|
91
|
-
} else {
|
92
|
-
console.warn(
|
93
|
-
`Unsupport type: ${templateType}, so the template is ignored`
|
94
|
-
);
|
95
|
-
}
|
96
|
-
}
|
97
|
-
|
98
|
-
// transform script
|
99
|
-
if (script) {
|
100
|
-
const ret = transformJs(
|
101
|
-
script.content,
|
102
|
-
{
|
103
|
-
allTranslated,
|
104
|
-
allUpdated,
|
105
|
-
allUsedKeys,
|
106
|
-
},
|
107
|
-
{
|
108
|
-
primaryRegx,
|
109
|
-
i18nObject,
|
110
|
-
i18nMethod,
|
111
|
-
importCode,
|
112
|
-
babelPresets,
|
113
|
-
babelPlugins,
|
114
|
-
ignoreComponents,
|
115
|
-
ignoreMethods,
|
116
|
-
}
|
117
|
-
);
|
118
|
-
|
119
|
-
script.content = ret.source;
|
120
|
-
hasTouch = hasTouch || ret.hasTouch;
|
121
|
-
}
|
122
|
-
|
123
|
-
const code = combineVue(template, script, styles, customBlocks);
|
124
|
-
|
125
|
-
return { source: code, hasTouch };
|
126
|
-
};
|
1
|
+
const compiler = require('vue-template-compiler');
|
2
|
+
const transformJs = require('./transformJs');
|
3
|
+
const transformPug = require('./transformPug');
|
4
|
+
const transformHtml = require('./transformHtml');
|
5
|
+
|
6
|
+
function openTag(sfcBlock) {
|
7
|
+
const { type, lang, src, scoped, module, attrs } = sfcBlock;
|
8
|
+
|
9
|
+
let tag = `<${type}`;
|
10
|
+
if (lang) tag += ` lang="${lang}"`;
|
11
|
+
if (src) tag += ` src="${src}"`;
|
12
|
+
if (scoped) tag += ' scoped';
|
13
|
+
if (module) {
|
14
|
+
if (typeof module === 'string') tag += ` module="${module}"`;
|
15
|
+
else tag += ' module';
|
16
|
+
}
|
17
|
+
for (let k in attrs) {
|
18
|
+
if (!['type', 'lang', 'src', 'scoped', 'module'].includes(k)) {
|
19
|
+
tag += ` ${k}="${attrs[k]}"`;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
tag += '>';
|
23
|
+
|
24
|
+
return tag;
|
25
|
+
}
|
26
|
+
|
27
|
+
function closeTag(sfcBlock) {
|
28
|
+
return '</' + sfcBlock.type + '>';
|
29
|
+
}
|
30
|
+
|
31
|
+
function combineVue(template, script, sytles, customBlocks) {
|
32
|
+
return [template, script, ...sytles, ...customBlocks]
|
33
|
+
.map((sfc) =>
|
34
|
+
sfc ? `${openTag(sfc)}\n${sfc.content.trim()}\n${closeTag(sfc)}\n` : ''
|
35
|
+
)
|
36
|
+
.join('\n');
|
37
|
+
}
|
38
|
+
|
39
|
+
module.exports = function transformVue(source, localeInfo = {}, options = {}) {
|
40
|
+
const { allTranslated = {}, allUpdated = {}, allUsedKeys = [] } = localeInfo;
|
41
|
+
|
42
|
+
const {
|
43
|
+
primaryRegx = /[\u4e00-\u9fa5]/,
|
44
|
+
i18nObject = 'intl',
|
45
|
+
i18nMethod = '$t',
|
46
|
+
importCode = "import { intl } from 'di18n-vue';",
|
47
|
+
babelPresets = [],
|
48
|
+
babelPlugins = [],
|
49
|
+
ignoreComponents = [],
|
50
|
+
ignoreMethods = [],
|
51
|
+
pkMap = {},
|
52
|
+
} = options;
|
53
|
+
|
54
|
+
const sfc = compiler.parseComponent(source, {
|
55
|
+
pad: 'space',
|
56
|
+
deindent: false,
|
57
|
+
});
|
58
|
+
|
59
|
+
const { template, script, styles, customBlocks } = sfc;
|
60
|
+
let hasTouch = false;
|
61
|
+
|
62
|
+
if (template) {
|
63
|
+
const templateType = (template.lang || 'html').toLowerCase();
|
64
|
+
|
65
|
+
// transform template
|
66
|
+
if (['html', 'pug'].includes(templateType)) {
|
67
|
+
const transform = templateType === 'html' ? transformHtml : transformPug;
|
68
|
+
|
69
|
+
const ret = transform(
|
70
|
+
template.content,
|
71
|
+
{
|
72
|
+
allTranslated,
|
73
|
+
allUpdated,
|
74
|
+
allUsedKeys,
|
75
|
+
},
|
76
|
+
{
|
77
|
+
primaryRegx,
|
78
|
+
i18nObject: '',
|
79
|
+
i18nMethod,
|
80
|
+
importCode: '',
|
81
|
+
babelPresets,
|
82
|
+
babelPlugins,
|
83
|
+
ignoreComponents,
|
84
|
+
ignoreMethods,
|
85
|
+
pkMap,
|
86
|
+
}
|
87
|
+
);
|
88
|
+
|
89
|
+
template.content = ret.source;
|
90
|
+
hasTouch = ret.hasTouch;
|
91
|
+
} else {
|
92
|
+
console.warn(
|
93
|
+
`Unsupport type: ${templateType}, so the template is ignored`
|
94
|
+
);
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
// transform script
|
99
|
+
if (script) {
|
100
|
+
const ret = transformJs(
|
101
|
+
script.content,
|
102
|
+
{
|
103
|
+
allTranslated,
|
104
|
+
allUpdated,
|
105
|
+
allUsedKeys,
|
106
|
+
},
|
107
|
+
{
|
108
|
+
primaryRegx,
|
109
|
+
i18nObject,
|
110
|
+
i18nMethod,
|
111
|
+
importCode,
|
112
|
+
babelPresets,
|
113
|
+
babelPlugins,
|
114
|
+
ignoreComponents,
|
115
|
+
ignoreMethods,
|
116
|
+
}
|
117
|
+
);
|
118
|
+
|
119
|
+
script.content = ret.source;
|
120
|
+
hasTouch = hasTouch || ret.hasTouch;
|
121
|
+
}
|
122
|
+
|
123
|
+
const code = combineVue(template, script, styles, customBlocks);
|
124
|
+
|
125
|
+
return { source: code, hasTouch };
|
126
|
+
};
|
@@ -1,105 +1,105 @@
|
|
1
|
-
const fs = require('fs');
|
2
|
-
const path = require('path');
|
3
|
-
const prettier = require('prettier');
|
4
|
-
const transformTs = require('./transformTs');
|
5
|
-
const transformJs = require('./transformJs');
|
6
|
-
const transformVue = require('./transformVue');
|
7
|
-
const log = require('../utils/log');
|
8
|
-
|
9
|
-
function transformReact(
|
10
|
-
codeFileInfo,
|
11
|
-
allTranslatedWord,
|
12
|
-
updatedTranslatedWord,
|
13
|
-
keysInUse,
|
14
|
-
option
|
15
|
-
) {
|
16
|
-
const { filePath, currentEntry, currentOutput, noImport } = codeFileInfo;
|
17
|
-
const sourceCode = fs.readFileSync(filePath, 'utf8');
|
18
|
-
const isTSX = ['.ts', '.tsx'].includes(path.extname(filePath));
|
19
|
-
|
20
|
-
const transform = isTSX ? transformTs : transformJs;
|
21
|
-
|
22
|
-
const { source, hasTouch } = transform(
|
23
|
-
sourceCode,
|
24
|
-
{
|
25
|
-
allTranslated: allTranslatedWord,
|
26
|
-
allUpdated: updatedTranslatedWord,
|
27
|
-
allUsedKeys: keysInUse,
|
28
|
-
},
|
29
|
-
option
|
30
|
-
);
|
31
|
-
|
32
|
-
if (!option.extractOnly && hasTouch && !noImport) {
|
33
|
-
let code = source;
|
34
|
-
if (option.prettier) {
|
35
|
-
const parser = isTSX ? 'typescript' : 'babel';
|
36
|
-
code = prettier.format(source, { ...option.prettier, parser });
|
37
|
-
}
|
38
|
-
|
39
|
-
const target = currentOutput
|
40
|
-
? filePath.replace(currentEntry, currentOutput)
|
41
|
-
: filePath;
|
42
|
-
fs.writeFileSync(target, code, { encoding: 'utf-8' });
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
function transformVueAdapter(
|
47
|
-
codeFileInfo,
|
48
|
-
allTranslatedWord,
|
49
|
-
updatedTranslatedWord,
|
50
|
-
keysInUse,
|
51
|
-
option
|
52
|
-
) {
|
53
|
-
const { filePath, currentEntry, currentOutput } = codeFileInfo;
|
54
|
-
const sourceCode = fs.readFileSync(filePath, 'utf8');
|
55
|
-
|
56
|
-
const { source, hasTouch } = transformVue(
|
57
|
-
sourceCode,
|
58
|
-
{
|
59
|
-
allTranslated: allTranslatedWord,
|
60
|
-
allUpdated: updatedTranslatedWord,
|
61
|
-
allUsedKeys: keysInUse,
|
62
|
-
},
|
63
|
-
option
|
64
|
-
);
|
65
|
-
|
66
|
-
if (!option.extractOnly && hasTouch) {
|
67
|
-
let code = source;
|
68
|
-
if (option.prettier) {
|
69
|
-
const parser = 'vue';
|
70
|
-
code = prettier.format(source, { ...option.prettier, parser });
|
71
|
-
}
|
72
|
-
|
73
|
-
const target = currentOutput
|
74
|
-
? filePath.replace(currentEntry, currentOutput)
|
75
|
-
: filePath;
|
76
|
-
fs.writeFileSync(target, code, { encoding: 'utf-8' });
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
/**
|
81
|
-
* 转换 react 和 普通 js 文件
|
82
|
-
* @param {object} codeFileInfo 源码文件信息
|
83
|
-
* @param {object} allTranslatedWord 现有的中文资源
|
84
|
-
* @param {object} updatedTranslatedWord 在远端做过中文文案修改的 key/value
|
85
|
-
* @param {array} keysInUse 使用中的key
|
86
|
-
* @param {object} option 透传过来的 di18n 配置
|
87
|
-
*/
|
88
|
-
module.exports = function transformZeroToDi18n(
|
89
|
-
codeFileInfo,
|
90
|
-
allTranslatedWord,
|
91
|
-
updatedTranslatedWord,
|
92
|
-
keysInUse,
|
93
|
-
option
|
94
|
-
) {
|
95
|
-
const { ext } = codeFileInfo;
|
96
|
-
const doTransform = ext === '.vue' ? transformVueAdapter : transformReact;
|
97
|
-
log.info(codeFileInfo.filePath);
|
98
|
-
doTransform(
|
99
|
-
codeFileInfo,
|
100
|
-
allTranslatedWord,
|
101
|
-
updatedTranslatedWord,
|
102
|
-
keysInUse,
|
103
|
-
option
|
104
|
-
);
|
105
|
-
};
|
1
|
+
const fs = require('fs');
|
2
|
+
const path = require('path');
|
3
|
+
const prettier = require('prettier');
|
4
|
+
const transformTs = require('./transformTs');
|
5
|
+
const transformJs = require('./transformJs');
|
6
|
+
const transformVue = require('./transformVue');
|
7
|
+
const log = require('../utils/log');
|
8
|
+
|
9
|
+
function transformReact(
|
10
|
+
codeFileInfo,
|
11
|
+
allTranslatedWord,
|
12
|
+
updatedTranslatedWord,
|
13
|
+
keysInUse,
|
14
|
+
option
|
15
|
+
) {
|
16
|
+
const { filePath, currentEntry, currentOutput, noImport } = codeFileInfo;
|
17
|
+
const sourceCode = fs.readFileSync(filePath, 'utf8');
|
18
|
+
const isTSX = ['.ts', '.tsx'].includes(path.extname(filePath));
|
19
|
+
|
20
|
+
const transform = isTSX ? transformTs : transformJs;
|
21
|
+
|
22
|
+
const { source, hasTouch } = transform(
|
23
|
+
sourceCode,
|
24
|
+
{
|
25
|
+
allTranslated: allTranslatedWord,
|
26
|
+
allUpdated: updatedTranslatedWord,
|
27
|
+
allUsedKeys: keysInUse,
|
28
|
+
},
|
29
|
+
option
|
30
|
+
);
|
31
|
+
|
32
|
+
if (!option.extractOnly && hasTouch && !noImport) {
|
33
|
+
let code = source;
|
34
|
+
if (option.prettier) {
|
35
|
+
const parser = isTSX ? 'typescript' : 'babel';
|
36
|
+
code = prettier.format(source, { ...option.prettier, parser });
|
37
|
+
}
|
38
|
+
|
39
|
+
const target = currentOutput
|
40
|
+
? filePath.replace(currentEntry, currentOutput)
|
41
|
+
: filePath;
|
42
|
+
fs.writeFileSync(target, code, { encoding: 'utf-8' });
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
function transformVueAdapter(
|
47
|
+
codeFileInfo,
|
48
|
+
allTranslatedWord,
|
49
|
+
updatedTranslatedWord,
|
50
|
+
keysInUse,
|
51
|
+
option
|
52
|
+
) {
|
53
|
+
const { filePath, currentEntry, currentOutput } = codeFileInfo;
|
54
|
+
const sourceCode = fs.readFileSync(filePath, 'utf8');
|
55
|
+
|
56
|
+
const { source, hasTouch } = transformVue(
|
57
|
+
sourceCode,
|
58
|
+
{
|
59
|
+
allTranslated: allTranslatedWord,
|
60
|
+
allUpdated: updatedTranslatedWord,
|
61
|
+
allUsedKeys: keysInUse,
|
62
|
+
},
|
63
|
+
option
|
64
|
+
);
|
65
|
+
|
66
|
+
if (!option.extractOnly && hasTouch) {
|
67
|
+
let code = source;
|
68
|
+
if (option.prettier) {
|
69
|
+
const parser = 'vue';
|
70
|
+
code = prettier.format(source, { ...option.prettier, parser });
|
71
|
+
}
|
72
|
+
|
73
|
+
const target = currentOutput
|
74
|
+
? filePath.replace(currentEntry, currentOutput)
|
75
|
+
: filePath;
|
76
|
+
fs.writeFileSync(target, code, { encoding: 'utf-8' });
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
* 转换 react 和 普通 js 文件
|
82
|
+
* @param {object} codeFileInfo 源码文件信息
|
83
|
+
* @param {object} allTranslatedWord 现有的中文资源
|
84
|
+
* @param {object} updatedTranslatedWord 在远端做过中文文案修改的 key/value
|
85
|
+
* @param {array} keysInUse 使用中的key
|
86
|
+
* @param {object} option 透传过来的 di18n 配置
|
87
|
+
*/
|
88
|
+
module.exports = function transformZeroToDi18n(
|
89
|
+
codeFileInfo,
|
90
|
+
allTranslatedWord,
|
91
|
+
updatedTranslatedWord,
|
92
|
+
keysInUse,
|
93
|
+
option
|
94
|
+
) {
|
95
|
+
const { ext } = codeFileInfo;
|
96
|
+
const doTransform = ext === '.vue' ? transformVueAdapter : transformReact;
|
97
|
+
log.info(codeFileInfo.filePath);
|
98
|
+
doTransform(
|
99
|
+
codeFileInfo,
|
100
|
+
allTranslatedWord,
|
101
|
+
updatedTranslatedWord,
|
102
|
+
keysInUse,
|
103
|
+
option
|
104
|
+
);
|
105
|
+
};
|
@@ -1,6 +1,6 @@
|
|
1
|
-
// https://github.com/matheuss/google-translate-api/issues/79#issuecomment-427841889
|
2
|
-
const googleTranslate = require('@vitalets/google-translate-api');
|
3
|
-
|
4
|
-
module.exports = function translateByGoogle(text, targetLang) {
|
5
|
-
return googleTranslate(text, { client: 'gtx', to: targetLang });
|
6
|
-
};
|
1
|
+
// https://github.com/matheuss/google-translate-api/issues/79#issuecomment-427841889
|
2
|
+
const googleTranslate = require('@vitalets/google-translate-api');
|
3
|
+
|
4
|
+
module.exports = function translateByGoogle(text, targetLang) {
|
5
|
+
return googleTranslate(text, { client: 'gtx', to: targetLang });
|
6
|
+
};
|
@@ -1,3 +1,3 @@
|
|
1
|
-
exports.REACT_JS = 'js';
|
2
|
-
exports.REACT_TS = 'ts';
|
3
|
-
exports.VUE = 'vue';
|
1
|
+
exports.REACT_JS = 'js';
|
2
|
+
exports.REACT_TS = 'ts';
|
3
|
+
exports.VUE = 'vue';
|
@@ -1,14 +1,14 @@
|
|
1
|
-
module.exports = function getIgnoreLines(tpl) {
|
2
|
-
// 仅支持 // di18n-disable 和 // di18n-enable 注释指令
|
3
|
-
const ignores = [];
|
4
|
-
let ignoring = false;
|
5
|
-
|
6
|
-
const lines = tpl.split(/\n|\r\n/g);
|
7
|
-
for (let i = 0; i < lines.length; i++) {
|
8
|
-
if (lines[i].includes('zti18n-disable')) ignoring = true;
|
9
|
-
if (lines[i].includes('zti18n-enable')) ignoring = false;
|
10
|
-
if (ignoring) ignores.push(i + 1);
|
11
|
-
}
|
12
|
-
|
13
|
-
return ignores;
|
14
|
-
};
|
1
|
+
module.exports = function getIgnoreLines(tpl) {
|
2
|
+
// 仅支持 // di18n-disable 和 // di18n-enable 注释指令
|
3
|
+
const ignores = [];
|
4
|
+
let ignoring = false;
|
5
|
+
|
6
|
+
const lines = tpl.split(/\n|\r\n/g);
|
7
|
+
for (let i = 0; i < lines.length; i++) {
|
8
|
+
if (lines[i].includes('zti18n-disable')) ignoring = true;
|
9
|
+
if (lines[i].includes('zti18n-enable')) ignoring = false;
|
10
|
+
if (ignoring) ignores.push(i + 1);
|
11
|
+
}
|
12
|
+
|
13
|
+
return ignores;
|
14
|
+
};
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module.exports = function isChinese(text) {
|
2
|
-
return /[\u4e00-\u9fa5]/.test(text);
|
3
|
-
};
|
1
|
+
module.exports = function isChinese(text) {
|
2
|
+
return /[\u4e00-\u9fa5]/.test(text);
|
3
|
+
};
|
@@ -1,8 +1,8 @@
|
|
1
|
-
const chalk = require('chalk');
|
2
|
-
|
3
|
-
module.exports = {
|
4
|
-
info: (msg) => console.log(chalk.cyan(msg)),
|
5
|
-
warning: (msg) => console.log(chalk.yellow(msg)),
|
6
|
-
success: (msg) => console.log(chalk.green(msg)),
|
7
|
-
error: (msg) => console.log(chalk.red(msg)),
|
8
|
-
};
|
1
|
+
const chalk = require('chalk');
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
info: (msg) => console.log(chalk.cyan(msg)),
|
5
|
+
warning: (msg) => console.log(chalk.yellow(msg)),
|
6
|
+
success: (msg) => console.log(chalk.green(msg)),
|
7
|
+
error: (msg) => console.log(chalk.red(msg)),
|
8
|
+
};
|
@@ -1,24 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @description 数据模型创建
|
3
|
-
*/
|
4
|
-
function createSuccessModel(data, message) {
|
5
|
-
return {
|
6
|
-
data: data,
|
7
|
-
message: message || '数据请求成功',
|
8
|
-
success: true,
|
9
|
-
};
|
10
|
-
}
|
11
|
-
function createErrorModel(message) {
|
12
|
-
return {
|
13
|
-
message: message || '数据请求失败',
|
14
|
-
success: false,
|
15
|
-
};
|
16
|
-
}
|
17
|
-
|
18
|
-
var dataModel = /*#__PURE__*/Object.freeze({
|
19
|
-
__proto__: null,
|
20
|
-
createSuccessModel: createSuccessModel,
|
21
|
-
createErrorModel: createErrorModel
|
22
|
-
});
|
23
|
-
|
24
|
-
export { createErrorModel as a, createSuccessModel as c, dataModel as d };
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import instance from './i18next.js';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* @description 数据模型创建
|
5
|
-
*/
|
6
|
-
function createSuccessModel(data, message) {
|
7
|
-
return {
|
8
|
-
data: data,
|
9
|
-
message: message || instance.t('数据请求成功'),
|
10
|
-
success: true,
|
11
|
-
};
|
12
|
-
}
|
13
|
-
function createErrorModel(message) {
|
14
|
-
return {
|
15
|
-
message: message || instance.t('数据请求失败'),
|
16
|
-
success: false,
|
17
|
-
};
|
18
|
-
}
|
19
|
-
|
20
|
-
var dataModel = /*#__PURE__*/Object.freeze({
|
21
|
-
__proto__: null,
|
22
|
-
createSuccessModel: createSuccessModel,
|
23
|
-
createErrorModel: createErrorModel
|
24
|
-
});
|
25
|
-
|
26
|
-
export { createErrorModel as a, createSuccessModel as c, dataModel as d };
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import instance from './i18next.js';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* @description 数据模型创建
|
5
|
-
*/
|
6
|
-
function createSuccessModel(data, message) {
|
7
|
-
return {
|
8
|
-
data: data,
|
9
|
-
message: message || instance.t('数据请求成功'),
|
10
|
-
success: true,
|
11
|
-
};
|
12
|
-
}
|
13
|
-
function createErrorModel(message) {
|
14
|
-
return {
|
15
|
-
message: message || instance.t('数据请求失败'),
|
16
|
-
success: false,
|
17
|
-
};
|
18
|
-
}
|
19
|
-
|
20
|
-
var dataModel = /*#__PURE__*/Object.freeze({
|
21
|
-
__proto__: null,
|
22
|
-
createSuccessModel: createSuccessModel,
|
23
|
-
createErrorModel: createErrorModel
|
24
|
-
});
|
25
|
-
|
26
|
-
export { createErrorModel as a, createSuccessModel as c, dataModel as d };
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import instance from './i18next.js';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* @description 数据模型创建
|
5
|
-
*/
|
6
|
-
function createSuccessModel(data, message) {
|
7
|
-
return {
|
8
|
-
data: data,
|
9
|
-
message: message || instance.t('数据请求成功'),
|
10
|
-
success: true,
|
11
|
-
};
|
12
|
-
}
|
13
|
-
function createErrorModel(message) {
|
14
|
-
return {
|
15
|
-
message: message || instance.t('数据请求失败'),
|
16
|
-
success: false,
|
17
|
-
};
|
18
|
-
}
|
19
|
-
|
20
|
-
var dataModel = /*#__PURE__*/Object.freeze({
|
21
|
-
__proto__: null,
|
22
|
-
createSuccessModel: createSuccessModel,
|
23
|
-
createErrorModel: createErrorModel
|
24
|
-
});
|
25
|
-
|
26
|
-
export { createErrorModel as a, createSuccessModel as c, dataModel as d };
|