@drewjbartlett/i17n
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -5,3 +5,3 @@ { | ||
"type": "module", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"files": [ | ||
@@ -8,0 +8,0 @@ "dist" |
@@ -9,3 +9,3 @@ # i17n | ||
- ✅ basic `{ "key": "value" }` translations `t('hello.world')` | ||
- ✅ basic `{ "key": "value" }` translations `t('key')` | ||
- ✅ interpolated values `t('Hello, {name}!', { name: 'Drew' })` | ||
@@ -28,3 +28,3 @@ - ✅ count based translations `t('tree', { count: 1 }) // "tree"`, `t('tree', { count: 10 }) // "trees"` | ||
```bash | ||
npm i @drewjbartlett/i17n | ||
npm i @drewjbartlett/i17n --save | ||
``` | ||
@@ -36,3 +36,2 @@ | ||
```json | ||
// translations.json | ||
{ | ||
@@ -50,3 +49,3 @@ "helloWorld": "Hello World!", | ||
}, | ||
}; | ||
} | ||
``` | ||
@@ -79,14 +78,22 @@ | ||
const i17n = createI17n({ | ||
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 coding conventions. | ||
*/ | ||
```ts | ||
// 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') | ||
``` | ||
@@ -93,0 +100,0 @@ |
15794
159