@lingual/i18n-check 0.8.0 → 0.8.2

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