@intlayer/docs 8.6.1 → 8.6.10

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 (197) hide show
  1. package/dist/cjs/doc.cjs.map +1 -1
  2. package/dist/cjs/generated/docs.entry.cjs +60 -0
  3. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  4. package/dist/esm/doc.mjs.map +1 -1
  5. package/dist/esm/generated/docs.entry.mjs +60 -0
  6. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  7. package/dist/types/doc.d.ts.map +1 -1
  8. package/dist/types/generated/docs.entry.d.ts +3 -0
  9. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  10. package/docs/ar/cli/index.md +54 -42
  11. package/docs/ar/cli/init.md +32 -20
  12. package/docs/ar/cli/standalone.md +91 -0
  13. package/docs/ar/configuration.md +39 -7
  14. package/docs/ar/custom_domains.md +250 -0
  15. package/docs/ar/intlayer_with_tanstack+solid.md +14 -33
  16. package/docs/ar/intlayer_with_tanstack.md +25 -16
  17. package/docs/ar/intlayer_with_vanilla.md +506 -0
  18. package/docs/bn/cli/index.md +195 -0
  19. package/docs/bn/cli/init.md +96 -0
  20. package/docs/bn/cli/standalone.md +91 -0
  21. package/docs/bn/configuration.md +46 -14
  22. package/docs/bn/custom_domains.md +250 -0
  23. package/docs/bn/intlayer_with_vanilla.md +506 -0
  24. package/docs/cs/cli/index.md +195 -0
  25. package/docs/cs/cli/init.md +96 -0
  26. package/docs/cs/cli/standalone.md +91 -0
  27. package/docs/cs/configuration.md +46 -7
  28. package/docs/cs/custom_domains.md +250 -0
  29. package/docs/cs/intlayer_with_vanilla.md +506 -0
  30. package/docs/de/cli/index.md +53 -41
  31. package/docs/de/cli/standalone.md +91 -0
  32. package/docs/de/configuration.md +46 -7
  33. package/docs/de/custom_domains.md +250 -0
  34. package/docs/de/intlayer_with_tanstack+solid.md +14 -33
  35. package/docs/de/intlayer_with_tanstack.md +25 -16
  36. package/docs/de/intlayer_with_vanilla.md +506 -0
  37. package/docs/en/bundle_optimization.md +288 -23
  38. package/docs/en/cli/index.md +6 -1
  39. package/docs/en/cli/init.md +13 -1
  40. package/docs/en/cli/standalone.md +91 -0
  41. package/docs/en/configuration.md +46 -7
  42. package/docs/en/custom_domains.md +245 -0
  43. package/docs/en/intlayer_with_tanstack+solid.md +14 -33
  44. package/docs/en/intlayer_with_tanstack.md +25 -16
  45. package/docs/en/intlayer_with_vanilla.md +506 -0
  46. package/docs/en-GB/cli/index.md +56 -44
  47. package/docs/en-GB/cli/init.md +28 -21
  48. package/docs/en-GB/cli/standalone.md +91 -0
  49. package/docs/en-GB/configuration.md +53 -14
  50. package/docs/en-GB/custom_domains.md +250 -0
  51. package/docs/en-GB/intlayer_with_tanstack+solid.md +14 -33
  52. package/docs/en-GB/intlayer_with_tanstack.md +25 -16
  53. package/docs/en-GB/intlayer_with_vanilla.md +506 -0
  54. package/docs/es/cli/index.md +65 -53
  55. package/docs/es/cli/init.md +33 -21
  56. package/docs/es/cli/standalone.md +91 -0
  57. package/docs/es/configuration.md +39 -1
  58. package/docs/es/custom_domains.md +250 -0
  59. package/docs/es/intlayer_with_tanstack+solid.md +14 -33
  60. package/docs/es/intlayer_with_tanstack.md +25 -16
  61. package/docs/es/intlayer_with_vanilla.md +506 -0
  62. package/docs/fr/cli/index.md +43 -31
  63. package/docs/fr/cli/init.md +37 -25
  64. package/docs/fr/cli/standalone.md +91 -0
  65. package/docs/fr/configuration.md +46 -7
  66. package/docs/fr/custom_domains.md +250 -0
  67. package/docs/fr/intlayer_with_tanstack+solid.md +14 -33
  68. package/docs/fr/intlayer_with_tanstack.md +25 -16
  69. package/docs/fr/intlayer_with_vanilla.md +506 -0
  70. package/docs/hi/cli/index.md +71 -59
  71. package/docs/hi/cli/init.md +37 -33
  72. package/docs/hi/cli/standalone.md +91 -0
  73. package/docs/hi/configuration.md +39 -7
  74. package/docs/hi/custom_domains.md +250 -0
  75. package/docs/hi/intlayer_with_tanstack+solid.md +14 -33
  76. package/docs/hi/intlayer_with_tanstack.md +25 -16
  77. package/docs/hi/intlayer_with_vanilla.md +506 -0
  78. package/docs/id/cli/index.md +59 -47
  79. package/docs/id/cli/init.md +32 -25
  80. package/docs/id/cli/standalone.md +91 -0
  81. package/docs/id/configuration.md +46 -7
  82. package/docs/id/custom_domains.md +250 -0
  83. package/docs/id/intlayer_with_tanstack+solid.md +14 -33
  84. package/docs/id/intlayer_with_tanstack.md +25 -16
  85. package/docs/id/intlayer_with_vanilla.md +506 -0
  86. package/docs/it/cli/index.md +58 -41
  87. package/docs/it/cli/init.md +37 -38
  88. package/docs/it/cli/standalone.md +91 -0
  89. package/docs/it/configuration.md +46 -7
  90. package/docs/it/custom_domains.md +250 -0
  91. package/docs/it/intlayer_with_tanstack+solid.md +14 -33
  92. package/docs/it/intlayer_with_tanstack.md +25 -16
  93. package/docs/it/intlayer_with_vanilla.md +506 -0
  94. package/docs/ja/cli/index.md +59 -47
  95. package/docs/ja/cli/init.md +36 -24
  96. package/docs/ja/cli/standalone.md +91 -0
  97. package/docs/ja/configuration.md +46 -7
  98. package/docs/ja/custom_domains.md +250 -0
  99. package/docs/ja/intlayer_with_tanstack+solid.md +14 -33
  100. package/docs/ja/intlayer_with_tanstack.md +25 -16
  101. package/docs/ja/intlayer_with_vanilla.md +506 -0
  102. package/docs/ko/cli/index.md +58 -46
  103. package/docs/ko/cli/init.md +39 -35
  104. package/docs/ko/cli/standalone.md +91 -0
  105. package/docs/ko/configuration.md +47 -8
  106. package/docs/ko/custom_domains.md +250 -0
  107. package/docs/ko/intlayer_with_tanstack+solid.md +14 -33
  108. package/docs/ko/intlayer_with_tanstack.md +25 -16
  109. package/docs/ko/intlayer_with_vanilla.md +506 -0
  110. package/docs/nl/cli/index.md +195 -0
  111. package/docs/nl/cli/init.md +96 -0
  112. package/docs/nl/cli/standalone.md +91 -0
  113. package/docs/nl/configuration.md +46 -7
  114. package/docs/nl/custom_domains.md +250 -0
  115. package/docs/nl/intlayer_with_vanilla.md +506 -0
  116. package/docs/pl/cli/index.md +56 -44
  117. package/docs/pl/cli/init.md +36 -32
  118. package/docs/pl/cli/standalone.md +91 -0
  119. package/docs/pl/configuration.md +46 -7
  120. package/docs/pl/custom_domains.md +250 -0
  121. package/docs/pl/intlayer_with_tanstack+solid.md +14 -33
  122. package/docs/pl/intlayer_with_tanstack.md +25 -16
  123. package/docs/pl/intlayer_with_vanilla.md +506 -0
  124. package/docs/pt/cli/index.md +64 -52
  125. package/docs/pt/cli/init.md +35 -31
  126. package/docs/pt/cli/standalone.md +91 -0
  127. package/docs/pt/configuration.md +46 -7
  128. package/docs/pt/custom_domains.md +250 -0
  129. package/docs/pt/intlayer_with_tanstack+solid.md +14 -33
  130. package/docs/pt/intlayer_with_tanstack.md +25 -16
  131. package/docs/pt/intlayer_with_vanilla.md +506 -0
  132. package/docs/ru/cli/index.md +54 -42
  133. package/docs/ru/cli/init.md +31 -27
  134. package/docs/ru/cli/standalone.md +91 -0
  135. package/docs/ru/configuration.md +46 -7
  136. package/docs/ru/custom_domains.md +250 -0
  137. package/docs/ru/intlayer_with_tanstack+solid.md +14 -33
  138. package/docs/ru/intlayer_with_tanstack.md +25 -16
  139. package/docs/ru/intlayer_with_vanilla.md +506 -0
  140. package/docs/tr/cli/index.md +64 -52
  141. package/docs/tr/cli/init.md +37 -30
  142. package/docs/tr/cli/standalone.md +91 -0
  143. package/docs/tr/configuration.md +46 -7
  144. package/docs/tr/custom_domains.md +250 -0
  145. package/docs/tr/intlayer_with_tanstack+solid.md +14 -33
  146. package/docs/tr/intlayer_with_tanstack.md +25 -16
  147. package/docs/tr/intlayer_with_vanilla.md +506 -0
  148. package/docs/uk/cli/index.md +60 -55
  149. package/docs/uk/cli/init.md +32 -20
  150. package/docs/uk/cli/standalone.md +91 -0
  151. package/docs/uk/configuration.md +46 -7
  152. package/docs/uk/custom_domains.md +250 -0
  153. package/docs/uk/intlayer_with_tanstack+solid.md +14 -33
  154. package/docs/uk/intlayer_with_tanstack.md +25 -16
  155. package/docs/uk/intlayer_with_vanilla.md +506 -0
  156. package/docs/ur/cli/index.md +195 -0
  157. package/docs/ur/cli/init.md +96 -0
  158. package/docs/ur/cli/standalone.md +91 -0
  159. package/docs/ur/configuration.md +46 -7
  160. package/docs/ur/custom_domains.md +250 -0
  161. package/docs/ur/intlayer_with_vanilla.md +506 -0
  162. package/docs/vi/cli/index.md +72 -61
  163. package/docs/vi/cli/init.md +33 -21
  164. package/docs/vi/cli/standalone.md +91 -0
  165. package/docs/vi/configuration.md +46 -7
  166. package/docs/vi/custom_domains.md +250 -0
  167. package/docs/vi/intlayer_with_tanstack+solid.md +14 -33
  168. package/docs/vi/intlayer_with_tanstack.md +25 -16
  169. package/docs/vi/intlayer_with_vanilla.md +506 -0
  170. package/docs/zh/cli/index.md +56 -49
  171. package/docs/zh/cli/init.md +30 -18
  172. package/docs/zh/cli/standalone.md +91 -0
  173. package/docs/zh/configuration.md +46 -7
  174. package/docs/zh/custom_domains.md +250 -0
  175. package/docs/zh/intlayer_with_tanstack+solid.md +14 -33
  176. package/docs/zh/intlayer_with_tanstack.md +25 -16
  177. package/docs/zh/intlayer_with_vanilla.md +506 -0
  178. package/package.json +8 -8
  179. package/src/doc.ts +4 -1
  180. package/src/generated/docs.entry.ts +60 -0
  181. package/docs/ar/bundle_optimization.md +0 -185
  182. package/docs/de/bundle_optimization.md +0 -195
  183. package/docs/en-GB/bundle_optimization.md +0 -184
  184. package/docs/es/bundle_optimization.md +0 -194
  185. package/docs/fr/bundle_optimization.md +0 -184
  186. package/docs/hi/bundle_optimization.md +0 -185
  187. package/docs/id/bundle_optimization.md +0 -185
  188. package/docs/it/bundle_optimization.md +0 -185
  189. package/docs/ja/bundle_optimization.md +0 -185
  190. package/docs/ko/bundle_optimization.md +0 -185
  191. package/docs/pl/bundle_optimization.md +0 -185
  192. package/docs/pt/bundle_optimization.md +0 -184
  193. package/docs/ru/bundle_optimization.md +0 -185
  194. package/docs/tr/bundle_optimization.md +0 -184
  195. package/docs/uk/bundle_optimization.md +0 -186
  196. package/docs/vi/bundle_optimization.md +0 -185
  197. package/docs/zh/bundle_optimization.md +0 -185
