-
Notifications
You must be signed in to change notification settings - Fork 21
/
i18next-scanner.config.js
59 lines (55 loc) · 1.43 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
48
49
50
51
52
53
54
55
56
57
58
59
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const path = require('path');
const typescript = require('typescript');
module.exports = {
input: ['src/**/*.{js,jsx,ts,tsx}'],
output: './',
options: {
debug: true,
func: {
list: ['i18next.t', 'i18n.t', 't'],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
trans: {
component: 'Trans',
extensions: [],
fallbackKey: function (ns, value) {
return value;
},
},
lngs: ['en'],
ns: ['plugin__kubevirt-plugin'],
defaultLng: 'en',
defaultNs: 'plugin__kubevirt-plugin',
resource: {
loadPath: 'locales/{{lng}}/{{ns}}.json',
savePath: 'locales/{{lng}}/{{ns}}.json',
jsonIndent: 2,
lineEnding: '\n',
},
nsSeparator: '~',
keySeparator: false,
interpolation: {
prefix: '{{',
suffix: '}}',
},
defaultValue: function (lng, ns, key) {
return key;
},
},
transform: function (file, enc, done) {
const { base, ext } = path.parse(file.path);
if (['.ts', '.tsx'].includes(ext) && !base.includes('.d.ts')) {
const content = fs.readFileSync(file.path, enc);
const { outputText } = typescript.transpileModule(content, {
compilerOptions: {
target: 'es2016',
},
fileName: path.basename(file.path),
});
this.parser.parseTransFromString(outputText);
}
done();
},
};