Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
easygettext
Advanced tools
Simple gettext tokens extraction tools for HTML and Jade files. Also converts from PO to JSON.
angular-gettext is a very neat tool, that comes with Grunt tooling to extract translation tokens from your Jade/HTML templates and JavaScript code.
Unfortunately, this has two drawbacks:
This library comes up with two simple CLI tools to extract and compile your HTML tokens.
Our frontend toolchain, systematic doesn't rely on Grunt/Gulp/Broccoli/... and uses a combination of simple Makefiles and CLI tools to do the job.
The toolchain being framework-agnostic, we don't want to depend on Angular to extract our HTML translation tokens. On another note, we use the standard xgettext tool to extract our JavaScript translation tokens.
Nevertheless, the way [angular-gettext] does it (with tokens, directly in HTML) is elegant, is used by many other libraries and will also be the way to do it in Angular2.
Simply invoke the tool on the templates you want to extract a POT dictionary template from. The optional '--ouput' argument enables you to directly output to a file.
gettext-extract --output dictionary.pot foo.html bar.jade
It recognizes the following token flavours (currently; feel free to extend it!)
<div translate>Hello World</div>
<div translate translate-context="According to...">Hello World</div>
<div translate translate-comment="My comment...">Hello World</div>
<div translate translate-plural="Hello worlds">Hello World</div>
<div placeholder="{{ 'Hello World' | translate }}"></div>
<div placeholder="{{ scopeVariable || ('Hello World' | translate) }}"></div>
<translate>Hello World</translate>
You can combine any context, comment and plural together. Also, you can use 'i18n' instead of 'translate' as master token.
Outputs or writes to an output file, the sanitized JSON version of a PO file.
gettext-compile --output cn-translations.json cn.po
Run the tests using mocha:
npm test
We also have extensive coverage:
npm run cover
Thanks a million to @rubenv for the initial ideas and implementations in angular-gettext-tools, which inspired me a lot.
Thanks to ES6 and Babel for being awesome.
MIT
FAQs
Simple tools to extract gettext strings
The npm package easygettext receives a total of 9,328 weekly downloads. As such, easygettext popularity was classified as popular.
We found that easygettext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.