Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
babel-gettext-extractor
Advanced tools
Extract gettext string with babel support syntax JSX, ES6, ... It is based on
node-gettext. This is a fork of the npm module babel-gettext-plugin
which
adds support for references and runs on earlier versions of node.
Supports babel 7.
yarn add babel-gettext-extractor
or
npm install --save babel-gettext-extractor
var babel = require("babel");
babel.transform(code, { plugins:["babel-gettext-extractor"]});
babel --plugins babel-gettext-extractor code.js
"plugins": [
[ "babel-gettext-extractor", {
"headers": <Object>,
"functionNames": <Object>,
"fileName": <String|Function>,
"baseDirectory": <String>,
"stripTemplateLiteralIndent": <Boolean>
}]
]
The headers to put in the po file.
headers: {
"content-type": "text/plain; charset=UTF-8",
"plural-forms": "nplurals=2; plural=(n!=1);"
}
A list of function names to extract. The list is the definition of the
parameters: "domain"
, "msgctxt"
, "msgid"
, "msgid_plural"
and
"count"
example:
functionNames: {
myfunction: ["msgid"]
}
The filename where the end result is placed. If you supply a function, it will receive the current file babel is working on and you can return the full path to where you want to save your translation template for this particular file.
example:
[
require("babel-gettext-extractor"),
{
fileName: (file) => {
const sourceFile = file.opts.sourceFileName;
if (/^node_modules\//.test(sourceFile)) {
return false;
}
return sourceFile
.split(/[\/\\.]/)
.filter(name => !['src', 'packages', 'js'].includes(name))
.slice(0, 2)
.join('-') + '-template.pot';
},
},
]
If provided, then file names are chopped off in relation to this base path if filenames start with that path.
If true this will strip leading indents from multiline strings. Note: this requires gettext function implementations to do the same leading indent removal. Useful if you want to use Template literals for multiline strings to be passed into to gettext functions.
FAQs
Extract gettext string with babel
The npm package babel-gettext-extractor receives a total of 7,119 weekly downloads. As such, babel-gettext-extractor popularity was classified as popular.
We found that babel-gettext-extractor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.