@intlayer/docs 5.5.8 → 5.5.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 (172) hide show
  1. package/ar/autoFill.md +1 -2
  2. package/ar/intlayer_with_create_react_app.md +1 -14
  3. package/ar/intlayer_with_nextjs_14.md +1 -14
  4. package/ar/intlayer_with_nextjs_15.md +1 -14
  5. package/ar/intlayer_with_nextjs_page_router.md +1 -13
  6. package/ar/intlayer_with_nuxt.md +792 -0
  7. package/ar/intlayer_with_react_native+expo.md +6 -3
  8. package/ar/intlayer_with_vite+preact.md +7 -18
  9. package/ar/intlayer_with_vite+react.md +7 -17
  10. package/ar/intlayer_with_vite+vue.md +25 -5
  11. package/ar/packages/nuxt-intlayer/index.md +29 -0
  12. package/ar/roadmap.md +11 -11
  13. package/de/autoFill.md +1 -2
  14. package/de/how_works_intlayer.md +1 -1
  15. package/de/intlayer_with_create_react_app.md +1 -14
  16. package/de/intlayer_with_nextjs_14.md +1 -14
  17. package/de/intlayer_with_nextjs_15.md +1 -14
  18. package/de/intlayer_with_nextjs_page_router.md +1 -13
  19. package/de/intlayer_with_nuxt.md +791 -0
  20. package/de/intlayer_with_react_native+expo.md +6 -3
  21. package/de/intlayer_with_vite+preact.md +7 -18
  22. package/de/intlayer_with_vite+react.md +7 -17
  23. package/de/intlayer_with_vite+vue.md +84 -62
  24. package/de/packages/nuxt-intlayer/index.md +29 -0
  25. package/de/roadmap.md +11 -11
  26. package/en/autoFill.md +1 -2
  27. package/en/how_works_intlayer.md +17 -3
  28. package/en/intlayer_with_angular.md +535 -6
  29. package/en/intlayer_with_create_react_app.md +1 -14
  30. package/en/intlayer_with_nextjs_14.md +193 -59
  31. package/en/intlayer_with_nextjs_15.md +192 -61
  32. package/en/intlayer_with_nextjs_page_router.md +396 -61
  33. package/en/intlayer_with_nuxt.md +737 -0
  34. package/en/intlayer_with_react_native+expo.md +6 -3
  35. package/en/intlayer_with_vite+preact.md +8 -27
  36. package/en/intlayer_with_vite+react.md +7 -17
  37. package/en/intlayer_with_vite+solid.md +6 -3
  38. package/en/intlayer_with_vite+svelte.md +6 -3
  39. package/en/intlayer_with_vite+vue.md +17 -6
  40. package/en/packages/nuxt-intlayer/index.md +31 -0
  41. package/en/roadmap.md +13 -13
  42. package/en/t.md +5 -5
  43. package/en-GB/how_works_intlayer.md +16 -4
  44. package/en-GB/intlayer_with_create_react_app.md +1 -14
  45. package/en-GB/intlayer_with_nextjs_14.md +1 -14
  46. package/en-GB/intlayer_with_nextjs_15.md +1 -14
  47. package/en-GB/intlayer_with_nextjs_page_router.md +1 -13
  48. package/en-GB/intlayer_with_nuxt.md +795 -0
  49. package/en-GB/intlayer_with_react_native+expo.md +6 -3
  50. package/en-GB/intlayer_with_vite+preact.md +7 -18
  51. package/en-GB/intlayer_with_vite+react.md +6 -9
  52. package/en-GB/intlayer_with_vite+vue.md +65 -59
  53. package/en-GB/packages/nuxt-intlayer/index.md +31 -0
  54. package/en-GB/roadmap.md +11 -11
  55. package/es/autoFill.md +1 -2
  56. package/es/how_works_intlayer.md +1 -1
  57. package/es/intlayer_with_create_react_app.md +1 -14
  58. package/es/intlayer_with_nextjs_14.md +1 -14
  59. package/es/intlayer_with_nextjs_15.md +1 -14
  60. package/es/intlayer_with_nextjs_page_router.md +1 -13
  61. package/es/intlayer_with_nuxt.md +731 -0
  62. package/es/intlayer_with_react_native+expo.md +6 -3
  63. package/es/intlayer_with_vite+preact.md +7 -18
  64. package/es/intlayer_with_vite+react.md +7 -17
  65. package/es/intlayer_with_vite+vue.md +64 -51
  66. package/es/packages/nuxt-intlayer/index.md +29 -0
  67. package/fr/autoFill.md +1 -2
  68. package/fr/how_works_intlayer.md +1 -1
  69. package/fr/intlayer_with_create_react_app.md +1 -14
  70. package/fr/intlayer_with_nextjs_14.md +1 -14
  71. package/fr/intlayer_with_nextjs_15.md +1 -14
  72. package/fr/intlayer_with_nextjs_page_router.md +1 -13
  73. package/fr/intlayer_with_nuxt.md +731 -0
  74. package/fr/intlayer_with_react_native+expo.md +6 -3
  75. package/fr/intlayer_with_vite+preact.md +7 -18
  76. package/fr/intlayer_with_vite+react.md +7 -17
  77. package/fr/intlayer_with_vite+vue.md +30 -15
  78. package/fr/packages/nuxt-intlayer/index.md +29 -0
  79. package/fr/roadmap.md +11 -11
  80. package/hi/autoFill.md +1 -2
  81. package/hi/how_works_intlayer.md +1 -1
  82. package/hi/intlayer_with_create_react_app.md +1 -14
  83. package/hi/intlayer_with_nextjs_14.md +1 -14
  84. package/hi/intlayer_with_nextjs_15.md +1 -14
  85. package/hi/intlayer_with_nextjs_page_router.md +1 -13
  86. package/hi/intlayer_with_nuxt.md +784 -0
  87. package/hi/intlayer_with_react_native+expo.md +6 -3
  88. package/hi/intlayer_with_vite+preact.md +7 -18
  89. package/hi/intlayer_with_vite+react.md +7 -17
  90. package/hi/intlayer_with_vite+vue.md +59 -47
  91. package/hi/packages/nuxt-intlayer/index.md +29 -0
  92. package/hi/roadmap.md +11 -11
  93. package/index.cjs +30 -0
  94. package/index.d.ts +2 -0
  95. package/it/autoFill.md +1 -2
  96. package/it/how_works_intlayer.md +1 -1
  97. package/it/intlayer_with_create_react_app.md +0 -6
  98. package/it/intlayer_with_nextjs_14.md +1 -14
  99. package/it/intlayer_with_nextjs_15.md +1 -14
  100. package/it/intlayer_with_nextjs_page_router.md +1 -13
  101. package/it/intlayer_with_nuxt.md +793 -0
  102. package/it/intlayer_with_react_native+expo.md +6 -3
  103. package/it/intlayer_with_vite+preact.md +7 -18
  104. package/it/intlayer_with_vite+react.md +7 -17
  105. package/it/intlayer_with_vite+vue.md +26 -17
  106. package/it/packages/nuxt-intlayer/index.md +29 -0
  107. package/it/roadmap.md +11 -11
  108. package/ja/autoFill.md +1 -2
  109. package/ja/how_works_intlayer.md +1 -1
  110. package/ja/intlayer_with_create_react_app.md +1 -14
  111. package/ja/intlayer_with_nextjs_14.md +1 -14
  112. package/ja/intlayer_with_nextjs_15.md +1 -14
  113. package/ja/intlayer_with_nextjs_page_router.md +1 -13
  114. package/ja/intlayer_with_nuxt.md +792 -0
  115. package/ja/intlayer_with_react_native+expo.md +6 -3
  116. package/ja/intlayer_with_vite+preact.md +7 -18
  117. package/ja/intlayer_with_vite+react.md +7 -17
  118. package/ja/intlayer_with_vite+vue.md +68 -63
  119. package/ja/packages/nuxt-intlayer/index.md +29 -0
  120. package/ja/roadmap.md +11 -11
  121. package/ko/autoFill.md +1 -2
  122. package/ko/how_works_intlayer.md +1 -1
  123. package/ko/intlayer_with_create_react_app.md +1 -14
  124. package/ko/intlayer_with_nextjs_14.md +1 -14
  125. package/ko/intlayer_with_nextjs_15.md +1 -14
  126. package/ko/intlayer_with_nextjs_page_router.md +1 -13
  127. package/ko/intlayer_with_nuxt.md +784 -0
  128. package/ko/intlayer_with_react_native+expo.md +6 -3
  129. package/ko/intlayer_with_vite+preact.md +7 -18
  130. package/ko/intlayer_with_vite+react.md +7 -17
  131. package/ko/intlayer_with_vite+vue.md +69 -59
  132. package/ko/packages/nuxt-intlayer/index.md +31 -0
  133. package/ko/roadmap.md +11 -11
  134. package/package.json +4 -4
  135. package/pt/autoFill.md +1 -2
  136. package/pt/how_works_intlayer.md +1 -1
  137. package/pt/intlayer_with_create_react_app.md +1 -14
  138. package/pt/intlayer_with_nextjs_14.md +1 -14
  139. package/pt/intlayer_with_nextjs_15.md +1 -14
  140. package/pt/intlayer_with_nextjs_page_router.md +1 -13
  141. package/pt/intlayer_with_nuxt.md +792 -0
  142. package/pt/intlayer_with_react_native+expo.md +6 -3
  143. package/pt/intlayer_with_vite+preact.md +7 -18
  144. package/pt/intlayer_with_vite+react.md +7 -17
  145. package/pt/intlayer_with_vite+vue.md +23 -19
  146. package/pt/packages/nuxt-intlayer/index.md +29 -0
  147. package/pt/roadmap.md +11 -11
  148. package/ru/autoFill.md +1 -2
  149. package/ru/how_works_intlayer.md +1 -1
  150. package/ru/intlayer_with_create_react_app.md +1 -14
  151. package/ru/intlayer_with_nextjs_14.md +1 -14
  152. package/ru/intlayer_with_nextjs_15.md +1 -14
  153. package/ru/intlayer_with_nextjs_page_router.md +1 -13
  154. package/ru/intlayer_with_nuxt.md +792 -0
  155. package/ru/intlayer_with_react_native+expo.md +6 -3
  156. package/ru/intlayer_with_vite+preact.md +7 -18
  157. package/ru/intlayer_with_vite+react.md +7 -17
  158. package/ru/intlayer_with_vite+vue.md +25 -17
  159. package/ru/packages/nuxt-intlayer/index.md +31 -0
  160. package/ru/roadmap.md +11 -11
  161. package/zh/autoFill.md +1 -2
  162. package/zh/intlayer_with_create_react_app.md +1 -14
  163. package/zh/intlayer_with_nextjs_14.md +1 -14
  164. package/zh/intlayer_with_nextjs_15.md +1 -14
  165. package/zh/intlayer_with_nextjs_page_router.md +1 -13
  166. package/zh/intlayer_with_nuxt.md +784 -0
  167. package/zh/intlayer_with_react_native+expo.md +6 -3
  168. package/zh/intlayer_with_vite+preact.md +7 -18
  169. package/zh/intlayer_with_vite+react.md +7 -17
  170. package/zh/intlayer_with_vite+vue.md +68 -57
  171. package/zh/packages/nuxt-intlayer/index.md +31 -0
  172. package/zh/roadmap.md +11 -11
