@intlayer/docs 6.1.5 → 6.1.6

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 (284) hide show
  1. package/blog/ar/next-i18next_vs_next-intl_vs_intlayer.md +404 -173
  2. package/blog/de/next-i18next_vs_next-intl_vs_intlayer.md +262 -113
  3. package/blog/en/intlayer_with_next-i18next.mdx +431 -0
  4. package/blog/en/intlayer_with_next-intl.mdx +335 -0
  5. package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +463 -209
  6. package/blog/en-GB/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
  7. package/blog/es/next-i18next_vs_next-intl_vs_intlayer.md +185 -71
  8. package/blog/fr/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
  9. package/blog/it/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
  10. package/blog/ja/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
  11. package/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
  12. package/blog/pt/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
  13. package/blog/ru/next-i18next_vs_next-intl_vs_intlayer.md +36 -28
  14. package/blog/tr/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
  15. package/blog/zh/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
  16. package/dist/cjs/generated/docs.entry.cjs +32 -0
  17. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  18. package/dist/esm/generated/docs.entry.mjs +32 -0
  19. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  20. package/dist/types/generated/docs.entry.d.ts +2 -0
  21. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  22. package/docs/ar/component_i18n.md +186 -0
  23. package/docs/ar/intlayer_with_angular.md +2 -2
  24. package/docs/ar/intlayer_with_astro.md +246 -0
  25. package/docs/ar/intlayer_with_create_react_app.md +3 -2
  26. package/docs/ar/intlayer_with_express.md +2 -2
  27. package/docs/ar/intlayer_with_nestjs.md +2 -2
  28. package/docs/ar/intlayer_with_nextjs_14.md +2 -2
  29. package/docs/ar/intlayer_with_nextjs_15.md +2 -2
  30. package/docs/ar/intlayer_with_nextjs_page_router.md +2 -2
  31. package/docs/ar/intlayer_with_nuxt.md +2 -2
  32. package/docs/ar/intlayer_with_react_native+expo.md +11 -20
  33. package/docs/ar/intlayer_with_react_router_v7.md +195 -241
  34. package/docs/ar/intlayer_with_tanstack.md +198 -272
  35. package/docs/ar/intlayer_with_vite+preact.md +9 -9
  36. package/docs/ar/intlayer_with_vite+react.md +7 -7
  37. package/docs/ar/intlayer_with_vite+vue.md +9 -9
  38. package/docs/ar/vs_code_extension.md +48 -109
  39. package/docs/de/component_i18n.md +186 -0
  40. package/docs/de/intlayer_with_angular.md +2 -2
  41. package/docs/de/intlayer_with_astro.md +246 -0
  42. package/docs/de/intlayer_with_create_react_app.md +2 -2
  43. package/docs/de/intlayer_with_express.md +2 -2
  44. package/docs/de/intlayer_with_nestjs.md +2 -2
  45. package/docs/de/intlayer_with_nextjs_14.md +2 -2
  46. package/docs/de/intlayer_with_nextjs_15.md +2 -2
  47. package/docs/de/intlayer_with_nextjs_page_router.md +2 -2
  48. package/docs/de/intlayer_with_nuxt.md +2 -2
  49. package/docs/de/intlayer_with_react_native+expo.md +11 -20
  50. package/docs/de/intlayer_with_react_router_v7.md +193 -242
  51. package/docs/de/intlayer_with_tanstack.md +194 -266
  52. package/docs/de/intlayer_with_vite+preact.md +9 -9
  53. package/docs/de/intlayer_with_vite+react.md +9 -9
  54. package/docs/de/intlayer_with_vite+vue.md +11 -11
  55. package/docs/de/packages/vite-intlayer/index.md +3 -3
  56. package/docs/de/vs_code_extension.md +46 -107
  57. package/docs/en/component_i18n.md +186 -0
  58. package/docs/en/how_works_intlayer.md +1 -1
  59. package/docs/en/index.md +1 -1
  60. package/docs/en/intlayer_cli.md +1 -1
  61. package/docs/en/intlayer_with_angular.md +4 -4
  62. package/docs/en/intlayer_with_astro.md +246 -0
  63. package/docs/en/intlayer_with_create_react_app.md +4 -4
  64. package/docs/en/intlayer_with_express.md +3 -3
  65. package/docs/en/intlayer_with_lynx+react.md +1 -1
  66. package/docs/en/intlayer_with_nestjs.md +2 -2
  67. package/docs/en/intlayer_with_nextjs_14.md +31 -5
  68. package/docs/en/intlayer_with_nextjs_15.md +31 -5
  69. package/docs/en/intlayer_with_nextjs_page_router.md +5 -5
  70. package/docs/en/intlayer_with_nuxt.md +4 -4
  71. package/docs/en/intlayer_with_react_native+expo.md +46 -24
  72. package/docs/en/intlayer_with_react_router_v7.md +164 -211
  73. package/docs/en/intlayer_with_tanstack.md +166 -241
  74. package/docs/en/intlayer_with_vite+preact.md +12 -12
  75. package/docs/en/intlayer_with_vite+react.md +12 -12
  76. package/docs/en/intlayer_with_vite+solid.md +2 -2
  77. package/docs/en/intlayer_with_vite+svelte.md +2 -2
  78. package/docs/en/intlayer_with_vite+vue.md +12 -12
  79. package/docs/en/introduction.md +1 -1
  80. package/docs/en/packages/next-intlayer/useDictionary.md +1 -1
  81. package/docs/en/packages/next-intlayer/useIntlayer.md +1 -1
  82. package/docs/en/packages/react-intlayer/useDictionary.md +1 -1
  83. package/docs/en/packages/react-intlayer/useI18n.md +1 -1
  84. package/docs/en/packages/react-intlayer/useIntlayer.md +1 -1
  85. package/docs/en/releases/v6.md +1 -0
  86. package/docs/en/roadmap.md +1 -1
  87. package/docs/en/vs_code_extension.md +24 -114
  88. package/docs/en-GB/component_i18n.md +186 -0
  89. package/docs/en-GB/intlayer_with_angular.md +3 -3
  90. package/docs/en-GB/intlayer_with_astro.md +246 -0
  91. package/docs/en-GB/intlayer_with_create_react_app.md +5 -4
  92. package/docs/en-GB/intlayer_with_express.md +2 -2
  93. package/docs/en-GB/intlayer_with_nestjs.md +2 -2
  94. package/docs/en-GB/intlayer_with_nextjs_14.md +4 -4
  95. package/docs/en-GB/intlayer_with_nextjs_15.md +2 -2
  96. package/docs/en-GB/intlayer_with_nextjs_page_router.md +2 -2
  97. package/docs/en-GB/intlayer_with_nuxt.md +2 -2
  98. package/docs/en-GB/intlayer_with_react_native+expo.md +11 -20
  99. package/docs/en-GB/intlayer_with_react_router_v7.md +171 -220
  100. package/docs/en-GB/intlayer_with_tanstack.md +174 -248
  101. package/docs/en-GB/intlayer_with_vite+preact.md +9 -9
  102. package/docs/en-GB/intlayer_with_vite+react.md +9 -9
  103. package/docs/en-GB/intlayer_with_vite+vue.md +11 -11
  104. package/docs/en-GB/packages/next-intlayer/useIntlayer.md +1 -1
  105. package/docs/en-GB/packages/react-intlayer/useIntlayer.md +1 -1
  106. package/docs/en-GB/vs_code_extension.md +42 -103
  107. package/docs/es/component_i18n.md +182 -0
  108. package/docs/es/intlayer_with_angular.md +2 -2
  109. package/docs/es/intlayer_with_astro.md +246 -0
  110. package/docs/es/intlayer_with_create_react_app.md +3 -2
  111. package/docs/es/intlayer_with_express.md +2 -2
  112. package/docs/es/intlayer_with_nextjs_14.md +2 -2
  113. package/docs/es/intlayer_with_nextjs_15.md +2 -2
  114. package/docs/es/intlayer_with_react_native+expo.md +11 -20
  115. package/docs/es/intlayer_with_react_router_v7.md +188 -232
  116. package/docs/es/intlayer_with_tanstack.md +203 -273
  117. package/docs/es/intlayer_with_vite+preact.md +7 -7
  118. package/docs/es/intlayer_with_vite+react.md +7 -7
  119. package/docs/es/intlayer_with_vite+vue.md +9 -9
  120. package/docs/es/vs_code_extension.md +53 -114
  121. package/docs/fr/component_i18n.md +186 -0
  122. package/docs/fr/intlayer_with_angular.md +2 -2
  123. package/docs/fr/intlayer_with_astro.md +246 -0
  124. package/docs/fr/intlayer_with_create_react_app.md +3 -2
  125. package/docs/fr/intlayer_with_express.md +2 -2
  126. package/docs/fr/intlayer_with_nestjs.md +2 -2
  127. package/docs/fr/intlayer_with_nextjs_14.md +2 -2
  128. package/docs/fr/intlayer_with_react_native+expo.md +11 -20
  129. package/docs/fr/intlayer_with_react_router_v7.md +188 -248
  130. package/docs/fr/intlayer_with_tanstack.md +192 -265
  131. package/docs/fr/intlayer_with_vite+preact.md +7 -7
  132. package/docs/fr/intlayer_with_vite+react.md +7 -7
  133. package/docs/fr/intlayer_with_vite+vue.md +9 -9
  134. package/docs/fr/vs_code_extension.md +50 -111
  135. package/docs/hi/component_i18n.md +186 -0
  136. package/docs/hi/intlayer_cli.md +1 -4
  137. package/docs/hi/intlayer_with_angular.md +2 -2
  138. package/docs/hi/intlayer_with_astro.md +246 -0
  139. package/docs/hi/intlayer_with_create_react_app.md +2 -2
  140. package/docs/hi/intlayer_with_express.md +2 -2
  141. package/docs/hi/intlayer_with_nestjs.md +2 -2
  142. package/docs/hi/intlayer_with_nextjs_14.md +2 -2
  143. package/docs/hi/intlayer_with_nextjs_15.md +2 -2
  144. package/docs/hi/intlayer_with_nextjs_page_router.md +2 -2
  145. package/docs/hi/intlayer_with_nuxt.md +2 -2
  146. package/docs/hi/intlayer_with_react_native+expo.md +11 -20
  147. package/docs/hi/intlayer_with_react_router_v7.md +199 -243
  148. package/docs/hi/intlayer_with_tanstack.md +210 -285
  149. package/docs/hi/intlayer_with_vite+preact.md +9 -9
  150. package/docs/hi/intlayer_with_vite+react.md +9 -9
  151. package/docs/hi/intlayer_with_vite+solid.md +1 -1
  152. package/docs/hi/intlayer_with_vite+vue.md +11 -11
  153. package/docs/hi/vs_code_extension.md +49 -110
  154. package/docs/it/component_i18n.md +186 -0
  155. package/docs/it/intlayer_with_angular.md +2 -2
  156. package/docs/it/intlayer_with_astro.md +246 -0
  157. package/docs/it/intlayer_with_create_react_app.md +3 -2
  158. package/docs/it/intlayer_with_express.md +2 -2
  159. package/docs/it/intlayer_with_nestjs.md +2 -2
  160. package/docs/it/intlayer_with_nextjs_14.md +2 -2
  161. package/docs/it/intlayer_with_nextjs_15.md +2 -2
  162. package/docs/it/intlayer_with_nextjs_page_router.md +2 -2
  163. package/docs/it/intlayer_with_nuxt.md +2 -2
  164. package/docs/it/intlayer_with_react_native+expo.md +11 -21
  165. package/docs/it/intlayer_with_react_router_v7.md +195 -242
  166. package/docs/it/intlayer_with_tanstack.md +203 -267
  167. package/docs/it/intlayer_with_vite+preact.md +9 -9
  168. package/docs/it/intlayer_with_vite+react.md +13 -11
  169. package/docs/it/intlayer_with_vite+vue.md +11 -11
  170. package/docs/it/vs_code_extension.md +50 -111
  171. package/docs/ja/component_i18n.md +186 -0
  172. package/docs/ja/intlayer_with_angular.md +2 -2
  173. package/docs/ja/intlayer_with_astro.md +246 -0
  174. package/docs/ja/intlayer_with_create_react_app.md +3 -2
  175. package/docs/ja/intlayer_with_express.md +2 -2
  176. package/docs/ja/intlayer_with_nestjs.md +2 -2
  177. package/docs/ja/intlayer_with_nextjs_14.md +2 -2
  178. package/docs/ja/intlayer_with_nextjs_15.md +2 -2
  179. package/docs/ja/intlayer_with_nextjs_page_router.md +2 -2
  180. package/docs/ja/intlayer_with_nuxt.md +2 -2
  181. package/docs/ja/intlayer_with_react_native+expo.md +18 -29
  182. package/docs/ja/intlayer_with_react_router_v7.md +204 -250
  183. package/docs/ja/intlayer_with_tanstack.md +218 -286
  184. package/docs/ja/intlayer_with_vite+preact.md +9 -9
  185. package/docs/ja/intlayer_with_vite+react.md +11 -11
  186. package/docs/ja/intlayer_with_vite+vue.md +11 -11
  187. package/docs/ja/vs_code_extension.md +50 -111
  188. package/docs/ko/component_i18n.md +186 -0
  189. package/docs/ko/intlayer_with_angular.md +2 -2
  190. package/docs/ko/intlayer_with_astro.md +246 -0
  191. package/docs/ko/intlayer_with_create_react_app.md +3 -2
  192. package/docs/ko/intlayer_with_express.md +2 -2
  193. package/docs/ko/intlayer_with_nestjs.md +2 -2
  194. package/docs/ko/intlayer_with_nextjs_14.md +2 -2
  195. package/docs/ko/intlayer_with_nextjs_15.md +2 -2
  196. package/docs/ko/intlayer_with_nextjs_page_router.md +2 -2
  197. package/docs/ko/intlayer_with_nuxt.md +2 -2
  198. package/docs/ko/intlayer_with_react_native+expo.md +19 -28
  199. package/docs/ko/intlayer_with_react_router_v7.md +190 -244
  200. package/docs/ko/intlayer_with_tanstack.md +200 -270
  201. package/docs/ko/intlayer_with_vite+preact.md +9 -9
  202. package/docs/ko/intlayer_with_vite+react.md +9 -9
  203. package/docs/ko/intlayer_with_vite+vue.md +11 -11
  204. package/docs/ko/vs_code_extension.md +48 -109
  205. package/docs/pt/component_i18n.md +186 -0
  206. package/docs/pt/intlayer_with_angular.md +2 -2
  207. package/docs/pt/intlayer_with_astro.md +246 -0
  208. package/docs/pt/intlayer_with_create_react_app.md +3 -2
  209. package/docs/pt/intlayer_with_express.md +2 -2
  210. package/docs/pt/intlayer_with_nestjs.md +2 -2
  211. package/docs/pt/intlayer_with_nextjs_14.md +2 -2
  212. package/docs/pt/intlayer_with_nextjs_15.md +2 -2
  213. package/docs/pt/intlayer_with_nextjs_page_router.md +2 -2
  214. package/docs/pt/intlayer_with_nuxt.md +2 -2
  215. package/docs/pt/intlayer_with_react_native+expo.md +11 -20
  216. package/docs/pt/intlayer_with_react_router_v7.md +7 -13
  217. package/docs/pt/intlayer_with_tanstack.md +183 -258
  218. package/docs/pt/intlayer_with_vite+preact.md +9 -9
  219. package/docs/pt/intlayer_with_vite+react.md +9 -9
  220. package/docs/pt/intlayer_with_vite+vue.md +9 -9
  221. package/docs/pt/vs_code_extension.md +46 -107
  222. package/docs/ru/component_i18n.md +186 -0
  223. package/docs/ru/intlayer_with_angular.md +2 -2
  224. package/docs/ru/intlayer_with_astro.md +246 -0
  225. package/docs/ru/intlayer_with_create_react_app.md +3 -2
  226. package/docs/ru/intlayer_with_express.md +2 -2
  227. package/docs/ru/intlayer_with_nestjs.md +2 -2
  228. package/docs/ru/intlayer_with_nextjs_14.md +2 -2
  229. package/docs/ru/intlayer_with_nextjs_15.md +2 -2
  230. package/docs/ru/intlayer_with_nextjs_page_router.md +2 -2
  231. package/docs/ru/intlayer_with_nuxt.md +2 -2
  232. package/docs/ru/intlayer_with_react_native+expo.md +11 -20
  233. package/docs/ru/intlayer_with_react_router_v7.md +192 -238
  234. package/docs/ru/intlayer_with_tanstack.md +197 -269
  235. package/docs/ru/intlayer_with_vite+preact.md +9 -9
  236. package/docs/ru/intlayer_with_vite+react.md +9 -9
  237. package/docs/ru/intlayer_with_vite+vue.md +11 -11
  238. package/docs/ru/vs_code_extension.md +48 -109
  239. package/docs/tr/component_i18n.md +186 -0
  240. package/docs/tr/how_works_intlayer.md +1 -1
  241. package/docs/tr/index.md +1 -1
  242. package/docs/tr/intlayer_cli.md +1 -1
  243. package/docs/tr/intlayer_with_angular.md +4 -4
  244. package/docs/tr/intlayer_with_astro.md +246 -0
  245. package/docs/tr/intlayer_with_create_react_app.md +4 -4
  246. package/docs/tr/intlayer_with_express.md +3 -3
  247. package/docs/tr/intlayer_with_lynx+react.md +1 -1
  248. package/docs/tr/intlayer_with_nestjs.md +2 -2
  249. package/docs/tr/intlayer_with_nextjs_14.md +2 -2
  250. package/docs/tr/intlayer_with_nextjs_15.md +4 -4
  251. package/docs/tr/intlayer_with_nextjs_page_router.md +5 -5
  252. package/docs/tr/intlayer_with_nuxt.md +4 -4
  253. package/docs/tr/intlayer_with_react_native+expo.md +12 -21
  254. package/docs/tr/intlayer_with_react_router_v7.md +222 -267
  255. package/docs/tr/intlayer_with_tanstack.md +400 -303
  256. package/docs/tr/intlayer_with_vite+preact.md +12 -12
  257. package/docs/tr/intlayer_with_vite+react.md +12 -12
  258. package/docs/tr/intlayer_with_vite+solid.md +2 -2
  259. package/docs/tr/intlayer_with_vite+svelte.md +2 -2
  260. package/docs/tr/intlayer_with_vite+vue.md +12 -12
  261. package/docs/tr/introduction.md +1 -1
  262. package/docs/tr/packages/react-intlayer/useDictionary.md +1 -1
  263. package/docs/tr/packages/react-intlayer/useI18n.md +1 -1
  264. package/docs/tr/roadmap.md +1 -1
  265. package/docs/tr/vs_code_extension.md +54 -115
  266. package/docs/zh/component_i18n.md +186 -0
  267. package/docs/zh/intlayer_with_angular.md +2 -2
  268. package/docs/zh/intlayer_with_astro.md +246 -0
  269. package/docs/zh/intlayer_with_create_react_app.md +3 -2
  270. package/docs/zh/intlayer_with_express.md +2 -2
  271. package/docs/zh/intlayer_with_nestjs.md +2 -2
  272. package/docs/zh/intlayer_with_nextjs_14.md +2 -2
  273. package/docs/zh/intlayer_with_nextjs_15.md +2 -2
  274. package/docs/zh/intlayer_with_nextjs_page_router.md +2 -2
  275. package/docs/zh/intlayer_with_nuxt.md +2 -2
  276. package/docs/zh/intlayer_with_react_native+expo.md +19 -28
  277. package/docs/zh/intlayer_with_react_router_v7.md +200 -248
  278. package/docs/zh/intlayer_with_tanstack.md +208 -283
  279. package/docs/zh/intlayer_with_vite+preact.md +9 -9
  280. package/docs/zh/intlayer_with_vite+react.md +9 -9
  281. package/docs/zh/intlayer_with_vite+vue.md +9 -9
  282. package/docs/zh/vs_code_extension.md +51 -105
  283. package/package.json +10 -10
  284. package/src/generated/docs.entry.ts +32 -0
