@intlayer/docs 7.0.4-canary.0 → 7.0.5

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 (107) hide show
  1. package/blog/ar/intlayer_with_i18next.md +68 -106
  2. package/blog/ar/intlayer_with_next-i18next.md +84 -288
  3. package/blog/ar/intlayer_with_next-intl.md +58 -337
  4. package/blog/ar/intlayer_with_react-i18next.md +68 -290
  5. package/blog/ar/intlayer_with_react-intl.md +63 -266
  6. package/blog/de/intlayer_with_i18next.md +77 -97
  7. package/blog/de/intlayer_with_next-i18next.md +69 -296
  8. package/blog/de/intlayer_with_next-intl.md +59 -340
  9. package/blog/de/intlayer_with_react-i18next.md +68 -290
  10. package/blog/de/intlayer_with_react-intl.md +62 -264
  11. package/blog/en/intlayer_with_i18next.md +36 -1638
  12. package/blog/en/intlayer_with_next-i18next.md +22 -847
  13. package/blog/en/intlayer_with_next-intl.md +32 -1053
  14. package/blog/en/intlayer_with_react-i18next.md +38 -764
  15. package/blog/en/intlayer_with_react-intl.md +42 -1018
  16. package/blog/en-GB/intlayer_with_i18next.md +67 -103
  17. package/blog/en-GB/intlayer_with_next-i18next.md +71 -292
  18. package/blog/en-GB/intlayer_with_next-intl.md +58 -337
  19. package/blog/en-GB/intlayer_with_react-i18next.md +67 -289
  20. package/blog/en-GB/intlayer_with_react-intl.md +61 -264
  21. package/blog/es/intlayer_with_i18next.md +67 -103
  22. package/blog/es/intlayer_with_next-i18next.md +71 -296
  23. package/blog/es/intlayer_with_next-intl.md +57 -338
  24. package/blog/es/intlayer_with_react-i18next.md +68 -290
  25. package/blog/es/intlayer_with_react-intl.md +62 -265
  26. package/blog/fr/intlayer_with_i18next.md +66 -104
  27. package/blog/fr/intlayer_with_next-i18next.md +82 -285
  28. package/blog/fr/intlayer_with_next-intl.md +57 -338
  29. package/blog/fr/intlayer_with_react-i18next.md +67 -289
  30. package/blog/fr/intlayer_with_react-intl.md +61 -264
  31. package/blog/hi/intlayer_with_i18next.md +68 -104
  32. package/blog/hi/intlayer_with_next-i18next.md +74 -299
  33. package/blog/hi/intlayer_with_next-intl.md +57 -239
  34. package/blog/hi/intlayer_with_react-i18next.md +69 -291
  35. package/blog/hi/intlayer_with_react-intl.md +65 -268
  36. package/blog/id/intlayer_with_i18next.md +126 -0
  37. package/blog/id/intlayer_with_next-i18next.md +142 -0
  38. package/blog/id/intlayer_with_next-intl.md +113 -0
  39. package/blog/id/intlayer_with_react-i18next.md +124 -0
  40. package/blog/id/intlayer_with_react-intl.md +122 -0
  41. package/blog/it/intlayer_with_i18next.md +67 -103
  42. package/blog/it/intlayer_with_next-i18next.md +71 -296
  43. package/blog/it/intlayer_with_next-intl.md +57 -338
  44. package/blog/it/intlayer_with_react-i18next.md +68 -290
  45. package/blog/it/intlayer_with_react-intl.md +62 -265
  46. package/blog/ja/intlayer_with_i18next.md +68 -103
  47. package/blog/ja/intlayer_with_next-i18next.md +85 -283
  48. package/blog/ja/intlayer_with_next-intl.md +58 -336
  49. package/blog/ja/intlayer_with_react-i18next.md +68 -290
  50. package/blog/ja/intlayer_with_react-intl.md +62 -264
  51. package/blog/ko/intlayer_with_i18next.md +80 -96
  52. package/blog/ko/intlayer_with_next-i18next.md +85 -287
  53. package/blog/ko/intlayer_with_next-intl.md +68 -327
  54. package/blog/ko/intlayer_with_react-i18next.md +68 -290
  55. package/blog/ko/intlayer_with_react-intl.md +64 -266
  56. package/blog/pl/intlayer_with_i18next.md +126 -0
  57. package/blog/pl/intlayer_with_next-i18next.md +142 -0
  58. package/blog/pl/intlayer_with_next-intl.md +111 -0
  59. package/blog/pl/intlayer_with_react-i18next.md +124 -0
  60. package/blog/pl/intlayer_with_react-intl.md +122 -0
  61. package/blog/pt/intlayer_with_i18next.md +67 -103
  62. package/blog/pt/intlayer_with_next-i18next.md +72 -293
  63. package/blog/pt/intlayer_with_next-intl.md +57 -256
  64. package/blog/pt/intlayer_with_react-i18next.md +104 -78
  65. package/blog/pt/intlayer_with_react-intl.md +62 -266
  66. package/blog/ru/intlayer_with_i18next.md +66 -104
  67. package/blog/ru/intlayer_with_next-i18next.md +71 -296
  68. package/blog/ru/intlayer_with_next-intl.md +58 -337
  69. package/blog/ru/intlayer_with_react-i18next.md +68 -290
  70. package/blog/ru/intlayer_with_react-intl.md +62 -265
  71. package/blog/tr/intlayer_with_i18next.md +71 -107
  72. package/blog/tr/intlayer_with_next-i18next.md +72 -297
  73. package/blog/tr/intlayer_with_next-intl.md +58 -339
  74. package/blog/tr/intlayer_with_react-i18next.md +69 -291
  75. package/blog/tr/intlayer_with_react-intl.md +63 -285
  76. package/blog/vi/intlayer_with_i18next.md +126 -0
  77. package/blog/vi/intlayer_with_next-i18next.md +142 -0
  78. package/blog/vi/intlayer_with_next-intl.md +111 -0
  79. package/blog/vi/intlayer_with_react-i18next.md +124 -0
  80. package/blog/vi/intlayer_with_react-intl.md +122 -0
  81. package/blog/zh/intlayer_with_i18next.md +67 -102
  82. package/blog/zh/intlayer_with_next-i18next.md +72 -296
  83. package/blog/zh/intlayer_with_next-intl.md +58 -336
  84. package/blog/zh/intlayer_with_react-i18next.md +68 -290
  85. package/blog/zh/intlayer_with_react-intl.md +63 -106
  86. package/docs/ar/plugins/sync-json.md +244 -0
  87. package/docs/de/plugins/sync-json.md +244 -0
  88. package/docs/en/intlayer_cli.md +25 -0
  89. package/docs/en/intlayer_with_nextjs_14.md +2 -0
  90. package/docs/en/intlayer_with_nextjs_15.md +2 -0
  91. package/docs/en/intlayer_with_nextjs_16.md +2 -0
  92. package/docs/en/plugins/sync-json.md +1 -1
  93. package/docs/en-GB/plugins/sync-json.md +244 -0
  94. package/docs/es/plugins/sync-json.md +244 -0
  95. package/docs/fr/plugins/sync-json.md +244 -0
  96. package/docs/hi/plugins/sync-json.md +244 -0
  97. package/docs/id/plugins/sync-json.md +244 -0
  98. package/docs/it/plugins/sync-json.md +244 -0
  99. package/docs/ja/plugins/sync-json.md +244 -0
  100. package/docs/ko/plugins/sync-json.md +244 -0
  101. package/docs/pl/plugins/sync-json.md +244 -0
  102. package/docs/pt/plugins/sync-json.md +244 -0
  103. package/docs/ru/plugins/sync-json.md +244 -0
  104. package/docs/tr/plugins/sync-json.md +245 -0
  105. package/docs/vi/plugins/sync-json.md +244 -0
  106. package/docs/zh/plugins/sync-json.md +244 -0
  107. package/package.json +14 -14
