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