@@ -0,0 +1,186 @@
1
+ ---
2
+ createdAt: 2024-03-07
3
+ updatedAt: 2025-09-30
4
+ title: Make a component multilingual (i18n library) in React and Next.js
5
+ description: Learn how to declare and retrieve localised content to build a multilingual React or Next.js component with Intlayer.
6
+ keywords:
7
+ - i18n
8
+ - component
9
+ - react
10
+ - multilingual
11
+ - next.js
12
+ - intlayer
13
+ slugs:
14
+ - doc
15
+ - component
16
+ - i18n
17
+ applicationTemplate: https://github.com/aymericzip/intlayer-vite-react-template
18
+ youtubeVideo: https://www.youtube.com/watch?v=dS9L7uJeak4
19
+ ---
20
+
21
+ # How to make a component multilingual (i18n) with Intlayer
22
+
23
+ This guide shows the minimal steps to make a UI component multilingual in two common setups:
24
+
25
+ - React (Vite/SPA)
26
+ - Next.js (App Router)
27
+
28
+ You will first declare your content, then retrieve it in your component.
29
+
30
+ ## 1) Declare your content (shared for React and Next.js)
31
+
32
+ Create a content declaration file near your component. This keeps translations close to where they are used and enables type safety.
33
+
34
+ ```ts fileName="component.content.ts"
35
+ import { t, type Dictionary } from "intlayer";
36
+
37
+ const componentContent = {
38
+ key: "component-example",
39
+ content: {
40
+ title: t({
41
+ en: "Hello",
42
+ fr: "Bonjour",
43
+ es: "Hola",
44
+ }),
45
+ description: t({
46
+ en: "A multilingual React component",
47
+ fr: "Un composant React multilingue",
48
+ es: "Un componente React multilingüe",
49
+ }),
50
+ },
51
+ } satisfies Dictionary;
52
+
53
+ export default componentContent;
54
+ ```
55
+
56
+ JSON is also supported if you prefer configuration files.
57
+
58
+ ```json fileName="component.content.json"
59
+ {
60
+ "$schema": "https://intlayer.org/schema.json",
61
+ "key": "component-example",
62
+ "content": {
63
+ "title": {
64
+ "nodeType": "translation",
65
+ "translation": { "en": "Hello", "fr": "Bonjour", "es": "Hola" }
66
+ },
67
+ "description": {
68
+ "nodeType": "translation",
69
+ "translation": {
70
+ "en": "A multilingual React component",
71
+ "fr": "Un composant React multilingue",
72
+ "es": "Un componente React multilingüe"
73
+ }
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ ## 2) Retrieve your content
80
+
81
+ ### Case A — React app (Vite/SPA)
82
+
83
+ Default approach: use `useIntlayer` to retrieve by key. This keeps components lean and typed.
84
+
85
+ ```tsx fileName="ComponentExample.tsx"
86
+ import { useIntlayer } from "react-intlayer";
87
+
88
+ export function ComponentExample() {
89
+ const content = useIntlayer("component-example");
90
+ return (
91
+ <div>
92
+ <h1>{content.title}</h1>
93
+ <p>{content.description}</p>
94
+ </div>
95
+ );
96
+ }
97
+ ```
98
+
99
+ Server-side rendering or outside provider: use `react-intlayer/server` and pass an explicit `locale` when required.
100
+
101
+ ```tsx fileName="ServerRenderedExample.tsx"
102
+ import { useIntlayer } from "react-intlayer/server";
103
+
104
+ export function ServerRenderedExample({ locale }: { locale: string }) {
105
+ const content = useIntlayer("component-example", locale);
106
+ return (
107
+ <>
108
+ <h1>{content.title}</h1>
109
+ <p>{content.description}</p>
110
+ </>
111
+ );
112
+ }
113
+ ```
114
+
115
+ Alternative: `useDictionary` can read an entire declared object if you prefer collocating structure at the call site.
116
+
117
+ ```tsx fileName="ComponentWithDictionary.tsx"
118
+ import { useDictionary } from "react-intlayer";
119
+ import componentContent from "./component.content";
120
+
121
+ export function ComponentWithDictionary() {
122
+ const { title, description } = useDictionary(componentContent);
123
+ return (
124
+ <div>
125
+ <h1>{title}</h1>
126
+ <p>{description}</p>
127
+ </div>
128
+ );
129
+ }
130
+ ```
131
+
132
+ ### Case B — Next.js (App Router)
133
+
134
+ Prefer server components for data safety and performance. Use `useIntlayer` from `next-intlayer/server` in server files, and `useIntlayer` from `next-intlayer` in client components.
135
+
136
+ ```tsx fileName="app/[locale]/example/ServerComponent.tsx"
137
+ import { useIntlayer } from "next-intlayer/server";
138
+
139
+ export default function ServerComponent() {
140
+ const content = useIntlayer("component-example");
141
+ return (
142
+ <>
143
+ <h1>{content.title}</h1>
144
+ <p>{content.description}</p>
145
+ </>
146
+ );
147
+ }
148
+ ```
149
+
150
+ ```tsx fileName="app/[locale]/example/ClientComponent.tsx"
151
+ "use client";
152
+
153
+ import { useIntlayer } from "next-intlayer";
154
+
155
+ export function ClientComponent() {
156
+ const content = useIntlayer("component-example");
157
+ return (
158
+ <div>
159
+ <h1>{content.title}</h1>
160
+ <p>{content.description}</p>
161
+ </div>
162
+ );
163
+ }
164
+ ```
165
+
166
+ Tip: For page metadata and SEO, you can also fetch content using `getIntlayer` and generate multilingual URLs via `getMultilingualUrls`.
167
+
168
+ ## Why Intlayer’s component approach is best
169
+
170
+ - **Collocation**: Content declarations live near components, reducing drift and improving reuse across design systems.
171
+ - **Type safety**: Keys and structures are strongly typed; missing translations surface at build-time rather than at runtime.
172
+ - **Server-first**: Works natively in server components for better security and performance; client hooks remain ergonomic.
173
+ - **Tree-shaking**: Only content used by the component is bundled, keeping payloads small in large applications.
174
+ - **DX & tooling**: Built-in middleware, SEO helpers, and optional Visual Editor/AI translations streamline everyday work.
175
+
176
+ See the comparisons and patterns in the Next.js-focused roundup: https://intlayer.org/blog/next-i18next-vs-next-intl-vs-intlayer
177
+
178
+ ## Related guides and references
179
+
180
+ - React setup (Vite): https://intlayer.org/doc/environment/vite-and-react
181
+ - React Router v7: https://intlayer.org/doc/environment/vite-and-react/react-router-v7
182
+ - TanStack Start: https://intlayer.org/doc/environment/vite-and-react/tanstack-start
183
+ - Next.js setup: https://intlayer.org/doc/environment/nextjs
184
+ - Why Intlayer vs. next-intl vs. next-i18next: https://intlayer.org/blog/next-i18next-vs-next-intl-vs-intlayer
185
+
186
+ These pages include end-to-end setup, providers, routing, and SEO helpers.
@@ -310,7 +310,7 @@ export default appContent;
310
310
 
311
311
  > Your content declarations can be defined anywhere in your application as soon they are included into 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}`).
