Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Simple, standards-based localization. Just one T
away.
Just wrap your user-facing strings in T
. Don't worry about IDs.
// Import T as a singleton
import {T} from "t-i18n"
T("Hello world")
Extract the strings from your code:
extract-strings --outfile=messages.en.json ./src/**/*.ts
Translate the JSON files:
// messages.es.json
{
"Hello-world": "Hola mundo"
}
Then load the translations, pass them to T
and set the locale.
T.setup({
locale: "es",
messages: {
en: englishJSON,
es: spanishJSON
}
})
And that's it. You're localized.
Formatting is provided courtesy of the Intl API built into modern browsers.
// Get a localized, formatted date
T.date(Date.now(), "short")
// Or a number
T.number(5, "currency")
Formatters cache themselves automatically, so you don't have to.
Basic values are easy to replace.
// "First name: Wendy"
T("First name: {userName}", { userName: "Wendy"})
Non-string values (like React components) can be interpolated using an XML syntax.
// ["There's a ", <button>button</button>, " in my sentence!"]
T.$(
"There's a <myButton /> in my {text}!",
{
myButton: () => <button>button</button>,
text: "sentence",
}
)
If your components have string children, you can translate them inline.
// [
// <a href={"/user/" + user.uuid}>Visit your <strong>profile</strong></a>,
// " to change your profile picture."
// ]
T.$(
"<link>Visit your <strong>profile</strong></link> to change your profile picture.",
{
link: (...children) => <a href={"/user/" + user.uuid}>{...children}</a>,
strong: (...children) => <strong>{...children}</strong>,
}
)
To get locale-aware pluralization, you should precompile your translations using an ICU-compliant tool. Then pass the compiled messages to T.setup
instead of strings.
// Pluralization with ICU syntax
T("You have { plural, numCats, =0 {0 cats} other {# cats} }", {numCats: 4})
FAQs
Simple, standards-based localization
The npm package t-i18n receives a total of 0 weekly downloads. As such, t-i18n popularity was classified as not popular.
We found that t-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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.