-
Notifications
You must be signed in to change notification settings - Fork 2
/
pot-extractor.js
50 lines (45 loc) · 1.27 KB
/
pot-extractor.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
const {
GettextExtractor,
JsExtractors,
HtmlExtractors
} = require('gettext-extractor');
let extractor = new GettextExtractor();
export function extract() {
extractor
.createJsParser([
JsExtractors.callExpression('getText', {
arguments: {
text: 0,
context: 1
}
}),
JsExtractors.callExpression('i18n.__', {
arguments: {
text: 0,
context: 1
}
}),
JsExtractors.callExpression('getPlural', {
arguments: {
text: 1,
textPlural: 2,
context: 3
}
}),
JsExtractors.callExpression('i18n.__n', {
arguments: {
text: 1,
textPlural: 2,
context: 3
}
})
])
.parseFilesGlob('./src/**/*.@(ts|js|tsx|jsx)');
extractor
.createHtmlParser([
HtmlExtractors.elementContent('translate, [translate]')
])
.parseFilesGlob('./src/**/*.html');
extractor.savePotFile('./locales/messages.pot');
extractor.printStats();
}