312
312
 
313
- > For more details, refer to the [content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/get_started.md).
313
+ > For more details, refer to the [content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md).
314
314
 
315
315
  ### Step 5: Utilize Intlayer in Your Code
316
316
 
@@ -663,9 +663,9 @@ For more complex scenarios, you can create a pipe to safely render the HTML.
663
663
 
664
664
  Intlayer uses module augmentation to get benefits of TypeScript and make your codebase stronger.
665
665
 
666
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png)
666
+ ![Autocompletion](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
667
667
 
668
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png)
668
+ ![Translation error](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
669
669
 
670
670
  Ensure your TypeScript configuration includes the autogenerated types.
671
671
 
@@ -0,0 +1,246 @@
1
+ ---
2
+ createdAt: 2024-03-07
3
+ updatedAt: 2025-10-03
4
+ title: Getting Started with Intlayer in Astro
5
+ description: Learn how to add internationalisation (i18n) to your Vite and React application using Intlayer. Follow this guide to make your app multilingual.
6
+ keywords:
7
+ - Internationalisation
8
+ - Documentation
9
+ - Intlayer
10
+ - Vite
11
+ - React
12
+ - i18n
13
+ - JavaScript
14
+ slugs:
15
+ - doc
16
+ - environment
17
+ - astro
18
+ applicationTemplate: https://github.com/aymericzip/intlayer-astro-template
19
+ ---
20
+
21
+ # Getting Started Internationalising (i18n) with Intlayer and Astro
22
+
23
+ See [Application Template](https://github.com/aymericzip/intlayer-astro-template) on GitHub.
24
+
25
+ ## What is Intlayer?
26
+
27
+ **Intlayer** is an innovative, open-source internationalisation (i18n) library designed to simplify multilingual support in modern web applications.
28
+
29
+ With Intlayer, you can:
30
+
31
+ - **Easily manage translations** using declarative dictionaries at the component level.
32
+ - **Dynamically localise metadata**, routes, and content.
33
+ - **Ensure TypeScript support** with autogenerated types, improving autocompletion and error detection.
34
+ - **Benefit from advanced features**, like dynamic locale detection and switching.
35
+
36
+ ---
37
+
38
+ ## Step-by-Step Guide to Set Up Intlayer in Astro
39
+
40
+ ### Step 1: Install Dependencies
41
+
42
+ Install the necessary packages using your package manager:
43
+
44
+ ```bash packageManager="npm"
45
+ npm install intlayer astro-intlayer
46
+ # Optional: add React island support
47
+ npm install react react-dom react-intlayer @astrojs/react
48
+ ```
49
+
50
+ ```bash packageManager="pnpm"
51
+ pnpm add intlayer astro-intlayer
52
+ # Optional: add React island support
53
+ pnpm add react react-dom react-intlayer @astrojs/react
54
+ ```
55
+
56
+ ```bash packageManager="yarn"
57
+ yarn add intlayer astro-intlayer
58
+ # Optional: add React island support
59
+ yarn add react react-dom react-intlayer @astrojs/react
60
+ ```
61
+
62
+ - **intlayer**
63
+ 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).
64
+
65
+ - **astro-intlayer**
66
+ Includes the Astro integration plugin for integrating Intlayer with the [Vite bundler](https://vite.dev/guide/why.html#why-bundle-for-production), as well as middleware for detecting the user's preferred locale, managing cookies, and handling URL redirection.
67
+
68
+ ### Step 2: Configuration of your project
69
+
70
+ Create a config file to configure the languages of your application:
71
+
72
+ ```typescript fileName="intlayer.config.ts"
73
+ import { Locales, type IntlayerConfig } from "intlayer";
74
+
75
+ const config: IntlayerConfig = {
76
+ internationalization: {
77
+ locales: [
78
+ Locales.ENGLISH,
79
+ Locales.FRENCH,
80
+ Locales.SPANISH,
81
+ // Your other locales
82
+ ],
83
+ defaultLocale: Locales.ENGLISH,
84
+ },
85
+ };
86
+
87
+ export default config;
88
+ ```
89
+
90
+ > 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).
91
+
92
+ ### Step 3: Integrate Intlayer in Your Astro Configuration
93
+
94
+ Add the intlayer plugin into your configuration.
95
+
96
+ ```typescript fileName="astro.config.ts"
97
+ // @ts-check
98
+
99
+ import { intlayer } from "astro-intlayer";
100
+ import { defineConfig } from "astro/config";
101
+
102
+ // https://astro.build/config
103
+ export default defineConfig({
104
+ integrations: [intlayer()],
105
+ });
106
+ ```
107
+
108
+ > The `intlayer()` Astro integration plugin is used to integrate Intlayer with Astro. It ensures the building of content declaration files and monitors them in development mode. It defines Intlayer environment variables within the Astro application. Additionally, it provides aliases to optimise performance.
109
+
110
+ ### Step 4: Declare Your Content
111
+
112
+ Create and manage your content declarations to store translations:
113
+
114
+ ```tsx fileName="src/app.content.tsx"
115
+ import { t, type Dictionary } from "intlayer";
116
+ import type { ReactNode } from "react";
117
+
118
+ const appContent = {
119
+ key: "app",
120
+ content: {
121
+ title: t({
122
+ en: "Hello World",
123
+ fr: "Bonjour le monde",
124
+ es: "Hola mundo",
125
+ }),
126
+ },
127
+ } satisfies Dictionary;
128
+
129
+ export default appContent;
130
+ ```
131
+
132
+ > Your content declarations can be defined anywhere in your application as soon 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}`).
133
+
134
+ > For more details, refer to the [content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/dictionary/get_started.md).
135
+
136
+ ### Step 5: Use your content in Astro
137
+
138
+ You can consume dictionaries directly in `.astro` files using the core helpers exported by `intlayer`.
139
+
140
+ ```astro fileName="src/pages/index.astro"
141
+ <!-- astro -->
142
+ ---
143
+ import { getIntlayer } from "intlayer";
144
+ import appContent from "../app.content";
145
+
146
+ const { title } = getIntlayer('app');
147
+ ---
148
+
149
+ <html lang="en">
150
+ <head>
151
+ <meta charset="utf-8" />
152
+ <meta name="viewport" content="width=device-width" />
153
+ <title>{title}</title>
154
+ </head>
155
+ <body>
156
+ <h1>{title}</h1>
157
+ </body>
158
+ </html>
159
+ ```
160
+
161
+ ### Step 6: Localised routing
162
+
163
+ Create a dynamic route segment to serve localised pages, for example `src/pages/[locale]/index.astro`:
164
+
165
+ ```astro fileName="src/pages/[locale]/index.astro"
166
+ <!-- astro -->
167
+ ---
168
+ import { getIntlayer } from "intlayer";
169
+
170
+ const { title } = getIntlayer('app');
171
+ ---
172
+
173
+ <h1>{title}</h1>
174
+ ```
175
+
176
+ The Astro integration adds a Vite middleware during development that helps with locale-aware routing and environment definitions. You can still link between locales using your own logic, or utility functions like `getLocalizedUrl` from `intlayer`.
177
+
178
+ ### Step 7: Continue using your favourite framework
179
+
180
+ Continue using your favourite framework to build your application.
181
+
182
+ - Intlayer + React: [Intlayer with React](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/intlayer_with_vite+react.md)
183
+ - Intlayer + Vue: [Intlayer with Vue](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/intlayer_with_vite+vue.md)
184
+ - Intlayer + Svelte: [Intlayer with Svelte](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/intlayer_with_vite+svelte.md)
185
+ - Intlayer + Solid: [Intlayer with Solid](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/intlayer_with_vite+solid.md)
186
+ - Intlayer + Preact: [Intlayer with Preact](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/intlayer_with_vite+preact.md)
187
+
188
+ ### Configure TypeScript
189
+
190
+ Intlayer uses module augmentation to benefit from TypeScript and strengthen your codebase.
191
+
192
+ ![Autocompletion](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
193
+
194
+ ![Translation error](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
195
+
196
+ Ensure your TypeScript configuration includes the autogenerated types.
197
+
198
+ ```json5 fileName="tsconfig.json"
199
+ {
200
+ // ... Your existing TypeScript configurations
201
+ "include": [
202
+ // ... Your existing TypeScript configurations
203
+ ".intlayer/**/*.ts", // Include the auto-generated types
204
+ ],
205
+ }
206
+ ```
207
+
208
+ ### Git Configuration
209
+
210
+ It is recommended to ignore the files generated by Intlayer. This allows you to avoid committing them to your Git repository.
211
+
212
+ To do this, you can add the following instructions to your `.gitignore` file:
213
+
214
+ ```plaintext
215
+ # Ignore the files generated by Intlayer
216
+ .intlayer
217
+ ```
218
+
219
+ ### VS Code Extension
220
+
221
+ To enhance your development experience with Intlayer, you can install the official **Intlayer VS Code Extension**.
222
+
223
+ [Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
224
+
225
+ This extension provides:
226
+
227
+ - **Autocompletion** for translation keys.
228
+ - **Real-time error detection** for missing translations.
229
+ - **Inline previews** of translated content.
230
+ - **Quick actions** to easily create and update translations.
231
+
232
+ For more details on how to use the extension, refer to the [Intlayer VS Code Extension documentation](https://intlayer.org/doc/vs-code-extension).
233
+
234
+ ---
235
+
236
+ ### Go Further
237
+
238
+ 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).
239
+
240
+ ---
241
+
242
+ ## Doc History
243
+
244
+ | Version | Date | Changes |
245
+ | ------- | ---------- | -------------------------------------------- |
246
+ | 6.2.0 | 2025-10-03 | Refresh for Astro integration, config, usage |
@@ -1307,9 +1307,10 @@ By applying these changes, your application will:
1307
1307
 
1308
1308
  Intlayer use module augmentation to get benefits of TypeScript and make your codebase stronger.
1309
1309
 
1310
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png)
1310
+ ![Autocompletion](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
1311
+
1312
+ ![Translation error](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
1311
1313
 
1312
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png)
1313
1314
  module.exports = App;
1314
1315
 
1315
1316
  By applying these changes, your application will:
@@ -1322,9 +1323,9 @@ By applying these changes, your application will:
1322
1323
 
1323
1324
  Intlayer uses module augmentation to get the benefits of TypeScript and make your codebase stronger.
1324
1325
 
1325
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png)
1326
+ ![Autocompletion](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
1326
1327
 
1327
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png)
1328
+ ![Translation error](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
1328
1329
 
1329
1330
  Ensure your TypeScript configuration includes the autogenerated types.
1330
1331
 
@@ -369,9 +369,9 @@ By default, `express-intlayer` will interpret the `Accept-Language` header to de
369
369
 
370
370
  `express-intlayer` leverages the robust capabilities of TypeScript to enhance the internationalisation process. TypeScript's static typing ensures that every translation key is accounted for, reducing the risk of missing translations and improving maintainability.
371
371
 
372
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png)
372
+ ![Autocompletion](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
373
373
 
374
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png)
374
+ ![Translation error](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
375
375
 
376
376
  Ensure the autogenerated types (by default at ./types/intlayer.d.ts) are included in your tsconfig.json file.
377
377
 
@@ -219,9 +219,9 @@ By default, `express-intlayer` will interpret the `Accept-Language` header to de
219
219
 
220
220
  `express-intlayer` leverages the robust capabilities of TypeScript to enhance the internationalisation process. TypeScript's static typing ensures that every translation key is accounted for, reducing the risk of missing translations and improving maintainability.
221
221
 
222
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png)
222
+ ![Autocompletion](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
223
223
 
224
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png)
224
+ ![Translation error](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
225
225
 
226
226
  Ensure the autogenerated types (by default at ./types/intlayer.d.ts) are included in your tsconfig.json file.
227
227
 
@@ -58,7 +58,7 @@ yarn add intlayer next-intlayer
58
58
 
59
59
  - **intlayer**
60
60
 
61
- The core package that provides internationalization tools for configuration management, translation, [content declaration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/get_started.md), transpilation, and [CLI commands](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_cli.md).
61
+ The core package that provides internationalization tools for configuration management, translation, [content declaration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md), transpilation, and [CLI commands](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_cli.md).
62
62
 
63
63
  - **next-intlayer**
64
64
 
@@ -397,7 +397,7 @@ module.exports = pageContent;
397
397
 
398
398
  > Your content declarations can be defined anywhere in your application as soon they are included into 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}`).
