@intlayer/docs 7.0.3 → 7.0.4

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 (159) hide show
  1. package/blog/ar/intlayer_with_i18next.md +68 -106
  2. package/blog/ar/intlayer_with_next-i18next.md +84 -288
  3. package/blog/ar/intlayer_with_next-intl.md +58 -337
  4. package/blog/ar/intlayer_with_react-i18next.md +68 -290
  5. package/blog/ar/intlayer_with_react-intl.md +63 -266
  6. package/blog/de/intlayer_with_i18next.md +77 -97
  7. package/blog/de/intlayer_with_next-i18next.md +69 -296
  8. package/blog/de/intlayer_with_next-intl.md +59 -340
  9. package/blog/de/intlayer_with_react-i18next.md +68 -290
  10. package/blog/de/intlayer_with_react-intl.md +62 -264
  11. package/blog/en/intlayer_with_i18next.md +67 -103
  12. package/blog/en/intlayer_with_next-i18next.md +69 -294
  13. package/blog/en/intlayer_with_next-intl.md +48 -300
  14. package/blog/en/intlayer_with_react-i18next.md +61 -289
  15. package/blog/en/intlayer_with_react-intl.md +61 -284
  16. package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +1 -1
  17. package/blog/en-GB/intlayer_with_i18next.md +67 -103
  18. package/blog/en-GB/intlayer_with_next-i18next.md +71 -292
  19. package/blog/en-GB/intlayer_with_next-intl.md +58 -337
  20. package/blog/en-GB/intlayer_with_react-i18next.md +67 -289
  21. package/blog/en-GB/intlayer_with_react-intl.md +61 -264
  22. package/blog/es/intlayer_with_i18next.md +67 -103
  23. package/blog/es/intlayer_with_next-i18next.md +71 -296
  24. package/blog/es/intlayer_with_next-intl.md +57 -338
  25. package/blog/es/intlayer_with_react-i18next.md +68 -290
  26. package/blog/es/intlayer_with_react-intl.md +62 -265
  27. package/blog/fr/intlayer_with_i18next.md +66 -104
  28. package/blog/fr/intlayer_with_next-i18next.md +82 -285
  29. package/blog/fr/intlayer_with_next-intl.md +57 -338
  30. package/blog/fr/intlayer_with_react-i18next.md +67 -289
  31. package/blog/fr/intlayer_with_react-intl.md +61 -264
  32. package/blog/hi/intlayer_with_i18next.md +68 -104
  33. package/blog/hi/intlayer_with_next-i18next.md +74 -299
  34. package/blog/hi/intlayer_with_next-intl.md +57 -239
  35. package/blog/hi/intlayer_with_react-i18next.md +69 -291
  36. package/blog/hi/intlayer_with_react-intl.md +65 -268
  37. package/blog/id/intlayer_with_i18next.md +126 -0
  38. package/blog/id/intlayer_with_next-i18next.md +142 -0
  39. package/blog/id/intlayer_with_next-intl.md +113 -0
  40. package/blog/id/intlayer_with_react-i18next.md +124 -0
  41. package/blog/id/intlayer_with_react-intl.md +122 -0
  42. package/blog/it/intlayer_with_i18next.md +67 -103
  43. package/blog/it/intlayer_with_next-i18next.md +71 -296
  44. package/blog/it/intlayer_with_next-intl.md +57 -338
  45. package/blog/it/intlayer_with_react-i18next.md +68 -290
  46. package/blog/it/intlayer_with_react-intl.md +62 -265
  47. package/blog/ja/intlayer_with_i18next.md +68 -103
  48. package/blog/ja/intlayer_with_next-i18next.md +85 -283
  49. package/blog/ja/intlayer_with_next-intl.md +58 -336
  50. package/blog/ja/intlayer_with_react-i18next.md +68 -290
  51. package/blog/ja/intlayer_with_react-intl.md +62 -264
  52. package/blog/ko/intlayer_with_i18next.md +80 -96
  53. package/blog/ko/intlayer_with_next-i18next.md +85 -287
  54. package/blog/ko/intlayer_with_next-intl.md +68 -327
  55. package/blog/ko/intlayer_with_react-i18next.md +68 -290
  56. package/blog/ko/intlayer_with_react-intl.md +64 -266
  57. package/blog/pl/intlayer_with_i18next.md +126 -0
  58. package/blog/pl/intlayer_with_next-i18next.md +142 -0
  59. package/blog/pl/intlayer_with_next-intl.md +111 -0
  60. package/blog/pl/intlayer_with_react-i18next.md +124 -0
  61. package/blog/pl/intlayer_with_react-intl.md +122 -0
  62. package/blog/pt/intlayer_with_i18next.md +67 -103
  63. package/blog/pt/intlayer_with_next-i18next.md +72 -293
  64. package/blog/pt/intlayer_with_next-intl.md +57 -256
  65. package/blog/pt/intlayer_with_react-i18next.md +104 -78
  66. package/blog/pt/intlayer_with_react-intl.md +62 -266
  67. package/blog/ru/intlayer_with_i18next.md +66 -104
  68. package/blog/ru/intlayer_with_next-i18next.md +71 -296
  69. package/blog/ru/intlayer_with_next-intl.md +58 -337
  70. package/blog/ru/intlayer_with_react-i18next.md +68 -290
  71. package/blog/ru/intlayer_with_react-intl.md +62 -265
  72. package/blog/tr/intlayer_with_i18next.md +71 -107
  73. package/blog/tr/intlayer_with_next-i18next.md +72 -297
  74. package/blog/tr/intlayer_with_next-intl.md +58 -339
  75. package/blog/tr/intlayer_with_react-i18next.md +69 -291
  76. package/blog/tr/intlayer_with_react-intl.md +63 -285
  77. package/blog/vi/intlayer_with_i18next.md +126 -0
  78. package/blog/vi/intlayer_with_next-i18next.md +142 -0
  79. package/blog/vi/intlayer_with_next-intl.md +111 -0
  80. package/blog/vi/intlayer_with_react-i18next.md +124 -0
  81. package/blog/vi/intlayer_with_react-intl.md +122 -0
  82. package/blog/zh/intlayer_with_i18next.md +67 -102
  83. package/blog/zh/intlayer_with_next-i18next.md +72 -296
  84. package/blog/zh/intlayer_with_next-intl.md +58 -336
  85. package/blog/zh/intlayer_with_react-i18next.md +68 -290
  86. package/blog/zh/intlayer_with_react-intl.md +63 -106
  87. package/dist/cjs/generated/blog.entry.cjs +13 -1
  88. package/dist/cjs/generated/blog.entry.cjs.map +1 -1
  89. package/dist/cjs/generated/docs.entry.cjs +13 -1
  90. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  91. package/dist/cjs/generated/frequentQuestions.entry.cjs +13 -1
  92. package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
  93. package/dist/cjs/generated/legal.entry.cjs +13 -1
  94. package/dist/cjs/generated/legal.entry.cjs.map +1 -1
  95. package/dist/esm/generated/blog.entry.mjs +13 -2
  96. package/dist/esm/generated/blog.entry.mjs.map +1 -1
  97. package/dist/esm/generated/docs.entry.mjs +13 -2
  98. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  99. package/dist/esm/generated/frequentQuestions.entry.mjs +13 -2
  100. package/dist/esm/generated/frequentQuestions.entry.mjs.map +1 -1
  101. package/dist/esm/generated/legal.entry.mjs +13 -2
  102. package/dist/esm/generated/legal.entry.mjs.map +1 -1
  103. package/dist/types/generated/blog.entry.d.ts.map +1 -1
  104. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  105. package/dist/types/generated/frequentQuestions.entry.d.ts.map +1 -1
  106. package/dist/types/generated/legal.entry.d.ts.map +1 -1
  107. package/docs/ar/plugins/sync-json.md +244 -0
  108. package/docs/de/plugins/sync-json.md +244 -0
  109. package/docs/de/releases/v7.md +1 -18
  110. package/docs/en/CI_CD.md +1 -1
  111. package/docs/en/configuration.md +1 -1
  112. package/docs/en/formatters.md +1 -1
  113. package/docs/en/how_works_intlayer.md +1 -1
  114. package/docs/en/intlayer_CMS.md +1 -1
  115. package/docs/en/intlayer_cli.md +26 -1
  116. package/docs/en/intlayer_with_nextjs_14.md +3 -1
  117. package/docs/en/intlayer_with_nextjs_15.md +3 -1
  118. package/docs/en/intlayer_with_nextjs_16.md +3 -1
  119. package/docs/en/intlayer_with_nextjs_page_router.md +1 -1
  120. package/docs/en/intlayer_with_nuxt.md +1 -1
  121. package/docs/en/intlayer_with_react_native+expo.md +1 -1
  122. package/docs/en/intlayer_with_react_router_v7.md +1 -1
  123. package/docs/en/intlayer_with_tanstack.md +1 -1
  124. package/docs/en/intlayer_with_vite+preact.md +1 -1
  125. package/docs/en/intlayer_with_vite+react.md +1 -1
  126. package/docs/en/intlayer_with_vite+solid.md +1 -1
  127. package/docs/en/intlayer_with_vite+svelte.md +1 -1
  128. package/docs/en/intlayer_with_vite+vue.md +1 -1
  129. package/docs/en/plugins/sync-json.md +1 -1
  130. package/docs/en/roadmap.md +1 -1
  131. package/docs/en-GB/plugins/sync-json.md +244 -0
  132. package/docs/es/plugins/sync-json.md +244 -0
  133. package/docs/es/releases/v7.md +1 -18
  134. package/docs/fr/intlayer_with_nextjs_16.md +2 -51
  135. package/docs/fr/plugins/sync-json.md +244 -0
  136. package/docs/fr/releases/v7.md +1 -18
  137. package/docs/hi/intlayer_with_nextjs_16.md +3 -2
  138. package/docs/hi/plugins/sync-json.md +244 -0
  139. package/docs/id/plugins/sync-json.md +244 -0
  140. package/docs/id/releases/v7.md +1 -18
  141. package/docs/it/plugins/sync-json.md +244 -0
  142. package/docs/it/releases/v7.md +1 -18
  143. package/docs/ja/intlayer_with_nextjs_16.md +44 -205
  144. package/docs/ja/plugins/sync-json.md +244 -0
  145. package/docs/ja/releases/v7.md +1 -18
  146. package/docs/ko/plugins/sync-json.md +244 -0
  147. package/docs/ko/releases/v7.md +1 -18
  148. package/docs/pl/plugins/sync-json.md +244 -0
  149. package/docs/pt/intlayer_with_nextjs_16.md +1 -52
  150. package/docs/pt/plugins/sync-json.md +244 -0
  151. package/docs/ru/plugins/sync-json.md +244 -0
  152. package/docs/tr/plugins/sync-json.md +245 -0
  153. package/docs/vi/plugins/sync-json.md +244 -0
  154. package/docs/zh/plugins/sync-json.md +244 -0
  155. package/package.json +14 -14
  156. package/src/generated/blog.entry.ts +26 -3
  157. package/src/generated/docs.entry.ts +26 -3
  158. package/src/generated/frequentQuestions.entry.ts +26 -3
  159. package/src/generated/legal.entry.ts +26 -3
