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.
translations
Advanced tools
translations api for node.js, browsers and the command line.
npm install translations
var locale = require('locales/de-DE.json'); // node.js;
var locale = window.locale; // browser example
var t = translations(locale); // production mode: ignores most errors
var t = translations(locale, true); // development mode: throws more errors
t('How are you?');
// "Wie geht es dir?"
t('Hello {name}, how are you?', { name: 'Max' });
// "Hallo Max, wie geht es dir?"
t('Hello {name}, how is {thing}?', { name: 'Max', thing: t('the weather') });
// "Hallo Max, wie ist das Wetter?"
t('undefined key in locale');
// throws error in development mode for undefined keys
// returns empty string in production mode
t('Hello {name}, how is {thing}?', { name: 'Max' });
// throws error in development mode for undefined variables
// prints placeholders in production mode
de-DE.json
{
"How are you?": "Wie geht es dir?",
"Hello {name}, how are you?": "Hallo {name}, wie geht es dir?",
"Hello {name}, how is {thing}?": "Hallo {name}, wie ist {thing}?",
"the weather": "das Wetter"
}
npm install translations -g # if you want to use the cli globally
# sync locales
translations sync <master> <target>
# example
translations sync locales/en.json locales/de-DE.json
translations sync
syncs the master
translations file with the target
one:
If target
has values that are not strings, it throws an error.
If target
does not exist yet, a copy of master
will be created with the target’s name (de-DE.json
).
If target
does already exist, the command does the following:
master
is removedtarget
is added# export locales for browser usage
translations export <inputDirectory> <outputDirectory> --assign <variable>
translations export
will create or overwrite the given output directory with js files for valid locales in the input directory. Each js
file assigns the locale’s translations to the given variable (or window.locale
by default).
MIT (2015) Maximilian Hoffmann
FAQs
translations api for node.js, browsers and the command line
The npm package translations receives a total of 347 weekly downloads. As such, translations popularity was classified as not popular.
We found that translations 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.
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.