399
399
 
400
- > For more details, refer to the [content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/get_started.md).
400
+ > For more details, refer to the [content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md).
401
401
 
402
402
  ### Step 7: Utilize Content in Your Code
403
403
 
@@ -1407,9 +1407,9 @@ yarn add @intlayer/swc --save-dev
1407
1407
 
1408
1408
  Intlayer use module augmentation to get benefits of TypeScript and make your codebase stronger.
1409
1409
 
1410
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png)
1410
+ ![Autocompletion](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
1411
1411
 
1412
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png)
1412
+ ![Translation error](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
1413
1413
 
1414
1414
  Ensure your TypeScript configuration includes the autogenerated types.
1415
1415
 
@@ -1482,9 +1482,9 @@ yarn add @intlayer/swc --save-dev
1482
1482
 
1483
1483
  Intlayer uses module augmentation to benefit from TypeScript and make your codebase stronger.
1484
1484
 
1485
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png)
1485
+ ![Autocompletion](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
1486
1486
 
1487
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png)
1487
+ ![Translation error](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
1488
1488
 
1489
1489
  Ensure your TypeScript configuration includes the autogenerated types.
1490
1490
 
@@ -1434,9 +1434,9 @@ yarn add @intlayer/swc --save-dev
1434
1434
 
1435
1435
  Intlayer uses module augmentation to leverage the benefits of TypeScript and strengthen your codebase.
1436
1436
 
1437
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png)
1437
+ ![Autocompletion](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
1438
1438
 
1439
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png)
1439
+ ![Translation error](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
1440
1440
 
1441
1441
  Ensure your TypeScript configuration includes the autogenerated types.
1442
1442
 
@@ -753,9 +753,9 @@ module.exports = aboutMetaContent;
753
753
 
754
754
  Intlayer uses module augmentation to gain the benefits of TypeScript and strengthen your codebase.
755
755
 
756
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png)
756
+ ![Autocompletion](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
757
757
 
758
- ![alt text](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png)
758
+ ![Translation error](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
759
759
 
760
760
  Ensure your TypeScript configuration includes the autogenerated types.
761
761
 
@@ -148,28 +148,25 @@ module.exports = (async () => {
148
148
 
149
149
  ## Step 4: Add the Intlayer provider
150
150
 
151
- To keep the user language synchronised across your application, you need to wrap your root component with the `IntlayerProvider` component from `react-intlayer`.
151
+ To keep synchronized the user language across your application, you need to wrap your root component with the `IntlayerProvider` component from `react-intlayer-native`.
152
152
 
153
- Additionally, you need to add the `intlayerPolyfill` function to your `index.js` file to ensure that Intlayer functions correctly.
153
+ > Make sure to use the provider from `react-native-intlayer` instead of `react-intlayer`. The export from `react-native-intlayer` includes polyfills for the web API.
154
154
 
155
155
  ```tsx fileName="app/_layout.tsx" codeFormat="typescript"
156
156
  import { Stack } from "expo-router";
157
157
  import { getLocales } from "expo-localization";
158
- import { IntlayerProviderContent } from "react-intlayer";
159
- import { intlayerPolyfill } from "react-native-intlayer";
158
+ import { IntlayerProvider } from "react-native-intlayer";
160
159
  import { type FC } from "react";
161
160
 
162
- intlayerPolyfill();
163
-
164
161
  const getDeviceLocale = () => getLocales()[0]?.languageTag;
165
162
 
166
163
  const RootLayout: FC = () => {
167
164
  return (
168
- <IntlayerProviderContent defaultLocale={getDeviceLocale()}>
165
+ <IntlayerProvider defaultLocale={getDeviceLocale()}>
169
166
  <Stack>
170
167
  <Stack.Screen name="(tabs)" options={{ headerShown: false }} />
171
168
  </Stack>
172
- </IntlayerProviderContent>
169
+ </IntlayerProvider>
173
170
  );
174
171
  };
175
172
 
@@ -179,20 +176,17 @@ export default RootLayout;
179
176
  ```jsx fileName="app/_layout.mjx" codeFormat="esm"
180
177
  import { Stack } from "expo-router";
181
178
  import { getLocales } from "expo-localization";
182
- import { IntlayerProviderContent } from "react-intlayer";
183
- import { intlayerPolyfill } from "react-native-intlayer";
184
-
185
- intlayerPolyfill();
179
+ import { IntlayerProvider } from "react-native-intlayer";
186
180
 
187
181
  const getDeviceLocale = () => getLocales()[0]?.languageTag;
188
182
 
189
183
  const RootLayout = () => {
190
184
  return (
191
- <IntlayerProviderContent defaultLocale={getDeviceLocale()}>
185
+ <IntlayerProvider defaultLocale={getDeviceLocale()}>
192
186
  <Stack>
193
187
  <Stack.Screen name="(tabs)" options={{ headerShown: false }} />
194
188
  </Stack>
195
- </IntlayerProviderContent>
189
+ </IntlayerProvider>
196
190
  );
197
191
  };
198
192
 
@@ -202,21 +196,18 @@ export default RootLayout;
202
196
  ```jsx fileName="app/_layout.cjx" codeFormat="commonjs"
203
197
  const { Stack } = require("expo-router");
204
198
  const { getLocales } = require("expo-localization");
205
- const { IntlayerProviderContent } = require("react-intlayer");
206
- const { intlayerPolyfill } = require("react-native-intlayer");
207
-
208
- intlayerPolyfill();
199
+ const { IntlayerProvider } = require("react-native-intlayer");
209
200
 
210
201
  // Function to get the device's locale
211
202
  const getDeviceLocale = () => getLocales()[0]?.languageTag;
212
203
 
213
204
  const RootLayout = () => {
214
205
  return (
215
- <IntlayerProviderContent defaultLocale={getDeviceLocale()}>
206
+ <IntlayerProvider defaultLocale={getDeviceLocale()}>
216
207
  <Stack>
217
208
  <Stack.Screen name="(tabs)" options={{ headerShown: false }} />
218
209
  </Stack>
219
- </IntlayerProviderContent>
210
+ </IntlayerProvider>
220
211
  );
221
212
  };
222
213