inline-i18n-multi 0.1.0 → 0.1.2
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 +56 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
> **Important:** For complete documentation, examples, and best practices, please read the [full documentation on GitHub](https://github.com/exiivy98/inline-i18n-multi).
|
|
2
|
+
|
|
3
|
+
# inline-i18n-multi
|
|
4
|
+
|
|
5
|
+
Inline i18n for JavaScript/TypeScript. Write translations where you use them.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install inline-i18n-multi
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { it, setLocale } from 'inline-i18n-multi'
|
|
17
|
+
|
|
18
|
+
setLocale('ko')
|
|
19
|
+
|
|
20
|
+
// Inline translation
|
|
21
|
+
it('안녕하세요', 'Hello') // → '안녕하세요'
|
|
22
|
+
|
|
23
|
+
// Object syntax for multiple languages
|
|
24
|
+
it({ ko: '안녕', en: 'Hi', ja: 'こんにちは' })
|
|
25
|
+
|
|
26
|
+
// With variables
|
|
27
|
+
it('안녕, {name}님', 'Hello, {name}', { name: 'World' })
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Key-Based Translation
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { t, loadDictionaries, setLocale } from 'inline-i18n-multi'
|
|
34
|
+
|
|
35
|
+
loadDictionaries({
|
|
36
|
+
en: { greeting: 'Hello', items: { count_one: '{count} item', count_other: '{count} items' } },
|
|
37
|
+
ko: { greeting: '안녕하세요', items: { count_other: '{count}개' } },
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
setLocale('en')
|
|
41
|
+
t('greeting') // → 'Hello'
|
|
42
|
+
t('items.count', { count: 5 }) // → '5 items'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Framework Integrations
|
|
46
|
+
|
|
47
|
+
- **React**: [`inline-i18n-multi-react`](https://www.npmjs.com/package/inline-i18n-multi-react)
|
|
48
|
+
- **Next.js**: [`inline-i18n-multi-next`](https://www.npmjs.com/package/inline-i18n-multi-next)
|
|
49
|
+
|
|
50
|
+
## Documentation
|
|
51
|
+
|
|
52
|
+
**Please read the [full documentation on GitHub](https://github.com/exiivy98/inline-i18n-multi)** for complete API reference, framework integrations, and best practices.
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
MIT
|