
Research
/Security News
11 Malicious NuGet Tools Pose as Game Cheats to Drop a Windows Host-Surveillance Payload
11 malicious NuGet tools pose as game cheats to deploy Windows payloads, track hosts, and use Google Sheets for telemetry and control.
@k14v/i18njs
Advanced tools
i18njs it's made to intended simplify and normalize internationalization and make compatible with all kind of javascript environments.
In general, many logics that has an exposed API to end users should have the accessibility to handle literals that the user can understand in their language. Many libraries try to solve this by using static translation catalogs, but typically when the catalog is heavily loaded with data, the scalability is actually seen to be well below performance. To handle this with a dynamic way, the store has the capability to load fragments of catalogs using remotes sources of data using a sourcemap to track the needed snippets, this becomes a logic asynchronous with smaller pieces of load that also can handle changes without impacting performance.
Using this system the library includes a feedback system to manage the current state and decide if its logic needs to be frozen to wait until the process is finished. This library offers many ways to manage it (subscriptions, events or promises).
$ npm install --save @k14v/i18njs
Provides a instance of i18njs to handle multiple locales asynchronously
options optionsconst i18n = i18njs({
locale: 'es',
locales: ['de', 'es', 'en'],
resolver: (locale) => ({ foo: 'bar' }),
});
Returns object i18n instance
Option struct.
Type: object
locale string? predefined default locale, if setted it will execute setLocale internally to load the locale resource, keep it undefined to handle this behaviour outside the logic.locales (Array<string> | object)? Array of strings of available locales using the standard ISO_639-1resolver function used to resolve asyncronous locale resourcesTranslation singleton with all interpolation utilities corresponding to the current locale
Type: object
Updates the current locale and refresh trls singleton
locale string [description]Returns promise
Obtain and array of string in ISO_639 format with all loaded locales
Returns Array Array of string ISO_639-1
Obtain current locale ISO_639
Get current catalog of literal translations from cache
Returns object
Get all catalogs of literal translations
Returns object
Subcribe to the changes of loading state flow
const unsubscribe = i18n.subscribe(({ type, locale }) => {
switch(type) {
case 'loading':
// dispatch function to handle loading state
break;
case 'loaded':
// dispatch function to handle loading state
break;
case 'error':
// dispatch function to handle error state
break;
}
});
Returns object
Fetch i18n instance with preloaded locale resource
i18njs
.fetch({
locale: 'es',
resolver: () => Promise.resolve({ 'foo': 'bar' })
...options
})
.then((i18n) => {
i18n.trls.__('foo') // bar
});
trls.__('esto es una prueba')
const i18n = i18njs({
locales: {
en: {
'Group': 'Grupo',
'The cow': 'La vaca',
'the fence': 'la valla',
'The rabbit': 'El conejo',
'the table': 'la mesa',
'Sometimes I drink %d beers': {
one: 'A veces me bebo una cerveza',
other: 'A veces me bebo muchas cervezas',
},
'%s jumped over %s, %d times': {
one: '%s saltó por encima de %s, una vez',
other: '%s saltó por encima de %s, %d veces'
}
}
},
});
i18n.trls.__('Sometimes I drink 1 beers')
// A veces me bebo una cerveza
i18n.trls.__('Sometimes I drink 10 beers')
// A veces me bebo muchas cervezas
i18n.trls.__('The cow jumped over the fence, 10 times')
// La vaca saltó por encima de la valla, 10 veces
i18n.trls.__('The rabbit jumped over the table, 1 times')
// El conejo saltó por encima de la mesa, una vez
FAQs
Library to internationalize literals
We found that @k14v/i18njs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
11 malicious NuGet tools pose as game cheats to deploy Windows payloads, track hosts, and use Google Sheets for telemetry and control.

Research
/Security News
4 compromised asyncapi packages deliver miasma botnet loader on macOS, Linux and Windows.

Research
/Security News
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.