@@ -1,346 +1,124 @@
1
1
  ---
2
2
  createdAt: 2025-01-02
3
- updatedAt: 2025-06-29
4
- title: Intlayer et react-i18next
5
- description: Comparer Intlayer avec react-i18next pour une application React
3
+ updatedAt: 2025-10-29
4
+ title: Comment automatiser vos traductions JSON react-i18next avec Intlayer
5
+ description: Automatisez vos traductions JSON avec Intlayer et react-i18next pour une internationalisation améliorée dans les applications React.
6
6
  keywords:
7
7
  - react-i18next
8
8
  - i18next
9
9
  - Intlayer
10
10
  - Internationalisation
11
+ - i18n
11
12
  - Blog
12
- - Next.js
13
- - JavaScript
14
13
  - React
14
+ - JavaScript
15
+ - TypeScript
16
+ - Gestion de contenu
15
17
  slugs:
16
18
  - blog
17
19
  - intlayer-with-react-i18next
20
+ history:
21
+ - version: 7.0.0
22
+ date: 2025-10-29
23
+ changes: Passage au plugin syncJSON
18
24
  ---
19
25
 
20
- # React Internationalization (i18n) avec react-i18next et Intlayer
21
-
22
- ## Aperçu
23
-
24
- - **Intlayer** vous aide à gérer les traductions via des fichiers de déclaration de contenu au **niveau du composant**.
25
- - **react-i18next** est une intégration populaire de React pour **i18next** qui fournit des hooks comme `useTranslation` pour récupérer des chaînes localisées dans vos composants.
26
-
27
- Lorsqu'ils sont combinés, Intlayer peut **exporter** des dictionnaires en **JSON compatible avec i18next** afin que react-i18next puisse **les consommer** à l'exécution.
28
-
29
- ## Pourquoi utiliser Intlayer avec react-i18next ?
30
-
31
- Les fichiers de déclaration de contenu **Intlayer** offrent une meilleure expérience développeur car ils sont :
32
-
33
- 1. **Flexibles dans le placement des fichiers**
34
- Placez chaque fichier de déclaration de contenu juste à côté du composant qui en a besoin. Cette structure vous permet de garder les traductions co-localisées, empêchant les traductions orphelines lorsque les composants sont déplacés ou supprimés.
35
-
36
- ```bash codeFormat="typescript"
37
- .
38
- └── src
39
- └── components
40
- └── MyComponent
41
- ├── index.content.ts # Fichier de déclaration de contenu
42
- └── index.tsx
43
- ```
44
-
45
- ```bash codeFormat="esm"
46
- .
47
- └── src
48
- └── components
49
- └── MyComponent
50
- ├── index.content.mjs # Fichier de déclaration de contenu
51
- └── index.mjx
52
- ```
53
-
54
- ```bash codeFormat="cjs"
55
- .
56
- └── src
57
- └── components
58
- └── MyComponent
59
- ├── index.content.cjs # Fichier de déclaration de contenu
60
- └── index.cjx
61
- ```
62
-
63
- ```bash codeFormat="json"
64
- .
65
- └── src
66
- └── components
67
- └── MyComponent
68
- ├── index.content.json # Fichier de déclaration de contenu
69
- └── index.jsx
70
- ```
71
-
72
- 2. **Traductions centralisées**
73
- Un seul fichier de déclaration de contenu collecte toutes les traductions nécessaires pour un composant, rendant les traductions manquantes plus faciles à détecter.
74
- Avec TypeScript, vous obtenez même des erreurs à la compilation si des traductions sont manquantes.
75
-
76
- ## Installation
77
-
78
- Dans un projet Create React App, installez ces dépendances :
79
-
80
- ```bash
81
- # Avec npm
82
- npm install intlayer react-i18next i18next i18next-resources-to-backend
83
- ```
26
+ # Comment automatiser vos traductions JSON react-i18next avec Intlayer
84
27
 
