Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
cjs-gettext
Advanced tools
This localization module is an instance of Emitter module. Contains localization messages data used by other modules and provides methods to requests these messages.
npm install cjs-gettext
Example data
format:
{
"meta": {
"charset": "utf-8",
"project": "downloads",
"language": "ru",
"plural": "(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)"
},
"data": {
"": {
"some text": "некоторый текст",
"Close": "Закрыть",
"Error": "Ошибка",
"File name:": "Имя файла:",
},
"some context": {
"some text": "Лирика",
"Close": "Выйти",
"Error": "Недопустимое действие",
}
}
}
Add the constructor to the scope and create an instance with some data:
var Gettext = require('cjs-gettext'),
gettext = new Gettext(data);
Then it's possible to make direct calls to make simple replacement:
console.log(gettext.gettext('Close'));
Fetch a particular translation of the textual message:
console.log(gettext.pgettext('some context', 'some text'));
Native language translation of a textual message whose grammatical form depends on a number:
console.log(gettext.ngettext('{0} cat', '{0} cats', 1));
There is a global var
DEVELOP
which activates additional consistency checks and protection logic not available in release mode.
If you have any problems or suggestions please open an issue according to the contribution rules.
cjs-gettext
is released under the MIT License.
FAQs
Application localization tools.
We found that cjs-gettext 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
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.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.