@intlayer/docs 5.7.6 → 5.7.8

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.
Files changed (85) hide show
  1. package/dist/cjs/generated/docs.entry.cjs +44 -238
  2. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  3. package/dist/esm/generated/docs.entry.mjs +44 -238
  4. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  5. package/dist/types/generated/docs.entry.d.ts +1 -2
  6. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  7. package/docs/ar/CI_CD.md +67 -41
  8. package/docs/ar/intlayer_with_tanstack.md +457 -0
  9. package/docs/ar/packages/next-intlayer/index.md +0 -1
  10. package/docs/ar/packages/react-intlayer/index.md +0 -1
  11. package/docs/de/CI_CD.md +63 -37
  12. package/docs/de/intlayer_with_tanstack.md +458 -0
  13. package/docs/de/packages/next-intlayer/index.md +0 -1
  14. package/docs/de/packages/react-intlayer/index.md +0 -1
  15. package/docs/en/CI_CD.md +51 -27
  16. package/docs/en/intlayer_with_tanstack.md +452 -0
  17. package/docs/en/packages/next-intlayer/index.md +0 -1
  18. package/docs/en/packages/react-intlayer/index.md +0 -1
  19. package/docs/en-GB/CI_CD.md +58 -32
  20. package/docs/en-GB/intlayer_with_tanstack.md +457 -0
  21. package/docs/en-GB/packages/next-intlayer/index.md +0 -1
  22. package/docs/en-GB/packages/react-intlayer/index.md +0 -1
  23. package/docs/es/CI_CD.md +68 -42
  24. package/docs/es/intlayer_with_tanstack.md +435 -0
  25. package/docs/es/packages/next-intlayer/index.md +0 -1
  26. package/docs/es/packages/react-intlayer/index.md +0 -1
  27. package/docs/fr/intlayer_with_tanstack.md +435 -0
  28. package/docs/fr/packages/next-intlayer/index.md +0 -1
  29. package/docs/fr/packages/react-intlayer/index.md +0 -1
  30. package/docs/hi/CI_CD.md +69 -44
  31. package/docs/hi/intlayer_with_tanstack.md +438 -0
  32. package/docs/hi/packages/next-intlayer/index.md +0 -1
  33. package/docs/hi/packages/react-intlayer/index.md +0 -1
  34. package/docs/it/CI_CD.md +67 -41
  35. package/docs/it/intlayer_with_tanstack.md +457 -0
  36. package/docs/it/packages/next-intlayer/index.md +0 -1
  37. package/docs/it/packages/react-intlayer/index.md +0 -1
  38. package/docs/ja/CI_CD.md +67 -41
  39. package/docs/ja/intlayer_with_tanstack.md +457 -0
  40. package/docs/ja/packages/next-intlayer/index.md +0 -1
  41. package/docs/ja/packages/react-intlayer/index.md +0 -1
  42. package/docs/ko/CI_CD.md +63 -37
  43. package/docs/ko/intlayer_with_tanstack.md +457 -0
  44. package/docs/ko/packages/next-intlayer/index.md +0 -1
  45. package/docs/ko/packages/react-intlayer/index.md +0 -1
  46. package/docs/pt/CI_CD.md +67 -41
  47. package/docs/pt/intlayer_with_tanstack.md +457 -0
  48. package/docs/pt/packages/next-intlayer/index.md +0 -1
  49. package/docs/pt/packages/react-intlayer/index.md +0 -1
  50. package/docs/ru/CI_CD.md +70 -44
  51. package/docs/ru/intlayer_with_tanstack.md +458 -0
  52. package/docs/ru/packages/next-intlayer/index.md +0 -1
  53. package/docs/ru/packages/react-intlayer/index.md +0 -1
  54. package/docs/zh/CI_CD.md +62 -36
  55. package/docs/zh/intlayer_with_tanstack.md +435 -0
  56. package/docs/zh/packages/next-intlayer/index.md +0 -1
  57. package/docs/zh/packages/react-intlayer/index.md +0 -1
  58. package/package.json +9 -9
  59. package/src/generated/docs.entry.ts +44 -238
  60. package/docs/ar/packages/next-intlayer/useIntlayerAsync.md +0 -237
  61. package/docs/ar/packages/react-intlayer/useIntlayerAsync.md +0 -252
  62. package/docs/de/packages/next-intlayer/useIntlayerAsync.md +0 -262
  63. package/docs/de/packages/react-intlayer/useIntlayerAsync.md +0 -256
  64. package/docs/en/packages/next-intlayer/useIntlayerAsync.md +0 -239
  65. package/docs/en/packages/react-intlayer/useIntlayerAsync.md +0 -254
  66. package/docs/en-GB/packages/next-intlayer/useIntlayerAsync.md +0 -237
  67. package/docs/en-GB/packages/react-intlayer/useIntlayerAsync.md +0 -257
  68. package/docs/es/packages/next-intlayer/useIntlayerAsync.md +0 -240
  69. package/docs/es/packages/react-intlayer/useIntlayerAsync.md +0 -276
  70. package/docs/fr/packages/next-intlayer/useIntlayerAsync.md +0 -238
  71. package/docs/fr/packages/react-intlayer/useIntlayerAsync.md +0 -252
  72. package/docs/hi/packages/next-intlayer/useIntlayerAsync.md +0 -237
  73. package/docs/hi/packages/react-intlayer/useIntlayerAsync.md +0 -252
  74. package/docs/it/packages/next-intlayer/useIntlayerAsync.md +0 -237
  75. package/docs/it/packages/react-intlayer/useIntlayerAsync.md +0 -252
  76. package/docs/ja/packages/next-intlayer/useIntlayerAsync.md +0 -237
  77. package/docs/ja/packages/react-intlayer/useIntlayerAsync.md +0 -268
  78. package/docs/ko/packages/next-intlayer/useIntlayerAsync.md +0 -260
  79. package/docs/ko/packages/react-intlayer/useIntlayerAsync.md +0 -271
  80. package/docs/pt/packages/next-intlayer/useIntlayerAsync.md +0 -238
  81. package/docs/pt/packages/react-intlayer/useIntlayerAsync.md +0 -252
  82. package/docs/ru/packages/next-intlayer/useIntlayerAsync.md +0 -237
  83. package/docs/ru/packages/react-intlayer/useIntlayerAsync.md +0 -252
  84. package/docs/zh/packages/next-intlayer/useIntlayerAsync.md +0 -239
  85. package/docs/zh/packages/react-intlayer/useIntlayerAsync.md +0 -257