85
- ```bash
86
- # Avec yarn
87
- yarn add intlayer react-i18next i18next i18next-resources-to-backend
88
- ```
28
+ ## Qu'est-ce que Intlayer ?
89
29
 
90
- ```bash
91
- # Avec pnpm
92
- pnpm add intlayer react-i18next i18next i18next-resources-to-backend
93
- ```
30
+ **Intlayer** est une bibliothèque d'internationalisation innovante et open-source conçue pour pallier les lacunes des solutions i18n traditionnelles. Elle offre une approche moderne de la gestion de contenu dans les applications React.
94
31
 
95
- ### Que sont ces packages ?
32
+ Consultez une comparaison concrète avec react-i18next dans notre article de blog [react-i18next vs. react-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/fr/react-i18next_vs_react-intl_vs_intlayer.md).
96
33
 
97
- - **intlayer** La CLI et la bibliothèque principale pour gérer les configurations i18n, les déclarations de contenu et la génération des sorties de dictionnaires.
98
- - **react-intlayer** – Intégration spécifique à React pour Intlayer, fournissant notamment des scripts pour automatiser la construction des dictionnaires.
99
- - **react-i18next** – Bibliothèque d'intégration spécifique à React pour i18next, incluant le hook `useTranslation`.
100
- - **i18next** – Le cadre sous-jacent pour la gestion des traductions.
101
- - **i18next-resources-to-backend** – Un backend i18next qui importe dynamiquement les ressources JSON.
34
+ ## Pourquoi combiner Intlayer avec react-i18next ?
102
35
 
