-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
i18next-scanner.config.js
47 lines (46 loc) · 1.27 KB
/
i18next-scanner.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const fs = require('fs');
module.exports = {
input: [
'src/**/*.{js,jsx}',
'!src/**/*.test.{js,jsx}',
// '!**/node_modules/**',
],
output: './',
options: {
debug: true,
func: {
list: ['t'],
extensions: ['.js', '.jsx'],
},
trans: {
extensions: [],
},
lngs: ['en', 'fr', 'de', 'es', 'it', 'pt', 'pl', 'eo', 'bg', 'cs', 'da', 'el', 'hr', 'lv', 'hu', 'nl', 'ro', 'sk', 'sl', 'fi', 'sv', 'ru'],
defaultValue: (lng, ns, key) => (lng === 'en' ? key : '__NOT_TRANSLATED__'),
resource: {
loadPath: 'resources/i18n/{{lng}}.json',
savePath: 'resources/i18n/{{lng}}.json',
jsonIndent: 2,
lineEnding: '\n',
},
nsSeparator: false,
keySeparator: false,
interpolation: {
prefix: '{{',
suffix: '}}',
},
transform(file, enc, done) {
const { parser } = this;
const content = fs.readFileSync(file.path, enc);
let count = 0;
parser.parseFuncFromString(content, { list: ['t'] }, (key, options) => {
parser.set(key, { ...options, nsSeparator: false, keySeparator: false });
count++;
});
if (count) {
console.log(`🗣️ i18next-scanner: count=${count}, file=${JSON.stringify(file.relative)}`);
}
done();
},
},
};