@intlayer/docs 7.3.10 → 7.3.12

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 (90) hide show
  1. package/dist/cjs/generated/docs.entry.cjs +19 -0
  2. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  3. package/dist/esm/generated/docs.entry.mjs +19 -0
  4. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  5. package/dist/types/generated/docs.entry.d.ts +1 -0
  6. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  7. package/docs/ar/intlayer_with_nuxt.md +305 -421
  8. package/docs/ar/intlayer_with_react_router_v7.md +33 -4
  9. package/docs/ar/intlayer_with_react_router_v7_fs_routes.md +516 -0
  10. package/docs/ar/intlayer_with_tanstack.md +2 -12
  11. package/docs/ar/intlayer_with_vite+vue.md +1 -0
  12. package/docs/de/intlayer_with_nuxt.md +296 -394
  13. package/docs/de/intlayer_with_react_router_v7.md +33 -4
  14. package/docs/de/intlayer_with_react_router_v7_fs_routes.md +573 -0
  15. package/docs/de/intlayer_with_tanstack.md +1 -0
  16. package/docs/de/intlayer_with_vite+vue.md +1 -0
  17. package/docs/en/intlayer_with_nuxt.md +242 -321
  18. package/docs/en/intlayer_with_react_router_v7.md +24 -0
  19. package/docs/en/intlayer_with_react_router_v7_fs_routes.md +570 -0
  20. package/docs/en/intlayer_with_tanstack.md +2 -12
  21. package/docs/en/intlayer_with_vite+vue.md +49 -48
  22. package/docs/en-GB/intlayer_with_nuxt.md +262 -358
  23. package/docs/en-GB/intlayer_with_react_router_v7.md +33 -4
  24. package/docs/en-GB/intlayer_with_react_router_v7_fs_routes.md +513 -0
  25. package/docs/en-GB/intlayer_with_tanstack.md +2 -12
  26. package/docs/en-GB/intlayer_with_vite+vue.md +1 -0
  27. package/docs/es/intlayer_with_nuxt.md +284 -375
  28. package/docs/es/intlayer_with_react_router_v7.md +33 -4
  29. package/docs/es/intlayer_with_react_router_v7_fs_routes.md +575 -0
  30. package/docs/es/intlayer_with_tanstack.md +1 -0
  31. package/docs/es/intlayer_with_vite+vue.md +1 -2
  32. package/docs/fr/intlayer_with_nuxt.md +288 -387
  33. package/docs/fr/intlayer_with_react_router_v7.md +34 -5
  34. package/docs/fr/intlayer_with_react_router_v7_fs_routes.md +574 -0
  35. package/docs/fr/intlayer_with_tanstack.md +1 -0
  36. package/docs/fr/intlayer_with_vite+vue.md +1 -0
  37. package/docs/hi/intlayer_with_nuxt.md +318 -434
  38. package/docs/hi/intlayer_with_react_router_v7.md +33 -4
  39. package/docs/hi/intlayer_with_react_router_v7_fs_routes.md +518 -0
  40. package/docs/hi/intlayer_with_tanstack.md +2 -12
  41. package/docs/hi/intlayer_with_vite+vue.md +1 -0
  42. package/docs/id/intlayer_with_nuxt.md +275 -376
  43. package/docs/id/intlayer_with_react_router_v7.md +29 -4
  44. package/docs/id/intlayer_with_react_router_v7_fs_routes.md +521 -0
  45. package/docs/id/intlayer_with_tanstack.md +2 -12
  46. package/docs/id/intlayer_with_vite+vue.md +1 -0
  47. package/docs/it/intlayer_with_nuxt.md +312 -408
  48. package/docs/it/intlayer_with_react_router_v7.md +33 -4
  49. package/docs/it/intlayer_with_react_router_v7_fs_routes.md +574 -0
  50. package/docs/it/intlayer_with_tanstack.md +1 -0
  51. package/docs/ja/intlayer_with_nuxt.md +319 -414
  52. package/docs/ja/intlayer_with_react_router_v7.md +33 -4
  53. package/docs/ja/intlayer_with_react_router_v7_fs_routes.md +574 -0
  54. package/docs/ja/intlayer_with_tanstack.md +2 -12
  55. package/docs/ja/intlayer_with_vite+vue.md +1 -0
  56. package/docs/ko/intlayer_with_nuxt.md +307 -406
  57. package/docs/ko/intlayer_with_react_router_v7.md +33 -4
  58. package/docs/ko/intlayer_with_react_router_v7_fs_routes.md +515 -0
  59. package/docs/ko/intlayer_with_tanstack.md +2 -12
  60. package/docs/ko/intlayer_with_vite+vue.md +1 -0
  61. package/docs/pl/intlayer_with_nuxt.md +282 -457
  62. package/docs/pl/intlayer_with_react_router_v7.md +32 -5
  63. package/docs/pl/intlayer_with_react_router_v7_fs_routes.md +615 -0
  64. package/docs/pl/intlayer_with_tanstack.md +2 -12
  65. package/docs/pl/intlayer_with_vite+vue.md +1 -0
  66. package/docs/pt/intlayer_with_nuxt.md +288 -403
  67. package/docs/pt/intlayer_with_react_router_v7.md +28 -0
  68. package/docs/pt/intlayer_with_tanstack.md +1 -0
  69. package/docs/ru/intlayer_with_nuxt.md +300 -410
  70. package/docs/ru/intlayer_with_react_router_v7.md +33 -4
  71. package/docs/ru/intlayer_with_react_router_v7_fs_routes.md +574 -0
  72. package/docs/ru/intlayer_with_tanstack.md +1 -0
  73. package/docs/ru/intlayer_with_vite+vue.md +1 -0
  74. package/docs/tr/intlayer_with_nuxt.md +327 -392
  75. package/docs/tr/intlayer_with_react_router_v7.md +33 -4
  76. package/docs/tr/intlayer_with_react_router_v7_fs_routes.md +572 -0
  77. package/docs/tr/intlayer_with_tanstack.md +2 -12
  78. package/docs/tr/intlayer_with_vite+vue.md +1 -0
  79. package/docs/vi/intlayer_with_nuxt.md +282 -399
  80. package/docs/vi/intlayer_with_react_router_v7.md +29 -4
  81. package/docs/vi/intlayer_with_react_router_v7_fs_routes.md +523 -0
  82. package/docs/vi/intlayer_with_tanstack.md +2 -12
  83. package/docs/vi/intlayer_with_vite+vue.md +1 -0
  84. package/docs/zh/intlayer_with_nuxt.md +311 -444
  85. package/docs/zh/intlayer_with_react_router_v7.md +33 -4
  86. package/docs/zh/intlayer_with_react_router_v7_fs_routes.md +516 -0
  87. package/docs/zh/intlayer_with_tanstack.md +2 -12
  88. package/docs/zh/intlayer_with_vite+vue.md +1 -0
  89. package/package.json +6 -6
  90. package/src/generated/docs.entry.ts +19 -0
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  createdAt: 2025-06-18
3
- updatedAt: 2025-06-29
4
- title: How to translate your Nuxt app – i18n guide 2025
3
+ updatedAt: 2025-12-07
4
+ title: How to translate your Nuxt and Vue app – i18n guide 2025
5
5
  description: Discover how to make your Nuxt and Vue website multilingual. Follow the documentation to internationalise (i18n) and translate it.
