inline-i18n-multi-next 0.6.0 → 0.8.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 CHANGED
@@ -15,7 +15,7 @@ npm install inline-i18n-multi-next
15
15
  | Entry point | Environment | Key exports |
16
16
  |---|---|---|
17
17
  | `inline-i18n-multi-next/server` | Server Components | `it`, `t`, `configureI18n`, `generateLocaleParams`, `createMetadata`, `getAlternates`, `createI18nMiddleware` |
18
- | `inline-i18n-multi-next/client` | Client Components | `LocaleProvider`, `useLocale`, `useT`, `it`, `T`, `RichText`, `useRichText`, `useLoadDictionaries`, `useDetectedLocale`, `registerFormatter`, `clearFormatters`, `detectLocale`, `configure`, `resetConfig` |
18
+ | `inline-i18n-multi-next/client` | Client Components | `LocaleProvider`, `useLocale`, `useT`, `useScopedT`, `it`, `T`, `RichText`, `useRichText`, `useLoadDictionaries`, `useDetectedLocale`, `registerFormatter`, `clearFormatters`, `detectLocale`, `clearICUCache`, `restoreLocale`, `configure`, `resetConfig`, `createScope` |
19
19
 
20
20
  ## Quick Start
21
21
 
@@ -229,6 +229,77 @@ export async function generateMetadata({ params }) {
229
229
  }
