@fluenti/next 0.3.3 → 0.4.0-rc.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.
@@ -2,10 +2,18 @@
2
2
  * Per-component locale isolation for RSC.
3
3
  *
4
4
  * Temporarily switches the request-scoped locale, executes a function,
5
- * then restores the previous locale.
5
+ * then restores the previous locale. This allows rendering a subtree in
6
+ * a different locale without affecting the rest of the page.
6
7
  *
7
- * @example
8
+ * @param locale - The locale to switch to for the duration of `fn`.
9
+ * @param fn - The function to execute with the switched locale.
10
+ * @param serverModule - The generated server module reference (auto-injected
11
+ * by the webpack loader in production; only needed when calling manually).
12
+ * @returns The return value of `fn`.
13
+ *
14
+ * @example Basic usage in a Server Component
8
15
  * ```tsx
16
+ * // app/page.tsx (Server Component)
9
17
  * import { withLocale } from '@fluenti/next/server'
10
18
  *
11
19
  * export default async function Page() {
@@ -20,6 +28,26 @@
20
28
  * )
21
29
  * }
22
30
  * ```
31
+ *
32
+ * @example Rendering a multilingual page section
33
+ * ```tsx
34
+ * import { withLocale } from '@fluenti/next/server'
35
+ *
36
+ * export default async function MultilingualPage() {
37
+ * const englishContent = await withLocale('en', async () => (
38
+ * <p>{t`Welcome`}</p>
39
+ * ))
40
+ * const japaneseContent = await withLocale('ja', async () => (
41
+ * <p>{t`Welcome`}</p>
42
+ * ))
43
+ * return (
44
+ * <div>
45
+ * {englishContent}
46
+ * {japaneseContent}
47
+ * </div>
48
+ * )
49
+ * }
50
+ * ```
23
51
  */
24
52
  export declare function withLocale<T>(locale: string, fn: () => T | Promise<T>, serverModule?: {
25
53
  setLocale: (l: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"with-locale.d.ts","sourceRoot":"","sources":["../src/with-locale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAChC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EACxB,YAAY,CAAC,EAAE;IAAE,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;CAAE,GACjF,OAAO,CAAC,CAAC,CAAC,CAwBZ"}
1
+ {"version":3,"file":"with-locale.d.ts","sourceRoot":"","sources":["../src/with-locale.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAsB,UAAU,CAAC,CAAC,EAChC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EACxB,YAAY,CAAC,EAAE;IAAE,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;CAAE,GACjF,OAAO,CAAC,CAAC,CAAC,CAwBZ"}
package/llms-full.txt CHANGED
@@ -50,7 +50,8 @@ In a `withFluenti()` project, the recommended authoring surface is:
50
50
 
51
51
  ```tsx
52
52
  // ✅ Preferred: compile-time authoring surface
53
- import { t, Trans, Plural, Select, DateTime, NumberFormat } from '@fluenti/react'
53
+ import { t } from '@fluenti/react'
54
+ import { Trans, Plural, Select, DateTime, NumberFormat } from '@fluenti/react/components'
54
55
  ```
55
56
 
56
57
  This applies to both client and server authoring.
package/llms.txt CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  `@fluenti/next` wires Fluenti into Next.js. In a `withFluenti()` project, the recommended authoring path is:
6
6
 
7
- - client and server authoring: `import { t, Trans, Plural, Select, DateTime, NumberFormat } from '@fluenti/react'`
7
+ - client and server authoring: `import { t } from '@fluenti/react'` + `import { Trans, Plural, Select, DateTime, NumberFormat } from '@fluenti/react/components'`
8
8
  - Next runtime/integration: `I18nProvider`, `getI18n()`, and `setLocale()` from `@fluenti/next`
9
9
 
10
10
  ## Install
@@ -49,6 +49,43 @@ Provider entry (`@fluenti/next/provider`):
49
49
 
50
50
  ❌ AVOID: `t('some.key')` as the default — this is a legacy i18n pattern.
51
51
 
52
+ ## Code Examples — Next.js
53
+
54
+ ### Client Components
55
+
56
+ ```tsx
57
+ 'use client'
58
+ import { useI18n } from '@fluenti/react'
59
+
60
+ export function Header() {
61
+ const { t } = useI18n()
62
+ return <h1>{t\`Welcome to our app\`}</h1>
63
+ }
64
+ ```
65
+
66
+ ### Server Components (RSC)
67
+
68
+ ```tsx
69
+ import { getI18n } from '@fluenti/next/server'
70
+
71
+ export default async function Page() {
72
+ const { t } = await getI18n()
73
+ return <h1>{t\`Welcome to our app\`}</h1>
74
+ }
75
+ ```
76
+
77
+ ### What NOT to write
78
+
79
+ ❌ Do not use manual key strings:
80
+ ```tsx
81
+ // WRONG
82
+ const { t } = useI18n()
83
+ return <h1>{t('welcome_key')}</h1>
84
+
85
+ // CORRECT
86
+ return <h1>{t\`Welcome to our app\`}</h1>
87
+ ```
88
+
52
89
  ## Docs
53
90
 
54
91
  - Full docs: https://fluenti.dev
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluenti/next",
3
- "version": "0.3.3",
3
+ "version": "0.4.0-rc.0",
4
4
  "type": "module",
5
5
  "description": "Next.js plugin for Fluenti — withFluenti, I18nProvider, t`` transforms for App Router and Pages Router",
6
6
  "homepage": "https://fluenti.dev",
@@ -80,6 +80,20 @@
80
80
  "types": "./dist/navigation.d.ts",
81
81
  "default": "./dist/navigation.cjs"
82
82
  }
83
+ },
84
+ "./loader": {
85
+ "import": "./dist/loader.js",
86
+ "require": "./dist/loader.cjs"
87
+ },
88
+ "./i18n-config": {
89
+ "import": {
90
+ "types": "./dist/i18n-config.d.ts",
91
+ "default": "./dist/i18n-config.js"
92
+ },
93
+ "require": {
94
+ "types": "./dist/i18n-config.d.ts",
95
+ "default": "./dist/i18n-config.cjs"
96
+ }
83
97
  }
84
98
  },
85
99
  "files": [
@@ -93,15 +107,15 @@
93
107
  "dependencies": {
94
108
  "jiti": "^2",
95
109
  "picomatch": "^4",
96
- "@fluenti/core": "0.3.3",
97
- "@fluenti/react": "0.3.3"
110
+ "@fluenti/core": "0.4.0-rc.0",
111
+ "@fluenti/react": "0.4.0-rc.0"
98
112
  },
99
113
  "devDependencies": {
100
114
  "@types/node": "^25",
101
115
  "@types/react": "^19.0.0",
102
116
  "@types/react-dom": "^19.0.0",
103
117
  "@vitest/coverage-v8": "^4",
104
- "next": "^15",
118
+ "next": "^16",
105
119
  "react": "^19.0.0",
106
120
  "react-dom": "^19.0.0",
107
121
  "typescript": "^5.9",