Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
node-gettext
Advanced tools
node-gettext is a Node.JS module to use .MO and .PO files.
NB! If you just want to parse or compile mo/po files, check out gettext-parser.
npm install node-gettext
var Gettext = require("node-gettext");
var gt = new Gettext();
addTextdomain(domain, file)
Language data needs to be in the Buffer format - it can be either contents of a MO or PO file.
addTextdomain(domain[, fileContents])
Load from a MO file
var fileContents = fs.readFileSync("et.mo");
gt.addTextdomain("et", fileContents);
or load from a PO file
var fileContents = fs.readFileSync("et.po");
gt.addTextdomain("et", fileContents);
Plural rules are automatically detected from the language code
gt.addTextdomain("et");
gt.setTranslation("et", false, "hello!", "tere!");
textdomain(domain)
gt.textdomain("et");
The function also returns the current texdomain value
var curlang = gt.textdomain();
gettext(msgid)
var greeting = gt.gettext("Hello!");
dgettext(domain, msgid)
var greeting = gt.dgettext("et", "Hello!");
ngettext(msgid, msgid_plural, count)
gt.ngettext("%d Comment", "%d Comments", 10);
dngettext(domain, msgid, msgid_plural, count)
gt.dngettext("et", "%d Comment", "%d Comments", 10)
pgettext(msgctxt, msgid)
gt.pgettext("menu items", "File");
dpgettext(domain, msgctxt, msgid)
gt.dpgettext("et", "menu items", "File");
npgettext(msgctxt, msgid, msgid_plural, count)
gt.npgettext("menu items", "%d Recent File", "%d Recent Files", 3);
dnpgettext(domain, msgctxt, msgid, msgid_plural, count)
gt.dnpgettext("et", "menu items", "%d Recent File", "%d Recent Files", 3);
getComment(domain, msgctxt, msgid)
gt.getComment("et", "menu items", "%d Recent File");
Returns an object in the form of {translator: "", extracted: "", reference: "", flag: "", previous: ""}
If you need the translation object for a domain, for example et_EE
, you can access it from gt.domains.et_EE
.
If you want modify it and compile it to mo or po, checkout gettext-parser module.
MIT
v1.1.0
FAQs
A JavaScript implementation of gettext, a localization framework
The npm package node-gettext receives a total of 66,341 weekly downloads. As such, node-gettext popularity was classified as popular.
We found that node-gettext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.