@lingual/i18n-check 0.8.1 → 0.8.3
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 +10 -18
- package/dist/bin/index.js +73 -99
- package/dist/bin/index.test.js +560 -472
- package/dist/errorReporters.d.ts +5 -7
- package/dist/errorReporters.js +67 -81
- package/dist/errorReporters.test.d.ts +1 -0
- package/dist/errorReporters.test.js +165 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +78 -54
- package/dist/types.d.ts +5 -0
- package/dist/utils/findInvalidTranslations.d.ts +4 -7
- package/dist/utils/findInvalidTranslations.js +23 -22
- package/dist/utils/findInvalidTranslations.test.js +30 -30
- package/dist/utils/findInvalidi18nTranslations.d.ts +4 -4
- package/dist/utils/findInvalidi18nTranslations.js +36 -36
- package/dist/utils/findInvalidi18nTranslations.test.js +72 -72
- package/dist/utils/findMissingKeys.d.ts +2 -2
- package/dist/utils/findMissingKeys.js +3 -3
- package/dist/utils/findMissingKeys.test.js +20 -20
- package/dist/utils/flattenTranslations.d.ts +1 -1
- package/dist/utils/flattenTranslations.js +4 -4
- package/dist/utils/flattenTranslations.test.js +13 -13
- package/dist/utils/i18NextParser.d.ts +6 -6
- package/dist/utils/i18NextParser.js +29 -29
- package/dist/utils/i18NextParser.test.js +104 -104
- package/dist/utils/nextIntlSrcParser.js +11 -11
- package/dist/utils/nextIntlSrcParser.test.js +206 -206
- package/package.json +14 -4
package/dist/bin/index.test.js
CHANGED
|
@@ -1,299 +1,358 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const child_process_1 = require("child_process");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const errorReporters_1 = require("../errorReporters");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
function tr(file) {
|
|
10
|
+
return path_1.default.join('translations', file);
|
|
11
|
+
}
|
|
12
|
+
function multiFiles(file) {
|
|
13
|
+
return path_1.default.join('translations/multipleFilesFolderExample', file);
|
|
14
|
+
}
|
|
15
|
+
function multiFolders(file) {
|
|
16
|
+
return path_1.default.join('translations/multipleFoldersExample', file);
|
|
17
|
+
}
|
|
18
|
+
function codeEx(file) {
|
|
19
|
+
return path_1.default.join('translations/codeExamples', file);
|
|
20
|
+
}
|
|
21
|
+
function ymlMultiFolders(file) {
|
|
22
|
+
return path_1.default.join('translations/yaml/multipleFoldersExample', file);
|
|
23
|
+
}
|
|
24
|
+
function execAsync(cmd) {
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
(0, child_process_1.exec)(cmd, (error, stdout) => {
|
|
27
|
+
resolve(stdout);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
describe('CLI', () => {
|
|
32
|
+
describe('JSON', () => {
|
|
33
|
+
it('should return the missing keys for single folder translations', async () => {
|
|
34
|
+
const stdout = await execAsync('node dist/bin/index.js -s en-US -l translations/flattenExamples');
|
|
35
|
+
const result = stdout.split('Done')[0];
|
|
36
|
+
const filePath = tr('flattenExamples/de-de.json');
|
|
37
|
+
const table = (0, errorReporters_1.formatTable)([
|
|
38
|
+
[['file', 'key']],
|
|
39
|
+
[
|
|
40
|
+
[filePath, 'other.nested.three'],
|
|
41
|
+
[filePath, 'other.nested.deep.more.final'],
|
|
42
|
+
],
|
|
43
|
+
]);
|
|
44
|
+
expect(result).toEqual(`i18n translations checker
|
|
10
45
|
Source: en-US
|
|
11
46
|
|
|
12
47
|
Found missing keys!
|
|
13
|
-
|
|
14
|
-
│ file │ key │
|
|
15
|
-
├───────────────────────────────────────────┼────────────────────────────────┤
|
|
16
|
-
│ translations/flattenExamples/de-de.json │ other.nested.three │
|
|
17
|
-
│ translations/flattenExamples/de-de.json │ other.nested.deep.more.final │
|
|
18
|
-
└───────────────────────────────────────────┴────────────────────────────────┘
|
|
48
|
+
${table}
|
|
19
49
|
|
|
20
50
|
No invalid translations found!
|
|
21
51
|
|
|
22
52
|
`);
|
|
23
|
-
done();
|
|
24
|
-
});
|
|
25
53
|
});
|
|
26
|
-
it(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
54
|
+
it('should return the missing/invalid keys for folder per locale with single file', async () => {
|
|
55
|
+
const stdout = await execAsync('node dist/bin/index.js -l translations/folderExample/ -s en-US');
|
|
56
|
+
const result = stdout.split('Done')[0];
|
|
57
|
+
const missingKeysTable = (0, errorReporters_1.formatTable)([
|
|
58
|
+
[['file', 'key']],
|
|
59
|
+
[[tr('folderExample/de-DE/index.json'), 'message.text-format']],
|
|
60
|
+
]);
|
|
61
|
+
const invalidKeysTable = (0, errorReporters_1.formatTable)([
|
|
62
|
+
[['info', 'result']],
|
|
63
|
+
[
|
|
64
|
+
['file', tr('folderExample/de-DE/index.json')],
|
|
65
|
+
['key', 'message.select'],
|
|
66
|
+
[
|
|
67
|
+
'msg',
|
|
68
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
69
|
+
],
|
|
70
|
+
],
|
|
71
|
+
]);
|
|
72
|
+
expect(result).toEqual(`i18n translations checker
|
|
30
73
|
Source: en-US
|
|
31
74
|
|
|
32
75
|
Found missing keys!
|
|
33
|
-
|
|
34
|
-
│ file │ key │
|
|
35
|
-
├───────────────────────────────────────────────┼───────────────────────┤
|
|
36
|
-
│ translations/folderExample/de-DE/index.json │ message.text-format │
|
|
37
|
-
└───────────────────────────────────────────────┴───────────────────────┘
|
|
76
|
+
${missingKeysTable}
|
|
38
77
|
|
|
39
78
|
Found invalid keys!
|
|
40
|
-
|
|
41
|
-
│ info │ result │
|
|
42
|
-
├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
43
|
-
│ file │ translations/folderExample/de-DE/index.json │
|
|
44
|
-
│ key │ message.select │
|
|
45
|
-
│ msg │ Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element... │
|
|
46
|
-
└────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
|
79
|
+
${invalidKeysTable}
|
|
47
80
|
|
|
48
81
|
`);
|
|
49
|
-
done();
|
|
50
|
-
});
|
|
51
82
|
});
|
|
52
|
-
it(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
83
|
+
it('should return the missing/invalid keys for folder per locale with multiple files', async () => {
|
|
84
|
+
const stdout = await execAsync('node dist/bin/index.js -l translations/multipleFilesFolderExample/ -s en-US');
|
|
85
|
+
const missingKeysTable = (0, errorReporters_1.formatTable)([
|
|
86
|
+
[['file', 'key']],
|
|
87
|
+
[
|
|
88
|
+
[multiFiles('de-DE/one.json'), 'message.text-format'],
|
|
89
|
+
[multiFiles('de-DE/two.json'), 'test.drive.four'],
|
|
90
|
+
],
|
|
91
|
+
]);
|
|
92
|
+
const invalidKeysTable = (0, errorReporters_1.formatTable)([
|
|
93
|
+
[['info', 'result']],
|
|
94
|
+
[
|
|
95
|
+
['file', multiFiles('de-DE/one.json')],
|
|
96
|
+
['key', 'message.select'],
|
|
97
|
+
[
|
|
98
|
+
'msg',
|
|
99
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
100
|
+
],
|
|
101
|
+
],
|
|
102
|
+
[
|
|
103
|
+
['file', multiFiles('de-DE/three.json')],
|
|
104
|
+
['key', 'multipleVariables'],
|
|
105
|
+
['msg', 'Expected argument to contain "user" but received "name" '],
|
|
106
|
+
],
|
|
107
|
+
]);
|
|
108
|
+
const result = stdout.split('Done')[0];
|
|
109
|
+
expect(result).toEqual(`i18n translations checker
|
|
56
110
|
Source: en-US
|
|
57
111
|
|
|
58
112
|
Found missing keys!
|
|
59
|
-
|
|
60
|
-
│ file │ key │
|
|
61
|
-
├──────────────────────────────────────────────────────────┼───────────────────────┤
|
|
62
|
-
│ translations/multipleFilesFolderExample/de-DE/one.json │ message.text-format │
|
|
63
|
-
│ translations/multipleFilesFolderExample/de-DE/two.json │ test.drive.four │
|
|
64
|
-
└──────────────────────────────────────────────────────────┴───────────────────────┘
|
|
113
|
+
${missingKeysTable}
|
|
65
114
|
|
|
66
115
|
Found invalid keys!
|
|
67
|
-
|
|
68
|
-
│ info │ result │
|
|
69
|
-
├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
70
|
-
│ file │ translations/multipleFilesFolderExample/de-DE/one.json │
|
|
71
|
-
│ key │ message.select │
|
|
72
|
-
│ msg │ Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element... │
|
|
73
|
-
├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
74
|
-
│ file │ translations/multipleFilesFolderExample/de-DE/three.json │
|
|
75
|
-
│ key │ multipleVariables │
|
|
76
|
-
│ msg │ Expected argument to contain "user" but received "name" │
|
|
77
|
-
└────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
|
116
|
+
${invalidKeysTable}
|
|
78
117
|
|
|
79
118
|
`);
|
|
80
|
-
done();
|
|
81
|
-
});
|
|
82
119
|
});
|
|
83
|
-
it(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
120
|
+
it('should return the missing/invalid keys for folder containing multiple locale folders', async () => {
|
|
121
|
+
const stdout = await execAsync('node dist/bin/index.js -l translations/multipleFoldersExample -s en-US');
|
|
122
|
+
const result = stdout.split('Done')[0];
|
|
123
|
+
expect(result).toEqual(`i18n translations checker
|
|
87
124
|
Source: en-US
|
|
88
125
|
|
|
89
126
|
Found missing keys!
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
127
|
+
${(0, errorReporters_1.formatTable)([
|
|
128
|
+
[['file', 'key']],
|
|
129
|
+
[
|
|
130
|
+
[multiFolders('spaceOne/locales/de-DE/one.json'), 'message.text-format'],
|
|
131
|
+
[multiFolders('spaceOne/locales/de-DE/two.json'), 'test.drive.four'],
|
|
132
|
+
[multiFolders('spaceTwo/locales/de-DE/one.json'), 'message.plural'],
|
|
133
|
+
[multiFolders('spaceTwo/locales/de-DE/two.json'), 'test.drive.two'],
|
|
134
|
+
],
|
|
135
|
+
])}
|
|
98
136
|
|
|
99
137
|
Found invalid keys!
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
138
|
+
${(0, errorReporters_1.formatTable)([
|
|
139
|
+
[['info', 'result']],
|
|
140
|
+
[
|
|
141
|
+
['file', multiFolders('spaceOne/locales/de-DE/one.json')],
|
|
142
|
+
['key', 'message.select'],
|
|
143
|
+
[
|
|
144
|
+
'msg',
|
|
145
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
146
|
+
],
|
|
147
|
+
],
|
|
148
|
+
[
|
|
149
|
+
['file', multiFolders('spaceOne/locales/de-DE/three.json')],
|
|
150
|
+
['key', 'multipleVariables'],
|
|
151
|
+
['msg', 'Expected argument to contain "user" but received "name"'],
|
|
152
|
+
],
|
|
153
|
+
[
|
|
154
|
+
['file', multiFolders('spaceTwo/locales/de-DE/one.json')],
|
|
155
|
+
['key', 'message.text-format'],
|
|
156
|
+
[
|
|
157
|
+
'msg',
|
|
158
|
+
'Expected element of type "tag" but received "number", Unexpected tag element',
|
|
159
|
+
],
|
|
160
|
+
],
|
|
161
|
+
[
|
|
162
|
+
['file', multiFolders('spaceTwo/locales/de-DE/three.json')],
|
|
163
|
+
['key', 'numberFormat'],
|
|
164
|
+
['msg', 'Missing element number'],
|
|
165
|
+
],
|
|
166
|
+
])}
|
|
119
167
|
|
|
120
168
|
`);
|
|
121
|
-
done();
|
|
122
|
-
});
|
|
123
169
|
});
|
|
124
|
-
it(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
170
|
+
it('should return the missing/invalid keys for multiple locale folders', async () => {
|
|
171
|
+
const stdout = await execAsync('node dist/bin/index.js -l translations/multipleFoldersExample/spaceOne translations/multipleFoldersExample/spaceTwo -s en-US');
|
|
172
|
+
const result = stdout.split('Done')[0];
|
|
173
|
+
expect(result).toEqual(`i18n translations checker
|
|
128
174
|
Source: en-US
|
|
129
175
|
|
|
130
176
|
Found missing keys!
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
177
|
+
${(0, errorReporters_1.formatTable)([
|
|
178
|
+
[['file', 'key']],
|
|
179
|
+
[
|
|
180
|
+
[multiFolders('spaceOne/locales/de-DE/one.json'), 'message.text-format'],
|
|
181
|
+
[multiFolders('spaceOne/locales/de-DE/two.json'), 'test.drive.four'],
|
|
182
|
+
[multiFolders('spaceTwo/locales/de-DE/one.json'), 'message.plural'],
|
|
183
|
+
[multiFolders('spaceTwo/locales/de-DE/two.json'), 'test.drive.two'],
|
|
184
|
+
],
|
|
185
|
+
])}
|
|
139
186
|
|
|
140
187
|
Found invalid keys!
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
188
|
+
${(0, errorReporters_1.formatTable)([
|
|
189
|
+
[['info', 'result']],
|
|
190
|
+
[
|
|
191
|
+
['file', multiFolders('spaceOne/locales/de-DE/one.json')],
|
|
192
|
+
['key', 'message.select'],
|
|
193
|
+
[
|
|
194
|
+
'msg',
|
|
195
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
196
|
+
],
|
|
197
|
+
],
|
|
198
|
+
[
|
|
199
|
+
['file', multiFolders('spaceOne/locales/de-DE/three.json')],
|
|
200
|
+
['key', 'multipleVariables'],
|
|
201
|
+
['msg', 'Expected argument to contain "user" but received "name"'],
|
|
202
|
+
],
|
|
203
|
+
[
|
|
204
|
+
['file', multiFolders('spaceTwo/locales/de-DE/one.json')],
|
|
205
|
+
['key', 'message.text-format'],
|
|
206
|
+
[
|
|
207
|
+
'msg',
|
|
208
|
+
'Expected element of type "tag" but received "number", Unexpected tag element',
|
|
209
|
+
],
|
|
210
|
+
],
|
|
211
|
+
[
|
|
212
|
+
['file', multiFolders('spaceTwo/locales/de-DE/three.json')],
|
|
213
|
+
['key', 'numberFormat'],
|
|
214
|
+
['msg', 'Missing element number'],
|
|
215
|
+
],
|
|
216
|
+
])}
|
|
160
217
|
|
|
161
218
|
`);
|
|
162
|
-
done();
|
|
163
|
-
});
|
|
164
219
|
});
|
|
165
|
-
it(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
220
|
+
it('should return the missing/invalid keys for all files in the provided locale folders', async () => {
|
|
221
|
+
const stdout = await execAsync('node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples');
|
|
222
|
+
const result = stdout.split('Done')[0];
|
|
223
|
+
expect(result).toEqual(`i18n translations checker
|
|
169
224
|
Source: en-US
|
|
170
225
|
|
|
171
226
|
Found missing keys!
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
227
|
+
${(0, errorReporters_1.formatTable)([
|
|
228
|
+
[['file', 'key']],
|
|
229
|
+
[
|
|
230
|
+
[tr('flattenExamples/de-de.json'), 'other.nested.three'],
|
|
231
|
+
[tr('flattenExamples/de-de.json'), 'other.nested.deep.more.final'],
|
|
232
|
+
[tr('messageExamples/de-de.json'), 'richText'],
|
|
233
|
+
[tr('messageExamples/de-de.json'), 'yo'],
|
|
234
|
+
[tr('messageExamples/de-de.json'), 'nesting1'],
|
|
235
|
+
[tr('messageExamples/de-de.json'), 'nesting2'],
|
|
236
|
+
[tr('messageExamples/de-de.json'), 'nesting3'],
|
|
237
|
+
[tr('messageExamples/de-de.json'), 'key1'],
|
|
238
|
+
],
|
|
239
|
+
])}
|
|
184
240
|
|
|
185
241
|
Found invalid keys!
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
242
|
+
${(0, errorReporters_1.formatTable)([
|
|
243
|
+
[['info', 'result']],
|
|
244
|
+
[
|
|
245
|
+
['file', tr('messageExamples/de-de.json')],
|
|
246
|
+
['key', 'multipleVariables'],
|
|
247
|
+
['msg', 'Unexpected date element'],
|
|
248
|
+
],
|
|
249
|
+
])}
|
|
193
250
|
|
|
194
251
|
`);
|
|
195
|
-
done();
|
|
196
|
-
});
|
|
197
252
|
});
|
|
198
|
-
it(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
253
|
+
it('should return the missing/invalid keys for all files with source matching folder and source matching file', async () => {
|
|
254
|
+
const stdout = await execAsync('node dist/bin/index.js -l translations/multipleFilesFolderExample translations/flattenExamples -s en-US');
|
|
255
|
+
const result = stdout.split('Done')[0];
|
|
256
|
+
expect(result).toEqual(`i18n translations checker
|
|
202
257
|
Source: en-US
|
|
203
258
|
|
|
204
259
|
Found missing keys!
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
260
|
+
${(0, errorReporters_1.formatTable)([
|
|
261
|
+
[['file', 'key']],
|
|
262
|
+
[
|
|
263
|
+
[tr('flattenExamples/de-de.json'), 'other.nested.three'],
|
|
264
|
+
[tr('flattenExamples/de-de.json'), 'other.nested.deep.more.final'],
|
|
265
|
+
[multiFiles('de-DE/one.json'), 'message.text-format'],
|
|
266
|
+
[multiFiles('de-DE/two.json'), 'test.drive.four'],
|
|
267
|
+
],
|
|
268
|
+
])}
|
|
213
269
|
|
|
214
270
|
Found invalid keys!
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
271
|
+
${(0, errorReporters_1.formatTable)([
|
|
272
|
+
[['info', 'result']],
|
|
273
|
+
[
|
|
274
|
+
['file', multiFiles('de-DE/one.json')],
|
|
275
|
+
['key', 'message.select'],
|
|
276
|
+
[
|
|
277
|
+
'msg',
|
|
278
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
279
|
+
],
|
|
280
|
+
],
|
|
281
|
+
[
|
|
282
|
+
['file', multiFiles('de-DE/three.json')],
|
|
283
|
+
['key', 'multipleVariables'],
|
|
284
|
+
['msg', 'Expected argument to contain "user" but received "name"'],
|
|
285
|
+
],
|
|
286
|
+
])}
|
|
226
287
|
|
|
227
288
|
`);
|
|
228
|
-
done();
|
|
229
|
-
});
|
|
230
289
|
});
|
|
231
|
-
it(
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
290
|
+
it('should ignore the excluded file', async () => {
|
|
291
|
+
const stdout = await execAsync('node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples --exclude translations/flattenExamples/de-de.json');
|
|
292
|
+
const result = stdout.split('Done')[0];
|
|
293
|
+
expect(result).toEqual(`i18n translations checker
|
|
235
294
|
Source: en-US
|
|
236
295
|
|
|
237
296
|
Found missing keys!
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
297
|
+
${(0, errorReporters_1.formatTable)([
|
|
298
|
+
[['file', 'key']],
|
|
299
|
+
[
|
|
300
|
+
[tr('messageExamples/de-de.json'), 'richText'],
|
|
301
|
+
[tr('messageExamples/de-de.json'), 'yo'],
|
|
302
|
+
[tr('messageExamples/de-de.json'), 'nesting1'],
|
|
303
|
+
[tr('messageExamples/de-de.json'), 'nesting2'],
|
|
304
|
+
[tr('messageExamples/de-de.json'), 'nesting3'],
|
|
305
|
+
[tr('messageExamples/de-de.json'), 'key1'],
|
|
306
|
+
],
|
|
307
|
+
])}
|
|
248
308
|
|
|
249
309
|
Found invalid keys!
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
310
|
+
${(0, errorReporters_1.formatTable)([
|
|
311
|
+
[['info', 'result']],
|
|
312
|
+
[
|
|
313
|
+
['file', tr('messageExamples/de-de.json')],
|
|
314
|
+
['key', 'multipleVariables'],
|
|
315
|
+
['msg', 'Unexpected date element'],
|
|
316
|
+
],
|
|
317
|
+
])}
|
|
257
318
|
|
|
258
319
|
`);
|
|
259
|
-
done();
|
|
260
|
-
});
|
|
261
320
|
});
|
|
262
|
-
it(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
321
|
+
it('should ignore the excluded folder', async () => {
|
|
322
|
+
const stdout = await execAsync('node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples --exclude translations/flattenExamples/*');
|
|
323
|
+
const result = stdout.split('Done')[0];
|
|
324
|
+
expect(result).toEqual(`i18n translations checker
|
|
266
325
|
Source: en-US
|
|
267
326
|
|
|
268
327
|
Found missing keys!
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
328
|
+
${(0, errorReporters_1.formatTable)([
|
|
329
|
+
[['file', 'key']],
|
|
330
|
+
[
|
|
331
|
+
[tr('messageExamples/de-de.json'), 'richText'],
|
|
332
|
+
[tr('messageExamples/de-de.json'), 'yo'],
|
|
333
|
+
[tr('messageExamples/de-de.json'), 'nesting1'],
|
|
334
|
+
[tr('messageExamples/de-de.json'), 'nesting2'],
|
|
335
|
+
[tr('messageExamples/de-de.json'), 'nesting3'],
|
|
336
|
+
[tr('messageExamples/de-de.json'), 'key1'],
|
|
337
|
+
],
|
|
338
|
+
])}
|
|
279
339
|
|
|
280
340
|
Found invalid keys!
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
341
|
+
${(0, errorReporters_1.formatTable)([
|
|
342
|
+
[['info', 'result']],
|
|
343
|
+
[
|
|
344
|
+
['file', tr('messageExamples/de-de.json')],
|
|
345
|
+
['key', 'multipleVariables'],
|
|
346
|
+
['msg', 'Unexpected date element'],
|
|
347
|
+
],
|
|
348
|
+
])}
|
|
288
349
|
|
|
289
350
|
`);
|
|
290
|
-
done();
|
|
291
|
-
});
|
|
292
351
|
});
|
|
293
|
-
it(
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
352
|
+
it('should ignore the excluded multiple files', async () => {
|
|
353
|
+
const stdout = await execAsync('node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples --exclude translations/flattenExamples/de-de.json translations/messageExamples/de-de.json');
|
|
354
|
+
const result = stdout.split('Done')[0];
|
|
355
|
+
expect(result).toEqual(`i18n translations checker
|
|
297
356
|
Source: en-US
|
|
298
357
|
|
|
299
358
|
No missing keys found!
|
|
@@ -301,13 +360,11 @@ No missing keys found!
|
|
|
301
360
|
No invalid translations found!
|
|
302
361
|
|
|
303
362
|
`);
|
|
304
|
-
done();
|
|
305
|
-
});
|
|
306
363
|
});
|
|
307
|
-
it(
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
364
|
+
it('should find unused and undefined keys for react-i18next applications', async () => {
|
|
365
|
+
const stdout = await execAsync('node dist/bin/index.js --source en --locales translations/codeExamples/reacti18next/locales -f i18next -u translations/codeExamples/reacti18next/src --parser-component-functions WrappedTransComponent');
|
|
366
|
+
const result = stdout.split('Done')[0];
|
|
367
|
+
expect(result).toEqual(`i18n translations checker
|
|
311
368
|
Source: en
|
|
312
369
|
Selected format is: i18next
|
|
313
370
|
|
|
@@ -316,28 +373,26 @@ No missing keys found!
|
|
|
316
373
|
No invalid translations found!
|
|
317
374
|
|
|
318
375
|
Found unused keys!
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
376
|
+
${(0, errorReporters_1.formatTable)([
|
|
377
|
+
[['file', 'key']],
|
|
378
|
+
[
|
|
379
|
+
[codeEx('reacti18next/locales/en/translation.json'), 'format.ebook'],
|
|
380
|
+
[codeEx('reacti18next/locales/en/translation.json'), 'nonExistentKey'],
|
|
381
|
+
],
|
|
382
|
+
])}
|
|
325
383
|
|
|
326
384
|
Found undefined keys!
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
└──────────────────────────────────────────────────────┴────────────────────────────────┘
|
|
385
|
+
${(0, errorReporters_1.formatTable)([
|
|
386
|
+
[['file', 'key']],
|
|
387
|
+
[[codeEx('reacti18next/src/App.tsx'), 'some.key.that.is.not.defined']],
|
|
388
|
+
])}
|
|
332
389
|
|
|
333
390
|
`);
|
|
334
|
-
done();
|
|
335
|
-
});
|
|
336
391
|
});
|
|
337
|
-
it(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
392
|
+
it('should find unused and undefined keys for react-i18next applications with multiple source folders', async () => {
|
|
393
|
+
const stdout = await execAsync('node dist/bin/index.js --source en --locales translations/codeExamples/reacti18next/locales -f i18next -u translations/codeExamples/reacti18next/src translations/codeExamples/reacti18next/secondSrcFolder --parser-component-functions WrappedTransComponent');
|
|
394
|
+
const result = stdout.split('Done')[0];
|
|
395
|
+
expect(result).toEqual(`i18n translations checker
|
|
341
396
|
Source: en
|
|
342
397
|
Selected format is: i18next
|
|
343
398
|
|
|
@@ -346,29 +401,32 @@ No missing keys found!
|
|
|
346
401
|
No invalid translations found!
|
|
347
402
|
|
|
348
403
|
Found unused keys!
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
404
|
+
${(0, errorReporters_1.formatTable)([
|
|
405
|
+
[['file', 'key']],
|
|
406
|
+
[
|
|
407
|
+
[codeEx('reacti18next/locales/en/translation.json'), 'format.ebook'],
|
|
408
|
+
[codeEx('reacti18next/locales/en/translation.json'), 'nonExistentKey'],
|
|
409
|
+
],
|
|
410
|
+
])}
|
|
355
411
|
|
|
356
412
|
Found undefined keys!
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
413
|
+
${(0, errorReporters_1.formatTable)([
|
|
414
|
+
[['file', 'key']],
|
|
415
|
+
[
|
|
416
|
+
[codeEx('reacti18next/src/App.tsx'), 'some.key.that.is.not.defined'],
|
|
417
|
+
[
|
|
418
|
+
codeEx('reacti18next/secondSrcFolder/Main.tsx'),
|
|
419
|
+
'another.key.that.is.not.defined',
|
|
420
|
+
],
|
|
421
|
+
],
|
|
422
|
+
])}
|
|
363
423
|
|
|
364
424
|
`);
|
|
365
|
-
done();
|
|
366
|
-
});
|
|
367
425
|
});
|
|
368
|
-
it(
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
426
|
+
it('should find unused and undefined keys for react-intl applications', async () => {
|
|
427
|
+
const stdout = await execAsync('node dist/bin/index.js --source en-US --locales translations/codeExamples/react-intl/locales -f react-intl -u translations/codeExamples/react-intl/src');
|
|
428
|
+
const result = stdout.split('Done')[0];
|
|
429
|
+
expect(result).toEqual(`i18n translations checker
|
|
372
430
|
Source: en-US
|
|
373
431
|
Selected format is: react-intl
|
|
374
432
|
|
|
@@ -377,28 +435,26 @@ No missing keys found!
|
|
|
377
435
|
No invalid translations found!
|
|
378
436
|
|
|
379
437
|
Found unused keys!
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
438
|
+
${(0, errorReporters_1.formatTable)([
|
|
439
|
+
[['file', 'key']],
|
|
440
|
+
[
|
|
441
|
+
[codeEx('react-intl/locales/en-US/one.json'), 'message.number-format'],
|
|
442
|
+
[codeEx('react-intl/locales/en-US/three.json'), 'multipleVariables'],
|
|
443
|
+
],
|
|
444
|
+
])}
|
|
386
445
|
|
|
387
446
|
Found undefined keys!
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
└────────────────────────────────────────────────────┴────────────────────────────────┘
|
|
447
|
+
${(0, errorReporters_1.formatTable)([
|
|
448
|
+
[['file', 'key']],
|
|
449
|
+
[[codeEx('react-intl/src/App.tsx'), 'some.key.that.is.not.defined']],
|
|
450
|
+
])}
|
|
393
451
|
|
|
394
452
|
`);
|
|
395
|
-
done();
|
|
396
|
-
});
|
|
397
453
|
});
|
|
398
|
-
it(
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
454
|
+
it('should find unused and undefined keys for next-intl applications', async () => {
|
|
455
|
+
const stdout = await execAsync('node dist/bin/index.js --source en --locales translations/codeExamples/next-intl/locales/ -f next-intl -u translations/codeExamples/next-intl/src');
|
|
456
|
+
const result = stdout.split('Done')[0];
|
|
457
|
+
expect(result).toEqual(`i18n translations checker
|
|
402
458
|
Source: en
|
|
403
459
|
Selected format is: next-intl
|
|
404
460
|
|
|
@@ -407,260 +463,292 @@ No missing keys found!
|
|
|
407
463
|
No invalid translations found!
|
|
408
464
|
|
|
409
465
|
Found unused keys!
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
466
|
+
${(0, errorReporters_1.formatTable)([
|
|
467
|
+
[['file', 'key']],
|
|
468
|
+
[
|
|
469
|
+
[codeEx('next-intl/locales/en/translation.json'), 'message.plural'],
|
|
470
|
+
[codeEx('next-intl/locales/en/translation.json'), 'notUsedKey'],
|
|
471
|
+
],
|
|
472
|
+
])}
|
|
416
473
|
|
|
417
474
|
Found undefined keys!
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
475
|
+
${(0, errorReporters_1.formatTable)([
|
|
476
|
+
[['file', 'key']],
|
|
477
|
+
[
|
|
478
|
+
[codeEx('next-intl/src/StrictTypesExample.tsx'), 'About.unknown'],
|
|
479
|
+
[codeEx('next-intl/src/StrictTypesExample.tsx'), 'About.unknown'],
|
|
480
|
+
[codeEx('next-intl/src/StrictTypesExample.tsx'), 'Test.title'],
|
|
481
|
+
[codeEx('next-intl/src/StrictTypesExample.tsx'), 'Test.title'],
|
|
482
|
+
[codeEx('next-intl/src/StrictTypesExample.tsx'), 'title'],
|
|
483
|
+
[codeEx('next-intl/src/StrictTypesExample.tsx'), 'title'],
|
|
484
|
+
[codeEx('next-intl/src/StrictTypesExample.tsx'), 'unknown'],
|
|
485
|
+
[codeEx('next-intl/src/StrictTypesExample.tsx'), 'unknown'],
|
|
486
|
+
[codeEx('next-intl/src/StrictTypesExample.tsx'), 'unknown.unknown'],
|
|
487
|
+
[codeEx('next-intl/src/StrictTypesExample.tsx'), 'unknown.unknown'],
|
|
488
|
+
[codeEx('next-intl/src/Basic.tsx'), 'message.select'],
|
|
489
|
+
],
|
|
490
|
+
])}
|
|
433
491
|
|
|
434
492
|
`);
|
|
435
|
-
done();
|
|
436
|
-
});
|
|
437
493
|
});
|
|
438
494
|
});
|
|
439
|
-
describe(
|
|
440
|
-
it(
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
495
|
+
describe('YAML', () => {
|
|
496
|
+
it('should return the missing keys for single folder translations', async () => {
|
|
497
|
+
const stdout = await execAsync('node dist/bin/index.js -s en-US -l translations/yaml/flattenExamples');
|
|
498
|
+
const result = stdout.split('Done')[0];
|
|
499
|
+
expect(result).toEqual(`i18n translations checker
|
|
444
500
|
Source: en-US
|
|
445
501
|
|
|
446
502
|
Found missing keys!
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
503
|
+
${(0, errorReporters_1.formatTable)([
|
|
504
|
+
[['file', 'key']],
|
|
505
|
+
[
|
|
506
|
+
[tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.three'],
|
|
507
|
+
[tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.deep.more.final'],
|
|
508
|
+
],
|
|
509
|
+
])}
|
|
453
510
|
|
|
454
511
|
No invalid translations found!
|
|
455
512
|
|
|
456
513
|
`);
|
|
457
|
-
done();
|
|
458
|
-
});
|
|
459
514
|
});
|
|
460
|
-
it(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
515
|
+
it('should return the missing/invalid keys for folder per locale with single file', async () => {
|
|
516
|
+
const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/folderExample/ -s en-US');
|
|
517
|
+
const result = stdout.split('Done')[0];
|
|
518
|
+
expect(result).toEqual(`i18n translations checker
|
|
464
519
|
Source: en-US
|
|
465
520
|
|
|
466
521
|
Found missing keys!
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
└────────────────────────────────────────────────────┴───────────────────────┘
|
|
522
|
+
${(0, errorReporters_1.formatTable)([
|
|
523
|
+
[['file', 'key']],
|
|
524
|
+
[[tr('yaml/folderExample/de-DE/index.yaml'), 'message.text-format']],
|
|
525
|
+
])}
|
|
472
526
|
|
|
473
527
|
Found invalid keys!
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
528
|
+
${(0, errorReporters_1.formatTable)([
|
|
529
|
+
[['info', 'result']],
|
|
530
|
+
[
|
|
531
|
+
['file', tr('yaml/folderExample/de-DE/index.yaml')],
|
|
532
|
+
['key', 'message.select'],
|
|
533
|
+
[
|
|
534
|
+
'msg',
|
|
535
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
536
|
+
],
|
|
537
|
+
],
|
|
538
|
+
])}
|
|
481
539
|
|
|
482
540
|
`);
|
|
483
|
-
done();
|
|
484
|
-
});
|
|
485
541
|
});
|
|
486
|
-
it(
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
542
|
+
it('should return the missing/invalid keys for folder per locale with multiple files', async () => {
|
|
543
|
+
const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/multipleFilesFolderExample/ -s en-US');
|
|
544
|
+
const result = stdout.split('Done')[0];
|
|
545
|
+
expect(result).toEqual(`i18n translations checker
|
|
490
546
|
Source: en-US
|
|
491
547
|
|
|
492
548
|
Found missing keys!
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
549
|
+
${(0, errorReporters_1.formatTable)([
|
|
550
|
+
[['file', 'key']],
|
|
551
|
+
[
|
|
552
|
+
[
|
|
553
|
+
tr('yaml/multipleFilesFolderExample/de-DE/one.yaml'),
|
|
554
|
+
'message.text-format',
|
|
555
|
+
],
|
|
556
|
+
[tr('yaml/multipleFilesFolderExample/de-DE/two.yaml'), 'test.drive.four'],
|
|
557
|
+
],
|
|
558
|
+
])}
|
|
499
559
|
|
|
500
560
|
Found invalid keys!
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
561
|
+
${(0, errorReporters_1.formatTable)([
|
|
562
|
+
[['info', 'result']],
|
|
563
|
+
[
|
|
564
|
+
['file', tr('yaml/multipleFilesFolderExample/de-DE/one.yaml')],
|
|
565
|
+
['key', 'message.select'],
|
|
566
|
+
[
|
|
567
|
+
'msg',
|
|
568
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
569
|
+
],
|
|
570
|
+
],
|
|
571
|
+
[
|
|
572
|
+
['file', tr('yaml/multipleFilesFolderExample/de-DE/three.yaml')],
|
|
573
|
+
['key', 'multipleVariables'],
|
|
574
|
+
['msg', 'Expected argument to contain "user" but received "name"'],
|
|
575
|
+
],
|
|
576
|
+
])}
|
|
512
577
|
|
|
513
578
|
`);
|
|
514
|
-
done();
|
|
515
|
-
});
|
|
516
579
|
});
|
|
517
|
-
it(
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
580
|
+
it('should return the missing/invalid keys for folder containing multiple locale folders', async () => {
|
|
581
|
+
const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/multipleFoldersExample -s en-US');
|
|
582
|
+
const result = stdout.split('Done')[0];
|
|
583
|
+
expect(result).toEqual(`i18n translations checker
|
|
521
584
|
Source: en-US
|
|
522
585
|
|
|
523
586
|
Found missing keys!
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
587
|
+
${(0, errorReporters_1.formatTable)([
|
|
588
|
+
[['file', 'key']],
|
|
589
|
+
[
|
|
590
|
+
[ymlMultiFolders('spaceOne/locales/de-DE/one.yaml'), 'message.text-format'],
|
|
591
|
+
[ymlMultiFolders('spaceOne/locales/de-DE/two.yaml'), 'test.drive.four'],
|
|
592
|
+
[ymlMultiFolders('spaceTwo/locales/de-DE/one.yaml'), 'message.plural'],
|
|
593
|
+
[ymlMultiFolders('spaceTwo/locales/de-DE/two.yaml'), 'test.drive.two'],
|
|
594
|
+
],
|
|
595
|
+
])}
|
|
532
596
|
|
|
533
597
|
Found invalid keys!
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
598
|
+
${(0, errorReporters_1.formatTable)([
|
|
599
|
+
[['info', 'result']],
|
|
600
|
+
[
|
|
601
|
+
['file', ymlMultiFolders('spaceOne/locales/de-DE/one.yaml')],
|
|
602
|
+
['key', 'message.select'],
|
|
603
|
+
[
|
|
604
|
+
'msg',
|
|
605
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
606
|
+
],
|
|
607
|
+
],
|
|
608
|
+
[
|
|
609
|
+
['file', ymlMultiFolders('spaceOne/locales/de-DE/three.yaml')],
|
|
610
|
+
['key', 'multipleVariables'],
|
|
611
|
+
['msg', 'Expected argument to contain "user" but received "name"'],
|
|
612
|
+
],
|
|
613
|
+
[
|
|
614
|
+
['file', ymlMultiFolders('spaceTwo/locales/de-DE/one.yaml')],
|
|
615
|
+
['key', 'message.text-format'],
|
|
616
|
+
[
|
|
617
|
+
'msg',
|
|
618
|
+
'Expected element of type "tag" but received "number", Unexpected tag element',
|
|
619
|
+
],
|
|
620
|
+
],
|
|
621
|
+
[
|
|
622
|
+
['file', ymlMultiFolders('spaceTwo/locales/de-DE/three.yaml')],
|
|
623
|
+
['key', 'numberFormat'],
|
|
624
|
+
['msg', 'Missing element number'],
|
|
625
|
+
],
|
|
626
|
+
])}
|
|
553
627
|
|
|
554
628
|
`);
|
|
555
|
-
done();
|
|
556
|
-
});
|
|
557
629
|
});
|
|
558
|
-
it(
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
630
|
+
it('should return the missing/invalid keys for multiple locale folders', async () => {
|
|
631
|
+
const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/multipleFoldersExample/spaceOne translations/yaml/multipleFoldersExample/spaceTwo -s en-US');
|
|
632
|
+
const result = stdout.split('Done')[0];
|
|
633
|
+
expect(result).toEqual(`i18n translations checker
|
|
562
634
|
Source: en-US
|
|
563
635
|
|
|
564
636
|
Found missing keys!
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
637
|
+
${(0, errorReporters_1.formatTable)([
|
|
638
|
+
[['file', 'key']],
|
|
639
|
+
[
|
|
640
|
+
[ymlMultiFolders('spaceOne/locales/de-DE/one.yaml'), 'message.text-format'],
|
|
641
|
+
[ymlMultiFolders('spaceOne/locales/de-DE/two.yaml'), 'test.drive.four'],
|
|
642
|
+
[ymlMultiFolders('spaceTwo/locales/de-DE/one.yaml'), 'message.plural'],
|
|
643
|
+
[ymlMultiFolders('spaceTwo/locales/de-DE/two.yaml'), 'test.drive.two'],
|
|
644
|
+
],
|
|
645
|
+
])}
|
|
573
646
|
|
|
574
647
|
Found invalid keys!
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
648
|
+
${(0, errorReporters_1.formatTable)([
|
|
649
|
+
[['info', 'result']],
|
|
650
|
+
[
|
|
651
|
+
['file', ymlMultiFolders('spaceOne/locales/de-DE/one.yaml')],
|
|
652
|
+
['key', 'message.select'],
|
|
653
|
+
[
|
|
654
|
+
'msg',
|
|
655
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
656
|
+
],
|
|
657
|
+
],
|
|
658
|
+
[
|
|
659
|
+
['file', ymlMultiFolders('spaceOne/locales/de-DE/three.yaml')],
|
|
660
|
+
['key', 'multipleVariables'],
|
|
661
|
+
['msg', 'Expected argument to contain "user" but received "name"'],
|
|
662
|
+
],
|
|
663
|
+
[
|
|
664
|
+
['file', ymlMultiFolders('spaceTwo/locales/de-DE/one.yaml')],
|
|
665
|
+
['key', 'message.text-format'],
|
|
666
|
+
[
|
|
667
|
+
'msg',
|
|
668
|
+
'Expected element of type "tag" but received "number", Unexpected tag element',
|
|
669
|
+
],
|
|
670
|
+
],
|
|
671
|
+
[
|
|
672
|
+
['file', ymlMultiFolders('spaceTwo/locales/de-DE/three.yaml')],
|
|
673
|
+
['key', 'numberFormat'],
|
|
674
|
+
['msg', 'Missing element number'],
|
|
675
|
+
],
|
|
676
|
+
])}
|
|
594
677
|
|
|
595
678
|
`);
|
|
596
|
-
done();
|
|
597
|
-
});
|
|
598
679
|
});
|
|
599
|
-
it(
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
680
|
+
it('should return the missing/invalid keys for all files in the provided locale folders', async () => {
|
|
681
|
+
const stdout = await execAsync('node dist/bin/index.js --source en-US --locales translations/yaml/flattenExamples translations/yaml/messageExamples');
|
|
682
|
+
const result = stdout.split('Done')[0];
|
|
683
|
+
expect(result).toEqual(`i18n translations checker
|
|
603
684
|
Source: en-US
|
|
604
685
|
|
|
605
686
|
Found missing keys!
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
687
|
+
${(0, errorReporters_1.formatTable)([
|
|
688
|
+
[['file', 'key']],
|
|
689
|
+
[
|
|
690
|
+
[tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.three'],
|
|
691
|
+
[tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.deep.more.final'],
|
|
692
|
+
[tr('yaml/messageExamples/de-de.yaml'), 'richText'],
|
|
693
|
+
[tr('yaml/messageExamples/de-de.yaml'), 'yo'],
|
|
694
|
+
[tr('yaml/messageExamples/de-de.yaml'), 'nesting1'],
|
|
695
|
+
[tr('yaml/messageExamples/de-de.yaml'), 'nesting2'],
|
|
696
|
+
[tr('yaml/messageExamples/de-de.yaml'), 'nesting3'],
|
|
697
|
+
[tr('yaml/messageExamples/de-de.yaml'), 'key1'],
|
|
698
|
+
],
|
|
699
|
+
])}
|
|
618
700
|
|
|
619
701
|
Found invalid keys!
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
702
|
+
${(0, errorReporters_1.formatTable)([
|
|
703
|
+
[['info', 'result']],
|
|
704
|
+
[
|
|
705
|
+
['file', tr('yaml/messageExamples/de-de.yaml')],
|
|
706
|
+
['key', 'multipleVariables'],
|
|
707
|
+
['msg', 'Unexpected date element'],
|
|
708
|
+
],
|
|
709
|
+
])}
|
|
627
710
|
|
|
628
711
|
`);
|
|
629
|
-
done();
|
|
630
|
-
});
|
|
631
712
|
});
|
|
632
|
-
it(
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
713
|
+
it('should return the missing/invalid keys for all files with source matching folder and source matching file', async () => {
|
|
714
|
+
const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/multipleFilesFolderExample translations/yaml/flattenExamples -s en-US');
|
|
715
|
+
const result = stdout.split('Done')[0];
|
|
716
|
+
expect(result).toEqual(`i18n translations checker
|
|
636
717
|
Source: en-US
|
|
637
718
|
|
|
638
719
|
Found missing keys!
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
720
|
+
${(0, errorReporters_1.formatTable)([
|
|
721
|
+
[['file', 'key']],
|
|
722
|
+
[
|
|
723
|
+
[tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.three'],
|
|
724
|
+
[tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.deep.more.final'],
|
|
725
|
+
[
|
|
726
|
+
tr('yaml/multipleFilesFolderExample/de-DE/one.yaml'),
|
|
727
|
+
'message.text-format',
|
|
728
|
+
],
|
|
729
|
+
[tr('yaml/multipleFilesFolderExample/de-DE/two.yaml'), 'test.drive.four'],
|
|
730
|
+
],
|
|
731
|
+
])}
|
|
647
732
|
|
|
648
733
|
Found invalid keys!
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
734
|
+
${(0, errorReporters_1.formatTable)([
|
|
735
|
+
[['info', 'result']],
|
|
736
|
+
[
|
|
737
|
+
['file', tr('yaml/multipleFilesFolderExample/de-DE/one.yaml')],
|
|
738
|
+
['key', 'message.select'],
|
|
739
|
+
[
|
|
740
|
+
'msg',
|
|
741
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
742
|
+
],
|
|
743
|
+
],
|
|
744
|
+
[
|
|
745
|
+
['file', tr('yaml/multipleFilesFolderExample/de-DE/three.yaml')],
|
|
746
|
+
['key', 'multipleVariables'],
|
|
747
|
+
['msg', 'Expected argument to contain "user" but received "name"'],
|
|
748
|
+
],
|
|
749
|
+
])}
|
|
660
750
|
|
|
661
751
|
`);
|
|
662
|
-
done();
|
|
663
|
-
});
|
|
664
752
|
});
|
|
665
753
|
});
|
|
666
754
|
});
|