103
- ## Configuration d'Intlayer pour exporter des dictionnaires i18next
36
+ Bien qu'Intlayer fournisse une excellente solution i18n autonome (voir notre [guide d'intégration React](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/intlayer_with_vite+react.md)), vous pourriez vouloir le combiner avec react-i18next pour plusieurs raisons :
104
37
 
105
- Créez (ou mettez à jour) votre `intlayer.config.ts` à la racine de votre projet :
38
+ 1. **Base de code existante** : Vous disposez d'une implémentation react-i18next établie et souhaitez migrer progressivement vers la meilleure expérience développeur d'Intlayer.
39
+ 2. **Exigences héritées** : Votre projet nécessite une compatibilité avec les plugins ou workflows react-i18next existants.
40
+ 3. **Familiarité de l'équipe** : Votre équipe est à l'aise avec react-i18next mais souhaite une meilleure gestion du contenu.
106
41
 
107
- ```typescript title="intlayer.config.ts"
108
- import { Locales, type IntlayerConfig } from "intlayer";
42
+ **Pour cela, Intlayer peut être implémenté comme un adaptateur pour react-i18next afin d'automatiser vos traductions JSON dans les pipelines CLI ou CI/CD, tester vos traductions, et plus encore.**
109
43
 
110
- const config: IntlayerConfig = {
111
- internationalization: {
112
- // Ajoutez autant de locales que vous le souhaitez
113
- locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
114
- defaultLocale: Locales.ENGLISH,
115
- },
116
- content: {
117
- // Dites à Intlayer de créer du JSON compatible avec i18next
118
- dictionaryOutput: ["i18next"],
44
+ Ce guide vous montre comment tirer parti du système supérieur de déclaration de contenu d'Intlayer tout en maintenant la compatibilité avec react-i18next.
119
45
 
120
- // Choisissez un répertoire de sortie pour les ressources générées
121
- // Ce dossier sera créé s'il n'existe pas encore.
122
- i18nextResourcesDir: "./i18next/resources",
123
- },
124
- };
46
+ ## Table des matières
125
47
 
126
- export default config;
127
- ```
48
+ <TOC/>
128
49
 
