inline-i18n-multi 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# inline-i18n-multi
|
|
2
|
+
|
|
3
|
+
Inline i18n for JavaScript/TypeScript. Write translations where you use them.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install inline-i18n-multi
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { it, setLocale } from 'inline-i18n-multi'
|
|
15
|
+
|
|
16
|
+
setLocale('ko')
|
|
17
|
+
|
|
18
|
+
// Inline translation
|
|
19
|
+
it('안녕하세요', 'Hello') // → '안녕하세요'
|
|
20
|
+
|
|
21
|
+
// Object syntax for multiple languages
|
|
22
|
+
it({ ko: '안녕', en: 'Hi', ja: 'こんにちは' })
|
|
23
|
+
|
|
24
|
+
// With variables
|
|
25
|
+
it('안녕, {name}님', 'Hello, {name}', { name: 'World' })
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Key-Based Translation
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { t, loadDictionaries, setLocale } from 'inline-i18n-multi'
|
|
32
|
+
|
|
33
|
+
loadDictionaries({
|
|
34
|
+
en: { greeting: 'Hello', items: { count_one: '{count} item', count_other: '{count} items' } },
|
|
35
|
+
ko: { greeting: '안녕하세요', items: { count_other: '{count}개' } },
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
setLocale('en')
|
|
39
|
+
t('greeting') // → 'Hello'
|
|
40
|
+
t('items.count', { count: 5 }) // → '5 items'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Framework Integrations
|
|
44
|
+
|
|
45
|
+
- **React**: [`inline-i18n-multi-react`](https://www.npmjs.com/package/inline-i18n-multi-react)
|
|
46
|
+
- **Next.js**: [`inline-i18n-multi-next`](https://www.npmjs.com/package/inline-i18n-multi-next)
|
|
47
|
+
|
|
48
|
+
## Documentation
|
|
49
|
+
|
|
50
|
+
Full documentation: [GitHub](https://github.com/jaesukpark/inline-i18n-multi)
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
MIT
|