0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-24 10:58:52 +01:00
wagtail/client/extract-translatable-strings.js
Matt Westcott d8ff3cbcf2 Fix JS string extraction for ngettext
The definition for ngettext in extract-translatable-strings had incorrect argument positions, and as a result strings translated with ngettext were missed from the .po file.
2022-10-28 11:30:19 +01:00

32 lines
684 B
JavaScript

const { GettextExtractor, JsExtractors } = require('gettext-extractor');
const extractor = new GettextExtractor();
extractor
.createJsParser([
JsExtractors.callExpression('gettext', {
arguments: {
text: 0,
context: 1,
},
}),
JsExtractors.callExpression('gettext_noop', {
arguments: {
text: 0,
context: 1,
},
}),
JsExtractors.callExpression('ngettext', {
arguments: {
text: 0,
textPlural: 1,
context: 3,
},
}),
])
.parseFilesGlob('./src/**/*.@(ts|js|tsx)');
extractor.savePotFile('../wagtail/admin/locale/en/LC_MESSAGES/djangojs.po');
extractor.printStats();