inline-i18n-multi-react 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 +76 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# inline-i18n-multi-react
|
|
2
|
+
|
|
3
|
+
React bindings for inline-i18n-multi. Write translations inline in your components.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install inline-i18n-multi-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { LocaleProvider, it, T, useT } from 'inline-i18n-multi-react'
|
|
15
|
+
|
|
16
|
+
function App() {
|
|
17
|
+
return (
|
|
18
|
+
<LocaleProvider locale="ko">
|
|
19
|
+
<MyComponent />
|
|
20
|
+
</LocaleProvider>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function MyComponent() {
|
|
25
|
+
return (
|
|
26
|
+
<div>
|
|
27
|
+
{/* Inline function */}
|
|
28
|
+
<p>{it('안녕하세요', 'Hello')}</p>
|
|
29
|
+
|
|
30
|
+
{/* T component */}
|
|
31
|
+
<T ko="환영합니다" en="Welcome" ja="ようこそ" />
|
|
32
|
+
|
|
33
|
+
{/* With variables */}
|
|
34
|
+
<T ko="{count}개" en="{count} items" count={5} />
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Key-Based Translation with useT
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { useT, loadDictionaries } from 'inline-i18n-multi-react'
|
|
44
|
+
|
|
45
|
+
loadDictionaries({
|
|
46
|
+
en: { nav: { home: 'Home', about: 'About' } },
|
|
47
|
+
ko: { nav: { home: '홈', about: '소개' } },
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
function Nav() {
|
|
51
|
+
const t = useT()
|
|
52
|
+
return (
|
|
53
|
+
<nav>
|
|
54
|
+
<a href="/">{t('nav.home')}</a>
|
|
55
|
+
<a href="/about">{t('nav.about')}</a>
|
|
56
|
+
</nav>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## API
|
|
62
|
+
|
|
63
|
+
- `LocaleProvider` - Context provider for locale
|
|
64
|
+
- `useLocale()` - Get/set current locale
|
|
65
|
+
- `it(ko, en, vars?)` - Inline translation function
|
|
66
|
+
- `T` - Translation component with language props
|
|
67
|
+
- `useT()` - Hook returning key-based `t()` function
|
|
68
|
+
- `loadDictionaries(dict)` - Load translation dictionaries
|
|
69
|
+
|
|
70
|
+
## Documentation
|
|
71
|
+
|
|
72
|
+
Full documentation: [GitHub](https://github.com/jaesukpark/inline-i18n-multi)
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inline-i18n-multi-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React integration for inline-i18n-multi",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"react": "^18.0.0 || ^19.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"inline-i18n-multi": "0.1.
|
|
37
|
+
"inline-i18n-multi": "0.1.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/react": "^19.0.2",
|