Add a script to extract strings from javascript

pull/8223/head
Karl Hobley 2022-02-10 17:20:59 +00:00 zatwierdzone przez Thibaud Colas
rodzic 1e884285a1
commit 2b1d1d0749
3 zmienionych plików z 38 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,32 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
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: 1,
textPlural: 2,
context: 3,
},
}),
])
.parseFilesGlob('./src/**/*.@(ts|js|tsx|jsx)');
extractor.savePotFile('../wagtail/admin/locale/en/LC_MESSAGES/djangojs.po');
extractor.printStats();

Wyświetl plik

@ -74,6 +74,7 @@
"enzyme-to-json": "^3.6.2",
"eslint": "^8.5.0",
"expose-loader": "^3.1.0",
"gettext-extractor": "^3.5.3",
"jest": "^26.6.3",
"mini-css-extract-plugin": "^2.4.5",
"postcss": "^8.4.7",

Wyświetl plik

@ -8,3 +8,8 @@ do
django-admin makemessages --locale=en
popd
done
# Extract translatable strings from JavaScript
pushd ../client
node extract-translatable-strings.js
popd