@@ -0,0 +1,506 @@
1
+ ---
2
+ createdAt: 2026-03-31
3
+ updatedAt: 2026-03-31
4
+ title: i18n Vanilla JS - Cómo traducir una aplicación Vanilla JS en 2026
5
+ description: Descubre cómo hacer que tu sitio web Vanilla JS sea multilingüe. Sigue la documentación para internacionalizarlo (i18n) y traducirlo.
6
+ keywords:
7
+ - Internacionalización
8
+ - Documentación
9
+ - Intlayer
10
+ - Vanilla JS
11
+ - JavaScript
12
+ - TypeScript
13
+ - HTML
14
+ slugs:
15
+ - doc
16
+ - environment
17
+ - vanilla
18
+ applicationTemplate: https://github.com/aymericzip/intlayer-vanilla-template
19
+ history:
20
+ - version: 8.4.10
21
+ date: 2026-03-31
22
+ changes: "Inicio del historial"
23
+ ---
24
+
25
+ # Traduce tu sitio web Vanilla JS usando Intlayer | Internacionalización (i18n)
26
+
27
+ ## Tabla de Contenidos
28
+
29
+ <TOC/>
30
+
31
+ ## ¿Qué es Intlayer?
32
+
33
+ **Intlayer** es una biblioteca de internacionalización (i18n) innovadora y de código abierto diseñada para simplificar el soporte multilingüe en aplicaciones web modernas.
34
+
35
+ Con Intlayer, puedes:
36
+
37
+ - **Gestionar fácilmente las traducciones** usando diccionarios declarativos a nivel de componente.
38
+ - **Localizar dinámicamente metadatos**, rutas y contenido.
39
+ - **Asegurar el soporte de TypeScript** con tipos autogenerados, mejorando el autocompletado y la detección de errores.
40
+ - **Beneficiarte de funciones avanzadas**, como la detección y el cambio dinámico de idioma.
41
+
42
+ Esta guía demuestra cómo usar Intlayer en una aplicación de Vanilla JavaScript **sin usar un gestor de paquetes o un empaquetador** (como Vite, Webpack, etc.).
43
+
44
+ Si tu aplicación usa un empaquetador (como Vite), te recomendamos seguir la [Guía de Vite + Vanilla JS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_with_vite+vanilla.md) en su lugar.
45
+
46
+ Usando el paquete independiente (standalone), puedes importar Intlayer directamente en tus archivos HTML mediante un único archivo JavaScript, lo que lo hace perfecto para proyectos heredados o sitios estáticos simples.
47
+
48
+ ---
49
+
50
+ ## Guía paso a paso para configurar Intlayer en una aplicación Vanilla JS
51
+
52
+ ### Paso 1: Instalar dependencias
53
+
54
+ Instala los paquetes necesarios usando npm:
55
+
56
+ ```bash packageManager="npm"
57
+ # Generar un paquete independiente de intlayer y vanilla-intlayer
58
+ # Este archivo se importará en tu archivo HTML
59
+ npx intlayer standalone --packages intlayer vanilla-intlayer --outfile intlayer.js
60
+
61
+ # Inicializar intlayer con el archivo de configuración
62
+ npx intlayer init --no-gitignore
63
+
64
+ # Construir los diccionarios
65
+ npx intlayer build
66
+ ```
67
+
68
+ ```bash packageManager="pnpm"
69
+ # Generar un paquete independiente de intlayer y vanilla-intlayer
70
+ # Este archivo se importará en tu archivo HTML
71
+ pnpm intlayer standalone --packages intlayer vanilla-intlayer --outfile intlayer.js
72
+
73
+ # Inicializar intlayer con el archivo de configuración
74
+ pnpm intlayer init --no-gitignore
75
+
76
+ # Construir los diccionarios
77
+ pnpm intlayer build
78
+ ```
79
+
80
+ ```bash packageManager="yarn"
81
+ # Generar un paquete independiente de intlayer y vanilla-intlayer
82
+ # Este archivo se importará en tu archivo HTML
83
+ yarn intlayer standalone --packages intlayer vanilla-intlayer --outfile intlayer.js
84
+
85
+ # Inicializar el archivo de configuración de intlayer, TypeScript si está configurado, variables de entorno
86
+ yarn intlayer init --no-gitignore
87
+
88
+ # Construir los diccionarios
89
+ yarn intlayer build
90
+ ```
91
+
92
+ ```bash packageManager="bun"
93
+ # Generar un paquete independiente de intlayer y vanilla-intlayer
94
+ # Este archivo se importará en tu archivo HTML
95
+ bun x intlayer standalone --packages intlayer vanilla-intlayer --outfile intlayer.js
96
+
97
+ # Inicializar intlayer con el archivo de configuración
98
+ bun x intlayer init --no-gitignore
99
+
100
+ # Construir los diccionarios
101
+ bun x intlayer build
102
+ ```
103
+
104
+ - **intlayer**
105
+ El paquete principal que proporciona herramientas de internacionalización para la gestión de la configuración, traducción, [declaración de contenido](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/dictionary/content_file.md), transpilación y [comandos de CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/cli/index.md).
106
+
107
+ - **vanilla-intlayer**
108
+ El paquete que integra Intlayer con aplicaciones puras de JavaScript / TypeScript. Proporciona un singleton de publicación/suscripción (`IntlayerClient`) y ayudantes basados en callbacks (`useIntlayer`, `useLocale`, etc.) para que cualquier parte de tu aplicación pueda reaccionar a los cambios de idioma sin depender de un framework de UI.
109
+
110
+ > La exportación de empaquetado (bundling) del CLI `intlayer standalone` produce una compilación optimizada mediante la eliminación de código muerto (tree-shaking) de paquetes no utilizados, idiomas y lógica no esencial (como redireccionamientos o prefijos) específica de su configuración.
111
+
112
+ ### Paso 2: Configuración de tu proyecto
113
+
114
+ Crea un archivo de configuración para configurar los idiomas de tu aplicación:
115
+
116
+ ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
117
+ import { Locales, type IntlayerConfig } from "intlayer";
118
+
119
+ const config: IntlayerConfig = {
120
+ internationalization: {
121
+ locales: [
122
+ Locales.ENGLISH,
123
+ Locales.FRENCH,
124
+ Locales.SPANISH,
125
+ // Tus otros idiomas
126
+ ],
127
+ defaultLocale: Locales.ENGLISH,
128
+ },
129
+ };
130
+
131
+ export default config;
132
+ ```
133
+
134
+ ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
135
+ import { Locales } from "intlayer";
136
+
137
+ /** @type {import('intlayer').IntlayerConfig} */
138
+ const config = {
139
+ internationalization: {
140
+ locales: [
141
+ Locales.ENGLISH,
142
+ Locales.FRENCH,
143
+ Locales.SPANISH,
144
+ // Tus otros idiomas
145
+ ],
146
+ defaultLocale: Locales.ENGLISH,
147
+ },
148
+ };
149
+
150
+ export default config;
151
+ ```
152
+
153
+ ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
154
+ const { Locales } = require("intlayer");
155
+
156
+ /** @type {import('intlayer').IntlayerConfig} */
157
+ const config = {
158
+ internationalization: {
159
+ locales: [
160
+ Locales.ENGLISH,
161
+ Locales.FRENCH,
162
+ Locales.SPANISH,
163
+ // Tus otros idiomas
164
+ ],
165
+ defaultLocale: Locales.ENGLISH,
166
+ },
167
+ };
168
+
169
+ module.exports = config;
170
+ ```
171
+
172
+ > A través de este archivo de configuración, puedes configurar URLs localizadas, redirección de middleware, nombres de cookies, la ubicación y extensión de tus declaraciones de contenido, desactivar los registros de Intlayer en la consola y más. Para una lista completa de los parámetros disponibles, consulta la [documentación de configuración](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/configuration.md).
173
+
174
+ ### Paso 3: Importar el paquete en tu HTML
175
+
176
+ Una vez que hayas generado el paquete `intlayer.js`, puedes importarlo en tu archivo HTML:
177
+
178
+ ```html fileName="index.html"
179
+ <!DOCTYPE html>
180
+ <html lang="es">
181
+ <head>
182
+ <meta charset="UTF-8" />
183
+
184
+ <!-- Importar el paquete -->
185
+ <script src="./intlayer.js" defer></script>
186
+ <!-- Importar tu script principal -->
187
+ <script src="./src/main.js" defer></script>
188
+ </head>
189
+ <body>
190
+ <h1 id="title"></h1>
191
+ <p class="read-the-docs"></p>
192
+ </body>
193
+ </html>
194
+ ```
195
+
196
+ El paquete expone `Intlayer` y `VanillaIntlayer` como objetos globales en `window`.
197
+
198
+ ### Paso 4: Inicializar Intlayer en tu punto de entrada
199
+
200
+ En tu `src/main.js`, llama a `installIntlayer()` **antes** de que se renderice cualquier contenido para que el singleton global de idioma esté listo.
201
+
202
+ ```javascript fileName="src/main.js"
203
+ const { installIntlayer } = window.VanillaIntlayer;
204
+
205
+ // Debe llamarse antes de renderizar cualquier contenido i18n.
206
+ installIntlayer();
207
+ ```
208
+
209
+ Si también quieres usar el renderizador de markdown, llama a `installIntlayerMarkdown()`:
210
+
211
+ ```javascript fileName="src/main.js"
212
+ const { installIntlayer, installIntlayerMarkdown } = window.VanillaIntlayer;
213
+
214
+ installIntlayer();
215
+ installIntlayerMarkdown();
216
+ ```
217
+
218
+ ### Paso 5: Declarar Tu Contenido
219
+
220
+ Crea y gestiona tus declaraciones de contenido para almacenar traducciones:
221
+
222
+ ```typescript fileName="src/app.content.ts" contentDeclarationFormat="typescript"
223
+ import { insert, t, type Dictionary } from "intlayer";
224
+
225
+ const appContent = {
226
+ key: "app",
227
+ content: {
228
+ title: "Vite + Vanilla",
229
+
230
+ viteLogoLabel: t({
231
+ en: "Vite Logo",
232
+ fr: "Logo Vite",
233
+ es: "Logo Vite",
234
+ }),
235
+
236
+ count: insert(
237
+ t({
238
+ en: "count is {{count}}",
239
+ fr: "le compte est {{count}}",
240
+ es: "el recuento es {{count}}",
241
+ })
242
+ ),
243
+
244
+ readTheDocs: t({
245
+ en: "Click on the Vite logo to learn more",
246
+ fr: "Cliquez sur le logo Vite pour en savoir plus",
247
+ es: "Haga clic en el logotipo de Vite para obtener más información",
248
+ }),
249
+ },
250
+ } satisfies Dictionary;
251
+
252
+ export default appContent;
253
+ ```
254
+
255
+ ```javascript fileName="src/app.content.mjs" contentDeclarationFormat="esm"
256
+ import { insert, t } from "intlayer";
257
+
258
+ /** @type {import('intlayer').Dictionary} */
259
+ const appContent = {
260
+ key: "app",
261
+ content: {
262
+ title: "Vite + Vanilla",
263
+
264
+ viteLogoLabel: t({
265
+ en: "Vite Logo",
266
+ fr: "Logo Vite",
267
+ es: "Logo Vite",
268
+ }),
269
+
270
+ count: insert(
271
+ t({
272
+ en: "count is {{count}}",
273
+ fr: "le compte est {{count}}",
274
+ es: "el recuento es {{count}}",
275
+ })
276
+ ),
277
+
278
+ readTheDocs: t({
279
+ en: "Click on the Vite logo to learn more",
280
+ fr: "Cliquez sur le logo Vite pour en savoir plus",
281
+ es: "Haga clic en el logotipo de Vite para obtener más información",
282
+ }),
283
+ },
284
+ };
285
+
286
+ export default appContent;
287
+ ```
288
+
289
+ ```javascript fileName="src/app.content.cjs" contentDeclarationFormat="commonjs"
290
+ const { insert, t } = require("intlayer");
291
+
292
+ /** @type {import('intlayer').Dictionary} */
293
+ const appContent = {
294
+ key: "app",
295
+ content: {
296
+ title: "Vite + Vanilla",
297
+
298
+ viteLogoLabel: t({
299
+ en: "Vite Logo",
300
+ fr: "Logo Vite",
301
+ es: "Logo Vite",
302
+ }),
303
+
304
+ count: insert(
305
+ t({
306
+ en: "count is {{count}}",
307
+ fr: "le compte est {{count}}",
308
+ es: "el recuento es {{count}}",
309
+ })
310
+ ),
311
+
312
+ readTheDocs: t({
313
+ en: "Click on the Vite logo to learn more",
314
+ fr: "Cliquez sur le logo Vite pour en savoir plus",
315
+ es: "Haga clic en el logotipo de Vite para obtener más información",
316
+ }),
317
+ },
318
+ };
319
+
320
+ module.exports = appContent;
321
+ ```
322
+
323
+ ```json fileName="src/app.content.json" contentDeclarationFormat="json"
324
+ {
325
+ "$schema": "https://intlayer.org/schema.json",
326
+ "key": "app",
327
+ "content": {
328
+ "title": "Vite + Vanilla",
329
+ "viteLogoLabel": {
330
+ "nodeType": "translation",
331
+ "translation": {
332
+ "en": "Vite Logo",
333
+ "fr": "Logo Vite",
334
+ "es": "Logo Vite"
335
+ }
336
+ },
337
+ "count": {
338
+ "nodeType": "insertion",
339
+ "insertion": {
340
+ "nodeType": "translation",
341
+ "translation": {
342
+ "en": "count is {{count}}",
343
+ "fr": "le compte est {{count}}",
344
+ "es": "el recuento es {{count}}"
345
+ }
346
+ }
347
+ },
348
+ "readTheDocs": {
349
+ "nodeType": "translation",
350
+ "translation": {
351
+ "en": "Click on the Vite logo to learn more",
352
+ "fr": "Cliquez sur le logo Vite pour en savoir plus",
353
+ "es": "Haga clic en el logotipo de Vite para obtener más información"
354
+ }
355
+ }
356
+ }
357
+ }
358
+ ```
359
+
360
+ > Tus declaraciones de contenido pueden definirse en cualquier lugar de tu aplicación siempre que estén incluidas en el directorio `contentDir` (por defecto, `./src`). Y coincidan con la extensión de archivo de declaración de contenido (por defecto, `.content.{json,ts,tsx,js,jsx,mjs,cjs}`).
361
+ >
362
+ > Para más detalles, consulta la [documentación de declaración de contenido](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/dictionary/content_file.md).
363
+
364
+ ### Paso 6: Usar Intlayer en tu JavaScript
365
+
366
+ El objeto `window.VanillaIntlayer` proporciona ayudantes de API: `useIntlayer(key, locale?)` devuelve el contenido traducido para una clave dada.
367
+
368
+ ```javascript fileName="src/main.js"
369
+ const { installIntlayer, useIntlayer } = window.VanillaIntlayer;
370
+
371
+ installIntlayer();
372
+
373
+ // Obtener el contenido inicial para el idioma actual.
374
+ // Encadenar .onChange() para ser notificado cada vez que cambie el idioma.
375
+ const content = useIntlayer("app").onChange((newContent) => {
376
+ // Volver a renderizar o parchear solo los nodos DOM afectados
377
+ document.querySelector("h1").textContent = String(newContent.title);
378
+ document.querySelector(".read-the-docs").textContent = String(
379
+ newContent.readTheDocs
380
+ );
381
+ });
382
+
383
+ // Renderizado inicial
384
+ document.querySelector("h1").textContent = String(content.title);
385
+ document.querySelector(".read-the-docs").textContent = String(
386
+ content.readTheDocs
387
+ );
388
+ ```
389
+
390
+ > Accede a los valores finales como cadenas envolviéndolos en `String()`, que llama al método `toString()` del nodo y devuelve el texto traducido.
391
+ >
392
+ > Cuando necesites el valor para un atributo HTML nativo (por ejemplo, `alt`, `aria-label`), usa `.value` directamente:
393
+ >
394
+ > ```javascript
395
+ > img.alt = content.viteLogoLabel.value;
396
+ > ```
397
+
398
+ ### (Opcional) Paso 7: Cambiar el idioma de tu contenido
399
+
400
+ Para cambiar el idioma de tu contenido, usa la función `setLocale` expuesta por `useLocale`.
401
+
402
+ ```javascript fileName="src/locale-switcher.js"
403
+ const { getLocaleName } = window.Intlayer;
404
+ const { useLocale } = window.VanillaIntlayer;
405
+
406
+ export function setupLocaleSwitcher(container) {
407
+ const { locale, availableLocales, setLocale, subscribe } = useLocale();
408
+
409
+ const select = document.createElement("select");
410
+ select.setAttribute("aria-label", "Idioma");
411
+
412
+ const render = (currentLocale) => {
413
+ select.innerHTML = availableLocales
414
+ .map(
415
+ (loc) =>
416
+ `<option value="${loc}"${loc === currentLocale ? " selected" : ""}>
417
+ ${getLocaleName(loc)}
418
+ </option>`
419
+ )
420
+ .join("");
421
+ };
422
+
423
+ render(locale);
424
+ container.appendChild(select);
425
+
426
+ select.addEventListener("change", () => setLocale(select.value));
427
+
428
+ // Mantener el menú desplegable sincronizado cuando el idioma cambia desde otro lugar
429
+ return subscribe((newLocale) => render(newLocale));
430
+ }
431
+ ```
432
+
433
+ ### (Opcional) Paso 8: Cambiar los atributos de idioma y dirección HTML
434
+
435
+ Actualiza los atributos `lang` y `dir` de la etiqueta `<html>` para que coincidan con la configuración regional actual para accesibilidad y SEO.
436
+
437
+ ```javascript fileName="src/main.js"
438
+ const { getHTMLTextDir } = window.Intlayer;
439
+ const { installIntlayer, useLocale } = window.VanillaIntlayer;
440
+
441
+ installIntlayer();
442
+
443
+ useLocale({
444
+ onLocaleChange: (locale) => {
445
+ document.documentElement.lang = locale;
446
+ document.documentElement.dir = getHTMLTextDir(locale);
447
+ },
448
+ });
449
+ ```
450
+
451
+ ### (Opcional) Paso 9: Carga diferida de diccionarios por idioma
452
+
453
+ Si deseas cargar diferidamente diccionarios por idioma, puedes usar `useDictionaryDynamic`. Esto es útil si no deseas incluir todas las traducciones en el archivo inicial `intlayer.js`.
454
+
455
+ ```javascript fileName="src/app.js"
456
+ const { installIntlayer, useDictionaryDynamic } = window.VanillaIntlayer;
457
+
458
+ installIntlayer();
459
+
460
+ const unsubscribe = useDictionaryDynamic(
461
+ {
462
+ en: () => import("../.intlayer/dictionaries/en/app.mjs"),
463
+ fr: () => import("../.intlayer/dictionaries/fr/app.mjs"),
464
+ es: () => import("../.intlayer/dictionaries/es/app.mjs"),
465
+ },
466
+ "app"
467
+ ).onChange((content) => {
468
+ document.querySelector("h1").textContent = String(content.title);
469
+ });
470
+ ```
471
+
472
+ > Nota: `useDictionaryDynamic` requiere que los diccionarios estén disponibles como archivos ESM separados. Este enfoque se usa típicamente si tienes un servidor web que sirve los diccionarios.
473
+
474
+ ### Configurar TypeScript
475
+
476
+ Asegúrate de que tu configuración de TypeScript incluya los tipos autogenerados.
477
+
478
+ ```json5 fileName="tsconfig.json"
479
+ {
480
+ "compilerOptions": {
481
+ // ...
482
+ },
483
+ "include": ["src", ".intlayer/**/*.ts"],
484
+ }
485
+ ```
486
+
487
+ ### Extensión de VS Code
488
+
489
+ Para mejorar tu experiencia de desarrollo con Intlayer, puedes instalar la **Extensión oficial de Intlayer para VS Code**.
490
+
491
+ [Instalar desde el Market de VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
492
+
493
+ Esta extensión proporciona:
494
+
495
+ - **Autocompletado** para las claves de traducción.
496
+ - **Detección de errores en tiempo real** para traducciones faltantes.
497
+ - **Previsualizaciones en línea** del contenido traducido.
498
+ - **Acciones rápidas** para crear y actualizar traducciones fácilmente.
499
+
500
+ Para más detalles sobre cómo usar la extensión, consulta la [documentación de la extensión Intlayer para VS Code](https://intlayer.org/doc/vs-code-extension).
501
+
502
+ ---
503
+
504
+ ### Ir más allá
505
+
506
+ Para ir más allá, puedes implementar el [editor visual](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_visual_editor.md) o externalizar tu contenido usando el [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_CMS.md).
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  createdAt: 2024-08-11
3
- updatedAt: 2026-01-06
4
- title: CLI
5
- description: Découvrez comment utiliser le CLI Intlayer pour gérer votre site web multilingue. Suivez les étapes de cette documentation en ligne pour configurer votre projet en quelques minutes.
3
+ updatedAt: 2026-03-31
4
+ title: CLI - Toutes les commandes CLI Intlayer pour votre site multilingue
5
+ description: Découvrez comment utiliser le CLI Intlayer pour gérer votre site multilingue. Suivez les étapes de cette documentation en ligne pour configurer votre projet en quelques minutes.
6
6
  keywords:
7
7
  - CLI
8
- - Interface en ligne de commande
8
+ - Command Line Interface
9
9
  - Internationalisation
10
10
  - Documentation
11
11
  - Intlayer
@@ -17,15 +17,21 @@ slugs:
17
17
  - concept
18
18
  - cli
19
19
  history:
20
+ - version: 8.6.4
21
+ date: 2026-03-31
22
+ changes: "Ajout de la commande standalone"
20
23
  - version: 7.5.11
21
24
  date: 2026-01-06
22
- changes: "Ajout de la commande projects list"
25
+ changes: "Ajout de la commande CI"
26
+ - version: 7.5.11
27
+ date: 2026-01-06
28
+ changes: "Ajout de la commande list projects"
23
29
  - version: 7.5.9
24
30
  date: 2025-12-30
25
31
  changes: "Ajout de la commande init"
26
32
  - version: 7.2.3
27
33
  date: 2025-11-22
28
- changes: "Ajout de la commande transform"
34
+ changes: "Ajout de la commande extract"
29
35
  - version: 7.1.0
30
36
  date: 2025-11-05
31
37
  changes: "Ajout de l'option skipIfExists à la commande translate"
@@ -40,7 +46,7 @@ history:
40
46
  changes: "Ajout de la commande version"
41
47
  - version: 6.1.0
42
48
  date: 2025-09-26
43
- changes: "Définir l'option verbose par défaut à true via le CLI"
49
+ changes: "Réglage de l'option verbose par défaut sur vrai via CLI"
44
50
  - version: 6.1.0
45
51
  date: 2025-09-23
46
52
  changes: "Ajout de la commande watch et de l'option with"
@@ -58,7 +64,7 @@ history:
58
64
  changes: "Initialisation de l'historique"
59
65
  ---
60
66
 
61
- # CLI Intlayer
67
+ # CLI Intlayer - Toutes les commandes CLI Intlayer pour votre site multilingue
62
68
 
63
69
  ---
64
70
 
@@ -68,9 +74,9 @@ history:
68
74
 
69
75
  ---
70
76
 
71
- ## Installer le package
77
+ ## Installer le paquet
72
78
 
73
- Installez les packages nécessaires en utilisant npm :
79
+ Installez les paquets nécessaires avec npm :
74
80
 
75
81
  ```bash packageManager="npm"
