This repository has been archived by the owner on May 6, 2023. It is now read-only.
forked from polkadot-js/apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
i18next-scanner.config.js
89 lines (83 loc) · 2.07 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const fs = require('fs');
const path = require('path');
const typescript = require('typescript');
module.exports = {
input: [
'packages/*/src/**/*.{ts,tsx}',
// Use ! to filter out files or directories
'!packages/*/src/**/*.spec.{ts,tsx}',
'!packages/*/src/i18n/**',
'!**/node_modules/**'
],
output: './',
options: {
debug: true,
func: {
list: ['t', 'i18next.t', 'i18n.t'],
extensions: ['.tsx']
},
trans: {
component: 'Trans'
},
lngs: ['en'],
defaultLng: 'en',
ns: [
'app-123code',
'app-accounts',
'app-address-book',
'app-claims',
'app-contracts',
'app-council',
'app-dashboard',
'app-democracy',
'app-explorer',
'app-extrinsics',
'app-generic-asset',
'app-js',
'app-parachains',
'app-settings',
'app-staking',
'app-storage',
'app-sudo',
'app-toolbox',
'app-transfer',
'app-treasury',
'apps',
'apps-routing',
'react-api',
'react-components',
'react-params',
'react-query',
'react-signer',
'ui'
],
defaultNs: 'ui',
resource: {
loadPath: 'packages/apps/public/locales/{{lng}}/{{ns}}.json',
savePath: 'packages/apps/public/locales/{{lng}}/{{ns}}.json',
jsonIndent: 2,
lineEnding: '\n'
},
nsSeparator: false, // namespace separator
keySeparator: false // key separator
},
transform: 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)
});
const parserHandler = (key, options) => {
options.defaultValue = key;
options.ns = /packages\/(.*?)\/src/g.exec(file.path)[1];
this.parser.set(key, options);
};
this.parser.parseFuncFromString(outputText, parserHandler);
}
done();
}
};