@@ -1,252 +0,0 @@
1
- ---
2
- createdAt: 2024-08-11
3
- updatedAt: 2025-06-29
4
- title: Documentazione Hook useIntlayerAsync | react-intlayer
5
- description: Scopri come utilizzare l'hook useIntlayerAsync per il pacchetto react-intlayer
6
- keywords:
7
- - useIntlayerAsync
8
- - dizionario
9
- - chiave
10
- - Intlayer
11
- - Internazionalizzazione
12
- - Documentazione
13
- - Next.js
14
- - JavaScript
15
- - React
16
- slugs:
17
- - doc
18
- - packages
19
- - react-intlayer
20
- - useIntlayerAsync
21
- ---
22
-
23
- # Integrazione React: Documentazione Hook `useIntlayerAsync`
24
-
25
- L'hook `useIntlayerAsync` estende la funzionalità di `useIntlayer` non solo restituendo dizionari pre-renderizzati, ma anche recuperando aggiornamenti in modo asincrono, rendendolo ideale per applicazioni che aggiornano frequentemente il loro contenuto localizzato dopo il rendering iniziale.
26
-
27
- ## Panoramica
28
-
29
- - **Caricamento asincrono del dizionario:**
30
- Al montaggio iniziale, `useIntlayerAsync` restituisce prima qualsiasi dizionario locale pre-caricato o incluso staticamente (proprio come farebbe `useIntlayer`) e poi recupera e unisce in modo asincrono eventuali nuovi dizionari remoti disponibili.
31
- - **Gestione dello stato di progresso:**
32
- L'hook fornisce anche uno stato `isLoading`, che indica quando un dizionario remoto è in fase di recupero. Questo permette agli sviluppatori di mostrare indicatori di caricamento o stati scheletro per un'esperienza utente più fluida.
33
-
34
- ## Configurazione dell'Ambiente
35
-
36
- Intlayer fornisce un sistema headless di Content Source Management (CSM) che permette anche ai non sviluppatori di gestire e aggiornare i contenuti dell'applicazione in modo semplice e fluido. Utilizzando la dashboard intuitiva di Intlayer, il tuo team può modificare testi localizzati, immagini e altre risorse senza dover intervenire direttamente sul codice. Questo semplifica il processo di gestione dei contenuti, favorisce la collaborazione e garantisce che gli aggiornamenti possano essere effettuati rapidamente e facilmente.
37
-
38
- Per iniziare con Intlayer:
39
-
40
- 1. **Registrati e ottieni un token di accesso** su [https://intlayer.org/dashboard](https://intlayer.org/dashboard).
41
- 2. **Aggiungi le credenziali al tuo file di configurazione:**
42
- Nel tuo progetto React, configura il client Intlayer con le tue credenziali:
43
-
44
- ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
45
- import type { IntlayerConfig } from "intlayer";
46
-
47
- export default {
48
- // ...
49
- editor: {
50
- clientId: process.env.INTLAYER_CLIENT_ID,
51
- clientSecret: process.env.INTLAYER_CLIENT_SECRET,
52
- },
53
- } satisfies IntlayerConfig;
54
- ```
55
-
56
- ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
57
- import { type IntlayerConfig } from "intlayer";
58
-
59
- /** @type {import('intlayer').IntlayerConfig} */
60
- const config = {
61
- // ...
62
- editor: {
63
- clientId: process.env.INTLAYER_CLIENT_ID,
64
- clientSecret: process.env.INTLAYER_CLIENT_SECRET,
65
- },
66
- };
67
-
68
- export default config;
69
- ```
70
-
71
- ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
72
- /** @type {import('intlayer').IntlayerConfig} */
73
- const config = {
74
- // ...
75
- editor: {
76
- clientId: process.env.INTLAYER_CLIENT_ID,
77
- clientSecret: process.env.INTLAYER_CLIENT_SECRET,
78
- },
79
- };
80
-
81
- module.exports = config;
82
- ```
83
-
84
- 3. **Inviare un nuovo dizionario di localizzazione a Intlayer:**
85
-
86
- ```bash
87
- npx intlayer dictionary push -d my-first-dictionary-key
88
- ```
89
-
90
- Questo comando carica i tuoi dizionari di contenuti iniziali, rendendoli disponibili per il recupero asincrono e la modifica tramite la piattaforma Intlayer.
91
-
92
- ## Importare `useIntlayerAsync` in React
93
-
94
- Nei tuoi componenti React, importa `useIntlayerAsync`:
95
-
96
- ```ts codeFormat="typescript"
97
- import { useIntlayerAsync } from "react-intlayer";
98
- ```
99
-
100
- ```js codeFormat="esm"
101
- import { useIntlayerAsync } from "react-intlayer";
102
- ```
103
-
104
- ```js codeFormat="commonjs"
105
- const { useIntlayerAsync } = require("react-intlayer");
106
- ```
107
-
108
- ## Parametri
109
-
110
- 1. **`key`**:
111
- **Tipo**: `DictionaryKeys`
112
- La chiave del dizionario utilizzata per identificare il blocco di contenuto localizzato. Questa chiave dovrebbe essere definita nei tuoi file di dichiarazione dei contenuti.
113
-
114
- 2. **`locale`** (opzionale):
115
- **Tipo**: `Locales`
116
- La locale specifica che vuoi utilizzare. Se omessa, il hook utilizza la locale dal contesto Intlayer corrente.
117
-
118
- 3. **`isRenderEditor`** (opzionale, predefinito a `true`):
119
- **Tipo**: `boolean`
120
- Determina se il contenuto deve essere pronto per il rendering con la sovrapposizione dell'editor Intlayer. Se impostato su `false`, i dati del dizionario restituiti escluderanno le funzionalità specifiche dell'editor.
121
-
122
- ## Valore di ritorno
123
-
124
- Il hook restituisce un oggetto dizionario contenente il contenuto localizzato indicizzato da `key` e `locale`. Include anche un booleano `isLoading` che indica se un dizionario remoto è attualmente in fase di recupero.
125
-
126
- ## Esempio di utilizzo in un componente React
127
-
128
- ```tsx fileName="src/components/ComponentExample.tsx" codeFormat="typescript"
129
- import { useEffect, type FC } from "react";
130
- import { useIntlayerAsync } from "react-intlayer";
131
-
132
- export const ComponentExample: FC = () => {
133
- const { title, description, isLoading } = useIntlayerAsync("async-component");
134
-
135
- useEffect(() => {
136
- if (isLoading) {
137
- console.log("Il contenuto si sta caricando...");
138
- }
139
- }, [isLoading]);
140
-
141
- return (
142
- <div>
143
- {isLoading ? (
144
- <div>
145
- <h1>Caricamento…</h1>
146
- <p>Attendere mentre il contenuto viene aggiornato.</p>
147
- </div>
148
- ) : (
149
- <div>
150
- <h1>{title.value}</h1>
151
- <p>{description.value}</p>
152
- </div>
153
- )}
154
- </div>
155
- );
156
- };
157
- ```
158
-
159
- ```jsx fileName="src/components/ComponentExample.mjx" codeFormat="esm"
160
- import { useEffect } from "react";
161
- import { useIntlayerAsync } from "react-intlayer";
162
-
163
- const ComponentExample = () => {
164
- const { title, description, isLoading } = useIntlayerAsync("async-component");
165
-
166
- useEffect(() => {
167
- if (isLoading) {
168
- console.log("Il contenuto è in caricamento...");
169
- }
170
- }, [isLoading]);
171
-
172
- return (
173
- <div>
174
- {isLoading ? (
175
- <div>
176
- <h1>Caricamento…</h1>
177
- <p>Attendere prego mentre il contenuto si aggiorna.</p>
178
- </div>
179
- ) : (
180
- <div>
181
- <h1>{title.value}</h1>
182
- <p>{description.value}</p>
183
- </div>
184
- )}
185
- </div>
186
- );
187
- };
188
- ```
189
-
190
- ```jsx fileName="src/components/ComponentExample.csx" codeFormat="commonjs"
191
- const { useEffect } = require("react");
192
- const { useIntlayerAsync } = require("react-intlayer");
193
-
194
- const ComponentExample = () => {
195
- const { title, description, isLoading } = useIntlayerAsync("async-component");
196
-
197
- useEffect(() => {
198
- if (isLoading) {
199
- console.log("Il contenuto si sta caricando...");
200
- }
201
- }, [isLoading]);
202
-
203
- return (
204
- <div>
205
- {isLoading ? (
206
- <div>
207
- <h1>Caricamento…</h1>
208
- <p>Attendere prego mentre il contenuto si aggiorna.</p>
209
- </div>
210
- ) : (
211
- <div>
212
- <h1>{title.value}</h1>
213
- <p>{description.value}</p>
214
- </div>
215
- )}
216
- </div>
217
- );
218
- };
219
- ```
220
-
221
- **Punti Chiave:**
222
-
223
- - Al primo rendering, `title` e `description` provengono dal dizionario locale pre-caricato o incorporato staticamente.
224
- - Mentre `isLoading` è `true`, una richiesta in background recupera un dizionario aggiornato.
225
- - Una volta completato il recupero, `title` e `description` vengono aggiornati con il contenuto più recente, e `isLoading` torna a `false`.
226
-
227
- ## Gestione della Localizzazione degli Attributi
228
-
229
- Puoi anche recuperare valori localizzati per vari attributi HTML (ad esempio, `alt`, `title`, `aria-label`):
230
-
231
- ```jsx
232
- <img src={title.image.src.value} alt={title.image.alt.value} />
233
- ```
234
-
235
- ## File del Dizionario
236
-
237
- Tutte le chiavi di contenuto devono essere definite nei tuoi file di dichiarazione del contenuto per garantire la sicurezza dei tipi e prevenire errori a runtime. Questi file abilitano la validazione TypeScript, assicurando che tu faccia sempre riferimento a chiavi e localizzazioni esistenti.
238
-
239
- Istruzioni per la configurazione dei file di dichiarazione dei contenuti sono disponibili [qui](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/dictionary/get_started.md).
240
-
241
- ## Ulteriori Informazioni
242
-
243
- - **Editor Visuale Intlayer:**
244
- Integra l'editor visuale Intlayer per gestire e modificare i contenuti direttamente dall'interfaccia utente. Maggiori dettagli [qui](https://github.com/aymericzip/intlayer/blob/main/docs/docs/it/intlayer_visual_editor.md).
245
-
246
- ---
247
-
248
- **In sintesi**, `useIntlayerAsync` è un potente hook di React progettato per migliorare l'esperienza utente e mantenere la freschezza dei contenuti unendo dizionari pre-renderizzati o pre-caricati con aggiornamenti asincroni dei dizionari. Sfruttando `isLoading` e le dichiarazioni di contenuto basate su TypeScript, puoi integrare senza soluzione di continuità contenuti dinamici e localizzati nelle tue applicazioni React.
249
-
250
- ## Cronologia del documento
251
-
252
- - 5.5.10 - 2025-06-29: Inizio cronologia
@@ -1,237 +0,0 @@
1
- ---
2
- createdAt: 2024-08-11
3
- updatedAt: 2025-06-29
4
- title: useIntlayerAsync フック ドキュメント | next-intlayer
5
- description: next-intlayer パッケージの useIntlayerAsync フックの使い方をご覧ください
6
- keywords:
7
- - useIntlayerAsync
8
- - 辞書
9
- - キー
10
- - Intlayer
11
- - 国際化
12
- - ドキュメント
13
- - Next.js
14
- - JavaScript
15
- - React
16
- slugs:
17
- - doc
18
- - packages
19
- - next-intlayer
20
- - useIntlayerAsync
21
- ---
22
-
23
- # Next.js 統合: `useIntlayerAsync` フック ドキュメント
24
-
25
- `useIntlayerAsync` フックは、プリレンダリングされた辞書を返すだけでなく、更新を非同期に取得する機能を `useIntlayer` から拡張しており、初回レンダリング後にローカライズされたコンテンツを頻繁に更新するアプリケーションに最適です。
26
-
27
- ## 概要
28
-
29
- - **非同期辞書読み込み:**
30
- クライアント側では、`useIntlayerAsync` はまずプリレンダリングされたロケール辞書を返し(`useIntlayer` と同様)、その後に非同期で新たに利用可能なリモート辞書を取得してマージします。
31
- - **進行状態管理:**
32
- このフックは、リモート辞書が取得中であることを示す `isLoading` 状態も提供します。これにより、開発者は読み込みインジケーターやスケルトン状態を表示して、よりスムーズなユーザー体験を実現できます。
33
-
34
- ## 環境設定
35
-
36
- Intlayerは、非開発者でもアプリケーションのコンテンツをシームレスに管理・更新できるヘッドレスコンテンツソース管理(CSM)システムを提供します。Intlayerの直感的なダッシュボードを使用することで、チームはコードを直接変更することなく、ローカライズされたテキスト、画像、その他のリソースを編集できます。これにより、コンテンツ管理プロセスが効率化され、コラボレーションが促進され、迅速かつ容易に更新が行えるようになります。
37
-
38
- Intlayerを始めるには、まず[ダッシュボード](https://intlayer.org/dashboard)で登録し、アクセストークンを取得する必要があります。認証情報を取得したら、以下のように設定ファイルに追加してください。
39
-
40
- ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
41
- import type { IntlayerConfig } from "intlayer";
42
-
43
- export default {
44
- // ...
45
- editor: {
46
- clientId: process.env.INTLAYER_CLIENT_ID,
47
- clientSecret: process.env.INTLAYER_CLIENT_SECRET,
48
- },
49
- } satisfies IntlayerConfig;
50
- ```
51
-
52
- ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
53
- import { type IntlayerConfig } from "intlayer";
54
-
55
- /** @type {import('intlayer').IntlayerConfig} */
56
- const config = {
57
- // ...
58
- editor: {
59
- clientId: process.env.INTLAYER_CLIENT_ID,
60
- clientSecret: process.env.INTLAYER_CLIENT_SECRET,
61
- },
62
- };
63
-
64
- export default config;
65
- ```
66
-
67
- ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
68
- /** @type {import('intlayer').IntlayerConfig} */
69
- const config = {
70
- // ...
71
- editor: {
72
- clientId: process.env.INTLAYER_CLIENT_ID,
73
- clientSecret: process.env.INTLAYER_CLIENT_SECRET,
74
- },
75
- };
76
-
77
- module.exports = config;
78
- ```
79
-
80
- 資格情報を設定した後、次のコマンドを実行して新しいロケール辞書をIntlayerにプッシュできます:
81
-
82
- ```bash
83
- npx intlayer dictionary push -d my-first-dictionary-key
84
- ```
85
-
86
- このコマンドは初期のコンテンツ辞書をアップロードし、Intlayerプラットフォームを通じて非同期に取得および編集できるようにします。
87
-
88
- ## Next.jsでの`useIntlayerAsync`のインポート
89
-
90
- `useIntlayerAsync`は**クライアントサイド**コンポーネント向けのため、`useIntlayer`と同じクライアントエントリポイントからインポートします:
91
-
92
- ```tsx codeFormat="typescript"
93
- "use client";
94
-
95
- import { useIntlayerAsync } from "next-intlayer";
96
- ```
97
-
98
- ```javascript codeFormat="esm"
99
- "use client";
100
-
101
- import { useIntlayerAsync } from "next-intlayer";
102
- ```
103
-
104
- ```javascript codeFormat="commonjs"
105
- "use client";
106
-
107
- const { useIntlayerAsync } = require("next-intlayer");
108
- ```
109
-
110
- Next.jsのApp Routerでサーバーコンポーネントとクライアントコンポーネントが分かれている場合は、インポートするファイルの先頭に必ず `"use client"` の注釈を付けてください。
111
-
112
- ## パラメーター
113
-
114
- 1. **`key`**:
115
- **型**: `DictionaryKeys`
116
- ローカライズされたコンテンツブロックを識別するための辞書キーです。このキーはコンテンツ宣言ファイルで定義されている必要があります。
117
-
118
- 2. **`locale`**(省略可能):
119
- **型**: `Locales`
120
- 対象とする特定のロケールです。省略した場合、フックはクライアントコンテキストのロケールを使用します。
121
-
122
- 3. **`isRenderEditor`**(省略可能、デフォルトは `true`):
123
- **型**: `boolean`
124
- コンテンツがIntlayerエディターのオーバーレイでレンダリング可能な状態にするかどうかを決定します。`false`に設定すると、返される辞書データにはエディター固有の機能が含まれません。
125
-
126
- ## 戻り値
127
-
128
- このフックは、`key`と`locale`でキー付けされたローカライズされたコンテンツを含む辞書オブジェクトを返します。また、遠隔辞書が現在取得中かどうかを示す`isLoading`というブール値も含まれます。
129
-
130
- ## Next.jsでの使用例
131
-
132
- ### クライアントサイドコンポーネントの例
133
-
134
- ```tsx fileName="src/components/AsyncClientComponentExample.tsx" codeFormat="typescript"
135
- "use client";
136
-
137
- import { useEffect, type FC } from "react";
138
- import { useIntlayerAsync } from "next-intlayer";
139
-
140
- export const AsyncClientComponentExample: FC = () => {
141
- const { title, description, isLoading } = useIntlayerAsync("async-component");
142
-
143
- useEffect(() => {
144
- if (isLoading) {
145
- console.log("コンテンツを読み込み中...");
146
- }
147
- }, [isLoading]);
148
-
149
- return (
150
- <div>
151
- <h1>{title.value}</h1>
152
- <p>{description.value}</p>
153
- </div>
154
- );
155
- };
156
- ```
157
-
158
- ```jsx fileName="src/components/AsyncClientComponentExample.mjx" codeFormat="esm"
159
- "use client";
160
-
161
- import { useEffect } from "react";
162
- import { useIntlayerAsync } from "next-intlayer";
163
-
164
- const AsyncClientComponentExample = () => {
165
- const { title, description, isLoading } = useIntlayerAsync("async-component");
166
-
167
- useEffect(() => {
168
- if (isLoading) {
169
- console.log("コンテンツを読み込み中...");
170
- }
171
- }, [isLoading]);
172
-
173
- return (
174
- <div>
175
- <h1>{title.value}</h1>
176
- <p>{description.value}</p>
177
- </div>
178
- );
179
- };
180
- ```
181
-
182
- ```jsx fileName="src/components/AsyncClientComponentExample.csx" codeFormat="commonjs"
183
- "use client";
184
-
185
- const { useEffect } = require("react");
186
- const { useIntlayerAsync } = require("next-intlayer");
187
-
188
- const AsyncClientComponentExample = () => {
189
- const { title, description, isLoading } = useIntlayerAsync("async-component");
190
-
191
- useEffect(() => {
192
- if (isLoading) {
193
- console.log("コンテンツを読み込み中です...");
194
- }
195
- }, [isLoading]);
196
-
197
- return (
198
- <div>
199
- <h1>{title.value}</h1>
200
- <p>{description.value}</p>
201
- </div>
202
- );
203
- };
204
- ```
205
-
206
- **重要なポイント:**
207
-
208
- - 初回レンダリング時、`title` と `description` は事前レンダリングされたロケール辞書から取得されます。
209
- - `isLoading` が `true` の間は、バックグラウンドでリモートリクエストが行われ、更新された辞書が取得されます。
210
- - フェッチが完了すると、`title` と `description` は最新のコンテンツに更新され、`isLoading` は `false` に戻ります。
211
-
212
- ## 属性のローカライズ処理
213
-
214
- `useIntlayer` と同様に、さまざまなHTML属性(例:`alt`、`title`、`aria-label`)のローカライズされた値を取得できます:
215
-
216
- ```tsx
217
- <img src={title.image.src.value} alt={title.image.alt.value} />
218
- ```
219
-
220
- ## 辞書ファイル
221
-
222
- すべてのコンテンツキーは、型の安全性を確保し実行時エラーを防ぐために、コンテンツ宣言ファイルで定義する必要があります。これらのファイルはTypeScriptの検証を可能にし、常に存在するキーとロケールを参照していることを保証します。
223
-
224
- コンテンツ宣言ファイルの設定手順は[こちら](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/dictionary/get_started.md)でご覧いただけます。
225
-
226
- ## さらに詳しく
227
-
228
- - **Intlayer ビジュアルエディター:**
229
- Intlayer ビジュアルエディターと統合することで、UIから直接コンテンツの管理や編集が可能になります。詳細は[こちら](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ja/intlayer_visual_editor.md)をご覧ください。
230
-
231
- ---
232
-
233
- **まとめ**、`useIntlayerAsync` は、事前レンダリングされた辞書と非同期の辞書更新を組み合わせることで、ユーザー体験を向上させ、コンテンツの鮮度を維持するために設計された強力なクライアントサイドフックです。`isLoading` と TypeScript ベースのコンテンツ宣言を活用することで、Next.js アプリケーションに動的でローカライズされたコンテンツをシームレスに統合できます。
234
-
235
- ## ドキュメント履歴
236
-
237
- - 5.5.10 - 2025-06-29: 履歴の初期化