ztxkutils 2.10.66-20 → 2.10.66-22

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.
Files changed (83) hide show
  1. package/dist/fileOperation.js +7 -7
  2. package/package.json +1 -1
  3. package/zti18n-cli/bin/index.js +3 -3
  4. package/zti18n-cli/index.js +23 -23
  5. package/zti18n-cli/src/command/convert.js +17 -17
  6. package/zti18n-cli/src/command/convert2.js +35 -35
  7. package/zti18n-cli/src/command/initFileConf.js +133 -133
  8. package/zti18n-cli/src/command/publish.js +24 -24
  9. package/zti18n-cli/src/conf/BaseConf.js +21 -21
  10. package/zti18n-cli/src/conf/FileConf.js +116 -116
  11. package/zti18n-cli/src/index.js +75 -75
  12. package/zti18n-cli/src/translate/google.js +6 -6
  13. package/zti18n-cli/src/utils/isChinese.js +3 -3
  14. package/zti18n-cli/src/utils/log.js +8 -8
  15. package/zti18n-cli/src/utils/mergeOptions.js +45 -45
  16. package/zti18n-cli/src/utils/reactOptions.js +73 -73
  17. package/zti18n-cli/src/utils/vueOptions.js +69 -69
  18. package/zti18n-core/index.js +1 -1
  19. package/zti18n-core/src/index.js +5 -5
  20. package/zti18n-core/src/plugin/reactIntlToReactIntlUniversal.js +224 -224
  21. package/zti18n-core/src/plugin/reactIntlUniversalToDi18n.js +64 -64
  22. package/zti18n-core/src/transform/defaultPkMap.js +79 -79
  23. package/zti18n-core/src/transform/transformHtml.js +271 -271
  24. package/zti18n-core/src/transform/transformJs.js +3 -3
  25. package/zti18n-core/src/transform/transformPug.js +272 -272
  26. package/zti18n-core/src/transform/transformReactIntlToReactIntlUniversal.js +96 -96
  27. package/zti18n-core/src/transform/transformReactIntlUniveralToDi18n.js +90 -90
  28. package/zti18n-core/src/transform/transformToDi18n.js +22 -22
  29. package/zti18n-core/src/transform/transformTs.js +41 -41
  30. package/zti18n-core/src/transform/transformVue.js +126 -126
  31. package/zti18n-core/src/translate/google.js +6 -6
  32. package/zti18n-core/src/utils/constants.js +3 -3
  33. package/zti18n-core/src/utils/getIgnoreLines.js +14 -14
  34. package/zti18n-core/src/utils/isChinese.js +3 -3
  35. package/zti18n-core/src/utils/log.js +8 -8
  36. package/dist/authority-e6bde99f.js +0 -423
  37. package/dist/reqUrl-22b880a4.js +0 -82
  38. package/dist/reqUrl-3792afcd.js +0 -82
  39. package/dist/reqUrl-787dd9e5.js +0 -82
  40. package/dist/request-0cc024b1.js +0 -2917
  41. package/dist/request-3c906c2d.js +0 -2913
  42. package/dist/request-87d93572.js +0 -2974
  43. package/dist/request-ba8abf99.js +0 -2902
  44. package/dist/request-ef290b9a.js +0 -2838
  45. package/dist/tools-09a4d620.js +0 -2445
  46. package/dist/tools-0ca888cd.js +0 -2473
  47. package/dist/tools-16a7fb45.js +0 -2446
  48. package/dist/validate-6e735536.js +0 -79
  49. package/dist/zti18n-cli/bin/index.d.ts +0 -2
  50. package/dist/zti18n-cli/index.d.ts +0 -1
  51. package/dist/zti18n-cli/src/command/collect.d.ts +0 -2
  52. package/dist/zti18n-cli/src/command/convert.d.ts +0 -2
  53. package/dist/zti18n-cli/src/command/convert2.d.ts +0 -2
  54. package/dist/zti18n-cli/src/command/initFileConf.d.ts +0 -2
  55. package/dist/zti18n-cli/src/command/publish.d.ts +0 -2
  56. package/dist/zti18n-cli/src/conf/BaseConf.d.ts +0 -8
  57. package/dist/zti18n-cli/src/conf/FileConf.d.ts +0 -6
  58. package/dist/zti18n-cli/src/index.d.ts +0 -1
  59. package/dist/zti18n-cli/src/translate/google.d.ts +0 -2
  60. package/dist/zti18n-cli/src/utils/isChinese.d.ts +0 -2
  61. package/dist/zti18n-cli/src/utils/log.d.ts +0 -4
  62. package/dist/zti18n-cli/src/utils/mergeOptions.d.ts +0 -24
  63. package/dist/zti18n-cli/src/utils/reactOptions.d.ts +0 -21
  64. package/dist/zti18n-cli/src/utils/vueOptions.d.ts +0 -17
  65. package/dist/zti18n-core/index.d.ts +0 -2
  66. package/dist/zti18n-core/src/index.d.ts +0 -8
  67. package/dist/zti18n-core/src/plugin/reactIntlToReactIntlUniversal.d.ts +0 -19
  68. package/dist/zti18n-core/src/plugin/reactIntlUniversalToDi18n.d.ts +0 -9
  69. package/dist/zti18n-core/src/transform/defaultPkMap.d.ts +0 -75
  70. package/dist/zti18n-core/src/transform/transformHtml.d.ts +0 -5
  71. package/dist/zti18n-core/src/transform/transformJs.d.ts +0 -5
  72. package/dist/zti18n-core/src/transform/transformPug.d.ts +0 -5
  73. package/dist/zti18n-core/src/transform/transformReactIntlToReactIntlUniversal.d.ts +0 -2
  74. package/dist/zti18n-core/src/transform/transformReactIntlUniveralToDi18n.d.ts +0 -2
  75. package/dist/zti18n-core/src/transform/transformToDi18n.d.ts +0 -5
  76. package/dist/zti18n-core/src/transform/transformTs.d.ts +0 -5
  77. package/dist/zti18n-core/src/transform/transformVue.d.ts +0 -5
  78. package/dist/zti18n-core/src/transform/transformZeroToDi18n.d.ts +0 -2
  79. package/dist/zti18n-core/src/translate/google.d.ts +0 -2
  80. package/dist/zti18n-core/src/utils/constants.d.ts +0 -3
  81. package/dist/zti18n-core/src/utils/getIgnoreLines.d.ts +0 -2
  82. package/dist/zti18n-core/src/utils/isChinese.d.ts +0 -2
  83. package/dist/zti18n-core/src/utils/log.d.ts +0 -4
@@ -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,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('di18n-disable')) ignoring = true;
9
- if (lines[i].includes('di18n-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
+ };