forked from polkadot-js/extension
-
Notifications
You must be signed in to change notification settings - Fork 1
/
i18next-scanner.config.js
57 lines (50 loc) · 1.35 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
// Copyright 2019-2023 @polkadot/extension authors & contributors
// SPDX-License-Identifier: Apache-2.0
const fs = require('fs');
const path = require('path');
const typescript = require('typescript');
function transform (file, enc, done) {
const { ext } = path.parse(file.path);
if (ext === '.tsx') {
const content = fs.readFileSync(file.path, enc);
const { outputText } = typescript.transpileModule(content, {
compilerOptions: {
target: 'es2018'
},
fileName: path.basename(file.path)
});
this.parser.parseFuncFromString(outputText);
}
done();
}
module.exports = {
input: [
'packages/extension-ui/src/**/*.{ts,tsx}',
// Use ! to filter out files or directories
'!packages/*/src/**/*.spec.{ts,tsx}',
'!packages/*/src/i18n/**',
'!**/node_modules/**'
],
options: {
debug: true,
defaultLng: 'en',
func: {
extensions: ['.tsx', '.ts'],
list: ['t', 'i18next.t', 'i18n.t']
},
keySeparator: false, // key separator
lngs: ['en'],
nsSeparator: false, // namespace separator
resource: {
jsonIndent: 2,
lineEnding: '\n',
loadPath: 'packages/extension/public/locales/{{lng}}/{{ns}}.json',
savePath: 'packages/extension/public/locales/{{lng}}/{{ns}}.json'
},
trans: {
component: 'Trans'
}
},
output: './',
transform
};