Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
@drewjbartlett/i17n
Advanced tools
[![Core CI](https://github.com/drewjbartlett/i17n/actions/workflows/core.yml/badge.svg)](https://github.com/drewjbartlett/i17n/actions/workflows/core.yml)
A 1.4kB internationalization library that acts is intended for projects needing basic translations.
mini17n features :
{ "key": "value" }
translations t('key')
t('Hello, {name}!', { name: 'Drew' })
t('tree', { count: 1 }) // "tree"
, t('tree', { count: 10 }) // "trees"
i17n is intended to inform that this is not a full-fledged i18n library. There is only support for a single translation or language at a time. If your project is smaller or a startup with no need for multiple languages yet, but may need them in the future, the i18n familiar API of i17n is exactly what you need.
Using internationalization is not just for languages. It helps create a consistent UX for your application and separates the concerns of text and UIs. Imagine your application sometimes says "Add Item" and other times says "Create Item" and even worse, says "New Item" in other places. This can be confusing to some users and leads to an inconsistent user experience. i17n allows you to have a single definition { "addItem": "Add {item}" }
that you can reference all over your application, t('addItem', { item: 'model.name' }).
npm i @drewjbartlett/i17n --save
{
"helloWorld": "Hello World!",
"welcomeUser": "Welcome, {user}!",
"global": {
"edit": "Edit",
"save": "Save",
"addNew": "Add New {item}",
},
"item": {
"name__one": "Item",
"name__many": "Items",
},
}
// or translations.ts
export const lang = {
helloWorld: 'Hello World!,
welcomeUser: 'Welcome, {user}!',
user: {
name: 'User',
},
global: {
edit: 'Edit',
save: 'Save',
addNew: 'Add New {item}',
},
item: {
name__one: 'Item',
name__many: 'Items',
},
};
// i17n.ts
import { createI7n } from '@drewjbartlett/i17n'
import Translations from 'path/to/translations';
export const i17n = createI17n({
translations: Translations,
});
// another-file.ts
import { i17n } from 'path/to/i17n'
i17n.t('helloWorld'); // "Hello World"
// Optionally, export your own helpers to match your conventions.
const $t = i18n.t;
export { $t }
// another-file.ts
import { $t } from 'path/to/i17n'
$t('helloWorld')
// i17n.ts
import { createI7n } from '@drewjbartlett/i17n'
import Translations from 'path/to/translations';
const i17n = createI17n({
translations: Translations,
});
const I18nPlugin = {
install(app) {
app.config.globalProperties.$t = i18n.t;
},
};
const app = createApp(MainApp);
app.use(I18nPlugin);
<template>
<h1>{{ $t('welcomeUser', { user: myUser }) }}</h1>
</template>
import Vue from 'vue';
const I18nPlugin = {
install: (Vue) => {
Vue.prototype.$t = i18n.t;
},
};
Vue.use(I18nPlugin)
<template>
<h1>{{ $t('welcomeUser', { user: myUser }) }}</h1>
</template>
FAQs
[![Core CI](https://github.com/drewjbartlett/i17n/actions/workflows/core.yml/badge.svg)](https://github.com/drewjbartlett/i17n/actions/workflows/core.yml) [![npm](https://img.shields.io/npm/dt/@drewjbartlett/i17n.svg?style=flat-square)](https://www.npmjs
The npm package @drewjbartlett/i17n receives a total of 5 weekly downloads. As such, @drewjbartlett/i17n popularity was classified as not popular.
We found that @drewjbartlett/i17n demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.