inline-i18n-multi-next 0.8.0 → 0.10.0
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 +36 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -300,6 +300,42 @@ export function ProfileForm() {
|
|
|
300
300
|
}
|
|
301
301
|
```
|
|
302
302
|
|
|
303
|
+
## Context System (v0.9.0)
|
|
304
|
+
|
|
305
|
+
Select translations based on context. Pass `_context` to `t()` to choose between contextual variants defined in your dictionaries.
|
|
306
|
+
|
|
307
|
+
```tsx
|
|
308
|
+
'use client'
|
|
309
|
+
import { useT } from 'inline-i18n-multi-next/client'
|
|
310
|
+
|
|
311
|
+
// Assuming dictionaries are loaded with contextual keys:
|
|
312
|
+
// { greeting: 'Hello', 'greeting#formal': 'Good day', 'greeting#casual': 'Hey' }
|
|
313
|
+
|
|
314
|
+
export function Greeting() {
|
|
315
|
+
const t = useT()
|
|
316
|
+
return (
|
|
317
|
+
<div>
|
|
318
|
+
<p>{t('greeting')}</p> {/* "Hello" */}
|
|
319
|
+
<p>{t('greeting', { _context: 'formal' })}</p> {/* "Good day" */}
|
|
320
|
+
<p>{t('greeting', { _context: 'casual' })}</p> {/* "Hey" */}
|
|
321
|
+
</div>
|
|
322
|
+
)
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Server components can also use context via the core `t()` function:
|
|
327
|
+
|
|
328
|
+
```tsx
|
|
329
|
+
import { t, setLocale } from 'inline-i18n-multi'
|
|
330
|
+
|
|
331
|
+
export default async function Page({ params }) {
|
|
332
|
+
const { locale } = await params
|
|
333
|
+
setLocale(locale)
|
|
334
|
+
|
|
335
|
+
return <h1>{t('greeting', { _context: 'formal' })}</h1>
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
303
339
|
## Custom Formatters
|
|
304
340
|
|
|
305
341
|
Register custom ICU formatters via the core re-exports.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inline-i18n-multi-next",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Next.js integration for inline-i18n-multi",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"react": "^18.0.0 || ^19.0.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"inline-i18n-multi": "0.
|
|
55
|
-
"inline-i18n-multi-react": "0.
|
|
54
|
+
"inline-i18n-multi": "0.10.0",
|
|
55
|
+
"inline-i18n-multi-react": "0.10.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/react": "^19.0.2",
|