@lingual/i18n-check 0.8.4 → 0.8.6
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 +4 -4
- package/dist/bin/index.js +4 -1
- package/dist/index.js +2 -2
- package/dist/utils/nextIntlSrcParser.js +43 -0
- package/package.json +12 -11
- package/dist/bin/index.test.d.ts +0 -1
- package/dist/bin/index.test.js +0 -786
- package/dist/errorReporters.test.d.ts +0 -1
- package/dist/errorReporters.test.js +0 -165
- package/dist/utils/findInvalidTranslations.test.d.ts +0 -1
- package/dist/utils/findInvalidTranslations.test.js +0 -83
- package/dist/utils/findInvalidi18nTranslations.test.d.ts +0 -1
- package/dist/utils/findInvalidi18nTranslations.test.js +0 -206
- package/dist/utils/findMissingKeys.test.d.ts +0 -1
- package/dist/utils/findMissingKeys.test.js +0 -41
- package/dist/utils/flattenTranslations.test.d.ts +0 -1
- package/dist/utils/flattenTranslations.test.js +0 -28
- package/dist/utils/i18NextParser.test.d.ts +0 -1
- package/dist/utils/i18NextParser.test.js +0 -150
- package/dist/utils/nextIntlSrcParser.test.d.ts +0 -1
- package/dist/utils/nextIntlSrcParser.test.js +0 -568
package/dist/bin/index.test.js
DELETED
|
@@ -1,786 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const child_process_1 = require("child_process");
|
|
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
|
|
45
|
-
Source: en-US
|
|
46
|
-
|
|
47
|
-
Found missing keys!
|
|
48
|
-
${table}
|
|
49
|
-
|
|
50
|
-
No invalid translations found!
|
|
51
|
-
|
|
52
|
-
`);
|
|
53
|
-
});
|
|
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
|
|
73
|
-
Source: en-US
|
|
74
|
-
|
|
75
|
-
Found missing keys!
|
|
76
|
-
${missingKeysTable}
|
|
77
|
-
|
|
78
|
-
Found invalid keys!
|
|
79
|
-
${invalidKeysTable}
|
|
80
|
-
|
|
81
|
-
`);
|
|
82
|
-
});
|
|
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
|
|
110
|
-
Source: en-US
|
|
111
|
-
|
|
112
|
-
Found missing keys!
|
|
113
|
-
${missingKeysTable}
|
|
114
|
-
|
|
115
|
-
Found invalid keys!
|
|
116
|
-
${invalidKeysTable}
|
|
117
|
-
|
|
118
|
-
`);
|
|
119
|
-
});
|
|
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
|
|
124
|
-
Source: en-US
|
|
125
|
-
|
|
126
|
-
Found missing keys!
|
|
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
|
-
])}
|
|
136
|
-
|
|
137
|
-
Found invalid keys!
|
|
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
|
-
])}
|
|
167
|
-
|
|
168
|
-
`);
|
|
169
|
-
});
|
|
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
|
|
174
|
-
Source: en-US
|
|
175
|
-
|
|
176
|
-
Found missing keys!
|
|
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
|
-
])}
|
|
186
|
-
|
|
187
|
-
Found invalid keys!
|
|
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
|
-
])}
|
|
217
|
-
|
|
218
|
-
`);
|
|
219
|
-
});
|
|
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
|
|
224
|
-
Source: en-US
|
|
225
|
-
|
|
226
|
-
Found missing keys!
|
|
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
|
-
])}
|
|
240
|
-
|
|
241
|
-
Found invalid keys!
|
|
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
|
-
])}
|
|
250
|
-
|
|
251
|
-
`);
|
|
252
|
-
});
|
|
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
|
|
257
|
-
Source: en-US
|
|
258
|
-
|
|
259
|
-
Found missing keys!
|
|
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
|
-
])}
|
|
269
|
-
|
|
270
|
-
Found invalid keys!
|
|
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
|
-
])}
|
|
287
|
-
|
|
288
|
-
`);
|
|
289
|
-
});
|
|
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
|
|
294
|
-
Source: en-US
|
|
295
|
-
|
|
296
|
-
Found missing keys!
|
|
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
|
-
])}
|
|
308
|
-
|
|
309
|
-
Found invalid keys!
|
|
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
|
-
])}
|
|
318
|
-
|
|
319
|
-
`);
|
|
320
|
-
});
|
|
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
|
|
325
|
-
Source: en-US
|
|
326
|
-
|
|
327
|
-
Found missing keys!
|
|
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
|
-
])}
|
|
339
|
-
|
|
340
|
-
Found invalid keys!
|
|
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
|
-
])}
|
|
349
|
-
|
|
350
|
-
`);
|
|
351
|
-
});
|
|
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
|
|
356
|
-
Source: en-US
|
|
357
|
-
|
|
358
|
-
No missing keys found!
|
|
359
|
-
|
|
360
|
-
No invalid translations found!
|
|
361
|
-
|
|
362
|
-
`);
|
|
363
|
-
});
|
|
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
|
|
368
|
-
Source: en
|
|
369
|
-
Selected format is: i18next
|
|
370
|
-
|
|
371
|
-
No missing keys found!
|
|
372
|
-
|
|
373
|
-
No invalid translations found!
|
|
374
|
-
|
|
375
|
-
Found unused keys!
|
|
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
|
-
])}
|
|
383
|
-
|
|
384
|
-
Found undefined keys!
|
|
385
|
-
${(0, errorReporters_1.formatTable)([
|
|
386
|
-
[['file', 'key']],
|
|
387
|
-
[[codeEx('reacti18next/src/App.tsx'), 'some.key.that.is.not.defined']],
|
|
388
|
-
])}
|
|
389
|
-
|
|
390
|
-
`);
|
|
391
|
-
});
|
|
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
|
|
396
|
-
Source: en
|
|
397
|
-
Selected format is: i18next
|
|
398
|
-
|
|
399
|
-
No missing keys found!
|
|
400
|
-
|
|
401
|
-
No invalid translations found!
|
|
402
|
-
|
|
403
|
-
Found unused keys!
|
|
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
|
-
])}
|
|
411
|
-
|
|
412
|
-
Found undefined keys!
|
|
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
|
-
])}
|
|
423
|
-
|
|
424
|
-
`);
|
|
425
|
-
});
|
|
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
|
|
430
|
-
Source: en-US
|
|
431
|
-
Selected format is: react-intl
|
|
432
|
-
|
|
433
|
-
No missing keys found!
|
|
434
|
-
|
|
435
|
-
No invalid translations found!
|
|
436
|
-
|
|
437
|
-
Found unused keys!
|
|
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
|
-
])}
|
|
445
|
-
|
|
446
|
-
Found undefined keys!
|
|
447
|
-
${(0, errorReporters_1.formatTable)([
|
|
448
|
-
[['file', 'key']],
|
|
449
|
-
[[codeEx('react-intl/src/App.tsx'), 'some.key.that.is.not.defined']],
|
|
450
|
-
])}
|
|
451
|
-
|
|
452
|
-
`);
|
|
453
|
-
});
|
|
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
|
|
458
|
-
Source: en
|
|
459
|
-
Selected format is: next-intl
|
|
460
|
-
|
|
461
|
-
No missing keys found!
|
|
462
|
-
|
|
463
|
-
No invalid translations found!
|
|
464
|
-
|
|
465
|
-
Found unused keys!
|
|
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
|
-
])}
|
|
473
|
-
|
|
474
|
-
Found undefined keys!
|
|
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
|
-
])}
|
|
491
|
-
|
|
492
|
-
`);
|
|
493
|
-
});
|
|
494
|
-
it('should skip ignored keys when checking for missing/invalid keys', async () => {
|
|
495
|
-
const stdout = await execAsync('node dist/bin/index.js -l translations/multipleFilesFolderExample translations/flattenExamples -s en-US -i "other.nested.*" test.drive.four');
|
|
496
|
-
const result = stdout.split('Done')[0];
|
|
497
|
-
expect(result).toEqual(`i18n translations checker
|
|
498
|
-
Source: en-US
|
|
499
|
-
|
|
500
|
-
Found missing keys!
|
|
501
|
-
${(0, errorReporters_1.formatTable)([
|
|
502
|
-
[['file', 'key']],
|
|
503
|
-
[[multiFiles('de-DE/one.json'), 'message.text-format']],
|
|
504
|
-
])}
|
|
505
|
-
|
|
506
|
-
Found invalid keys!
|
|
507
|
-
${(0, errorReporters_1.formatTable)([
|
|
508
|
-
[['info', 'result']],
|
|
509
|
-
[
|
|
510
|
-
['file', multiFiles('de-DE/one.json')],
|
|
511
|
-
['key', 'message.select'],
|
|
512
|
-
[
|
|
513
|
-
'msg',
|
|
514
|
-
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
515
|
-
],
|
|
516
|
-
],
|
|
517
|
-
[
|
|
518
|
-
['file', multiFiles('de-DE/three.json')],
|
|
519
|
-
['key', 'multipleVariables'],
|
|
520
|
-
['msg', 'Expected argument to contain "user" but received "name"'],
|
|
521
|
-
],
|
|
522
|
-
])}
|
|
523
|
-
|
|
524
|
-
`);
|
|
525
|
-
});
|
|
526
|
-
});
|
|
527
|
-
describe('YAML', () => {
|
|
528
|
-
it('should return the missing keys for single folder translations', async () => {
|
|
529
|
-
const stdout = await execAsync('node dist/bin/index.js -s en-US -l translations/yaml/flattenExamples');
|
|
530
|
-
const result = stdout.split('Done')[0];
|
|
531
|
-
expect(result).toEqual(`i18n translations checker
|
|
532
|
-
Source: en-US
|
|
533
|
-
|
|
534
|
-
Found missing keys!
|
|
535
|
-
${(0, errorReporters_1.formatTable)([
|
|
536
|
-
[['file', 'key']],
|
|
537
|
-
[
|
|
538
|
-
[tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.three'],
|
|
539
|
-
[tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.deep.more.final'],
|
|
540
|
-
],
|
|
541
|
-
])}
|
|
542
|
-
|
|
543
|
-
No invalid translations found!
|
|
544
|
-
|
|
545
|
-
`);
|
|
546
|
-
});
|
|
547
|
-
it('should return the missing/invalid keys for folder per locale with single file', async () => {
|
|
548
|
-
const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/folderExample/ -s en-US');
|
|
549
|
-
const result = stdout.split('Done')[0];
|
|
550
|
-
expect(result).toEqual(`i18n translations checker
|
|
551
|
-
Source: en-US
|
|
552
|
-
|
|
553
|
-
Found missing keys!
|
|
554
|
-
${(0, errorReporters_1.formatTable)([
|
|
555
|
-
[['file', 'key']],
|
|
556
|
-
[[tr('yaml/folderExample/de-DE/index.yaml'), 'message.text-format']],
|
|
557
|
-
])}
|
|
558
|
-
|
|
559
|
-
Found invalid keys!
|
|
560
|
-
${(0, errorReporters_1.formatTable)([
|
|
561
|
-
[['info', 'result']],
|
|
562
|
-
[
|
|
563
|
-
['file', tr('yaml/folderExample/de-DE/index.yaml')],
|
|
564
|
-
['key', 'message.select'],
|
|
565
|
-
[
|
|
566
|
-
'msg',
|
|
567
|
-
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
568
|
-
],
|
|
569
|
-
],
|
|
570
|
-
])}
|
|
571
|
-
|
|
572
|
-
`);
|
|
573
|
-
});
|
|
574
|
-
it('should return the missing/invalid keys for folder per locale with multiple files', async () => {
|
|
575
|
-
const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/multipleFilesFolderExample/ -s en-US');
|
|
576
|
-
const result = stdout.split('Done')[0];
|
|
577
|
-
expect(result).toEqual(`i18n translations checker
|
|
578
|
-
Source: en-US
|
|
579
|
-
|
|
580
|
-
Found missing keys!
|
|
581
|
-
${(0, errorReporters_1.formatTable)([
|
|
582
|
-
[['file', 'key']],
|
|
583
|
-
[
|
|
584
|
-
[
|
|
585
|
-
tr('yaml/multipleFilesFolderExample/de-DE/one.yaml'),
|
|
586
|
-
'message.text-format',
|
|
587
|
-
],
|
|
588
|
-
[tr('yaml/multipleFilesFolderExample/de-DE/two.yaml'), 'test.drive.four'],
|
|
589
|
-
],
|
|
590
|
-
])}
|
|
591
|
-
|
|
592
|
-
Found invalid keys!
|
|
593
|
-
${(0, errorReporters_1.formatTable)([
|
|
594
|
-
[['info', 'result']],
|
|
595
|
-
[
|
|
596
|
-
['file', tr('yaml/multipleFilesFolderExample/de-DE/one.yaml')],
|
|
597
|
-
['key', 'message.select'],
|
|
598
|
-
[
|
|
599
|
-
'msg',
|
|
600
|
-
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
601
|
-
],
|
|
602
|
-
],
|
|
603
|
-
[
|
|
604
|
-
['file', tr('yaml/multipleFilesFolderExample/de-DE/three.yaml')],
|
|
605
|
-
['key', 'multipleVariables'],
|
|
606
|
-
['msg', 'Expected argument to contain "user" but received "name"'],
|
|
607
|
-
],
|
|
608
|
-
])}
|
|
609
|
-
|
|
610
|
-
`);
|
|
611
|
-
});
|
|
612
|
-
it('should return the missing/invalid keys for folder containing multiple locale folders', async () => {
|
|
613
|
-
const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/multipleFoldersExample -s en-US');
|
|
614
|
-
const result = stdout.split('Done')[0];
|
|
615
|
-
expect(result).toEqual(`i18n translations checker
|
|
616
|
-
Source: en-US
|
|
617
|
-
|
|
618
|
-
Found missing keys!
|
|
619
|
-
${(0, errorReporters_1.formatTable)([
|
|
620
|
-
[['file', 'key']],
|
|
621
|
-
[
|
|
622
|
-
[ymlMultiFolders('spaceOne/locales/de-DE/one.yaml'), 'message.text-format'],
|
|
623
|
-
[ymlMultiFolders('spaceOne/locales/de-DE/two.yaml'), 'test.drive.four'],
|
|
624
|
-
[ymlMultiFolders('spaceTwo/locales/de-DE/one.yaml'), 'message.plural'],
|
|
625
|
-
[ymlMultiFolders('spaceTwo/locales/de-DE/two.yaml'), 'test.drive.two'],
|
|
626
|
-
],
|
|
627
|
-
])}
|
|
628
|
-
|
|
629
|
-
Found invalid keys!
|
|
630
|
-
${(0, errorReporters_1.formatTable)([
|
|
631
|
-
[['info', 'result']],
|
|
632
|
-
[
|
|
633
|
-
['file', ymlMultiFolders('spaceOne/locales/de-DE/one.yaml')],
|
|
634
|
-
['key', 'message.select'],
|
|
635
|
-
[
|
|
636
|
-
'msg',
|
|
637
|
-
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
638
|
-
],
|
|
639
|
-
],
|
|
640
|
-
[
|
|
641
|
-
['file', ymlMultiFolders('spaceOne/locales/de-DE/three.yaml')],
|
|
642
|
-
['key', 'multipleVariables'],
|
|
643
|
-
['msg', 'Expected argument to contain "user" but received "name"'],
|
|
644
|
-
],
|
|
645
|
-
[
|
|
646
|
-
['file', ymlMultiFolders('spaceTwo/locales/de-DE/one.yaml')],
|
|
647
|
-
['key', 'message.text-format'],
|
|
648
|
-
[
|
|
649
|
-
'msg',
|
|
650
|
-
'Expected element of type "tag" but received "number", Unexpected tag element',
|
|
651
|
-
],
|
|
652
|
-
],
|
|
653
|
-
[
|
|
654
|
-
['file', ymlMultiFolders('spaceTwo/locales/de-DE/three.yaml')],
|
|
655
|
-
['key', 'numberFormat'],
|
|
656
|
-
['msg', 'Missing element number'],
|
|
657
|
-
],
|
|
658
|
-
])}
|
|
659
|
-
|
|
660
|
-
`);
|
|
661
|
-
});
|
|
662
|
-
it('should return the missing/invalid keys for multiple locale folders', async () => {
|
|
663
|
-
const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/multipleFoldersExample/spaceOne translations/yaml/multipleFoldersExample/spaceTwo -s en-US');
|
|
664
|
-
const result = stdout.split('Done')[0];
|
|
665
|
-
expect(result).toEqual(`i18n translations checker
|
|
666
|
-
Source: en-US
|
|
667
|
-
|
|
668
|
-
Found missing keys!
|
|
669
|
-
${(0, errorReporters_1.formatTable)([
|
|
670
|
-
[['file', 'key']],
|
|
671
|
-
[
|
|
672
|
-
[ymlMultiFolders('spaceOne/locales/de-DE/one.yaml'), 'message.text-format'],
|
|
673
|
-
[ymlMultiFolders('spaceOne/locales/de-DE/two.yaml'), 'test.drive.four'],
|
|
674
|
-
[ymlMultiFolders('spaceTwo/locales/de-DE/one.yaml'), 'message.plural'],
|
|
675
|
-
[ymlMultiFolders('spaceTwo/locales/de-DE/two.yaml'), 'test.drive.two'],
|
|
676
|
-
],
|
|
677
|
-
])}
|
|
678
|
-
|
|
679
|
-
Found invalid keys!
|
|
680
|
-
${(0, errorReporters_1.formatTable)([
|
|
681
|
-
[['info', 'result']],
|
|
682
|
-
[
|
|
683
|
-
['file', ymlMultiFolders('spaceOne/locales/de-DE/one.yaml')],
|
|
684
|
-
['key', 'message.select'],
|
|
685
|
-
[
|
|
686
|
-
'msg',
|
|
687
|
-
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
688
|
-
],
|
|
689
|
-
],
|
|
690
|
-
[
|
|
691
|
-
['file', ymlMultiFolders('spaceOne/locales/de-DE/three.yaml')],
|
|
692
|
-
['key', 'multipleVariables'],
|
|
693
|
-
['msg', 'Expected argument to contain "user" but received "name"'],
|
|
694
|
-
],
|
|
695
|
-
[
|
|
696
|
-
['file', ymlMultiFolders('spaceTwo/locales/de-DE/one.yaml')],
|
|
697
|
-
['key', 'message.text-format'],
|
|
698
|
-
[
|
|
699
|
-
'msg',
|
|
700
|
-
'Expected element of type "tag" but received "number", Unexpected tag element',
|
|
701
|
-
],
|
|
702
|
-
],
|
|
703
|
-
[
|
|
704
|
-
['file', ymlMultiFolders('spaceTwo/locales/de-DE/three.yaml')],
|
|
705
|
-
['key', 'numberFormat'],
|
|
706
|
-
['msg', 'Missing element number'],
|
|
707
|
-
],
|
|
708
|
-
])}
|
|
709
|
-
|
|
710
|
-
`);
|
|
711
|
-
});
|
|
712
|
-
it('should return the missing/invalid keys for all files in the provided locale folders', async () => {
|
|
713
|
-
const stdout = await execAsync('node dist/bin/index.js --source en-US --locales translations/yaml/flattenExamples translations/yaml/messageExamples');
|
|
714
|
-
const result = stdout.split('Done')[0];
|
|
715
|
-
expect(result).toEqual(`i18n translations checker
|
|
716
|
-
Source: en-US
|
|
717
|
-
|
|
718
|
-
Found missing keys!
|
|
719
|
-
${(0, errorReporters_1.formatTable)([
|
|
720
|
-
[['file', 'key']],
|
|
721
|
-
[
|
|
722
|
-
[tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.three'],
|
|
723
|
-
[tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.deep.more.final'],
|
|
724
|
-
[tr('yaml/messageExamples/de-de.yaml'), 'richText'],
|
|
725
|
-
[tr('yaml/messageExamples/de-de.yaml'), 'yo'],
|
|
726
|
-
[tr('yaml/messageExamples/de-de.yaml'), 'nesting1'],
|
|
727
|
-
[tr('yaml/messageExamples/de-de.yaml'), 'nesting2'],
|
|
728
|
-
[tr('yaml/messageExamples/de-de.yaml'), 'nesting3'],
|
|
729
|
-
[tr('yaml/messageExamples/de-de.yaml'), 'key1'],
|
|
730
|
-
],
|
|
731
|
-
])}
|
|
732
|
-
|
|
733
|
-
Found invalid keys!
|
|
734
|
-
${(0, errorReporters_1.formatTable)([
|
|
735
|
-
[['info', 'result']],
|
|
736
|
-
[
|
|
737
|
-
['file', tr('yaml/messageExamples/de-de.yaml')],
|
|
738
|
-
['key', 'multipleVariables'],
|
|
739
|
-
['msg', 'Unexpected date element'],
|
|
740
|
-
],
|
|
741
|
-
])}
|
|
742
|
-
|
|
743
|
-
`);
|
|
744
|
-
});
|
|
745
|
-
it('should return the missing/invalid keys for all files with source matching folder and source matching file', async () => {
|
|
746
|
-
const stdout = await execAsync('node dist/bin/index.js -l translations/yaml/multipleFilesFolderExample translations/yaml/flattenExamples -s en-US');
|
|
747
|
-
const result = stdout.split('Done')[0];
|
|
748
|
-
expect(result).toEqual(`i18n translations checker
|
|
749
|
-
Source: en-US
|
|
750
|
-
|
|
751
|
-
Found missing keys!
|
|
752
|
-
${(0, errorReporters_1.formatTable)([
|
|
753
|
-
[['file', 'key']],
|
|
754
|
-
[
|
|
755
|
-
[tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.three'],
|
|
756
|
-
[tr('yaml/flattenExamples/de-de.yaml'), 'other.nested.deep.more.final'],
|
|
757
|
-
[
|
|
758
|
-
tr('yaml/multipleFilesFolderExample/de-DE/one.yaml'),
|
|
759
|
-
'message.text-format',
|
|
760
|
-
],
|
|
761
|
-
[tr('yaml/multipleFilesFolderExample/de-DE/two.yaml'), 'test.drive.four'],
|
|
762
|
-
],
|
|
763
|
-
])}
|
|
764
|
-
|
|
765
|
-
Found invalid keys!
|
|
766
|
-
${(0, errorReporters_1.formatTable)([
|
|
767
|
-
[['info', 'result']],
|
|
768
|
-
[
|
|
769
|
-
['file', tr('yaml/multipleFilesFolderExample/de-DE/one.yaml')],
|
|
770
|
-
['key', 'message.select'],
|
|
771
|
-
[
|
|
772
|
-
'msg',
|
|
773
|
-
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
774
|
-
],
|
|
775
|
-
],
|
|
776
|
-
[
|
|
777
|
-
['file', tr('yaml/multipleFilesFolderExample/de-DE/three.yaml')],
|
|
778
|
-
['key', 'multipleVariables'],
|
|
779
|
-
['msg', 'Expected argument to contain "user" but received "name"'],
|
|
780
|
-
],
|
|
781
|
-
])}
|
|
782
|
-
|
|
783
|
-
`);
|
|
784
|
-
});
|
|
785
|
-
});
|
|
786
|
-
});
|