76
82
  npm install intlayer-cli -g
@@ -88,13 +94,13 @@ pnpm add intlayer-cli -g
88
94
  bun add intlayer-cli -g
89
95
  ```
90
96
 
91
- > Si le package `intlayer` est déjà installé, le CLI est automatiquement installé. Vous pouvez passer cette étape.
97
+ > Si le paquet `intlayer` est déjà installé, le CLI est automatiquement installé. Vous pouvez ignorer cette étape.
92
98
 
93
- ## Package intlayer-cli
99
+ ## paquet intlayer-cli
94
100
 
95
- Le package `intlayer-cli` a pour but de transpiler vos [déclarations intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/dictionary/content_file.md) en dictionnaires.
101
+ Le paquet `intlayer-cli` est destiné à transpiler vos [déclarations intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/dictionary/content_file.md) en dictionnaires.
96
102
 
97
- Ce package va transpiler tous les fichiers intlayer, tels que `src/**/*.content.{ts|js|mjs|cjs|json}`. [Voir comment déclarer vos fichiers de déclaration Intlayer](https://github.com/aymericzip/intlayer/blob/main/packages/intlayer/README.md).
103
+ Ce paquet transpilera tous les fichiers intlayer, tels que `src/**/*.content.{ts|js|mjs|cjs|json}`. [Voir comment déclarer vos fichiers de déclaration Intlayer](https://github.com/aymericzip/intlayer/blob/main/packages/intlayer/README.md).
98
104
 
99
105
  Pour interpréter les dictionnaires intlayer, vous pouvez utiliser des interpréteurs, tels que [react-intlayer](https://www.npmjs.com/package/react-intlayer), ou [next-intlayer](https://www.npmjs.com/package/next-intlayer).
100
106
 
@@ -109,24 +115,25 @@ Intlayer accepte plusieurs formats de fichiers de configuration :
109
115
  - `intlayer.config.mjs`
110
116
  - `.intlayerrc`
111
117
 
112
- Pour voir comment configurer les locales disponibles, ou d'autres paramètres, référez-vous à la [documentation de configuration ici](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/configuration.md).
118
+ Pour voir comment configurer les locales disponibles ou d'autres paramètres, reportez-vous à la [documentation de configuration ici](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/configuration.md).
113
119
 
114
- ## Exécuter les commandes intlayer
120
+ ## Exécuter des commandes intlayer
115
121
 
116
122
  ### Authentification
117
123
 
118
- - **[Connexion](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/login.md)** - S'authentifier avec le CMS Intlayer et obtenir les identifiants d'accès
124
+ - **[Connexion](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/login.md)** - S'authentifier auprès du CMS Intlayer et obtenir les identifiants d'accès
119
125
 
120
126
  ### Commandes principales
121
127
 
122
- - **[Construire les dictionnaires](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/build.md)** - Construisez vos dictionnaires à partir des fichiers de déclaration de contenu
123
- - **[Surveiller les dictionnaires](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/watch.md)** - Surveillez les changements et construisez automatiquement les dictionnaires
124
- - **[Vérifier la version CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/version.md)** - Vérifiez la version installée de la CLI Intlayer
128
+ - **[Build de dictionnaires](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/build.md)** - Construisez vos dictionnaires à partir des fichiers de déclaration de contenu
129
+ - **[Surveillance de dictionnaires](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/watch.md)** - Surveillez les changements et construisez automatiquement les dictionnaires
130
+ - **[Créer un bundle autonome](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/standalone.md)** - Créez un bundle JavaScript autonome contenant Intlayer et les paquets spécifiés
131
+ - **[Vérifier la version du CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/version.md)** - Vérifiez la version installée du CLI Intlayer
125
132
  - **[Lister les projets](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/list_projects.md)** - Listez tous les projets Intlayer dans un répertoire ou un dépôt git
126
133
 
127
134
  ### Gestion des dictionnaires
128
135
 
129
- - **[Pousser les dictionnaires](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/push.md)** - Poussez les dictionnaires vers l'éditeur Intlayer et le CMS
136
+ - **[Pousser les dictionnaires](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/push.md)** - Poussez les dictionnaires vers l'éditeur et le CMS Intlayer
130
137
  - **[Récupérer les dictionnaires](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/pull.md)** - Récupérez les dictionnaires depuis l'éditeur et le CMS Intlayer
131
138
  - **[Remplir les dictionnaires](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/fill.md)** - Remplissez, auditez et traduisez les dictionnaires à l'aide de l'IA
132
139
  - **[Tester les traductions manquantes](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/test.md)** - Testez et identifiez les traductions manquantes
@@ -134,29 +141,33 @@ Pour voir comment configurer les locales disponibles, ou d'autres paramètres, r
134
141
 
135
142
  ### Gestion des composants
136
143
 
137
- - **[Transformer les composants](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/extract.md)** - Transformer les composants existants pour utiliser Intlayer
144
+ - **[Extraire des chaînes de caractères](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/extract.md)** - Extrayez les chaînes des composants dans un fichier .content à proximité du composant
138
145
 
139
146
  ### Configuration
140
147
 
141
- - **[Initialiser Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/init.md)** - Configurer Intlayer dans votre projet avec une configuration automatique
142
- - **[Gérer la configuration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/configuration.md)** - Récupérer et pousser votre configuration Intlayer vers le CMS
148
+ - **[Initialiser Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/init.md)** - Configurez Intlayer dans votre projet avec une configuration automatique
149
+ - **[Gérer la configuration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/configuration.md)** - Récupérez et poussez votre configuration Intlayer vers le CMS
143
150
 
144
151
  ### Gestion de la documentation
145
152
 
146
- - **[Traduire un document](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/doc-translate.md)** - Traduire automatiquement les fichiers de documentation avec l'IA
147
- - **[Relire un document](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/doc-review.md)** - Relire les fichiers de documentation pour la qualité et la cohérence
153
+ - **[Traduire un document](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/doc-translate.md)** - Traduisez automatiquement des fichiers de documentation à l'aide de l'IA
154
+ - **[Réviser un document](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/doc-review.md)** - Révisez les fichiers de documentation pour la qualité et la cohérence
155
+
156
+ ### Éditeur & Live Sync
157
+
158
+ - **[Commandes de l'éditeur](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/editor.md)** - Utilisez les commandes de l'éditeur Intlayer
159
+ - **[Commandes Live Sync](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/live.md)** - Utilisez Live Sync pour refléter les changements de contenu du CMS au moment de l'exécution
148
160
 
149
- ### Éditeur & Synchronisation en direct
161
+ ### CI/CD & Automatisation
150
162
 
151
- - **[Commandes de l’éditeur](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/editor.md)** - Utilisez les commandes de l’éditeur Intlayer
152
- - **[Commandes Live Sync](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/live.md)** - Utilisez Live Sync pour refléter les changements de contenu du CMS en temps réel
163
+ - **[Commande CI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/ci.md)** - Exécutez des commandes Intlayer avec des identifiants auto-injectés pour les pipelines CI/CD
153
164
 
154
165
  ### Outils de développement
155
166
 
156
167
  - **[SDK CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/sdk.md)** - Utilisez le SDK CLI Intlayer dans votre propre code
157
- - **[Commande Debug Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/debug.md)** - Déboguez et résolvez les problèmes du CLI Intlayer
168
+ - **[Déboguer la commande Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/cli/debug.md)** - Déboguez et dépannez les problèmes liés au CLI Intlayer
158
169
 
159
- ## Utilisez les commandes intlayer dans votre `package.json`
170
+ ## Utiliser les commandes intlayer dans votre `package.json`
160
171
 
161
172
  ```json fileName="package.json"
162
173
  "scripts": {
@@ -164,6 +175,7 @@ Pour voir comment configurer les locales disponibles, ou d'autres paramètres, r
164
175
  "intlayer:login": "npx intlayer login",
165
176
  "intlayer:build": "npx intlayer build",
166
177
  "intlayer:watch": "npx intlayer build --watch",
178
+ "intlayer:standalone": "npx intlayer standalone --packages intlayer vanilla-intlayer",
167
179
  "intlayer:push": "npx intlayer push",
168
180
  "intlayer:pull": "npx intlayer pull",
169
181
  "intlayer:fill": "npx intlayer fill",