@@ -1,367 +1,142 @@
1
1
  ---
2
2
  createdAt: 2025-08-23
3
- updatedAt: 2025-08-23
3
+ updatedAt: 2025-10-29
4
4
  title: Intlayer y next-i18next
5
- description: Integra Intlayer con next-i18next para una aplicación Next.js
5
+ description: Integra Intlayer con next-i18next para una solución integral de internacionalización en Next.js
6
6
  keywords:
7
7
  - i18next
8
8
  - next-i18next
9
9
  - Intlayer
10
10
  - Internacionalización
11
- - Blogumentación
11
+ - Blog
12
12
  - Next.js
13
13
  - JavaScript
14
14
  - React
15
15
  slugs:
16
16
  - blog
17
17
  - intlayer-with-next-i18next
18
+ history:
19
+ - version: 7.0.0
20
+ date: 2025-10-29
21
+ changes: Cambio al plugin syncJSON y reescritura integral
18
22
  ---
19
23
 
20
- # Next.js Internacionalización (i18n) con next-i18next y Intlayer
24
+ # Internacionalización (i18n) en Next.js con next-i18next e Intlayer
21
25
 
22
- Tanto next-i18next como Intlayer son frameworks de internacionalización (i18n) de código abierto diseñados para aplicaciones de Next.js. Son ampliamente utilizados para gestionar traducciones, localización y cambio de idioma en proyectos de software.
26
+ ## Tabla de Contenidos
23
27
 