230
230
  ```
231
231
 
232
+ ## Plural Shorthand (v0.7.0)
233
+
234
+ Concise plural syntax:
235
+
236
+ ```tsx
237
+ // Server Component
238
+ export default async function Page() {
239
+ return (
240
+ <p>
241
+ {await it({
242
+ en: '{count, p, item|items}',
243
+ ko: '{count}개',
244
+ }, { count: 5 })}
245
+ </p>
246
+ )
247
+ }
248
+
249
+ // Client Component - also supports 3-part (zero|singular|plural)
250
+ <T en="{count, p, no items|item|items}" ko="{count, p, 없음|개|개}" count={0} />
251
+ ```
252
+
253
+ ## Locale Persistence (v0.7.0)
254
+
255
+ Auto-save and restore locale:
256
+
257
+ ```tsx
258
+ 'use client'
259
+ import { configure, restoreLocale } from 'inline-i18n-multi-next/client'
260
+
261
+ configure({
262
+ persistLocale: { storage: 'cookie', key: 'LOCALE', expires: 365 }
263
+ })
264
+
265
+ // Restore on app init
266
+ const saved = restoreLocale() // returns locale string or undefined
267
+ ```
268
+
269
+ ## Translation Scope (v0.8.0)
270
+
271
+ Scope translations to a key prefix with `useScopedT`. Useful for large apps where each component only needs a subset of the dictionary.
272
+
273
+ ```tsx
274
+ 'use client'
275
+ import { useScopedT } from 'inline-i18n-multi-next/client'
276
+
277
+ export function Dashboard() {
278
+ const t = useScopedT('dashboard')
279
+ return (
280
+ <div>
281
+ <h1>{t('title')}</h1> {/* resolves to 'dashboard.title' */}
282
+ <p>{t('subtitle')}</p> {/* resolves to 'dashboard.subtitle' */}
283
+ </div>
284
+ )
285
+ }
286
+ ```
287
+
288
+ You can also create a reusable scope with `createScope`:
289
+
290
+ ```tsx
291
+ 'use client'
292
+ import { useScopedT } from 'inline-i18n-multi-next/client'
293
+ import { createScope } from 'inline-i18n-multi-next/client'
294
+
295
+ const scope = createScope('settings.profile')
296
+
297
+ export function ProfileForm() {
298
+ const t = useScopedT(scope)
299
+ return <label>{t('name')}</label> {/* resolves to 'settings.profile.name' */}
300
+ }
301
+ ```
302
+
232
303
  ## Custom Formatters
233
304
 
234
305
  Register custom ICU formatters via the core re-exports.
package/dist/client.d.mts CHANGED
@@ -1 +1 @@
1
- export { CustomFormatter, DetectLocaleOptions, DetectSource, Dictionaries, Dictionary, Locale, LocaleProvider, PluralRules, RichText, RichTextSegment, T, TranslationVars, Translations, clearDictionaries, clearFormatters, detectLocale, en_de, en_es, en_fr, en_ja, en_zh, getDictionary, getLoadedLocales, getLocale, hasTranslation, isLoaded, it, it_de, it_es, it_fr, it_ja, it_zh, ja_es, ja_zh, loadAsync, loadDictionaries, loadDictionary, parseRichText, registerFormatter, setLocale, t, useDetectedLocale, useLoadDictionaries, useLocale, useRichText, useT, zh_es } from 'inline-i18n-multi-react';
1
+ export { CustomFormatter, DetectLocaleOptions, DetectSource, Dictionaries, Dictionary, Locale, LocaleProvider, PluralRules, RichText, RichTextSegment, T, TranslationVars, Translations, clearDictionaries, clearFormatters, clearICUCache, createScope, detectLocale, en_de, en_es, en_fr, en_ja, en_zh, getDictionary, getLoadedLocales, getLocale, hasTranslation, isLoaded, it, it_de, it_es, it_fr, it_ja, it_zh, ja_es, ja_zh, loadAsync, loadDictionaries, loadDictionary, parseRichText, registerFormatter, restoreLocale, setLocale, t, useDetectedLocale, useLoadDictionaries, useLocale, useRichText, useScopedT, useT, zh_es } from 'inline-i18n-multi-react';
package/dist/client.d.ts CHANGED
@@ -1 +1 @@
1
- export { CustomFormatter, DetectLocaleOptions, DetectSource, Dictionaries, Dictionary, Locale, LocaleProvider, PluralRules, RichText, RichTextSegment, T, TranslationVars, Translations, clearDictionaries, clearFormatters, detectLocale, en_de, en_es, en_fr, en_ja, en_zh, getDictionary, getLoadedLocales, getLocale, hasTranslation, isLoaded, it, it_de, it_es, it_fr, it_ja, it_zh, ja_es, ja_zh, loadAsync, loadDictionaries, loadDictionary, parseRichText, registerFormatter, setLocale, t, useDetectedLocale, useLoadDictionaries, useLocale, useRichText, useT, zh_es } from 'inline-i18n-multi-react';
1
+ export { CustomFormatter, DetectLocaleOptions, DetectSource, Dictionaries, Dictionary, Locale, LocaleProvider, PluralRules, RichText, RichTextSegment, T, TranslationVars, Translations, clearDictionaries, clearFormatters, clearICUCache, createScope, detectLocale, en_de, en_es, en_fr, en_ja, en_zh, getDictionary, getLoadedLocales, getLocale, hasTranslation, isLoaded, it, it_de, it_es, it_fr, it_ja, it_zh, ja_es, ja_zh, loadAsync, loadDictionaries, loadDictionary, parseRichText, registerFormatter, restoreLocale, setLocale, t, useDetectedLocale, useLoadDictionaries, useLocale, useRichText, useScopedT, useT, zh_es } from 'inline-i18n-multi-react';
package/dist/client.js CHANGED
@@ -24,6 +24,14 @@ Object.defineProperty(exports, "clearFormatters", {
24
24
  enumerable: true,
25
25
  get: function () { return inlineI18nMultiReact.clearFormatters; }
26
26
  });
27
+ Object.defineProperty(exports, "clearICUCache", {
28
+ enumerable: true,
29
+ get: function () { return inlineI18nMultiReact.clearICUCache; }
30
+ });
31
+ Object.defineProperty(exports, "createScope", {
32
+ enumerable: true,
33
+ get: function () { return inlineI18nMultiReact.createScope; }
34
+ });
27
35
  Object.defineProperty(exports, "detectLocale", {
28
36
  enumerable: true,
29
37
  get: function () { return inlineI18nMultiReact.detectLocale; }
@@ -120,6 +128,10 @@ Object.defineProperty(exports, "registerFormatter", {
120
128
  enumerable: true,
121
129
  get: function () { return inlineI18nMultiReact.registerFormatter; }
122
130
  });
131
+ Object.defineProperty(exports, "restoreLocale", {
132
+ enumerable: true,
133
+ get: function () { return inlineI18nMultiReact.restoreLocale; }
134
+ });
123
135
  Object.defineProperty(exports, "setLocale", {
124
136
  enumerable: true,
125
137
  get: function () { return inlineI18nMultiReact.setLocale; }
@@ -144,6 +156,10 @@ Object.defineProperty(exports, "useRichText", {
144
156
  enumerable: true,
145
157
  get: function () { return inlineI18nMultiReact.useRichText; }
146
158
  });
159
+ Object.defineProperty(exports, "useScopedT", {
160
+ enumerable: true,
161
+ get: function () { return inlineI18nMultiReact.useScopedT; }
162
+ });
147
163
  Object.defineProperty(exports, "useT", {
148
164
  enumerable: true,
149
165
  get: function () { return inlineI18nMultiReact.useT; }
package/dist/client.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export { LocaleProvider, RichText, T, clearDictionaries, clearFormatters, detectLocale, en_de, en_es, en_fr, en_ja, en_zh, getDictionary, getLoadedLocales, getLocale, hasTranslation, isLoaded, it, it_de, it_es, it_fr, it_ja, it_zh, ja_es, ja_zh, loadAsync, loadDictionaries, loadDictionary, parseRichText, registerFormatter, setLocale, t, useDetectedLocale, useLoadDictionaries, useLocale, useRichText, useT, zh_es } from 'inline-i18n-multi-react';
1
+ export { LocaleProvider, RichText, T, clearDictionaries, clearFormatters, clearICUCache, createScope, detectLocale, en_de, en_es, en_fr, en_ja, en_zh, getDictionary, getLoadedLocales, getLocale, hasTranslation, isLoaded, it, it_de, it_es, it_fr, it_ja, it_zh, ja_es, ja_zh, loadAsync, loadDictionaries, loadDictionary, parseRichText, registerFormatter, restoreLocale, setLocale, t, useDetectedLocale, useLoadDictionaries, useLocale, useRichText, useScopedT, useT, zh_es } from 'inline-i18n-multi-react';
2
2
  //# sourceMappingURL=client.mjs.map
3
3
  //# sourceMappingURL=client.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inline-i18n-multi-next",
3
- "version": "0.6.0",
3
+ "version": "0.8.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.6.0",
55
- "inline-i18n-multi-react": "0.6.0"
54
+ "inline-i18n-multi": "0.8.0",
55
+ "inline-i18n-multi-react": "0.8.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/react": "^19.0.2",