6
6
  keywords:
7
7
  - Internationalisation
@@ -14,16 +14,22 @@ slugs:
14
14
  - doc
15
15
  - environment
16
16
  - nuxt-and-vue
17
- applicationTemplate: https://github.com/aymericzip/intlayer-nuxt-template
17
+ applicationTemplate: https://github.com/aymericzip/intlayer-nuxt-4-template
18
+ youtubeVideo: https://www.youtube.com/watch?v=IE3XWkZ6a5U
18
19
  history:
20
+ - version: 7.3.11
21
+ date: 2025-12-07
22
+ changes: Update LocaleSwitcher, SEO, metadata
19
23
  - version: 5.5.10
20
24
  date: 2025-06-29
21
25
  changes: Init history
22
26
  ---
23
27
 
24
- # Getting Started Internationalising (i18n) with Intlayer and Nuxt
28
+ # Translate your Nuxt and Vue website using Intlayer | Internationalisation (i18n)
25
29
 
26
- See [Application Template](https://github.com/aymericzip/intlayer-nuxt-template) on GitHub.
30
+ ## Table of Contents
31
+
32
+ <TOC/>
27
33
 
28
34
  ## What is Intlayer?
29
35
 
@@ -40,8 +46,37 @@ With Intlayer, you can:
40
46
 
41
47
  ## Step-by-Step Guide to Set Up Intlayer in a Nuxt Application
42
48
 
49
+ <iframe
50
+ src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-4-template?embed=1&ctl=1&file=intlayer.config.ts"
51
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
52
+ title="Demo CodeSandbox - How to Internationalise your application using Intlayer"
53
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
54
+ loading="lazy"
55
+ />
56
+
43
57
  ### Step 1: Install Dependencies
44
58
 
59
+ <Tab defaultTab="video">
60
+ <TabItem label="Video" value="video">
61
+
62
+ <iframe title="How to translate your Nuxt and Vue app using Intlayer? Discover Intlayer" class="m-auto aspect-[16/9] w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/IE3XWkZ6a5U?autoplay=0&amp;origin=http://intlayer.org&amp;controls=0&amp;rel=1"/>
63
+
64
+ </TabItem>
65
+ <TabItem label="Code" value="code">
66
+
67
+ <iframe
68
+ src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-4-template?embed=1&ctl=1&file=intlayer.config.ts"
69
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
70
+ title="Demo CodeSandbox - How to Internationalise your application using Intlayer"
71
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
72
+ loading="lazy"
73
+ />
74
+
75
+ </TabItem>
76
+ </Tab>
77
+
78
+ See [Application Template](https://github.com/aymericzip/intlayer-nuxt-4-template) on GitHub.
79
+
45
80
  Install the necessary packages using npm:
46
81
 
47
82
  ```bash packageManager="npm"
@@ -61,7 +96,7 @@ yarn add --save-dev nuxt-intlayer
61
96
 
62
97
  - **intlayer**
63
98
 
64
- The core package that provides internationalisation tools for configuration management, translation, [content declaration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/dictionary/get_started.md), transpilation, and [CLI commands](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/intlayer_cli.md).
99
+ The core package that provides internationalisation tools for configuration management, translation, [content declaration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/dictionary/content_file.md), transpilation, and [CLI commands](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/cli/index.md).
65
100
 
66
101
  - **vue-intlayer**
67
102
  The package that integrates Intlayer with Vue applications. It provides the composables for the Vue components.
@@ -86,9 +121,6 @@ const config: IntlayerConfig = {
86
121
  ],
87
122
  defaultLocale: Locales.ENGLISH,
88
123
  },
89
- content: {
90
- contentDir: ["."], // Because by default Intlayer will watch content declaration files from the `./src` directory
91
- },
92
124
  };
93
125
 
94
126
  export default config;
@@ -98,7 +130,6 @@ export default config;
98
130
  import { Locales } from "intlayer";
99
131
 
100
132
  /** @type {import('intlayer').IntlayerConfig} */
101
- // Configuration object for Intlayer
102
133
  const config = {
103
134
  internationalization: {
104
135
  locales: [
@@ -109,9 +140,6 @@ const config = {
109
140
  ],
110
141
  defaultLocale: Locales.ENGLISH,
111
142
  },
112
- content: {
113
- contentDir: ["."], // Default directory for content declarations
114
- },
115
143
  };
116
144
 
117
145
  export default config;
@@ -121,7 +149,6 @@ export default config;
121
149
  const { Locales } = require("intlayer");
122
150
 
123
151
  /** @type {import('intlayer').IntlayerConfig} */
124
- // Configuration object for Intlayer
125
152
  const config = {
126
153
  internationalization: {
127
154
  locales: [
@@ -132,15 +159,12 @@ const config = {
132
159
  ],
133
160
  defaultLocale: Locales.ENGLISH,
134
161
  },
135
- content: {
136
- contentDir: ["."],
137
- },
138
162
  };
139
163
 
140
164
  module.exports = config;
141
165
  ```
142
166
 
143
- > Through this configuration file, you can configure localised URLs, middleware redirection, cookie names, the location and extension of your content declarations, disable Intlayer logs in the console, and more. For a complete list of available parameters, refer to the [configuration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/configuration.md).
167
+ > Through this configuration file, you can set up localised URLs, middleware redirection, cookie names, the location and extension of your content declarations, disable Intlayer logs in the console, and more. For a complete list of available parameters, refer to the [configuration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/configuration.md).
144
168
 
145
169
  ### Step 3: Integrate Intlayer in Your Nuxt Configuration
146
170
 
@@ -161,220 +185,36 @@ export default defineNuxtConfig({
161
185
 
162
186
  Create and manage your content declarations to store translations:
163
187
 
164
- ```tsx fileName="components/helloWorld.content.ts" contentDeclarationFormat="typescript"
165
- import { t, type Dictionary } from "intlayer";
188
+ ```tsx fileName="content/home-page.content.ts" contentDeclarationFormat="typescript"
189
+ import { type Dictionary, t } from "intlayer";
166
190
 
167
- const helloWorldContent = {
168
- key: "helloworld",
191
+ const content = {
192
+ key: "home-page",
169
193
  content: {
170
- count: t({ en: "count is ", fr: "le compte est ", es: "el recuento es " }),
171
- edit: t({
172
- en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
173
- fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
174
- es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
175
- }),
176
- checkOut: t({
177
- "en-GB": "Check out ",
178
- en: "Check out ",
179
- fr: "Vérifiez ",
180
- es: "Compruebe ",
181
- }),
182
- nuxtIntlayer: t({
183
- "en-GB": "Nuxt Intlayer documentation",
184
- en: "Nuxt Intlayer documentation",
185
- fr: "Documentation de Nuxt Intlayer",
186
- es: "Documentación de Nuxt Intlayer",
187
- }),
188
- learnMore: t({
189
- "en-GB": "Learn more about Nuxt in the ",
190
- en: "Learn more about Nuxt in the ",
191
- fr: "En savoir plus sur Nuxt dans la ",
192
- es: "Aprenda más sobre Nuxt en la ",
194
+ title: t({
195
+ en: "Hello world",
196
+ fr: "Bonjour le monde",
197
+ es: "Hola mundo",
193
198
  }),
194
- nuxtDocs: t({
195
- "en-GB": "Nuxt Documentation",
196
- en: "Nuxt Documentation",
197
- fr: "Documentation Nuxt",
198
- es: "Documentación de Nuxt",
199
+ metaTitle: t({
200
+ en: "Welcome | My Application",
201
+ fr: "Bienvenue | Mon Application",
202
+ es: "Bienvenido | Mi Aplicación",
199
203
  }),
200
- readTheDocs: t({
201
- "en-GB": "Click on the Nuxt logo to learn more",
202
- fr: "Cliquez sur le logo Nuxt pour en savoir plus",
203
- es: "Haga clic en el logotipo de Nuxt para obtener más información",
204
+ metaDescription: t({
205
+ en: "Discover your multilingual Nuxt app homepage powered by Intlayer.",
206
+ fr: "Découvrez la page d'accueil multilingue de votre application Nuxt propulsée par Intlayer.",
207
+ es: "Descubre la página de inicio multilingüe de tu aplicación Nuxt impulsada por Intlayer.",
204
208
  }),
205
209
  },
206
210
  } satisfies Dictionary;
207
211
 
208
- export default helloWorldContent;
209
- ```
210
-
211
- ```javascript fileName="components/helloWorld.content.mjs" contentDeclarationFormat="esm"
212
- import { t } from "intlayer";
213
-
214
- /** @type {import('intlayer').Dictionary} */
215
- const helloWorldContent = {
216
- key: "helloworld",
217
- content: {
218
- count: t({
219
- "en-GB": "count is ",
220
- en: "count is ",
221
- fr: "le compte est ",
222
- es: "el recuento es ",
223
- }),
224
- edit: t({
225
- "en-GB":
226
- "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
227
- en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
228
- fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
229
- es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
230
- }),
231
- checkOut: t({ "en-GB": "Check out ", fr: "Vérifiez ", es: "Compruebe " }),
232
- nuxtIntlayer: t({
233
- "en-GB": "Nuxt Intlayer documentation",
234
- fr: "Documentation de Nuxt Intlayer",
235
- es: "Documentación de Nuxt Intlayer",
236
- }),
237
- learnMore: t({
238
- "en-GB": "Learn more about Nuxt in the ",
239
- fr: "En savoir plus sur Nuxt dans la ",
240
- es: "Aprenda más sobre Nuxt en la ",
241
- }),
242
- nuxtDocs: t({
243
- "en-GB": "Nuxt Documentation",
244
- fr: "Documentation Nuxt",
245
- es: "Documentación de Nuxt",
246
- }),
247
- readTheDocs: t({
248
- "en-GB": "Click on the Nuxt logo to learn more",
249
- fr: "Cliquez sur le logo Nuxt pour en savoir plus",
250
- es: "Haga clic en el logotipo de Nuxt para obtener más información",
251
- }),
252
- },
253
- };
254
-
255
- export default helloWorldContent;
256
- ```
257
-
258
- ```const { t } = require("intlayer");
259
-
260
- /** @type {import('intlayer').Dictionary} */
261
- const helloWorldContent = {
262
- key: "helloworld",
263
- content: {
264
- count: t({ 'en-GB': "count is ", en: "count is ", fr: "le compte est ", es: "el recuento es " }),
265
- edit: t({
266
- 'en-GB': "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
267
- en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
268
- fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
269
- es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
270
- }),
271
- checkOut: t({ 'en-GB': "Check out ", en: "Check out ", fr: "Vérifiez ", es: "Compruebe " }),
272
- nuxtIntlayer: t({
273
- 'en-GB': "Nuxt Intlayer documentation",
274
- en: "Nuxt Intlayer documentation",
275
- fr: "Documentation de Nuxt Intlayer",
276
- es: "Documentación de Nuxt Intlayer",
277
- }),
278
- es: "Documentación de Nuxt Intlayer",
279
- }),
280
- learnMore: t({
281
- 'en-GB': "Learn more about Nuxt in the ",
282
- en: "Learn more about Nuxt in the ",
283
- fr: "En savoir plus sur Nuxt dans la ",
284
- es: "Aprenda más sobre Nuxt en la ",
285
- }),
286
- nuxtDocs: t({
287
- 'en-GB': "Nuxt Documentation",
288
- en: "Nuxt Documentation",
289
- fr: "Documentation Nuxt",
290
- es: "Documentación de Nuxt",
291
- }),
292
- readTheDocs: t({
293
- 'en-GB': "Click on the Nuxt logo to learn more",
294
- en: "Click on the Nuxt logo to learn more",
295
- fr: "Cliquez sur le logo Nuxt pour en savoir plus",
296
- es: "Haga clic en el logotipo de Nuxt para obtener más información",
297
- }),
298
- },
299
- };
300
-
301
- module.exports = helloWorldContent;
302
- ```
303
-
304
- ```json fileName="components/helloWorld.content.json" contentDeclarationFormat="json"
305
- {
306
- "$schema": "https://intlayer.org/schema.json",
307
- "key": "helloworld",
308
- "content": {
309
- "count": {
310
- "nodeType": "translation",
311
- "translation": {
312
- "en-GB": "count is ",
313
- "en": "count is ",
314
- "fr": "le compte est ",
315
- "es": "el recuento es "
316
- }
317
- },
318
- "edit": {
319
- "nodeType": "translation",
320
- "translation": {
321
- "en-GB": "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
322
- "en": "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
323
- "fr": "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
324
- "es": "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR"
325
- }
326
- },
327
- "checkOut": {
328
- "nodeType": "translation",
329
- "translation": {
330
- "en-GB": "Check out ",
331
- "en": "Check out ",
332
- "fr": "Vérifiez ",
333
- "es": "Compruebe "
334
- }
335
- },
336
- "nuxtIntlayer": {
337
- "nodeType": "translation",
338
- "translation": {
339
- "en-GB": "Nuxt Intlayer documentation",
340
- "fr": "Documentation de Nuxt Intlayer",
341
- "es": "Documentación de Nuxt Intlayer"
342
- }
343
- },
344
- "learnMore": {
345
- "nodeType": "translation",
346
- "translation": {
347
- "en-GB": "Learn more about Nuxt in the ",
348
- "fr": "En savoir plus sur Nuxt dans la ",
349
- "es": "Aprenda más sobre Nuxt en la "
350
- }
351
- },
352
- "nuxtDocs": {
353
- "nodeType": "translation",
354
- "translation": {
355
- "en-GB": "Nuxt Documentation",
356
- "fr": "Documentation Nuxt",
357
- "es": "Documentación de Nuxt"
358
- }
359
- },
360
- "readTheDocs": {
361
- "nodeType": "translation",
362
- "translation": {
363
- "en-GB": "Click on the Nuxt logo to learn more",
364
- "fr": "Cliquez sur le logo Nuxt pour en savoir plus",
365
- "en-GB": "Click on the Nuxt logo to learn more",
366
- "en": "Click on the Nuxt logo to learn more",
367
- "fr": "Cliquez sur le logo Nuxt pour en savoir plus",
368
- "es": "Haga clic en el logotipo de Nuxt para obtener más información"
369
- }
370
- }
371
- }
372
- }
212
+ export default content;
373
213
  ```
374
214
 
375
215
  > Your content declarations can be defined anywhere in your application as long as they are included in the `contentDir` directory (by default, `./src`). And match the content declaration file extension (by default, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
376
216
 
377
- > For more details, refer to the [content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/dictionary/get_started.md).
217
+ > For more details, refer to the [content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md).
378
218
 
379
219
  ### Step 5: Utilise Intlayer in Your Code
380
220
 
@@ -441,7 +281,7 @@ Intlayer offers different APIs to access your content:
441
281
  Use `<div v-html="myContent" />` to render the content as raw HTML, without Visual Editor support.
442
282
 
443
283
  - **Destructuration syntax**:
444
- The `useIntlayer` composable returns a Proxy with the content. This proxy can be destructured to access the content while maintaining reactivity.
284
+ The `useIntlayer` composable returns a Proxy with the content. This proxy can be destructured to access the content while keeping the reactivity.
445
285
  - Use `const content = useIntlayer("myContent");` and `{{ content.myContent }}` / `<content.myContent />`.
446
286
  - Or use `const { myContent } = useIntlayer("myContent");` and `{{ myContent }}` / `<myContent />` to destructure the content.
447
287
 
@@ -449,64 +289,54 @@ Intlayer offers different APIs to access your content:
449
289
 
450
290
  To change the language of your content, you can use the `setLocale` function provided by the `useLocale` composable. This function allows you to set the locale of the application and update the content accordingly.
451
291
 
452
- Create a component to switch between languages:
292
+ Create a component to switch between languages using `NuxtLink`. **Using links instead of buttons for locale switching is a best practice for SEO and page discoverability**, as it allows search engines to crawl and index all localised versions of your pages:
453
293
 
454
294
  ```vue fileName="components/LocaleSwitcher.vue"
455
- <template>
456
- <div class="locale-switcher">
457
- <select v-model="selectedLocale" @change="changeLocale">
458
- <option v-for="loc in availableLocales" :key="loc" :value="loc">
459
- {{ getLocaleName(loc) }}
460
- </option>
461
- </select>
462
- </div>
463
- </template>
464
-
465
295
  <script setup lang="ts">
466
- import { ref, watch } from "vue";
467
- import { getLocaleName } from "intlayer";
296
+ import { getLocaleName, getLocalizedUrl } from "intlayer";
468
297
  import { useLocale } from "vue-intlayer";
469
298
 
470
- // Get locale information and setLocale function
299
+ // Nuxt auto-imports useRoute
300
+ const route = useRoute();
471
301
  const { locale, availableLocales, setLocale } = useLocale();
472
-
473
- // Track the selected locale with a ref
474
- const selectedLocale = ref(locale.value);
475
-
476
- // Update the locale when the selection changes
477
- const changeLocale = () => setLocale(selectedLocale.value);
478
-
479
- // Keep the selectedLocale in sync with the global locale
480
- watch(
481
- () => locale.value,
482
- (newLocale) => {
483
- selectedLocale.value = newLocale;
484
- }
485
- );
486
302
  </script>
303
+
304
+ <template>
305
+ <nav class="locale-switcher">
306
+ <NuxtLink
307
+ v-for="localeEl in availableLocales"
308
+ :key="localeEl"
309
+ :to="getLocalizedUrl(route.fullPath, localeEl)"
310
+ class="locale-link"
311
+ :class="{ 'active-locale': localeEl === locale }"
312
+ @click="setLocale(localeEl)"
313
+ >
314
+ {{ getLocaleName(localeEl) }}
315
+ </NuxtLink>
316
+ </nav>
487
317
  </template>
318
+ ```
488
319
 
489
- <style scoped>
490
- .locale-switcher {
491
- margin: 1rem 0;
492
- }
320
+ > Using `NuxtLink` with proper `href` attributes (via `getLocalizedUrl`) ensures that search engines can discover all language variants of your pages. This is preferable to JavaScript-only locale switching, which search engine crawlers may not follow.
493
321
 
494
- select {
495
- padding: 0.5rem;
496
- border-radius: 0.25rem;
497
- border: 1px solid #ccc;
498
- }
499
- </style>
322
+ Then, set up your `app.vue` to use layouts:
323
+
324
+ ```vue fileName="app.vue"
325
+ <template>
326
+ <NuxtLayout>
327
+ <NuxtPage />
328
+ </NuxtLayout>
329
+ </template>
500
330
  ```
501
331
 
502
- Then, use this component in your pages or layout:
332
+ ### (Optional) Step 6b: Create a Layout with Navigation
503
333
 
504
- ```vue fileName="app.vue"
334
+ Nuxt layouts allow you to define a common structure for your pages. Create a default layout that includes the locale switcher and navigation:
335
+
336
+ ```vue fileName="layouts/default.vue"
505
337
  <script setup lang="ts">
506
- import { useIntlayer } from "vue-intlayer";
338
+ import Links from "~/components/Links.vue";
507
339
  import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
508
-
509
- const content = useIntlayer("app"); // Create related intlayer declaration file
510
340
  </script>
511
341
 
512
342
  <template>
@@ -515,12 +345,17 @@ const content = useIntlayer("app"); // Create related intlayer declaration file
515
345
  <LocaleSwitcher />
516
346
  </header>
517
347
  <main>
518
- <NuxtPage />
348
+ <slot />
519
349
  </main>
350
+
351
+ <Links href="/">Home</Links>
352
+ <Links href="/about">About</Links>
520
353
  </div>
521
354
  </template>
522
355
  ```
523
356
 
357
+ The `Links` component (shown below) ensures that internal navigation links are automatically localised.
358
+
524
359
  ### (Optional) Step 7: Add localised Routing to your application
525
360
 
526
361
  Nuxt automatically handles localised routing when using the `nuxt-intlayer` module. This creates routes for each language automatically based on your pages directory structure.
@@ -535,23 +370,58 @@ pages/
535
370
  └── index.vue → /contact, /fr/contact, /es/contact
536
371
  ```
537
372
 
538
- To create a localised page, simply create your Vue files in the `pages/` directory:
373
+ To create localised pages, simply create your Vue files in the `pages/` directory. Here are two example pages:
374
+
375
+ **Home page (`pages/index.vue`):**
376
+
377
+ ```vue fileName="pages/index.vue"
378
+ <script setup lang="ts">
379
+ import { useIntlayer } from "vue-intlayer";
380
+
381
+ const content = useIntlayer("home-page");
382
+
383
+ useHead({
384
+ title: content.metaTitle.value,
385
+ meta: [
386
+ {
387
+ name: "description",
388
+ content: content.metaDescription.value,
389
+ },
390
+ ],
391
+ });
392
+ </script>
393
+
394
+ <template>
395
+ <h1><content.title /></h1>
396
+ </template>
397
+ ```
398
+
399
+ **About page (`pages/about.vue`):**
539
400
 
540
401
  ```vue fileName="pages/about.vue"
541
402
  <script setup lang="ts">
542
403
  import { useIntlayer } from "vue-intlayer";
543
404
 
544
- const content = useIntlayer("about");
405
+ const content = useIntlayer("about-page");
406
+
407
+ useHead({
408
+ title: content.metaTitle.raw, // Use .raw for primitive string access
409
+ meta: [
410
+ {
411
+ name: "description",
412
+ content: content.metaDescription.raw, // Use .raw for primitive string access
413
+ },
414
+ ],
415
+ });
545
416
  </script>
546
417
 
547
418
  <template>
548
- <div>
549
- <h1>{{ content.title }}</h1>
550
- <p>{{ content.description }}</p>
551
- </div>
419
+ <h1><content.title /></h1>
552
420
  </template>
553
421
  ```
554
422
 
423
+ > Note: `useHead` is auto-imported in Nuxt. You can access content values using either `.value` (reactive) or `.raw` (primitive string) depending on your needs.
424
+
555
425
  The `nuxt-intlayer` module will automatically:
556
426
 
557
427
  - Detect the user's preferred locale
@@ -562,192 +432,228 @@ The `nuxt-intlayer` module will automatically:
562
432
 
563
433
  ### (Optional) Step 8: Creating a Localised Link Component
564
434
 
565
- To ensure that your application's navigation respects the current locale, you can create a custom `LocalisedLink` component. This component automatically prefixes internal URLs with the current language.
566
-
567
- ```vue fileName="components/LocalisedLink.vue"
568
- <template>
569
- <NuxtLink :to="localisedHref" v-bind="$attrs">
570
- <slot />
571
- </NuxtLink>
572
- </template>
435
+ To ensure that your application's navigation respects the current locale, you can create a custom `Links` component. This component automatically prefixes internal URLs with the current language, which is essential for **SEO and page discoverability**.
573
436
 
437
+ ```vue fileName="components/Links.vue"
574
438
  <script setup lang="ts">
575
- import { computed } from "vue";
576
439
  import { getLocalizedUrl } from "intlayer";
577
440
  import { useLocale } from "vue-intlayer";
578
441
 
579
- const props = defineProps({
580
- to: {
581
- type: String,
582
- required: true,
583
- },
584
- });
442
+ interface Props {
443
+ href: string;
444
+ locale?: string;
445
+ }
585
446
 
586
- const { locale } = useLocale();
447
+ const props = defineProps<Props>();
587
448
 
588
- // Check if the link is external
589
- const isExternalLink = computed(() => /^https?:\/\//.test(props.to || ""));
449
+ const { locale: currentLocale } = useLocale();
590
450
 
591
- // Create a localised href for internal links
592
- const localizedHref = computed(() =>
593
- isExternalLink.value ? props.to : getLocalizedUrl(props.to, locale.value)
594
- );
451
+ // Compute the final path
452
+ const finalPath = computed(() => {
453
+ // 1. Check if the link is external
454
+ const isExternal = /^https?:\/\//.test(props.href || "");
455
+
456
+ // 2. If external, return as is (NuxtLink handles the <a> tag generation)
457
+ if (isExternal) return props.href;
458
+
459
+ // 3. If internal, localise the URL
460
+ const targetLocale = props.locale || currentLocale.value;
461
+ return getLocalizedUrl(props.href, targetLocale);
462
+ });
595
463
  </script>
464
+
465
+ <template>
466
+ <NuxtLink :to="finalPath" v-bind="$attrs">
467
+ <slot />
468
+ </NuxtLink>
469
+ </template>
596
470
  ```
597
471
 
598
472
  Then use this component throughout your application:
599
473
 
600
- ```vue fileName="pages/index.vue"
474
+ ```vue fileName="layouts/default.vue"
475
+ <script setup lang="ts">
476
+ import Links from "~/components/Links.vue";
477
+ import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
478
+ </script>
479
+
601
480
  <template>
602
481
  <div>
603
- <LocalizedLink to="/about">
604
- {{ content.aboutLink }}
605
- </LocalizedLink>
606
- <LocalizedLink to="/contact">
607
- {{ content.contactLink }}
608
- </LocalizedLink>
482
+ <header>
483
+ <LocaleSwitcher />
484
+ </header>
485
+ <main>
486
+ <slot />
487
+ </main>
488
+
489
+ <Links href="/">Home</Links>
490
+ <Links href="/about">About</Links>
609
491
  </div>
610
492
  </template>
611
-
612
- <script setup lang="ts">
613
- import { useIntlayer } from "vue-intlayer";
614
- import LocalizedLink from "~/components/LocalizedLink.vue";
615
-
616
- const content = useIntlayer("home");
617
- </script>
618
493
  ```
619
494
 
495
+ > By using `NuxtLink` with localised paths, you ensure that:
496
+ >
497
+ > - Search engines can crawl and index all language versions of your pages
498
+ > - Users can share localised URLs directly
499
+ > - Browser history works correctly with locale-prefixed URLs
500
+
620
501
  ### (Optional) Step 9: Handle Metadata and SEO
621
502
 
622
- Nuxt provides excellent SEO capabilities. You can use Intlayer to manage localised metadata:
503
+ Nuxt provides excellent SEO capabilities via the `useHead` composable (auto-imported). You can use Intlayer to handle localised metadata using the `.raw` or `.value` accessor to get the primitive string value:
623
504
 
624
505
  ```vue fileName="pages/about.vue"
625
506
  <script setup lang="ts">
626
- import { useSeoMeta } from "nuxt/app";
627
- import { getIntlayer } from "intlayer";
628
- import { useLocale } from "vue-intlayer";
507
+ import { useIntlayer } from "vue-intlayer";
629
508
 
630
- const { locale } = useLocale();
631
- const content = getIntlayer("about-meta", locale.value);
509
+ // useHead is auto-imported in Nuxt
510
+ const content = useIntlayer("about-page");
632
511
 
633
- useSeoMeta({
634
- title: content.title,
635
- description: content.description,
512
+ useHead({
513
+ title: content.metaTitle.raw, // Use .raw for primitive string access
514
+ meta: [
515
+ {
516
+ name: "description",
517
+ content: content.metaDescription.raw, // Use .raw for primitive string access
518
+ },
519
+ ],
636
520
  });
637
521
  </script>
638
522
 
639
523
  <template>
640
- <div>
641
- <h1>{{ content.pageTitle }}</h1>
642
- <p>{{ content.pageContent }}</p>
643
- </div>
524
+ <h1><content.title /></h1>
644
525
  </template>
645
526
  ```
646
527
 
528
+ > Alternatively, you can use the `import { getIntlayer } from "intlayer"` function to get the content without Vue reactivity.
529
+
530
+ > **Accessing content values:**
531
+ >
532
+ > - Use `.raw` to get the primitive string value (non-reactive)
533
+ > - Use `.value` to get the reactive value
534
+ > - Use `<content.key />` component syntax for Visual Editor support
535
+
647
536
  Create the corresponding content declaration:
648
537
 
649
- ```ts fileName="pages/about-meta.content.ts"
538
+ ```ts fileName="pages/about-page.content.ts" contentDeclarationFormat="typescript"
650
539
  import { t, type Dictionary } from "intlayer";
651
- import type { useSeoMeta } from "nuxt/app";
652
540
 
653
- const aboutMetaContent = {
654
- key: "about-meta",
541
+ const aboutPageContent = {
542
+ key: "about-page",
655
543
  content: {
656
- title: t({
657
- "en-GB": "About Us - My Company",
544
+ metaTitle: t({
658
545
  en: "About Us - My Company",
659
546
  fr: "À Propos - Ma Société",
660
547
  es: "Acerca de Nosotros - Mi Empresa",
661
548
  }),
662
- description: t({
663
- "en-GB": "Learn more about our company and our mission",
549
+ metaDescription: t({
664
550
  en: "Learn more about our company and our mission",
665
551
  fr: "En savoir plus sur notre société et notre mission",
666
552
  es: "Conozca más sobre nuestra empresa y nuestra misión",
667
553
  }),
554
+ title: t({
555
+ en: "About Us",
556
+ fr: "À Propos",
557
+ es: "Acerca de Nosotros",
558
+ }),
668
559
  },
669
- } satisfies Dictionary<Parameters<typeof useSeoMeta>[0]>;
560
+ } satisfies Dictionary;
670
561
 
671
- export default aboutMetaContent;
562
+ export default aboutPageContent;
672
563
  ```
673
564
 
674
- ```typescript fileName="pages/about-meta.content.mjs" contentDeclarationFormat="esm"
565
+ ```javascript fileName="pages/about-page.content.mjs" contentDeclarationFormat="esm"
675
566
  import { t } from "intlayer";
676
567
 
677
568
  /** @type {import('intlayer').Dictionary} */
678
- const aboutMetaContent = {
679
- key: "about-meta",
569
+ const aboutPageContent = {
570
+ key: "about-page",
680
571
  content: {
681
- title: t({
682
- zh: "关于我们 - 我的公司",
683
- "en-GB": "About Us - My Company",
572
+ metaTitle: t({
684
573
  en: "About Us - My Company",
685
574
  fr: "À Propos - Ma Société",
686
575
  es: "Acerca de Nosotros - Mi Empresa",
687
576
  }),
688
- description: t({
689
- zh: "了解更多关于我们公司和我们的使命",
577
+ metaDescription: t({
690
578
  "en-GB": "Learn more about our company and our mission",
691
579
  en: "Learn more about our company and our mission",
692
580
  fr: "En savoir plus sur notre société et notre mission",
693
581
  es: "Conozca más sobre nuestra empresa y nuestra misión",
694
582
  }),
583
+ title: t({
584
+ "en-GB": "About Us",
585
+ en: "About Us",
586
+ fr: "À Propos",
587
+ es: "Acerca de Nosotros",
588
+ }),
695
589
  },
696
590
  };
697
591
 
698
- export default aboutMetaContent;
592
+ export default aboutPageContent;
699
593
  ```
700
594
 
701
- ```typescript fileName="pages/about-meta.content.js" contentDeclarationFormat="cjs"
595
+ ```javascript fileName="pages/about-page.content.cjs" contentDeclarationFormat="commonjs"
702
596
  const { t } = require("intlayer");
703
597
 
704
598
  /** @type {import('intlayer').Dictionary} */
705
- const aboutMetaContent = {
706
- key: "about-meta",
599
+ const aboutPageContent = {
600
+ key: "about-page",
707
601
  content: {
708
- title: t({
709
- zh: "关于我们 - 我的公司",
602
+ metaTitle: t({
710
603
  "en-GB": "About Us - My Company",
711
604
  en: "About Us - My Company",
712
605
  fr: "À Propos - Ma Société",
713
606
  es: "Acerca de Nosotros - Mi Empresa",
714
607
  }),
715
- description: t({
716
- zh: "了解更多关于我们公司和我们的使命",
608
+ metaDescription: t({
717
609
  "en-GB": "Learn more about our company and our mission",
718
610
  en: "Learn more about our company and our mission",
719
611
  fr: "En savoir plus sur notre société et notre mission",
720
612
  es: "Conozca más sobre nuestra empresa y nuestra misión",
721
613
  }),
614
+ title: t({
615
+ "en-GB": "About Us",
616
+ en: "About Us",
617
+ fr: "À Propos",
618
+ es: "Acerca de Nosotros",
619
+ }),
722
620
  },
723
621
  };
724
622
 
725
- module.exports = aboutMetaContent;
623
+ module.exports = aboutPageContent;
726
624
  ```
727
625
 
728
- ```json fileName="pages/about-meta.content.json" contentDeclarationFormat="json"
626
+ ```json fileName="pages/about-page.content.json" contentDeclarationFormat="json"
729
627
  {
730
- "key": "about-meta",
628
+ "$schema": "https://intlayer.org/schema.json",
629
+ "key": "about-page",
731
630
  "content": {
732
- "title": {
631
+ "metaTitle": {
733
632
  "nodeType": "translation",
734
- "translations": {
735
- "zh": "关于我们 - 我的公司",
633
+ "translation": {
736
634
  "en-GB": "About Us - My Company",
737
635
  "en": "About Us - My Company",
738
636
  "fr": "À Propos - Ma Société",
739
637
  "es": "Acerca de Nosotros - Mi Empresa"
740
638
  }
741
639
  },
742
- "description": {
640
+ "metaDescription": {
743
641
  "nodeType": "translation",
744
- "translations": {
745
- "zh": "了解更多关于我们公司和我们的使命",
642
+ "translation": {
746
643
  "en-GB": "Learn more about our company and our mission",
747
644
  "en": "Learn more about our company and our mission",
748
645
  "fr": "En savoir plus sur notre société et notre mission",
749
646
  "es": "Conozca más sobre nuestra empresa y nuestra misión"
750
647
  }
648
+ },
649
+ "title": {
650
+ "nodeType": "translation",
651
+ "translation": {
652
+ "en-GB": "About Us",
653
+ "en": "About Us",
654
+ "fr": "À Propos",
655
+ "es": "Acerca de Nosotros"
656
+ }
751
657
  }
752
658
  }
753
659
  }
@@ -786,7 +692,7 @@ To do this, you can add the following instructions to your `.gitignore` file:
786
692
 
787
693
  ### VS Code Extension
788
694
 
789
- To enhance your development experience with Intlayer, you can install the official **Intlayer VS Code Extension**.
695
+ To improve your development experience with Intlayer, you can install the official **Intlayer VS Code Extension**.
790
696
 
791
697
  [Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
792
698
 
@@ -804,5 +710,3 @@ For more details on how to use the extension, refer to the [Intlayer VS Code Ext
804
710
  ### Go Further
805
711
 
806
712
  To go further, you can implement the [visual editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/intlayer_visual_editor.md) or externalise your content using the [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/intlayer_CMS.md).
807
-
808
- ---