24
- Ambas soluciones incluyen tres nociones principales:
28
+ <TOC/>
25
29
 
26
- 1. **Declaración de Contenido**: El método para definir el contenido traducible de tu aplicación.
27
- - Nombrado `resource` en el caso de `i18next`, la declaración de contenido es un objeto JSON estructurado que contiene pares clave-valor para traducciones en uno o varios idiomas. Consulta la [documentación de i18next](https://www.i18next.com/translation-function/essentials) para más información.
28
- - Nombrado `archivo de declaración de contenido` en el caso de `Intlayer`, la declaración de contenido puede ser un archivo JSON, JS o TS que exporta los datos estructurados. Consulta la [documentación de Intlayer](https://intlayer.org/fr/doc/concept/content) para más información.
30
+ ## ¿Qué es next-i18next?
29
31
 
30
- 2. **Utilidades**: Herramientas para construir e interpretar declaraciones de contenido en la aplicación, como `getI18n()`, `useCurrentLocale()`, o `useChangeLocale()` para next-i18next, y `useIntlayer()` o `useLocale()` para Intlayer.
32
+ **next-i18next** es uno de los frameworks de internacionalización (i18n) más populares para aplicaciones Next.js. Construido sobre el poderoso ecosistema de **i18next**, ofrece una solución integral para gestionar traducciones, localización y cambio de idioma en proyectos Next.js.
31
33
 
32
- 3. **Plugins y Middleware**: Características para gestionar la redirección de URL, optimización de empaquetado, y más, como `next-i18next/middleware` para next-i18next o `intlayerMiddleware` para Intlayer.
34
+ Sin embargo, next-i18next presenta algunos desafíos:
33
35
 
34
- ## Intlayer vs. i18next: Principales Diferencias
36
+ - **Configuración compleja**: Configurar next-i18next requiere múltiples archivos de configuración y una configuración cuidadosa de las instancias i18n del lado del servidor y del cliente.
37
+ - **Traducciones dispersas**: Los archivos de traducción suelen almacenarse en directorios separados de los componentes, lo que dificulta mantener la consistencia.
38
+ - **Gestión manual de namespaces**: Los desarrolladores deben gestionar manualmente los namespaces y asegurar la correcta carga de los recursos de traducción.
39
+ - **Seguridad de tipos limitada**: El soporte para TypeScript requiere configuración adicional y no proporciona generación automática de tipos para las traducciones.
35
40
 
36
- Para explorar las diferencias entre i18next e Intlayer, consulta nuestra publicación de blog [next-i18next vs. next-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/es/i18next_vs_next-intl_vs_intlayer.md).
41
+ ## ¿Qué es Intlayer?
37
42
 
38
- ## Cómo Generar Diccionarios de next-i18next con Intlayer
43
+ **Intlayer** es una biblioteca innovadora y de código abierto para internacionalización, diseñada para abordar las deficiencias de las soluciones i18n tradicionales. Ofrece un enfoque moderno para la gestión de contenido en aplicaciones Next.js.
39
44
 
40
- ### ¿Por qué Usar Intlayer con next-i18next?
45
+ Consulta una comparación concreta con next-intl en nuestro artículo del blog [next-i18next vs. next-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/es/next-i18next_vs_next-intl_vs_intlayer.md).
41
46
 
42
- Los archivos de declaración de contenido de Intlayer generalmente ofrecen una mejor experiencia de desarrollador. Son más flexibles y mantenibles debido a dos ventajas principales:
47
+ ## ¿Por qué combinar Intlayer con next-i18next?
43
48
 
44
- 1. **Colocación Flexible**: Un archivo de declaración de contenido de Intlayer se puede colocar en cualquier lugar del árbol de archivos de la aplicación, simplificando la gestión de componentes duplicados o eliminados sin dejar declaraciones de contenido no utilizadas.
49
+ Mientras que Intlayer ofrece una excelente solución i18n independiente (consulta nuestra [guía de integración con Next.js](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_with_nextjs_16.md)), es posible que desees combinarlo con next-i18next por varias razones:
45
50
 
46
- Ejemplos de estructuras de archivos:
51
+ 1. **Código existente**: Tienes una implementación establecida de next-i18next y quieres migrar gradualmente a la mejorada experiencia de desarrollo de Intlayer.
52
+ 2. **Requisitos heredados**: Tu proyecto requiere compatibilidad con plugins o flujos de trabajo existentes de i18next.
53
+ 3. **Familiaridad del equipo**: Tu equipo está cómodo con next-i18next pero desea una mejor gestión de contenido.
47
54
 
48
- ```bash codeFormat="typescript"
49
- .
50
- └── src
51
- └── components
52
- └── MyComponent
53
- ├── index.content.ts # Archivo de declaración de contenido
54
- └── index.tsx
55
- ```
55
+ **Para ello, Intlayer puede implementarse como un adaptador para next-i18next que ayude a automatizar tus traducciones JSON en la CLI o en pipelines de CI/CD, probar tus traducciones y más.**
56
56
 
57
- ```bash codeFormat="esm"
58
- .
59
- └── src
60
- └── components
61
- └── MyComponent
62
- ├── index.content.mjs # Archivo de declaración de contenido
63
- └── index.mjx
64
- ```
57
+ Esta guía te muestra cómo aprovechar el sistema superior de declaración de contenido de Intlayer mientras mantienes la compatibilidad con next-i18next.
65
58
 
66
- ```bash codeFormat="cjs"
67
- .
68
- └── src
69
- └── components
70
- └── MyComponent
71
- ├── index.content.cjs # Archivo de declaración de contenido
72
- └── index.cjx
73
- ```
59
+ ---
74
60
 
75
- ```bash codeFormat="json"
76
- .
77
- └── src
78
- └── components
79
- └── MyComponent
80
- ├── index.content.json # Archivo de declaración de contenido
81
- └── index.jsx
82
- ```
61
+ ## Guía paso a paso para configurar Intlayer con next-i18next
83
62
 
84
- 2. **Traducciones Centralizadas**: Intlayer almacena todas las traducciones en un solo archivo, asegurando que no falte ninguna traducción. Al usar TypeScript, las traducciones faltantes se detectan automáticamente y se informan como errores.
63
+ ### Paso 1: Instalar dependencias
85
64
 
86
- ### Instalación
65
+ Instala los paquetes necesarios usando tu gestor de paquetes preferido:
87
66
 
88
67
  ```bash packageManager="npm"
89
- npm install intlayer i18next next-i18next i18next-resources-to-backend
68
+ npm install intlayer @intlayer/sync-json-plugin
90
69
  ```
91
70
 
92
- ```bash packageManager="yarn"
93
- yarn add intlayer i18next next-i18next i18next-resources-to-backend
71
+ ```bash packageManager="pnpm"
72
+ pnpm add intlayer @intlayer/sync-json-plugin
94
73
  ```
95
74
 
96
- ```bash packageManager="pnpm"
97
- pnpm add intlayer i18next next-i18next i18next-resources-to-backend
75
+ ```bash packageManager="yarn"
76
+ yarn add intlayer @intlayer/sync-json-plugin
98
77
  ```
99
78
 
100
- ### Configurando Intlayer para Exportar Diccionarios de i18next
79
+ **Explicación de los paquetes:**
101
80
 
102
- > La exportación de recursos de i18next no asegura una compatibilidad 1:1 con otros frameworks. Se recomienda adherirse a una configuración basada en Intlayer para minimizar problemas.
81
+ - **intlayer**: Biblioteca principal para la declaración y gestión de contenido
82
+ - **next-intlayer**: Capa de integración para Next.js con plugins de compilación
83
+ - **i18next**: Framework principal de i18n
84
+ - **next-i18next**: Wrapper de Next.js para i18next
85
+ - **i18next-resources-to-backend**: Carga dinámica de recursos para i18next
86
+ - **@intlayer/sync-json-plugin**: Plugin para sincronizar las declaraciones de contenido de Intlayer al formato JSON de i18next
103
87
 
104
- Para exportar recursos de i18next, configura Intlayer en un archivo `intlayer.config.ts`. Ejemplos de configuraciones:
88
+ ### Paso 2: Implementar el plugin de Intlayer para envolver el JSON
105
89
 
106
- ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
107
- import { Locales, type IntlayerConfig } from "intlayer";
108
-
109
- const config: IntlayerConfig = {
110
- internationalization: {
111
- locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
112
- defaultLocale: Locales.ENGLISH,
113
- },
114
- content: {
115
- dictionaryOutput: ["i18next"],
116
- i18nextResourcesDir: "./i18next/resources",
117
- },
118
- };
90
+ Crea un archivo de configuración de Intlayer para definir los locales soportados:
119
91
 
120
- export default config;
121
- ```
92
+ **Si también quieres exportar diccionarios JSON para i18next**, añade el plugin `syncJSON`:
122
93
 
123
- ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
124
- import { Locales } from "intlayer";
94
+ ```typescript fileName="intlayer.config.ts"
95
+ import { Locales, type IntlayerConfig } from "intlayer";
96
+ import { syncJSON } from "@intlayer/sync-json-plugin";
125
97
 
126
- /** @type {import('intlayer').IntlayerConfig} */
127
- const config = {
98
+ const config: IntlayerConfig = {
128
99
  internationalization: {
129
100
  locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
130
101
  defaultLocale: Locales.ENGLISH,
131
102
  },
132
- content: {
133
- dictionaryOutput: ["i18next"],
134
- i18nextResourcesDir: "./i18next/resources",
135
- },
103
+ plugins: [
104
+ syncJSON({
105
+ source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
106
+ }),
107
+ ],
136
108
  };
137
109
 
138
110
  export default config;
139
111
  ```
140
112
 
141
- ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
142
- const { Locales } = require("intlayer");
113
+ El plugin `syncJSON` envolverá automáticamente el JSON. Leerá y escribirá los archivos JSON sin cambiar la arquitectura del contenido.
143
114
 
144
- /** @type {import('intlayer').IntlayerConfig} */
145
- const config = {
146
- internationalization: {
147
- locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
148
- defaultLocale: Locales.ENGLISH,
149
- },
150
- content: {
151
- dictionaryOutput: ["i18next"],
152
- i18nextResourcesDir: "./i18next/resources",
153
- },
154
- };
115
+ Si deseas hacer coexistir ese JSON con los archivos de declaración de contenido de intlayer (archivos `.content`), Intlayer procederá de la siguiente manera:
155
116
 
156
- module.exports = config;
157
- ```
117
+ 1. cargar tanto los archivos JSON como los archivos de declaración de contenido y transformarlos en un diccionario de intlayer.
118
+ 2. si hay conflictos entre el JSON y los archivos de declaración de contenido, Intlayer procederá a la fusión de todos esos diccionarios. Dependiendo de la prioridad de los plugins y la del archivo de declaración de contenido (todos son configurables).
158
119
 
159
- Aquí está la continuación y corrección de las partes restantes de tu documento:
120
+ Si se realizan cambios usando la CLI para traducir el JSON, o usando el CMS, Intlayer actualizará el archivo JSON con las nuevas traducciones.
160
121
 
161
122
  ---
162
123
 
163
- ### Importando Diccionarios en tu Configuración de i18next
164
-
165
- Para importar los recursos generados en tu configuración de i18next, utiliza `i18next-resources-to-backend`. A continuación se muestran ejemplos:
166
-
167
- ```typescript fileName="i18n/client.ts" codeFormat="typescript"
168
- import i18next from "i18next";
169
- import resourcesToBackend from "i18next-resources-to-backend";
170
-
171
- i18next.use(
172
- resourcesToBackend(
173
- (language: string, namespace: string) =>
174
- import(`../i18next/resources/${language}/${namespace}.json`)
175
- )
176
- );
177
- ```
178
-
179
- ```javascript fileName="i18n/client.mjs" codeFormat="esm"
180
- import i18next from "i18next";
181
- import resourcesToBackend from "i18next-resources-to-backend";
182
-
183
- i18next.use(
184
- resourcesToBackend(
185
- (language, namespace) =>
186
- import(`../i18next/resources/${language}/${namespace}.json`)
187
- )
188
- );
189
- ```
190
-
191
- ```javascript fileName="i18n/client.cjs" codeFormat="commonjs"
192
- const i18next = require("i18next");
193
- const resourcesToBackend = require("i18next-resources-to-backend");
194
-
195
- i18next.use(
196
- resourcesToBackend(
197
- (language, namespace) =>
198
- import(`../i18next/resources/${language}/${namespace}.json`)
199
- )
200
- );
201
- ```
202
-
203
- ### Declaración de Contenido
204
-
205
- Ejemplos de archivos de declaración de contenido en varios formatos:
206
-
207
- ```typescript fileName="**/*.content.ts" contentDeclarationFormat="typescript"
208
- import { t, type Dictionary } from "intlayer";
209
-
210
- const content = {
211
- key: "my-content",
212
- content: {
213
- myTranslatedContent: t({
214
- en: "Hello World",
215
- es: "Hola Mundo",
216
- fr: "Bonjour le monde",
217
- }),
218
- },
219
- } satisfies Dictionary;
220
-
221
- export default content;
222
- ```
223
-
224
- ```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
225
- import { t } from "intlayer";
226
-
227
- /** @type {import('intlayer').Dictionary} */
228
- const content = {
229
- key: "my-content",
230
- content: {
231
- myTranslatedContent: t({
232
- en: "Hello World",
233
- es: "Hola Mundo",
234
- fr: "Bonjour le monde",
235
- }),
236
- },
237
- };
238
- ```
239
-
240
- ```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
241
- const { t } = require("intlayer");
242
-
243
- module.exports = {
244
- key: "my-content",
245
- content: {
246
- myTranslatedContent: t({
247
- en: "Hello World",
248
- es: "Hola Mundo",
249
- fr: "Bonjour le monde",
250
- }),
251
- },
252
- };
253
- ```
254
-
255
- ```json fileName="**/*.content.json" contentDeclarationFormat="json"
256
- {
257
- "$schema": "https://intlayer.org/schema.json",
258
- "key": "my-content",
259
- "content": {
260
- "myTranslatedContent": {
261
- "nodeType": "translation",
262
- "translation": {
263
- "en": "Hello World",
264
- "fr": "Bonjour le monde",
265
- "es": "Hola Mundo"
266
- }
267
- }
268
- }
269
- }
270
- ```
271
-
272
- ### Construye los Recursos de next-i18next
273
-
274
- Para construir los recursos de next-i18next, ejecuta el siguiente comando:
275
-
276
- ```bash packageManager="npm"
277
- npx run intlayer build
278
- ```
279
-
280
- ```bash packageManager="yarn"
281
- yarn intlayer build
282
- ```
124
+ ## Configuración de Git
283
125
 
284
- ```bash packageManager="pnpm"
285
- pnpm intlayer build
286
- ```
287
-
288
- Esto generará recursos en el directorio `./i18next/resources`. La salida esperada:
289
-
290
- ```bash
291
- .
292
- └── i18next
293
- └── resources
294
- └── en
295
- └── my-content.json
296
- └── fr
297
- └── my-content.json
298
- └── es
299
- └── my-content.json
300
- ```
301
-
302
- Nota: El espacio de nombres de i18next corresponde a la clave de declaración de Intlayer.
303
-
304
- ### Implementar el Plugin de Next.js
305
-
306
- Una vez configurado, implementa el plugin de Next.js para reconstruir tus recursos de i18next cada vez que los archivos de declaración de contenido de Intlayer se actualicen.
307
-
308
- ```typescript fileName="next.config.mjs"
309
- import { withIntlayer } from "next-intlayer/server";
310
-
311
- /** @type {import('next').NextConfig} */
312
- const nextConfig = {};
313
-
314
- export default withIntlayer(nextConfig);
315
- ```
126
+ Excluir archivos generados del control de versiones:
316
127
 
317
- ### Usando Contenido en Componentes de Next.js
318
-
319
- Después de implementar el plugin de Next.js, puedes usar el contenido en tus componentes:
320
-
321
- ```typescript fileName="src/components/myComponent/index.tsx" codeFormat="typescript"
322
- import type { FC } from "react";
323
- import { useTranslation } from "react-i18next";
324
-
325
- const IndexPage: FC = () => {
326
- const { t } = useTranslation();
327
-
328
- return (
329
- <div>
330
- <h1>{t("my-content.title")}</h1>
331
- <p>{t("my-content.description")}</p>
332
- </div>
333
- );
334
- };
335
-
336
- export default IndexPage;
128
+ ```plaintext fileName=".gitignore"
129
+ # Ignorar archivos generados por Intlayer
130
+ .intlayer
131
+ intl
337
132
  ```
338
133
 
339
- ```jsx fileName="src/components/myComponent/index.mjx" codeFormat="esm"
340
- import { useTranslation } from "react-i18next";
134
+ Estos archivos se regeneran automáticamente durante el proceso de compilación y no necesitan ser comprometidos en tu repositorio.
341
135
 
342
- const IndexPage = () => {
343
- const { t } = useTranslation();
136
+ ### Extensión de VS Code
344
137
 
345
- return (
346
- <div>
347
- <h1>{t("my-content.title")}</h1>
348
- <p>{t("my-content.description")}</p>
349
- </div>
350
- );
351
- };
352
- ```
353
-
354
- ```jsx fileName="src/components/myComponent/index.cjx" codeFormat="commonjs"
355
- const { useTranslation } = require("react-i18next");
138
+ Para mejorar la experiencia del desarrollador, instala la **Extensión oficial de Intlayer para VS Code**:
356
139
 
357
- const IndexPage = () => {
358
- const { t } = useTranslation();
140
+ [Instalar desde el Marketplace de VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
359
141
 
360
- return (
361
- <div>
362
- <h1>{t("my-content.title")}</h1>
363
- <p>{t("my-content.description")}</p>
364
- </div>
365
- );
366
- };
367
- ```
142
+ [Instalar desde el Marketplace de VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)