@lingual/i18n-check 0.7.4 → 0.8.0

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.
@@ -11,100 +11,116 @@ const counterFile = node_path_1.default.join(srcPath, "Counter.tsx");
11
11
  const clientCounterFile = node_path_1.default.join(srcPath, "ClientCounter.tsx");
12
12
  const nestedExampleFile = node_path_1.default.join(srcPath, "NestedExample.tsx");
13
13
  const asyncExampleFile = node_path_1.default.join(srcPath, "AsyncExample.tsx");
14
- const dynamicKeysExamplFile = node_path_1.default.join(srcPath, "DynamicKeysExample.tsx");
14
+ const dynamicKeysExampleFile = node_path_1.default.join(srcPath, "DynamicKeysExample.tsx");
15
15
  const strictTypesExample = node_path_1.default.join(srcPath, "StrictTypesExample.tsx");
16
+ const advancedExample = node_path_1.default.join(srcPath, "AdvancedExample.tsx");
16
17
  describe("nextIntlSrcParser", () => {
17
18
  it("should find all the translation keys", () => {
18
19
  const keys = (0, nextIntlSrcParser_1.extract)([basicFile, counterFile, clientCounterFile]);
19
20
  expect(keys).toEqual([
20
21
  {
21
- key: "ClientCounter2.increment",
22
+ key: "ClientCounter.count",
22
23
  meta: {
23
24
  file: clientCounterFile,
25
+ namespace: "ClientCounter",
24
26
  },
25
27
  },
26
28
  {
27
- key: "ClientCounter2.count",
29
+ key: "ClientCounter.increment",
28
30
  meta: {
29
31
  file: clientCounterFile,
32
+ namespace: "ClientCounter",
30
33
  },
31
34
  },
32
35
  {
33
- key: "ClientCounter.increment",
36
+ key: "ClientCounter2.count",
34
37
  meta: {
35
38
  file: clientCounterFile,
39
+ namespace: "ClientCounter2",
36
40
  },
37
41
  },
38
42
  {
39
- key: "ClientCounter.count",
43
+ key: "ClientCounter2.increment",
40
44
  meta: {
41
45
  file: clientCounterFile,
46
+ namespace: "ClientCounter2",
42
47
  },
43
48
  },
44
49
  {
45
- key: "Counter.increment",
50
+ key: "Counter.count",
46
51
  meta: {
47
52
  file: counterFile,
53
+ namespace: "Counter",
48
54
  },
49
55
  },
50
56
  {
51
- key: "Counter.count",
57
+ key: "Counter.increment",
52
58
  meta: {
53
59
  file: counterFile,
60
+ namespace: "Counter",
54
61
  },
55
62
  },
56
63
  {
57
- key: "testKeyWithoutNamespace",
64
+ key: "Navigation.about",
58
65
  meta: {
59
66
  file: basicFile,
67
+ namespace: "Navigation",
60
68
  },
61
69
  },
62
70
  {
63
- key: "message.argument",
71
+ key: "Navigation.client",
64
72
  meta: {
65
73
  file: basicFile,
74
+ namespace: "Navigation",
66
75
  },
67
76
  },
68
77
  {
69
- key: "message.select",
78
+ key: "Navigation.home",
70
79
  meta: {
71
80
  file: basicFile,
81
+ namespace: "Navigation",
72
82
  },
73
83
  },
74
84
  {
75
- key: "message.simple",
85
+ key: "Navigation.nested",
76
86
  meta: {
77
87
  file: basicFile,
88
+ namespace: "Navigation",
78
89
  },
79
90
  },
80
91
  {
81
92
  key: "Navigation.news",
82
93
  meta: {
83
94
  file: basicFile,
95
+ namespace: "Navigation",
84
96
  },
85
97
  },
86
98
  {
87
- key: "Navigation.nested",
99
+ key: "message.argument",
88
100
  meta: {
89
101
  file: basicFile,
102
+ namespace: "message",
90
103
  },
91
104
  },
92
105
  {
93
- key: "Navigation.about",
106
+ key: "message.select",
94
107
  meta: {
95
108
  file: basicFile,
109
+ namespace: "message",
96
110
  },
97
111
  },
98
112
  {
99
- key: "Navigation.client",
113
+ key: "message.simple",
100
114
  meta: {
101
115
  file: basicFile,
116
+ namespace: "message",
102
117
  },
103
118
  },
104
119
  {
105
- key: "Navigation.home",
120
+ key: "testKeyWithoutNamespace",
106
121
  meta: {
107
122
  file: basicFile,
123
+ namespace: "",
108
124
  },
109
125
  },
110
126
  ]);
@@ -113,87 +129,101 @@ describe("nextIntlSrcParser", () => {
113
129
  const keys = (0, nextIntlSrcParser_1.extract)([nestedExampleFile]);
114
130
  expect(keys).toEqual([
115
131
  {
116
- key: "nested.three.htmlKey",
132
+ key: "deepNested.level1.one",
117
133
  meta: {
118
134
  file: "translations/codeExamples/next-intl/src/NestedExample.tsx",
135
+ namespace: "deepNested.level1",
119
136
  },
120
137
  },
121
138
  {
122
- key: "nested.three.markupKey",
139
+ key: "deepNested.level2.two",
123
140
  meta: {
124
141
  file: "translations/codeExamples/next-intl/src/NestedExample.tsx",
142
+ namespace: "deepNested.level2",
125
143
  },
126
144
  },
127
145
  {
128
- key: "nested.three.richTextKey",
146
+ key: "deepNested.level3.three",
129
147
  meta: {
130
148
  file: "translations/codeExamples/next-intl/src/NestedExample.tsx",
149
+ namespace: "deepNested.level3",
131
150
  },
132
151
  },
133
152
  {
134
- key: "nested.three.hasKeyCheck",
153
+ key: "deepNested.level4.four",
135
154
  meta: {
136
155
  file: "translations/codeExamples/next-intl/src/NestedExample.tsx",
156
+ namespace: "deepNested.level4",
137
157
  },
138
158
  },
139
159
  {
140
- key: "nested.three.basicKey",
160
+ key: "nested.nested.two.nestedTwoKey",
141
161
  meta: {
142
162
  file: "translations/codeExamples/next-intl/src/NestedExample.tsx",
163
+ namespace: "nested.nested.two",
143
164
  },
144
165
  },
145
166
  {
146
- key: "deepNested.level1.one",
167
+ key: "nested.one.nestedKey",
147
168
  meta: {
148
169
  file: "translations/codeExamples/next-intl/src/NestedExample.tsx",
170
+ namespace: "nested.one",
149
171
  },
150
172
  },
151
173
  {
152
- key: "deepNested.level2.two",
174
+ key: "nested.one.regularKey",
153
175
  meta: {
154
176
  file: "translations/codeExamples/next-intl/src/NestedExample.tsx",
177
+ namespace: "nested.one",
155
178
  },
156
179
  },
157
180
  {
158
- key: "deepNested.level3.three",
181
+ key: "nested.three.basicKey",
159
182
  meta: {
160
183
  file: "translations/codeExamples/next-intl/src/NestedExample.tsx",
184
+ namespace: "nested.three",
161
185
  },
162
186
  },
163
187
  {
164
- key: "deepNested.level4.four",
188
+ key: "nested.three.hasKeyCheck",
165
189
  meta: {
166
190
  file: "translations/codeExamples/next-intl/src/NestedExample.tsx",
191
+ namespace: "nested.three",
167
192
  },
168
193
  },
169
194
  {
170
- key: "nested.two.regularKey",
195
+ key: "nested.three.htmlKey",
171
196
  meta: {
172
197
  file: "translations/codeExamples/next-intl/src/NestedExample.tsx",
198
+ namespace: "nested.three",
173
199
  },
174
200
  },
175
201
  {
176
- key: "nested.two.nestedKey",
202
+ key: "nested.three.markupKey",
177
203
  meta: {
178
204
  file: "translations/codeExamples/next-intl/src/NestedExample.tsx",
205
+ namespace: "nested.three",
179
206
  },
180
207
  },
181
208
  {
182
- key: "nested.nested.two.nestedTwoKey",
209
+ key: "nested.three.richTextKey",
183
210
  meta: {
184
211
  file: "translations/codeExamples/next-intl/src/NestedExample.tsx",
212
+ namespace: "nested.three",
185
213
  },
186
214
  },
187
215
  {
188
- key: "nested.one.regularKey",
216
+ key: "nested.two.nestedKey",
189
217
  meta: {
190
218
  file: "translations/codeExamples/next-intl/src/NestedExample.tsx",
219
+ namespace: "nested.two",
191
220
  },
192
221
  },
193
222
  {
194
- key: "nested.one.nestedKey",
223
+ key: "nested.two.regularKey",
195
224
  meta: {
196
225
  file: "translations/codeExamples/next-intl/src/NestedExample.tsx",
226
+ namespace: "nested.two",
197
227
  },
198
228
  },
199
229
  ]);
@@ -202,277 +232,335 @@ describe("nextIntlSrcParser", () => {
202
232
  const keys = (0, nextIntlSrcParser_1.extract)([asyncExampleFile]);
203
233
  expect(keys).toEqual([
204
234
  {
205
- key: "async.two.title",
235
+ key: "Async.title",
206
236
  meta: {
207
237
  file: "translations/codeExamples/next-intl/src/AsyncExample.tsx",
238
+ namespace: "Async",
208
239
  },
209
240
  },
210
241
  {
211
- key: "Async.title",
242
+ key: "async.two.title",
212
243
  meta: {
213
244
  file: "translations/codeExamples/next-intl/src/AsyncExample.tsx",
245
+ namespace: "async.two",
214
246
  },
215
247
  },
216
248
  ]);
217
249
  });
218
250
  it("should find all dynamic keys defined as comments", () => {
219
- const keys = (0, nextIntlSrcParser_1.extract)([dynamicKeysExamplFile]);
251
+ const keys = (0, nextIntlSrcParser_1.extract)([dynamicKeysExampleFile]);
220
252
  expect(keys).toEqual([
221
253
  {
222
- key: "dynamic.three.value",
254
+ key: "dynamic",
223
255
  meta: {
256
+ dynamic: true,
224
257
  file: "translations/codeExamples/next-intl/src/DynamicKeysExample.tsx",
258
+ namespace: "dynamic",
225
259
  },
226
260
  },
227
261
  {
228
- key: "dynamic.three.title",
262
+ key: "dynamic.four",
229
263
  meta: {
264
+ dynamic: true,
230
265
  file: "translations/codeExamples/next-intl/src/DynamicKeysExample.tsx",
266
+ namespace: "dynamic.four",
231
267
  },
232
268
  },
233
269
  {
234
- key: "dynamic.two.value",
270
+ key: "dynamic.four.nameFour",
235
271
  meta: {
236
272
  file: "translations/codeExamples/next-intl/src/DynamicKeysExample.tsx",
273
+ namespace: "dynamic.four",
237
274
  },
238
275
  },
239
276
  {
240
- key: "dynamic.two.title",
277
+ key: "dynamic.four.nameOne",
241
278
  meta: {
242
279
  file: "translations/codeExamples/next-intl/src/DynamicKeysExample.tsx",
280
+ namespace: "dynamic.four",
243
281
  },
244
282
  },
245
283
  {
246
- key: "dynamic.one.value",
284
+ key: "dynamic.four.nameThree",
247
285
  meta: {
248
286
  file: "translations/codeExamples/next-intl/src/DynamicKeysExample.tsx",
287
+ namespace: "dynamic.four",
249
288
  },
250
289
  },
251
290
  {
252
- key: "dynamic.one.title",
291
+ key: "dynamic.four.nameTwo",
253
292
  meta: {
254
293
  file: "translations/codeExamples/next-intl/src/DynamicKeysExample.tsx",
294
+ namespace: "dynamic.four",
255
295
  },
256
296
  },
297
+ ]);
298
+ });
299
+ it("should find all strict typed keys", () => {
300
+ const keys = (0, nextIntlSrcParser_1.extract)([strictTypesExample]);
301
+ expect(keys).toEqual([
257
302
  {
258
- key: "dynamic.four.four",
303
+ key: "About.lastUpdated",
259
304
  meta: {
260
- file: "translations/codeExamples/next-intl/src/DynamicKeysExample.tsx",
305
+ file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
306
+ namespace: "About",
261
307
  },
262
308
  },
263
309
  {
264
- key: "dynamic.four.three",
310
+ key: "About.lastUpdated",
265
311
  meta: {
266
- file: "translations/codeExamples/next-intl/src/DynamicKeysExample.tsx",
312
+ file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
313
+ namespace: "About",
267
314
  },
268
315
  },
269
316
  {
270
- key: "dynamic.four.two",
317
+ key: "About.title",
271
318
  meta: {
272
- file: "translations/codeExamples/next-intl/src/DynamicKeysExample.tsx",
319
+ file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
320
+ namespace: undefined,
273
321
  },
274
322
  },
275
323
  {
276
- key: "dynamic.four.one",
324
+ key: "About.title",
277
325
  meta: {
278
- file: "translations/codeExamples/next-intl/src/DynamicKeysExample.tsx",
326
+ file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
327
+ namespace: "About",
279
328
  },
280
329
  },
281
330
  {
282
- key: "dynamic.four.nameFour",
331
+ key: "About.title",
283
332
  meta: {
284
- file: "translations/codeExamples/next-intl/src/DynamicKeysExample.tsx",
333
+ file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
334
+ namespace: undefined,
285
335
  },
286
336
  },
287
337
  {
288
- key: "dynamic.four.nameThree",
338
+ key: "About.title",
289
339
  meta: {
290
- file: "translations/codeExamples/next-intl/src/DynamicKeysExample.tsx",
340
+ file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
341
+ namespace: "About",
291
342
  },
292
343
  },
293
344
  {
294
- key: "dynamic.four.nameTwo",
345
+ key: "About.unknown",
295
346
  meta: {
296
- file: "translations/codeExamples/next-intl/src/DynamicKeysExample.tsx",
347
+ file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
348
+ namespace: "About",
297
349
  },
298
350
  },
299
351
  {
300
- key: "dynamic.four.nameOne",
352
+ key: "About.unknown",
301
353
  meta: {
302
- file: "translations/codeExamples/next-intl/src/DynamicKeysExample.tsx",
354
+ file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
355
+ namespace: "About",
303
356
  },
304
357
  },
305
- ]);
306
- });
307
- it("should find all strict typed keys", () => {
308
- const keys = (0, nextIntlSrcParser_1.extract)([strictTypesExample]);
309
- expect(keys).toEqual([
310
358
  {
311
- key: "unknown.unknown",
359
+ key: "Navigation.about",
312
360
  meta: {
313
361
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
362
+ namespace: undefined,
314
363
  },
315
364
  },
316
365
  {
317
- key: "About.unknown",
366
+ key: "Navigation.about",
318
367
  meta: {
319
368
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
369
+ namespace: "Navigation",
320
370
  },
321
371
  },
322
372
  {
323
- key: "unknown",
373
+ key: "Navigation.about",
324
374
  meta: {
325
375
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
376
+ namespace: undefined,
326
377
  },
327
378
  },
328
379
  {
329
- key: "Test.title",
380
+ key: "Navigation.about",
330
381
  meta: {
331
382
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
383
+ namespace: "Navigation",
332
384
  },
333
385
  },
334
386
  {
335
- key: "title",
387
+ key: "NotFound.title",
336
388
  meta: {
337
389
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
390
+ namespace: "NotFound",
338
391
  },
339
392
  },
340
393
  {
341
- key: "PageLayout.pageTitle",
394
+ key: "NotFound.title",
342
395
  meta: {
343
396
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
397
+ namespace: "NotFound",
344
398
  },
345
399
  },
346
400
  {
347
- key: "NotFound.title",
401
+ key: "PageLayout.pageTitle",
348
402
  meta: {
349
403
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
404
+ namespace: "PageLayout",
350
405
  },
351
406
  },
352
407
  {
353
- key: "Navigation.about",
408
+ key: "PageLayout.pageTitle",
354
409
  meta: {
355
410
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
411
+ namespace: "PageLayout",
356
412
  },
357
413
  },
358
414
  {
359
- key: "About.title",
415
+ key: "StrictTypes.nested.another.level",
360
416
  meta: {
361
417
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
418
+ namespace: "StrictTypes.nested",
362
419
  },
363
420
  },
364
421
  {
365
- key: "Navigation.about",
422
+ key: "StrictTypes.nested.another.level",
366
423
  meta: {
367
424
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
425
+ namespace: "StrictTypes.nested",
368
426
  },
369
427
  },
370
428
  {
371
- key: "About.lastUpdated",
429
+ key: "StrictTypes.nested.hello",
372
430
  meta: {
373
431
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
432
+ namespace: "StrictTypes",
374
433
  },
375
434
  },
376
435
  {
377
- key: "About.title",
436
+ key: "StrictTypes.nested.hello",
378
437
  meta: {
379
438
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
439
+ namespace: "StrictTypes",
380
440
  },
381
441
  },
382
442
  {
383
- key: "StrictTypes.nested.another.level",
443
+ key: "Test.title",
384
444
  meta: {
385
445
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
446
+ namespace: "Test",
386
447
  },
387
448
  },
388
449
  {
389
- key: "StrictTypes.nested.hello",
450
+ key: "Test.title",
390
451
  meta: {
391
452
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
453
+ namespace: "Test",
392
454
  },
393
455
  },
394
456
  {
395
- key: "unknown.unknown",
457
+ key: "title",
396
458
  meta: {
397
459
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
460
+ namespace: undefined,
398
461
  },
399
462
  },
400
463
  {
401
- key: "About.unknown",
464
+ key: "title",
402
465
  meta: {
403
466
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
467
+ namespace: undefined,
404
468
  },
405
469
  },
406
470
  {
407
471
  key: "unknown",
408
472
  meta: {
409
473
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
474
+ namespace: undefined,
410
475
  },
411
476
  },
412
477
  {
413
- key: "Test.title",
478
+ key: "unknown",
414
479
  meta: {
415
480
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
481
+ namespace: undefined,
416
482
  },
417
483
  },
418
484
  {
419
- key: "title",
485
+ key: "unknown.unknown",
420
486
  meta: {
421
487
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
488
+ namespace: "unknown",
422
489
  },
423
490
  },
424
491
  {
425
- key: "PageLayout.pageTitle",
492
+ key: "unknown.unknown",
426
493
  meta: {
427
494
  file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
495
+ namespace: "unknown",
496
+ },
497
+ },
498
+ ]);
499
+ });
500
+ it("should find all the keys for multiple useTranslations aliases", () => {
501
+ const keys = (0, nextIntlSrcParser_1.extract)([advancedExample]);
502
+ expect(keys).toEqual([
503
+ {
504
+ key: "aliasNestedFour.four",
505
+ meta: {
506
+ file: advancedExample,
507
+ namespace: "aliasNestedFour",
428
508
  },
429
509
  },
430
510
  {
431
- key: "NotFound.title",
511
+ key: "aliasNestedOne.one",
432
512
  meta: {
433
- file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
513
+ file: advancedExample,
514
+ namespace: "aliasNestedOne",
434
515
  },
435
516
  },
436
517
  {
437
- key: "Navigation.about",
518
+ key: "aliasNestedOne.threeOne",
438
519
  meta: {
439
- file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
520
+ file: advancedExample,
521
+ namespace: "aliasNestedOne",
440
522
  },
441
523
  },
442
524
  {
443
- key: "About.title",
525
+ key: "aliasNestedThree.three",
444
526
  meta: {
445
- file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
527
+ file: advancedExample,
528
+ namespace: "aliasNestedThree",
446
529
  },
447
530
  },
448
531
  {
449
- key: "Navigation.about",
532
+ key: "aliasNestedThree.threeThree",
450
533
  meta: {
451
- file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
534
+ file: advancedExample,
535
+ namespace: "aliasNestedThree",
452
536
  },
453
537
  },
454
538
  {
455
- key: "About.lastUpdated",
539
+ key: "aliasNestedTwo.threeTwo",
456
540
  meta: {
457
- file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
541
+ file: advancedExample,
542
+ namespace: "aliasNestedTwo",
458
543
  },
459
544
  },
460
545
  {
461
- key: "About.title",
546
+ key: "aliasNestedTwo.two",
462
547
  meta: {
463
- file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
548
+ file: advancedExample,
549
+ namespace: "aliasNestedTwo",
464
550
  },
465
551
  },
466
552
  {
467
- key: "StrictTypes.nested.another.level",
553
+ key: "aliasOne.keyOne",
468
554
  meta: {
469
- file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
555
+ file: advancedExample,
556
+ namespace: "aliasOne",
470
557
  },
471
558
  },
472
559
  {
473
- key: "StrictTypes.nested.hello",
560
+ key: "aliasTwo.keyTwo",
474
561
  meta: {
475
- file: "translations/codeExamples/next-intl/src/StrictTypesExample.tsx",
562
+ file: advancedExample,
563
+ namespace: "aliasTwo",
476
564
  },
477
565
  },
478
566
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingual/i18n-check",
3
- "version": "0.7.4",
3
+ "version": "0.8.0",
4
4
  "description": "i18n translation messages check",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",