-
Notifications
You must be signed in to change notification settings - Fork 11
/
i18next-scanner.config.js
52 lines (51 loc) · 1.32 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
const typescriptTransform = require('i18next-scanner-typescript');
module.exports = {
input: [
'src/**/*.{ts,tsx}',
// Use ! to filter out files or directories
'!src/**/*.spec.{ts,tsx}',
'!src/i18n/**',
'!**/node_modules/**',
],
output: './public/',
options: {
debug: false,
removeUnusedKeys: false,
browserLanguageDetection: true,
func: {
list: ['i18next.t', 'i18n.t', 't'],
extensions: ['.js', '.jsx'],
},
trans: {
extensions: ['.js', '.jsx'],
fallbackKey(_, value) {
return value;
},
},
lngs: ['en', 'zh'],
ns: ['translation'],
defaultLng: 'en',
defaultNs: 'translation',
defaultValue(lng, ns, key) {
if (lng === 'en') {
// Return key as the default value for English language
return key;
}
// Return the string '__NOT_TRANSLATED__' for other languages
return '__NOT_TRANSLATED__';
},
resource: {
loadPath: './public/locales/{{lng}}/{{ns}}.json',
savePath: 'locales/{{lng}}/{{ns}}.json',
jsonIndent: 2,
lineEnding: '\n',
},
nsSeparator: false, // namespace separator
keySeparator: false, // key separator
interpolation: {
prefix: '{{',
suffix: '}}',
},
},
transform: typescriptTransform({ extensions: ['.tsx', 'ts'] }),
};