129
- > **Remarque** : Si vous n'utilisez pas TypeScript, vous pouvez créer ce fichier de configuration en tant que `.cjs`, `.mjs` ou `.js` (voir la [documentation Intlayer](https://intlayer.org/fr/doc/concept/configuration) pour plus de détails).
50
+ ## Guide étape par étape pour configurer Intlayer avec react-i18next
130
51
 
131
- ## Construction des ressources i18next
52
+ ### Étape 1 : Installer les dépendances
132
53
 
133
- Une fois vos déclarations de contenu en place (section suivante), exécutez la **commande de construction Intlayer** :
54
+ Installez les paquets nécessaires :
134
55
 
135
- ```bash
136
- # Avec npm
137
- npx run intlayer build
56
+ ```bash packageManager="npm"
57
+ npm install intlayer @intlayer/sync-json-plugin
138
58
  ```
139
59
 
140
- ```bash
141
- # Avec yarn
142
- yarn intlayer build
60
+ ```bash packageManager="pnpm"
61
+ pnpm add intlayer @intlayer/sync-json-plugin
143
62
  ```
144
63
 
145
- ```bash
146
- # Avec pnpm
147
- pnpm intlayer build
64
+ ```bash packageManager="yarn"
65
+ yarn add intlayer @intlayer/sync-json-plugin
148
66
  ```
149
67
 
150
- > Cela générera vos ressources i18next dans le répertoire `./i18next/resources` par défaut.
68
+ **Descriptions des paquets :**
151
69
 
152
- Une sortie typique pourrait ressembler à ceci :
70
+ - **intlayer** : Bibliothèque principale pour la gestion de l'internationalisation, la déclaration de contenu et la construction
71
+ - **@intlayer/sync-json-plugin** : Plugin pour exporter les déclarations de contenu Intlayer au format JSON compatible avec react-i18next
153
72
 
154
- ```bash
155
- .
156
- └── i18next
157
- └── resources
158
- ├── en
159
- │ └── my-content.json
160
- ├── fr
161
- │ └── my-content.json
162
- └── es
163
- └── my-content.json
164
- ```
73
+ ### Étape 2 : Implémenter le plugin Intlayer pour envelopper le JSON
165
74
 
166
- chaque clé de déclaration **Intlayer** est utilisée comme un **espace de noms i18next** (ex : `my-content.json`).
167
-
168
- ## Importation des dictionnaires dans votre configuration react-i18next
169
-
170
- Pour charger dynamiquement ces ressources à l'exécution, utilisez [`i18next-resources-to-backend`](https://www.npmjs.com/package/i18next-resources-to-backend). Par exemple, créez un fichier `i18n.ts` (ou `.js`) dans votre projet :
171
-
172
- ```typescript title="i18n.ts"
173
- import i18next from "i18next";
174
- import { initReactI18next } from "react-i18next";
175
- import resourcesToBackend from "i18next-resources-to-backend";
176
-
177
- i18next
178
- // plugin react-i18next
179
- .use(initReactI18next)
180
- // charger dynamiquement les ressources
181
- .use(
182
- resourcesToBackend((language: string, namespace: string) => {
183
- // Ajustez le chemin d'importation vers votre répertoire de ressources
184
- return import(`../i18next/resources/${language}/${namespace}.json`);
185
- })
186
- )
187
- // Initialiser i18next
188
- .init({
189
- // Locale de repli
190
- fallbackLng: "en",
191
-
192
- // Vous pouvez ajouter d'autres options de configuration i18next ici, voir :
193
- // https://www.i18next.com/overview/configuration-options
194
- });
195
-
196
- export default i18next;
197
- ```
75
+ Créez un fichier de configuration Intlayer pour définir vos locales supportées :
198
76
 
199
- ```javascript title="i18n.js"
200
- import i18next from "i18next";
201
- import { initReactI18next } from "react-i18next";
202
- import resourcesToBackend from "i18next-resources-to-backend";
203
-
204
- i18next
205
- .use(initReactI18next)
206
- .use(
207
- resourcesToBackend(
208
- (language, namespace) =>
209
- import(`../i18next/resources/${language}/${namespace}.json`)
210
- )
211
- )
212
- .init({
213
- fallbackLng: "en",
214
- });
215
-
216
- export default i18next;
217
- ```
77
+ **Si vous souhaitez également exporter des dictionnaires JSON pour react-i18next**, ajoutez le plugin `syncJSON` :
218
78
 
219
- Ensuite, dans votre fichier **racine** ou **index** (par exemple, `src/index.tsx`), importez cette configuration `i18n` **avant** de rendre l'`App` :
220
-
221
- ```typescript
222
- import React from "react";
223
- import ReactDOM from "react-dom/client";
224
- // Initialiser i18n avant tout
225
- import "./i18n";
226
- import App from "./App";
227
-
228
- ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
229
- <React.StrictMode>
230
- <App />
231
- </React.StrictMode>
232
- );
233
- ```
234
-
235
- ## Création et gestion de vos déclarations de contenu
236
-
237
- Intlayer extrait les traductions des « fichiers de déclaration de contenu » situés n'importe où sous `./src` (par défaut).
238
- Voici un exemple minimal en TypeScript :
239
-
240
- ```typescript title="src/components/MyComponent/MyComponent.content.ts"
241
- import { t, type Dictionary } from "intlayer";
79
+ ```typescript fileName="intlayer.config.ts"
80
+ import { Locales, type IntlayerConfig } from "intlayer";
81
+ import { syncJSON } from "@intlayer/sync-json-plugin";
242
82
 
243
- const content = {
244
- // La "clé" sera votre espace de noms i18next (ex : "my-component")
245
- key: "my-component",
246
- content: {
247
- // Chaque appel "t" est un nœud de traduction séparé
248
- heading: t({
249
- en: "Hello World",
250
- es: "Hola Mundo",
251
- fr: "Bonjour le monde",
252
- }),
253
- description: t({
254
- en: "My i18n description text...",
255
- fr: "Ma description en i18n...",
256
- es: "Mi descripción en i18n...",
257
- }),
83
+ const config: IntlayerConfig = {
84
+ internationalization: {
85
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
86
+ defaultLocale: Locales.ENGLISH,
258
87
  },
259
- } satisfies Dictionary;
260
-
261
- export default content;
262
- ```
263
-
264
- Si vous préférez JSON, `.cjs`, ou `.mjs`, référez-vous aux [doc Intlayer](https://intlayer.org/fr/doc/concept/content).
265
-
266
- > Par défaut, des déclarations de contenu valides correspondent au modèle d'extension de fichier :
267
-
268
- > `*.content.{ts,tsx,js,jsx,mjs,mjx,cjs,cjx,json}`
269
-
270
- ## Utilisation des traductions dans les composants React
271
-
272
- Après avoir **construit** vos ressources Intlayer et configuré react-i18next, vous pouvez directement utiliser le hook `useTranslation` de **react-i18next**.
273
- Par exemple :
274
-
275
- ```tsx title="src/components/MyComponent/MyComponent.tsx"
276
- import type { FC } from "react";
277
- import { useTranslation } from "react-i18next";
278
-
279
- /**
280
- * L'espace de noms "i18next" est la `clé` Intlayer de "MyComponent.content.ts"
281
- * nous passerons donc "my-component" à useTranslation().
282
- */
283
- const MyComponent: FC = () => {
284
- const { t } = useTranslation("my-component");
285
-
286
- return (
287
- <div>
288
- <h1>{t("heading")}</h1>
289
- <p>{t("description")}</p>
290
- </div>
291
- );
88
+ plugins: [
89
+ syncJSON({
90
+ source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
91
+ }),
92
+ ],
292
93
  };
293
94
 
294
- export default MyComponent;
95
+ export default config;
295
96
  ```
296
97
 
297
- > Notez que la fonction `t` fait référence aux **clés** à l'intérieur de votre JSON généré. Pour une entrée de contenu Intlayer nommée `heading`, vous utiliserez `t("heading")`.
298
-
299
- ## Optionnel : Intégrer avec les Scripts Create React App (CRACO)
300
-
301
- **react-intlayer** fournit une approche basée sur CRACO pour les constructions personnalisées et la configuration du serveur de développement. Si vous souhaitez intégrer l'étape de construction d'Intlayer de manière transparente, vous pouvez :
98
+ Le plugin `syncJSON` enveloppera automatiquement le JSON. Il lira et écrira les fichiers JSON sans changer l'architecture du contenu.
302
99
 
303
- 1. **Installer react-intlayer** (si vous ne l'avez pas encore fait) :
304
- ```bash
305
- npm install react-intlayer --save-dev
306
- ```
307
- 2. **Ajustez vos scripts `package.json`** pour utiliser les scripts de `react-intlayer` :
100
+ Si vous souhaitez faire coexister ce JSON avec les fichiers de déclaration de contenu intlayer (`.content`), Intlayer procédera de la manière suivante :
308
101
 
309
- ```jsonc
310
- "scripts": {
311
- "start": "react-intlayer start",
312
- "build": "react-intlayer build",
313
- "transpile": "intlayer build"
314
- }
315
- ```
102
+ 1. charger à la fois les fichiers JSON et les fichiers de déclaration de contenu et les transformer en un dictionnaire intlayer.
103
+ 2. s'il y a des conflits entre les fichiers JSON et les fichiers de déclaration de contenu, Intlayer procédera à la fusion de tous ces dictionnaires. Cela dépendra de la priorité des plugins, ainsi que de celle du fichier de déclaration de contenu (tout est configurable).
316
104
 
317
- > Les scripts `react-intlayer` sont basés sur [CRACO](https://craco.js.org/). Vous pouvez également mettre en œuvre votre propre configuration basée sur le plugin craco intlayer. [Voir un exemple ici](https://github.com/aymericzip/intlayer/blob/main/examples/react-app/craco.config.js).
105
+ Si des modifications sont effectuées via la CLI pour traduire le JSON, ou en utilisant le CMS, Intlayer mettra à jour le fichier JSON avec les nouvelles traductions.
318
106
 
319
- Maintenant, exécuter `npm run build`, `yarn build` ou `pnpm build` déclenche à la fois les constructions d'Intlayer et de CRA.
320
-
321
- ## Configuration TypeScript
322
-
323
- **Intlayer** fournit des **définitions de type autogénérées** pour votre contenu. Pour vous assurer que TypeScript les prenne en compte, ajoutez **`types`** (ou `types` si vous l'avez configuré différemment) à votre tableau **include** de `tsconfig.json` :
324
-
325
- ```json5 title="tsconfig.json"
326
- {
327
- "compilerOptions": {
328
- // ...
329
- },
330
- "include": ["src", "types"],
331
- }
332
- ```
333
-
334
- > Cela permettra à TypeScript d'inférer la structure de vos traductions pour une meilleure autocomplétion et détection d'erreurs.
107
+ Pour plus de détails sur le plugin `syncJSON`, veuillez consulter la [documentation du plugin syncJSON](https://github.com/aymericzip/intlayer/blob/main/docs/docs/fr/plugins/sync-json.md).
335
108
 
336
109
  ## Configuration Git
337
110
 
338
- Il est recommandé d'**ignorer** les fichiers et dossiers auto-générés par Intlayer. Ajoutez cette ligne à votre `.gitignore` :
111
+ Il est recommandé d'ignorer les fichiers Intlayer générés automatiquement :
339
112
 
340
- ```plaintext
113
+ ```plaintext fileName=".gitignore"
341
114
  # Ignorer les fichiers générés par Intlayer
342
115
  .intlayer
343
- i18next
344
116
  ```
345
117
 
346
- Vous ne devez généralement **pas** valider ces ressources ou les artefacts internes de construction `.intlayer`, car ils peuvent être régénérés à chaque construction.
118
+ Ces fichiers peuvent être régénérés lors de votre processus de build et n'ont pas besoin d'être commités dans le contrôle de version.
119
+
120
+ ### Extension VS Code
121
+
122
+ Pour une meilleure expérience développeur, installez l'extension officielle **Intlayer VS Code Extension** :
123
+
124
+ [Installer depuis le Marketplace VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)