kopia lustrzana https://github.com/wagtail/wagtail
Add a script to extract strings from javascript
rodzic
1e884285a1
commit
2b1d1d0749
|
@ -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();
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
Ładowanie…
Reference in New Issue