@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.
- package/dist/bin/index.js +22 -45
- package/dist/bin/index.test.js +570 -451
- package/dist/errorReporters.d.ts +5 -7
- package/dist/errorReporters.js +59 -73
- package/dist/errorReporters.test.d.ts +1 -0
- package/dist/errorReporters.test.js +165 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +21 -14
- package/dist/types.d.ts +5 -0
- package/dist/utils/findInvalidTranslations.d.ts +3 -6
- package/dist/utils/findInvalidTranslations.js +3 -3
- package/dist/utils/findInvalidi18nTranslations.d.ts +3 -3
- package/dist/utils/findInvalidi18nTranslations.js +1 -1
- package/dist/utils/findMissingKeys.d.ts +1 -1
- package/dist/utils/findMissingKeys.js +1 -1
- package/dist/utils/flattenTranslations.js +1 -1
- package/dist/utils/nextIntlSrcParser.test.js +50 -50
- package/package.json +1 -1
package/dist/bin/index.test.js
CHANGED
|
@@ -1,299 +1,358 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const child_process_1 = require("child_process");
|
|
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", (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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", (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
54
|
+
it("should return the missing/invalid keys for folder per locale with single file", async () => {
|
|
55
|
+
const stdout = await execAsync("node dist/bin/index.js -l translations/folderExample/ -s en-US");
|
|
56
|
+
const result = stdout.split("Done")[0];
|
|
57
|
+
const missingKeysTable = (0, errorReporters_1.formatTable)([
|
|
58
|
+
[["file", "key"]],
|
|
59
|
+
[[tr("folderExample/de-DE/index.json"), "message.text-format"]],
|
|
60
|
+
]);
|
|
61
|
+
const invalidKeysTable = (0, errorReporters_1.formatTable)([
|
|
62
|
+
[["info", "result"]],
|
|
63
|
+
[
|
|
64
|
+
["file", tr("folderExample/de-DE/index.json")],
|
|
65
|
+
["key", "message.select"],
|
|
66
|
+
[
|
|
67
|
+
"msg",
|
|
68
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
69
|
+
],
|
|
70
|
+
],
|
|
71
|
+
]);
|
|
72
|
+
expect(result).toEqual(`i18n translations checker
|
|
30
73
|
Source: en-US
|
|
31
74
|
|
|
32
75
|
Found missing keys!
|
|
33
|
-
|
|
34
|
-
│ file │ key │
|
|
35
|
-
├───────────────────────────────────────────────┼───────────────────────┤
|
|
36
|
-
│ translations/folderExample/de-DE/index.json │ message.text-format │
|
|
37
|
-
└───────────────────────────────────────────────┴───────────────────────┘
|
|
76
|
+
${missingKeysTable}
|
|
38
77
|
|
|
39
78
|
Found invalid keys!
|
|
40
|
-
|
|
41
|
-
│ info │ result │
|
|
42
|
-
├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
43
|
-
│ file │ translations/folderExample/de-DE/index.json │
|
|
44
|
-
│ key │ message.select │
|
|
45
|
-
│ msg │ Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element... │
|
|
46
|
-
└────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
|
79
|
+
${invalidKeysTable}
|
|
47
80
|
|
|
48
81
|
`);
|
|
49
|
-
done();
|
|
50
|
-
});
|
|
51
82
|
});
|
|
52
|
-
it("should return the missing/invalid keys for folder per locale with multiple files", (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
83
|
+
it("should return the missing/invalid keys for folder per locale with multiple files", async () => {
|
|
84
|
+
const stdout = await execAsync("node dist/bin/index.js -l translations/multipleFilesFolderExample/ -s en-US");
|
|
85
|
+
const missingKeysTable = (0, errorReporters_1.formatTable)([
|
|
86
|
+
[["file", "key"]],
|
|
87
|
+
[
|
|
88
|
+
[multiFiles("de-DE/one.json"), "message.text-format"],
|
|
89
|
+
[multiFiles("de-DE/two.json"), "test.drive.four"],
|
|
90
|
+
],
|
|
91
|
+
]);
|
|
92
|
+
const invalidKeysTable = (0, errorReporters_1.formatTable)([
|
|
93
|
+
[["info", "result"]],
|
|
94
|
+
[
|
|
95
|
+
["file", multiFiles("de-DE/one.json")],
|
|
96
|
+
["key", "message.select"],
|
|
97
|
+
[
|
|
98
|
+
"msg",
|
|
99
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
100
|
+
],
|
|
101
|
+
],
|
|
102
|
+
[
|
|
103
|
+
["file", multiFiles("de-DE/three.json")],
|
|
104
|
+
["key", "multipleVariables"],
|
|
105
|
+
["msg", 'Expected argument to contain "user" but received "name" '],
|
|
106
|
+
],
|
|
107
|
+
]);
|
|
108
|
+
const result = stdout.split("Done")[0];
|
|
109
|
+
expect(result).toEqual(`i18n translations checker
|
|
56
110
|
Source: en-US
|
|
57
111
|
|
|
58
112
|
Found missing keys!
|
|
59
|
-
|
|
60
|
-
│ file │ key │
|
|
61
|
-
├──────────────────────────────────────────────────────────┼───────────────────────┤
|
|
62
|
-
│ translations/multipleFilesFolderExample/de-DE/one.json │ message.text-format │
|
|
63
|
-
│ translations/multipleFilesFolderExample/de-DE/two.json │ test.drive.four │
|
|
64
|
-
└──────────────────────────────────────────────────────────┴───────────────────────┘
|
|
113
|
+
${missingKeysTable}
|
|
65
114
|
|
|
66
115
|
Found invalid keys!
|
|
67
|
-
|
|
68
|
-
│ info │ result │
|
|
69
|
-
├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
70
|
-
│ file │ translations/multipleFilesFolderExample/de-DE/one.json │
|
|
71
|
-
│ key │ message.select │
|
|
72
|
-
│ msg │ Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element... │
|
|
73
|
-
├────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
74
|
-
│ file │ translations/multipleFilesFolderExample/de-DE/three.json │
|
|
75
|
-
│ key │ multipleVariables │
|
|
76
|
-
│ msg │ Expected argument to contain "user" but received "name" │
|
|
77
|
-
└────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
|
116
|
+
${invalidKeysTable}
|
|
78
117
|
|
|
79
118
|
`);
|
|
80
|
-
done();
|
|
81
|
-
});
|
|
82
119
|
});
|
|
83
|
-
it("should return the missing/invalid keys for folder containing multiple locale folders", (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
120
|
+
it("should return the missing/invalid keys for folder containing multiple locale folders", async () => {
|
|
121
|
+
const stdout = await execAsync("node dist/bin/index.js -l translations/multipleFoldersExample -s en-US");
|
|
122
|
+
const result = stdout.split("Done")[0];
|
|
123
|
+
expect(result).toEqual(`i18n translations checker
|
|
87
124
|
Source: en-US
|
|
88
125
|
|
|
89
126
|
Found missing keys!
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
127
|
+
${(0, errorReporters_1.formatTable)([
|
|
128
|
+
[["file", "key"]],
|
|
129
|
+
[
|
|
130
|
+
[multiFolders("spaceOne/locales/de-DE/one.json"), "message.text-format"],
|
|
131
|
+
[multiFolders("spaceOne/locales/de-DE/two.json"), "test.drive.four"],
|
|
132
|
+
[multiFolders("spaceTwo/locales/de-DE/one.json"), "message.plural"],
|
|
133
|
+
[multiFolders("spaceTwo/locales/de-DE/two.json"), "test.drive.two"],
|
|
134
|
+
],
|
|
135
|
+
])}
|
|
98
136
|
|
|
99
137
|
Found invalid keys!
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
138
|
+
${(0, errorReporters_1.formatTable)([
|
|
139
|
+
[["info", "result"]],
|
|
140
|
+
[
|
|
141
|
+
["file", multiFolders("spaceOne/locales/de-DE/one.json")],
|
|
142
|
+
["key", "message.select"],
|
|
143
|
+
[
|
|
144
|
+
"msg",
|
|
145
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
146
|
+
],
|
|
147
|
+
],
|
|
148
|
+
[
|
|
149
|
+
["file", multiFolders("spaceOne/locales/de-DE/three.json")],
|
|
150
|
+
["key", "multipleVariables"],
|
|
151
|
+
["msg", 'Expected argument to contain "user" but received "name"'],
|
|
152
|
+
],
|
|
153
|
+
[
|
|
154
|
+
["file", multiFolders("spaceTwo/locales/de-DE/one.json")],
|
|
155
|
+
["key", "message.text-format"],
|
|
156
|
+
[
|
|
157
|
+
"msg",
|
|
158
|
+
'Expected element of type "tag" but received "number", Unexpected tag element',
|
|
159
|
+
],
|
|
160
|
+
],
|
|
161
|
+
[
|
|
162
|
+
["file", multiFolders("spaceTwo/locales/de-DE/three.json")],
|
|
163
|
+
["key", "numberFormat"],
|
|
164
|
+
["msg", "Missing element number"],
|
|
165
|
+
],
|
|
166
|
+
])}
|
|
119
167
|
|
|
120
168
|
`);
|
|
121
|
-
done();
|
|
122
|
-
});
|
|
123
169
|
});
|
|
124
|
-
it("should return the missing/invalid keys for multiple locale folders", (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
170
|
+
it("should return the missing/invalid keys for multiple locale folders", async () => {
|
|
171
|
+
const stdout = await execAsync("node dist/bin/index.js -l translations/multipleFoldersExample/spaceOne translations/multipleFoldersExample/spaceTwo -s en-US");
|
|
172
|
+
const result = stdout.split("Done")[0];
|
|
173
|
+
expect(result).toEqual(`i18n translations checker
|
|
128
174
|
Source: en-US
|
|
129
175
|
|
|
130
176
|
Found missing keys!
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
177
|
+
${(0, errorReporters_1.formatTable)([
|
|
178
|
+
[["file", "key"]],
|
|
179
|
+
[
|
|
180
|
+
[multiFolders("spaceOne/locales/de-DE/one.json"), "message.text-format"],
|
|
181
|
+
[multiFolders("spaceOne/locales/de-DE/two.json"), "test.drive.four"],
|
|
182
|
+
[multiFolders("spaceTwo/locales/de-DE/one.json"), "message.plural"],
|
|
183
|
+
[multiFolders("spaceTwo/locales/de-DE/two.json"), "test.drive.two"],
|
|
184
|
+
],
|
|
185
|
+
])}
|
|
139
186
|
|
|
140
187
|
Found invalid keys!
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
188
|
+
${(0, errorReporters_1.formatTable)([
|
|
189
|
+
[["info", "result"]],
|
|
190
|
+
[
|
|
191
|
+
["file", multiFolders("spaceOne/locales/de-DE/one.json")],
|
|
192
|
+
["key", "message.select"],
|
|
193
|
+
[
|
|
194
|
+
"msg",
|
|
195
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
196
|
+
],
|
|
197
|
+
],
|
|
198
|
+
[
|
|
199
|
+
["file", multiFolders("spaceOne/locales/de-DE/three.json")],
|
|
200
|
+
["key", "multipleVariables"],
|
|
201
|
+
["msg", 'Expected argument to contain "user" but received "name"'],
|
|
202
|
+
],
|
|
203
|
+
[
|
|
204
|
+
["file", multiFolders("spaceTwo/locales/de-DE/one.json")],
|
|
205
|
+
["key", "message.text-format"],
|
|
206
|
+
[
|
|
207
|
+
"msg",
|
|
208
|
+
'Expected element of type "tag" but received "number", Unexpected tag element',
|
|
209
|
+
],
|
|
210
|
+
],
|
|
211
|
+
[
|
|
212
|
+
["file", multiFolders("spaceTwo/locales/de-DE/three.json")],
|
|
213
|
+
["key", "numberFormat"],
|
|
214
|
+
["msg", "Missing element number"],
|
|
215
|
+
],
|
|
216
|
+
])}
|
|
160
217
|
|
|
161
218
|
`);
|
|
162
|
-
done();
|
|
163
|
-
});
|
|
164
219
|
});
|
|
165
|
-
it("should return the missing/invalid keys for all files in the provided locale folders", (
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
220
|
+
it("should return the missing/invalid keys for all files in the provided locale folders", async () => {
|
|
221
|
+
const stdout = await execAsync("node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples");
|
|
222
|
+
const result = stdout.split("Done")[0];
|
|
223
|
+
expect(result).toEqual(`i18n translations checker
|
|
169
224
|
Source: en-US
|
|
170
225
|
|
|
171
226
|
Found missing keys!
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
227
|
+
${(0, errorReporters_1.formatTable)([
|
|
228
|
+
[["file", "key"]],
|
|
229
|
+
[
|
|
230
|
+
[tr("flattenExamples/de-de.json"), "other.nested.three"],
|
|
231
|
+
[tr("flattenExamples/de-de.json"), "other.nested.deep.more.final"],
|
|
232
|
+
[tr("messageExamples/de-de.json"), "richText"],
|
|
233
|
+
[tr("messageExamples/de-de.json"), "yo"],
|
|
234
|
+
[tr("messageExamples/de-de.json"), "nesting1"],
|
|
235
|
+
[tr("messageExamples/de-de.json"), "nesting2"],
|
|
236
|
+
[tr("messageExamples/de-de.json"), "nesting3"],
|
|
237
|
+
[tr("messageExamples/de-de.json"), "key1"],
|
|
238
|
+
],
|
|
239
|
+
])}
|
|
184
240
|
|
|
185
241
|
Found invalid keys!
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
242
|
+
${(0, errorReporters_1.formatTable)([
|
|
243
|
+
[["info", "result"]],
|
|
244
|
+
[
|
|
245
|
+
["file", tr("messageExamples/de-de.json")],
|
|
246
|
+
["key", "multipleVariables"],
|
|
247
|
+
["msg", "Unexpected date element"],
|
|
248
|
+
],
|
|
249
|
+
])}
|
|
193
250
|
|
|
194
251
|
`);
|
|
195
|
-
done();
|
|
196
|
-
});
|
|
197
252
|
});
|
|
198
|
-
it("should return the missing/invalid keys for all files with source matching folder and source matching file", (
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
253
|
+
it("should return the missing/invalid keys for all files with source matching folder and source matching file", async () => {
|
|
254
|
+
const stdout = await execAsync("node dist/bin/index.js -l translations/multipleFilesFolderExample translations/flattenExamples -s en-US");
|
|
255
|
+
const result = stdout.split("Done")[0];
|
|
256
|
+
expect(result).toEqual(`i18n translations checker
|
|
202
257
|
Source: en-US
|
|
203
258
|
|
|
204
259
|
Found missing keys!
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
260
|
+
${(0, errorReporters_1.formatTable)([
|
|
261
|
+
[["file", "key"]],
|
|
262
|
+
[
|
|
263
|
+
[tr("flattenExamples/de-de.json"), "other.nested.three"],
|
|
264
|
+
[tr("flattenExamples/de-de.json"), "other.nested.deep.more.final"],
|
|
265
|
+
[multiFiles("de-DE/one.json"), "message.text-format"],
|
|
266
|
+
[multiFiles("de-DE/two.json"), "test.drive.four"],
|
|
267
|
+
],
|
|
268
|
+
])}
|
|
213
269
|
|
|
214
270
|
Found invalid keys!
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
271
|
+
${(0, errorReporters_1.formatTable)([
|
|
272
|
+
[["info", "result"]],
|
|
273
|
+
[
|
|
274
|
+
["file", multiFiles("de-DE/one.json")],
|
|
275
|
+
["key", "message.select"],
|
|
276
|
+
[
|
|
277
|
+
"msg",
|
|
278
|
+
'Expected element of type "select" but received "argument", Unexpected date element, Unexpected date element...',
|
|
279
|
+
],
|
|
280
|
+
],
|
|
281
|
+
[
|
|
282
|
+
["file", multiFiles("de-DE/three.json")],
|
|
283
|
+
["key", "multipleVariables"],
|
|
284
|
+
["msg", 'Expected argument to contain "user" but received "name"'],
|
|
285
|
+
],
|
|
286
|
+
])}
|
|
226
287
|
|
|
227
288
|
`);
|
|
228
|
-
done();
|
|
229
|
-
});
|
|
230
289
|
});
|
|
231
|
-
it("should ignore the excluded file", (
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
290
|
+
it("should ignore the excluded file", async () => {
|
|
291
|
+
const stdout = await execAsync("node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples --exclude translations/flattenExamples/de-de.json");
|
|
292
|
+
const result = stdout.split("Done")[0];
|
|
293
|
+
expect(result).toEqual(`i18n translations checker
|
|
235
294
|
Source: en-US
|
|
236
295
|
|
|
237
296
|
Found missing keys!
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
297
|
+
${(0, errorReporters_1.formatTable)([
|
|
298
|
+
[["file", "key"]],
|
|
299
|
+
[
|
|
300
|
+
[tr("messageExamples/de-de.json"), "richText"],
|
|
301
|
+
[tr("messageExamples/de-de.json"), "yo"],
|
|
302
|
+
[tr("messageExamples/de-de.json"), "nesting1"],
|
|
303
|
+
[tr("messageExamples/de-de.json"), "nesting2"],
|
|
304
|
+
[tr("messageExamples/de-de.json"), "nesting3"],
|
|
305
|
+
[tr("messageExamples/de-de.json"), "key1"],
|
|
306
|
+
],
|
|
307
|
+
])}
|
|
248
308
|
|
|
249
309
|
Found invalid keys!
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
310
|
+
${(0, errorReporters_1.formatTable)([
|
|
311
|
+
[["info", "result"]],
|
|
312
|
+
[
|
|
313
|
+
["file", tr("messageExamples/de-de.json")],
|
|
314
|
+
["key", "multipleVariables"],
|
|
315
|
+
["msg", "Unexpected date element"],
|
|
316
|
+
],
|
|
317
|
+
])}
|
|
257
318
|
|
|
258
319
|
`);
|
|
259
|
-
done();
|
|
260
|
-
});
|
|
261
320
|
});
|
|
262
|
-
it("should ignore the excluded folder", (
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
321
|
+
it("should ignore the excluded folder", async () => {
|
|
322
|
+
const stdout = await execAsync("node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples --exclude translations/flattenExamples/*");
|
|
323
|
+
const result = stdout.split("Done")[0];
|
|
324
|
+
expect(result).toEqual(`i18n translations checker
|
|
266
325
|
Source: en-US
|
|
267
326
|
|
|
268
327
|
Found missing keys!
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
328
|
+
${(0, errorReporters_1.formatTable)([
|
|
329
|
+
[["file", "key"]],
|
|
330
|
+
[
|
|
331
|
+
[tr("messageExamples/de-de.json"), "richText"],
|
|
332
|
+
[tr("messageExamples/de-de.json"), "yo"],
|
|
333
|
+
[tr("messageExamples/de-de.json"), "nesting1"],
|
|
334
|
+
[tr("messageExamples/de-de.json"), "nesting2"],
|
|
335
|
+
[tr("messageExamples/de-de.json"), "nesting3"],
|
|
336
|
+
[tr("messageExamples/de-de.json"), "key1"],
|
|
337
|
+
],
|
|
338
|
+
])}
|
|
279
339
|
|
|
280
340
|
Found invalid keys!
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
341
|
+
${(0, errorReporters_1.formatTable)([
|
|
342
|
+
[["info", "result"]],
|
|
343
|
+
[
|
|
344
|
+
["file", tr("messageExamples/de-de.json")],
|
|
345
|
+
["key", "multipleVariables"],
|
|
346
|
+
["msg", "Unexpected date element"],
|
|
347
|
+
],
|
|
348
|
+
])}
|
|
288
349
|
|
|
289
350
|
`);
|
|
290
|
-
done();
|
|
291
|
-
});
|
|
292
351
|
});
|
|
293
|
-
it("should ignore the excluded multiple files", (
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
352
|
+
it("should ignore the excluded multiple files", async () => {
|
|
353
|
+
const stdout = await execAsync("node dist/bin/index.js --source en-US --locales translations/flattenExamples translations/messageExamples --exclude translations/flattenExamples/de-de.json translations/messageExamples/de-de.json");
|
|
354
|
+
const result = stdout.split("Done")[0];
|
|
355
|
+
expect(result).toEqual(`i18n translations checker
|
|
297
356
|
Source: en-US
|
|
298
357
|
|
|
299
358
|
No missing keys found!
|
|
@@ -301,13 +360,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", (
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
364
|
+
it("should find unused and undefined keys for react-i18next applications", async () => {
|
|
365
|
+
const stdout = await execAsync("node dist/bin/index.js --source en --locales translations/codeExamples/reacti18next/locales -f i18next -u translations/codeExamples/reacti18next/src --parser-component-functions WrappedTransComponent");
|
|
366
|
+
const result = stdout.split("Done")[0];
|
|
367
|
+
expect(result).toEqual(`i18n translations checker
|
|
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
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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", (
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
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
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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", (
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
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
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
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
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
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", (
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
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
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
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", (
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
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
|
-
|
|
438
|
-
|
|
439
|
-
|
|
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
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
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", (
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
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
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
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", (
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
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
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
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
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
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", (
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
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
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
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
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
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", (
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
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
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
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
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
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", (
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
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
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
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
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
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
|
});
|