@@ -0,0 +1,731 @@
1
+ # Commencer avec l'internationalisation (i18n) avec Intlayer et Nuxt
2
+
3
+ Voir [Modèle d'application](https://github.com/aymericzip/intlayer-nuxt-template) sur GitHub.
4
+
5
+ ## Qu'est-ce qu'Intlayer ?
6
+
7
+ **Intlayer** est une bibliothèque open-source innovante d'internationalisation (i18n) conçue pour simplifier le support multilingue dans les applications web modernes.
8
+
9
+ Avec Intlayer, vous pouvez :
10
+
11
+ - **Gérer facilement les traductions** en utilisant des dictionnaires déclaratifs au niveau des composants.
12
+ - **Localiser dynamiquement les métadonnées**, les routes et le contenu.
13
+ - **Assurer la prise en charge de TypeScript** avec des types autogénérés, améliorant l'autocomplétion et la détection des erreurs.
14
+ - **Bénéficier de fonctionnalités avancées**, comme la détection et le changement dynamiques de langue.
15
+
16
+ ---
17
+
18
+ ## Guide étape par étape pour configurer Intlayer dans une application Nuxt
19
+
20
+ ### Étape 1 : Installer les dépendances
21
+
22
+ Installez les packages nécessaires en utilisant npm :
23
+
24
+ ```bash packageManager="npm"
25
+ npm install intlayer vue-intlayer
26
+ npm install --save-dev nuxt-intlayer
27
+ ```
28
+
29
+ ```bash packageManager="pnpm"
30
+ pnpm add intlayer vue-intlayer
31
+ pnpm add --save-dev nuxt-intlayer
32
+ ```
33
+
34
+ ```bash packageManager="yarn"
35
+ yarn add intlayer vue-intlayer
36
+ yarn add --save-dev nuxt-intlayer
37
+ ```
38
+
39
+ - **intlayer**
40
+
41
+ Le package principal qui fournit des outils d'internationalisation pour la gestion des configurations, les traductions, [la déclaration de contenu](https://github.com/aymericzip/intlayer/blob/main/docs/fr/dictionary/get_started.md), la transpilation et les [commandes CLI](https://github.com/aymericzip/intlayer/blob/main/docs/fr/intlayer_cli.md).
42
+
43
+ - **vue-intlayer**
44
+ Le package qui intègre Intlayer avec une application Vue. Il fournit les composables pour les composants Vue.
45
+
46
+ - **nuxt-intlayer**
47
+ Le module Nuxt qui intègre Intlayer avec les applications Nuxt. Il offre une configuration automatique, un middleware pour la détection de langue, la gestion des cookies et la redirection des URL.
48
+
49
+ ### Étape 2 : Configuration de votre projet
50
+
51
+ Créez un fichier de configuration pour configurer les langues de votre application :
52
+
53
+ ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
54
+ import { Locales, type IntlayerConfig } from "intlayer";
55
+
56
+ const config: IntlayerConfig = {
57
+ internationalisation: {
58
+ locales: [
59
+ Locales.ENGLISH,
60
+ Locales.FRENCH,
61
+ Locales.SPANISH,
62
+ // Vos autres langues
63
+ ],
64
+ defaultLocale: Locales.ENGLISH,
65
+ },
66
+ };
67
+
68
+ export default config;
69
+ ```
70
+
71
+ ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
72
+ import { Locales } from "intlayer";
73
+
74
+ /** @type {import('intlayer').IntlayerConfig} */
75
+ const config = {
76
+ internationalisation: {
77
+ locales: [
78
+ Locales.ENGLISH,
79
+ Locales.FRENCH,
80
+ Locales.SPANISH,
81
+ // Vos autres langues
82
+ ],
83
+ defaultLocale: Locales.ENGLISH,
84
+ },
85
+ };
86
+
87
+ export default config;
88
+ ```
89
+
90
+ ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
91
+ const { Locales } = require("intlayer");
92
+
93
+ /** @type {import('intlayer').IntlayerConfig} */
94
+ const config = {
95
+ internationalisation: {
96
+ locales: [
97
+ Locales.ENGLISH,
98
+ Locales.FRENCH,
99
+ Locales.SPANISH,
100
+ // Vos autres langues
101
+ ],
102
+ defaultLocale: Locales.ENGLISH,
103
+ },
104
+ };
105
+
106
+ module.exports = config;
107
+ ```
108
+
109
+ > Grâce à ce fichier de configuration, vous pouvez configurer les URL localisées, la redirection via middleware, les noms de cookies, l'emplacement et l'extension de vos déclarations de contenu, désactiver les logs Intlayer dans la console, et plus encore. Pour une liste complète des paramètres disponibles, consultez la [documentation de configuration](https://github.com/aymericzip/intlayer/blob/main/docs/fr/configuration.md).
110
+
111
+ ### Étape 3 : Intégrer Intlayer dans votre configuration Nuxt
112
+
113
+ Ajoutez le module intlayer à votre configuration Nuxt :
114
+
115
+ ```typescript fileName="nuxt.config.ts"
116
+ import { defineNuxtConfig } from "nuxt/config";
117
+
118
+ export default defineNuxtConfig({
119
+ // ... Votre configuration Nuxt existante
120
+ modules: ["nuxt-intlayer"],
121
+ });
122
+ ```
123
+
124
+ > Le module `nuxt-intlayer` gère automatiquement l'intégration d'Intlayer avec Nuxt. Il configure la construction des déclarations de contenu, surveille les fichiers en mode développement, fournit un middleware pour la détection de langue et gère le routage localisé.
125
+
126
+ ### Étape 4 : Déclarer votre contenu
127
+
128
+ Créez et gérez vos déclarations de contenu pour stocker les traductions :
129
+
130
+ ```tsx fileName="components/helloWorld.content.ts" contentDeclarationFormat="typescript"
131
+ import { t, type Dictionary } from "intlayer";
132
+
133
+ const helloWorldContent = {
134
+ key: "helloworld",
135
+ content: {
136
+ count: t({ fr: "le compte est ", en: "count is ", es: "el recuento es " }),
137
+ edit: t({
138
+ fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
139
+ en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
140
+ es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
141
+ }),
142
+ checkOut: t({ fr: "Vérifiez ", en: "Check out ", es: "Compruebe " }),
143
+ nuxtIntlayer: t({
144
+ fr: "Documentation de Nuxt Intlayer",
145
+ en: "Nuxt Intlayer documentation",
146
+ es: "Documentación de Nuxt Intlayer",
147
+ }),
148
+ learnMore: t({
149
+ fr: "En savoir plus sur Nuxt dans la ",
150
+ en: "Learn more about Nuxt in the ",
151
+ es: "Aprenda más sobre Nuxt en la ",
152
+ }),
153
+ nuxtDocs: t({
154
+ fr: "Documentation Nuxt",
155
+ en: "Nuxt Documentation",
156
+ es: "Documentación de Nuxt",
157
+ }),
158
+ readTheDocs: t({
159
+ fr: "Cliquez sur le logo Nuxt pour en savoir plus",
160
+ en: "Click on the Nuxt logo to learn more",
161
+ es: "Haga clic en el logotipo de Nuxt para obtener más información",
162
+ }),
163
+ },
164
+ } satisfies Dictionary;
165
+
166
+ export default helloWorldContent;
167
+ ```
168
+
169
+ ```javascript fileName="components/helloWorld.content.mjs" contentDeclarationFormat="esm"
170
+ import { t } from "intlayer";
171
+
172
+ /** @type {import('intlayer').Dictionary} */
173
+ const helloWorldContent = {
174
+ key: "helloworld",
175
+ content: {
176
+ count: t({ fr: "le compte est ", en: "count is ", es: "el recuento es " }),
177
+ edit: t({
178
+ fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
179
+ en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
180
+ es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
181
+ }),
182
+ checkOut: t({ fr: "Vérifiez ", en: "Check out ", es: "Compruebe " }),
183
+ nuxtIntlayer: t({
184
+ fr: "Documentation de Nuxt Intlayer",
185
+ en: "Nuxt Intlayer documentation",
186
+ es: "Documentación de Nuxt Intlayer",
187
+ }),
188
+ learnMore: t({
189
+ fr: "En savoir plus sur Nuxt dans la ",
190
+ en: "Learn more about Nuxt in the ",
191
+ es: "Aprenda más sobre Nuxt en la ",
192
+ }),
193
+ nuxtDocs: t({
194
+ fr: "Documentation Nuxt",
195
+ en: "Nuxt Documentation",
196
+ es: "Documentación de Nuxt",
197
+ }),
198
+ readTheDocs: t({
199
+ fr: "Cliquez sur le logo Nuxt pour en savoir plus",
200
+ en: "Click on the Nuxt logo to learn more",
201
+ es: "Haga clic en el logotipo de Nuxt para obtener más información",
202
+ }),
203
+ },
204
+ };
205
+
206
+ export default helloWorldContent;
207
+ ```
208
+
209
+ ```javascript fileName="components/helloWorld.content.cjs" contentDeclarationFormat="commonjs"
210
+ const { t } = require("intlayer");
211
+
212
+ /** @type {import('intlayer').Dictionary} */
213
+ const helloWorldContent = {
214
+ key: "helloworld",
215
+ content: {
216
+ count: t({ fr: "le compte est ", en: "count is ", es: "el recuento es " }),
217
+ edit: t({
218
+ fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
219
+ en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
220
+ es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
221
+ }),
222
+ checkOut: t({ fr: "Vérifiez ", en: "Check out ", es: "Compruebe " }),
223
+ nuxtIntlayer: t({
224
+ fr: "Documentation de Nuxt Intlayer",
225
+ en: "Nuxt Intlayer documentation",
226
+ es: "Documentación de Nuxt Intlayer",
227
+ }),
228
+ learnMore: t({
229
+ fr: "En savoir plus sur Nuxt dans la ",
230
+ en: "Learn more about Nuxt in the ",
231
+ es: "Aprenda más sobre Nuxt en la ",
232
+ }),
233
+ nuxtDocs: t({
234
+ fr: "Documentation Nuxt",
235
+ en: "Nuxt Documentation",
236
+ es: "Documentación de Nuxt",
237
+ }),
238
+ readTheDocs: t({
239
+ fr: "Cliquez sur le logo Nuxt pour en savoir plus",
240
+ en: "Click on the Nuxt logo to learn more",
241
+ es: "Haga clic en el logotipo de Nuxt para obtener más información",
242
+ }),
243
+ },
244
+ };
245
+
246
+ module.exports = helloWorldContent;
247
+ ```
248
+
249
+ ```json fileName="components/helloWorld.content.json" contentDeclarationFormat="json"
250
+ {
251
+ "$schema": "https://intlayer.org/schema.json",
252
+ "key": "helloworld",
253
+ "content": {
254
+ "count": {
255
+ "nodeType": "translation",
256
+ "translation": {
257
+ "fr": "le compte est ",
258
+ "en": "count is ",
259
+ "es": "el recuento es "
260
+ }
261
+ },
262
+ "edit": {
263
+ "nodeType": "translation",
264
+ "translation": {
265
+ "fr": "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
266
+ "en": "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
267
+ "es": "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR"
268
+ }
269
+ },
270
+ "checkOut": {
271
+ "nodeType": "translation",
272
+ "translation": {
273
+ "fr": "Vérifiez ",
274
+ "en": "Check out ",
275
+ "es": "Compruebe "
276
+ }
277
+ },
278
+ "nuxtIntlayer": {
279
+ "nodeType": "translation",
280
+ "translation": {
281
+ "fr": "Documentation de Nuxt Intlayer",
282
+ "en": "Nuxt Intlayer documentation",
283
+ "es": "Documentación de Nuxt Intlayer"
284
+ }
285
+ },
286
+ "learnMore": {
287
+ "nodeType": "translation",
288
+ "translation": {
289
+ "fr": "En savoir plus sur Nuxt dans la ",
290
+ "en": "Learn more about Nuxt in the ",
291
+ "es": "Aprenda más sobre Nuxt en la "
292
+ }
293
+ },
294
+ "nuxtDocs": {
295
+ "nodeType": "translation",
296
+ "translation": {
297
+ "fr": "Documentation Nuxt",
298
+ "en": "Nuxt Documentation",
299
+ "es": "Documentación de Nuxt"
300
+ }
301
+ },
302
+ "readTheDocs": {
303
+ "nodeType": "translation",
304
+ "translation": {
305
+ "fr": "Cliquez sur le logo Nuxt pour en savoir plus",
306
+ "en": "Click on the Nuxt logo to learn more",
307
+ "es": "Haga clic en el logotipo de Nuxt para obtener más información"
308
+ }
309
+ }
310
+ }
311
+ }
312
+ ```
313
+
314
+ > Vos déclarations de contenu peuvent être définies n'importe où dans votre application tant qu'elles sont incluses dans le répertoire `contentDir` (par défaut, `./src`). Et correspondent à l'extension de fichier de déclaration de contenu (par défaut, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
315
+
316
+ > Pour plus de détails, consultez la [documentation sur les déclarations de contenu](https://github.com/aymericzip/intlayer/blob/main/docs/fr/dictionary/get_started.md).
317
+
318
+ ### Étape 5 : Utiliser Intlayer dans votre code
319
+
320
+ Accédez à vos dictionnaires de contenu dans toute votre application Nuxt en utilisant le composable `useIntlayer` :
321
+
322
+ ```vue fileName="components/HelloWorld.vue"
323
+ <script setup lang="ts">
324
+ import { ref } from "vue";
325
+ import { useIntlayer } from "vue-intlayer";
326
+
327
+ defineProps({
328
+ msg: String,
329
+ });
330
+
331
+ const {
332
+ count,
333
+ edit,
334
+ checkOut,
335
+ nuxtIntlayer,
336
+ learnMore,
337
+ nuxtDocs,
338
+ readTheDocs,
339
+ } = useIntlayer("helloworld");
340
+ const countRef = ref(0);
341
+ </script>
342
+
343
+ <template>
344
+ <h1>{{ msg }}</h1>
345
+
346
+ <div class="card">
347
+ <button type="button" @click="countRef++">
348
+ <count />
349
+ {{ countRef }}
350
+ </button>
351
+ <p v-html="edit"></p>
352
+ </div>
353
+
354
+ <p>
355
+ <checkOut />
356
+ <a href="https://nuxt.com/docs/getting-started/introduction" target="_blank"
357
+ >Nuxt</a
358
+ >, <nuxtIntlayer />
359
+ </p>
360
+ <p>
361
+ <learnMore />
362
+ <a href="https://nuxt.com" target="_blank"><nuxtDocs /></a>.
363
+ </p>
364
+ <p class="read-the-docs"><readTheDocs /></p>
365
+ <p class="read-the-docs">{{ readTheDocs }}</p>
366
+ </template>
367
+ ```
368
+
369
+ #### Accéder au contenu dans Intlayer
370
+
371
+ Intlayer propose deux API pour accéder à votre contenu :
372
+
373
+ - **Syntaxe basée sur les composants** (recommandée) :
374
+ Utilisez la syntaxe `<myContent />` ou `<Component :is="myContent" />` pour rendre le contenu en tant que nœud Intlayer. Cela s'intègre parfaitement avec l'[éditeur visuel](https://github.com/aymericzip/intlayer/blob/main/docs/fr/intlayer_visual_editor.md) et le [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/fr/intlayer_CMS.md).
375
+
376
+ - **Syntaxe basée sur les chaînes** :
377
+ Utilisez `{{ myContent }}` pour rendre le contenu sous forme de texte brut, sans support pour l'éditeur visuel.
378
+
379
+ - **Syntaxe HTML brute** :
380
+ Utilisez `<div v-html="myContent" />` pour rendre le contenu en tant que HTML brut, sans support pour l'éditeur visuel.
381
+
382
+ - **Syntaxe de déstructuration** :
383
+ Le composable `useIntlayer` retourne un Proxy avec le contenu. Ce proxy peut être déstructuré pour accéder au contenu tout en conservant la réactivité.
384
+ - Utilisez `const content = useIntlayer("myContent");` et `{{ content.myContent }}` / `<content.myContent />`.
385
+ - Ou utilisez `const { myContent } = useIntlayer("myContent");` et `{{ myContent }}` / `<myContent />` pour déstructurer le contenu.
386
+
387
+ ### (Optionnel) Étape 6 : Changer la langue de votre contenu
388
+
389
+ Pour changer la langue de votre contenu, vous pouvez utiliser la fonction `setLocale` fournie par le composable `useLocale`. Cette fonction vous permet de définir la langue de l'application et de mettre à jour le contenu en conséquence.
390
+
391
+ Créez un composant pour basculer entre les langues :
392
+
393
+ ```vue fileName="components/LocaleSwitcher.vue"
394
+ <template>
395
+ <div class="locale-switcher">
396
+ <select v-model="selectedLocale" @change="changeLocale">
397
+ <option v-for="loc in availableLocales" :key="loc" :value="loc">
398
+ {{ getLocaleName(loc) }}
399
+ </option>
400
+ </select>
401
+ </div>
402
+ </template>
403
+
404
+ <script setup lang="ts">
405
+ import { ref, watch } from "vue";
406
+ import { getLocaleName } from "intlayer";
407
+ import { useLocale } from "vue-intlayer";
408
+
409
+ // Obtenir les informations de langue et la fonction setLocale
410
+ const { locale, availableLocales, setLocale } = useLocale();
411
+
412
+ // Suivre la langue sélectionnée avec une référence
413
+ const selectedLocale = ref(locale.value);
414
+
415
+ // Mettre à jour la langue lorsque la sélection change
416
+ const changeLocale = () => setLocale(selectedLocale.value);
417
+
418
+ // Garder selectedLocale synchronisé avec la langue globale
419
+ watch(
420
+ () => locale.value,
421
+ (newLocale) => {
422
+ selectedLocale.value = newLocale;
423
+ }
424
+ );
425
+ </script>
426
+ </template>
427
+
428
+ <style scoped>
429
+ .locale-switcher {
430
+ margin: 1rem 0;
431
+ }
432
+
433
+ select {
434
+ padding: 0.5rem;
435
+ border-radius: 0.25rem;
436
+ border: 1px solid #ccc;
437
+ }
438
+ </style>
439
+ ```
440
+
441
+ Ensuite, utilisez ce composant dans vos pages ou votre mise en page :
442
+
443
+ ```vue fileName="app.vue"
444
+ <script setup lang="ts">
445
+ import { useIntlayer } from "vue-intlayer";
446
+ import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
447
+
448
+ const content = useIntlayer("app"); // Créez un fichier de déclaration Intlayer associé
449
+ </script>
450
+
451
+ <template>
452
+ <div>
453
+ <header>
454
+ <LocaleSwitcher />
455
+ </header>
456
+ <main>
457
+ <NuxtPage />
458
+ </main>
459
+ </div>
460
+ </template>
461
+ ```
462
+
463
+ ### (Optionnel) Étape 7 : Ajouter un routage localisé à votre application
464
+
465
+ Nuxt gère automatiquement le routage localisé lorsque vous utilisez le module `nuxt-intlayer`. Cela crée des routes pour chaque langue automatiquement en fonction de la structure de votre répertoire de pages.
466
+
467
+ Exemple :
468
+
469
+ ```plaintext
470
+ pages/
471
+ ├── index.vue → /, /fr, /es
472
+ ├── about.vue → /about, /fr/about, /es/about
473
+ └── contact/
474
+ └── index.vue → /contact, /fr/contact, /es/contact
475
+ ```
476
+
477
+ Pour créer une page localisée, créez simplement vos fichiers Vue dans le répertoire `pages/` :
478
+
479
+ ```vue fileName="pages/about.vue"
480
+ <script setup lang="ts">
481
+ import { useIntlayer } from "vue-intlayer";
482
+
483
+ const content = useIntlayer("about");
484
+ </script>
485
+
486
+ <template>
487
+ <div>
488
+ <h1>{{ content.title }}</h1>
489
+ <p>{{ content.description }}</p>
490
+ </div>
491
+ </template>
492
+ ```
493
+
494
+ Le module `nuxt-intlayer` effectuera automatiquement :
495
+
496
+ - La détection de la langue préférée de l'utilisateur
497
+ - La gestion du changement de langue via l'URL
498
+ - La définition de l'attribut `<html lang="">` approprié
499
+ - La gestion des cookies de langue
500
+ - La redirection des utilisateurs vers l'URL localisée appropriée
501
+
502
+ ### (Optionnel) Étape 8 : Créer un composant de lien localisé
503
+
504
+ Pour garantir que la navigation de votre application respecte la langue actuelle, vous pouvez créer un composant `LocalizedLink` personnalisé. Ce composant préfixe automatiquement les URL internes avec la langue actuelle.
505
+
506
+ ```vue fileName="components/LocalizedLink.vue"
507
+ <template>
508
+ <NuxtLink :to="localizedHref" v-bind="$attrs">
509
+ <slot />
510
+ </NuxtLink>
511
+ </template>
512
+
513
+ <script setup lang="ts">
514
+ import { computed } from "vue";
515
+ import { getLocalizedUrl } from "intlayer";
516
+ import { useLocale } from "vue-intlayer";
517
+
518
+ const props = defineProps({
519
+ to: {
520
+ type: String,
521
+ required: true,
522
+ },
523
+ });
524
+
525
+ const { locale } = useLocale();
526
+
527
+ // Vérifiez si le lien est externe
528
+ const isExternalLink = computed(() => /^https?:\/\//.test(props.to || ""));
529
+
530
+ // Créez un href localisé pour les liens internes
531
+ const localizedHref = computed(() =>
532
+ isExternalLink.value ? props.to : getLocalizedUrl(props.to, locale.value)
533
+ );
534
+ </script>
535
+ ```
536
+
537
+ Ensuite, utilisez ce composant dans toute votre application :
538
+
539
+ ```vue fileName="pages/index.vue"
540
+ <template>
541
+ <div>
542
+ <LocalizedLink to="/about">
543
+ {{ content.aboutLink }}
544
+ </LocalizedLink>
545
+
546
+ {{ content.contactLink }}
547
+ </LocalizedLink>
548
+ </div>
549
+ </template>
550
+
551
+ <script setup lang="ts">
552
+ import { useIntlayer } from "vue-intlayer";
553
+ import LocalizedLink from "~/components/LocalizedLink.vue";
554
+
555
+ const content = useIntlayer("home");
556
+ </script>
557
+ ```
558
+
559
+ ### (Optionnel) Étape 9 : Gérer les Métadonnées et le SEO
560
+
561
+ Nuxt offre d'excellentes capacités SEO. Vous pouvez utiliser Intlayer pour gérer les métadonnées localisées :
562
+
563
+ ```vue fileName="pages/about.vue"
564
+ <script setup lang="ts">
565
+ import { useSeoMeta } from "nuxt/app";
566
+ import { getIntlayer } from "intlayer";
567
+ import { useLocale } from "vue-intlayer";
568
+
569
+ const { locale } = useLocale();
570
+ const content = getIntlayer("about-meta", locale.value);
571
+
572
+ useSeoMeta({
573
+ title: content.title,
574
+ description: content.description,
575
+ });
576
+ </script>
577
+
578
+ <template>
579
+ <div>
580
+ <h1>{{ content.pageTitle }}</h1>
581
+ <p>{{ content.pageContent }}</p>
582
+ </div>
583
+ </template>
584
+ ```
585
+
586
+ Créez la déclaration de contenu correspondante :
587
+
588
+ ```typescript fileName="pages/about-meta.content.ts" contentDeclarationFormat="typescript"
589
+ import { t, type Dictionary } from "intlayer";
590
+ import type { useSeoMeta } from "nuxt/app";
591
+
592
+ const aboutMetaContent = {
593
+ key: "about-meta",
594
+ content: {
595
+ title: t({
596
+ fr: "À Propos - Ma Société",
597
+ en: "About Us - My Company",
598
+ es: "Acerca de Nosotros - Mi Empresa",
599
+ }),
600
+ description: t({
601
+ fr: "En savoir plus sur notre société et notre mission",
602
+ en: "Learn more about our company and our mission",
603
+ es: "Conozca más sobre nuestra empresa y nuestra misión",
604
+ }),
605
+ },
606
+ } satisfies Dictionary<Parameters<typeof useSeoMeta>[0]>;
607
+
608
+ export default aboutMetaContent;
609
+ ```
610
+
611
+ ```typescript fileName="pages/about-meta.content.mjs" contentDeclarationFormat="esm"
612
+ import { t } from "intlayer";
613
+
614
+ /** @type {import('intlayer').Dictionary} */
615
+ const aboutMetaContent = {
616
+ key: "about-meta",
617
+ content: {
618
+ title: t({
619
+ en: "About Us - My Company",
620
+ fr: "À Propos - Ma Société",
621
+ es: "Acerca de Nosotros - Mi Empresa",
622
+ }),
623
+ description: t({
624
+ en: "Learn more about our company and our mission",
625
+ fr: "En savoir plus sur notre société et notre mission",
626
+ es: "Conozca más sobre nuestra empresa y nuestra misión",
627
+ }),
628
+ },
629
+ };
630
+
631
+ export default aboutMetaContent;
632
+ ```
633
+
634
+ ```typescript fileName="pages/about-meta.content.js" contentDeclarationFormat="cjs"
635
+ const { t } = require("intlayer");
636
+
637
+ /** @type {import('intlayer').Dictionary} */
638
+ const aboutMetaContent = {
639
+ key: "about-meta",
640
+ content: {
641
+ title: t({
642
+ en: "About Us - My Company",
643
+ fr: "À Propos - Ma Société",
644
+ es: "Acerca de Nosotros - Mi Empresa",
645
+ }),
646
+ description: t({
647
+ en: "Learn more about our company and our mission",
648
+ fr: "En savoir plus sur notre société et notre mission",
649
+ es: "Conozca más sobre nuestra empresa y nuestra misión",
650
+ }),
651
+ },
652
+ };
653
+
654
+ module.exports = aboutMetaContent;
655
+ ```
656
+
657
+ ```json fileName="pages/about-meta.content.json" contentDeclarationFormat="json"
658
+ {
659
+ "key": "about-meta",
660
+ "content": {
661
+ "title": {
662
+ "nodeType": "translation",
663
+ "translations": {
664
+ "en": "About Us - My Company",
665
+ "fr": "À Propos - Ma Société",
666
+ "es": "Acerca de Nosotros - Mi Empresa"
667
+ }
668
+ },
669
+ "description": {
670
+ "nodeType": "translation",
671
+ "translations": {
672
+ "en": "Learn more about our company and our mission",
673
+ "fr": "En savoir plus sur notre société et notre mission",
674
+ "es": "Conozca más sobre nuestra empresa y nuestra misión"
675
+ }
676
+ }
677
+ }
678
+ }
679
+ ```
680
+
681
+ ### Configurer TypeScript
682
+
683
+ Intlayer utilise l'augmentation de module pour bénéficier de TypeScript et renforcer votre base de code.
684
+
685
+ ![texte alternatif](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png)
686
+
687
+ ![texte alternatif](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png)
688
+
689
+ Assurez-vous que votre configuration TypeScript inclut les types générés automatiquement.
690
+
691
+ ```json5 fileName="tsconfig.json"
692
+ {
693
+ // ... Vos configurations TypeScript existantes
694
+ "include": [
695
+ // ... Vos configurations TypeScript existantes
696
+ ".intlayer/**/*.ts", // Inclure les types générés automatiquement
697
+ ],
698
+ }
699
+ ```
700
+
701
+ ### Configuration Git
702
+
703
+ Il est recommandé d'ignorer les fichiers générés par Intlayer. Cela vous permet d'éviter de les ajouter à votre dépôt Git.
704
+
705
+ Pour ce faire, vous pouvez ajouter les instructions suivantes à votre fichier `.gitignore` :
706
+
707
+ ```plaintext fileName=".gitignore"
708
+ # Ignorer les fichiers générés par Intlayer
709
+ .intlayer
710
+ ```
711
+
712
+ ### Extension VS Code
713
+
714
+ Pour améliorer votre expérience de développement avec Intlayer, vous pouvez installer l'extension officielle **Intlayer VS Code Extension**.
715
+
716
+ [Installer depuis le Marketplace VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
717
+
718
+ Cette extension fournit :
719
+
720
+ - **Autocomplétion** pour les clés de traduction.
721
+ - **Détection d'erreurs en temps réel** pour les traductions manquantes.
722
+ - **Aperçus en ligne** du contenu traduit.
723
+ - **Actions rapides** pour créer et mettre à jour facilement les traductions.
724
+
725
+ Pour plus de détails sur l'utilisation de l'extension, consultez la [documentation de l'extension VS Code Intlayer](https://intlayer.org/doc/vs-code-extension).
726
+
727
+ ---
728
+
729
+ ### Aller Plus Loin
730
+
731
+ Pour aller plus loin, vous pouvez implémenter l'[éditeur visuel](https://github.com/aymericzip/intlayer/blob/main/docs/fr/intlayer_visual_editor.md) ou externaliser votre contenu en utilisant le [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/fr/intlayer_CMS.md).