Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
lingui-i18n
Advanced tools
JS API for I18n using ICU message format
lingui-i18n
provide helpers for writing texts using ICU message format
npm install --save-dev lingui-i18n
# or
yarn add --dev lingui-i18n
Import i18n
object and load message catalog:
import { i18n } from 'lingui-i18n'
// load messages
i18n.load({
fr: {
"Hello World!": "Salut le monde!",
"My name is {name}": "Je m'appelle {name}",
"{count, plural, one {# book} other {# books}}": "{count, plural, one {# livre} other {# livres}}"
}
})
// set active language
i18n.use('fr')
Wrap you text in i18n.t
template literal tag so it's translated into active
language. Variables must be wrapped inside object literal, so the name of variable is preserved in message catalog:
i18n.t`Hello World!`
// becomes "Salut le monde!"
const name = "Fred"
i18n.t`My name is ${{ name }}`
// becomes "Je m'appelle Fred"
Plurals and selections are possible using plural
and select
methods (value must be again wrapped inside object literal):
const count = 42
i18n.plural({
value: { count },
one: "# book",
other: "# books"
})
// becomes "42 livres"
It's also possible to nest message formats. Each message format method in i18n
has a standalone companion, which only returns message without performing the translation:
import { t, plural } from 'lingui-i18n'
// use i18n.select here, to translate message format
i18n.select({
value: { gender },
offset: 1,
// plural, instead of i18n.plural
female: plural({
value: { numOfGuests },
offset: 1,
// t, instead of i18n.t
0: t`${host} does not give a party.`,
1: t`${host} invites ${guest} to her party.`,
2: t`${host} invites ${guest} and one other person to her party.`,
other: t`${host} invites ${guest} and # other people to her party.`
}),
male: plural({...}),
other: plural({...}),
})
FAQs
I18n tools for javascript
The npm package lingui-i18n receives a total of 276 weekly downloads. As such, lingui-i18n popularity was classified as not popular.
We found that lingui-i18n 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
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.