
Security News
New React Server Components Vulnerabilities: DoS and Source Code Exposure
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.
gettext-extract
Advanced tools
CLI for extracting Gettext messages from JavaScript, TypeScript, JSX and HTML
This CLI is essentially a convenience wrapper around gettext-extractor, all the processing is done by this library.
npm install gettext-extract
Usage: gettext-extract [options]
Options:
-c, --config Config file [default: .gettext.json]
-o, --output Output file [default: template.pot]
-h, --help Show this help
Configuration for message extraction can be provided using a .gettext.json file, a custom JSON file using the
--config CLI option or by adding a gettext object in your package.json.
Here is an example configuration (remove comments for valid JSON):
{
"js": {
"parsers": [
{
"expression": "gettext",
"arguments": {
"text": 0
}
},
{
"expression": "ngettext",
"arguments": {
"text": 0,
"textPlural": 1
}
},
{
"expression": "pgettext",
"arguments": {
"context": 0,
"text": 1
}
}
],
"glob": {
// [node-glob pattern(https://github.com/isaacs/node-glob#glob-primer) to match your JS files
"pattern": "src/**/*.ts",
// Add any [node-glob options](https://github.com/isaacs/node-glob#options) here
"options": {
"ignore": "src/**/*.spec.ts"
}
}
},
"html": {
"parsers": [
{
// Extract message from content of the HTML element with the specified CSS selector
"element": "[translate]",
"attributes": {
"textPlural": "translate-plural",
"context": "translate-context"
}
},
{
// Extract message from attribute of the HTML element
"attribute": "translate-text",
"attributes": {
"textPlural": "translate-plural",
"context": "translate-context"
}
}
],
"glob": {
"pattern": "src/**/*.html"
}
},
//
"headers": {
"Language": ""
},
"output": "translations/template.pot"
}
At least one valid parser (JS or HTML) with glob pattern must be present, everything else is optional.
You can fin additional information concerning the
JavaScript / TypeScript / JSX
or HTML parsers on the gettext-extractor wiki.
FAQs
CLI for extracting Gettext messages from JavaScript, TypeScript, JSX and HTML
The npm package gettext-extract receives a total of 729 weekly downloads. As such, gettext-extract popularity was classified as not popular.
We found that gettext-extract demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.