@intlayer/docs 6.1.6-canary.0 → 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 (242) hide show
  1. package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +71 -80
  2. package/dist/cjs/generated/docs.entry.cjs +16 -0
  3. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  4. package/dist/esm/generated/docs.entry.mjs +16 -0
  5. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  6. package/dist/types/generated/docs.entry.d.ts +1 -0
  7. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  8. package/docs/ar/intlayer_with_angular.md +2 -2
  9. package/docs/ar/intlayer_with_astro.md +246 -0
  10. package/docs/ar/intlayer_with_create_react_app.md +3 -2
  11. package/docs/ar/intlayer_with_express.md +2 -2
  12. package/docs/ar/intlayer_with_nestjs.md +2 -2
  13. package/docs/ar/intlayer_with_nextjs_14.md +2 -2
  14. package/docs/ar/intlayer_with_nextjs_15.md +2 -2
  15. package/docs/ar/intlayer_with_nextjs_page_router.md +2 -2
  16. package/docs/ar/intlayer_with_nuxt.md +2 -2
  17. package/docs/ar/intlayer_with_react_native+expo.md +11 -20
  18. package/docs/ar/intlayer_with_react_router_v7.md +195 -241
  19. package/docs/ar/intlayer_with_tanstack.md +198 -272
  20. package/docs/ar/intlayer_with_vite+preact.md +9 -9
  21. package/docs/ar/intlayer_with_vite+react.md +7 -7
  22. package/docs/ar/intlayer_with_vite+vue.md +9 -9
  23. package/docs/de/intlayer_with_angular.md +2 -2
  24. package/docs/de/intlayer_with_astro.md +246 -0
  25. package/docs/de/intlayer_with_create_react_app.md +2 -2
  26. package/docs/de/intlayer_with_express.md +2 -2
  27. package/docs/de/intlayer_with_nestjs.md +2 -2
  28. package/docs/de/intlayer_with_nextjs_14.md +2 -2
  29. package/docs/de/intlayer_with_nextjs_15.md +2 -2
  30. package/docs/de/intlayer_with_nextjs_page_router.md +2 -2
  31. package/docs/de/intlayer_with_nuxt.md +2 -2
  32. package/docs/de/intlayer_with_react_native+expo.md +11 -20
  33. package/docs/de/intlayer_with_react_router_v7.md +193 -242
  34. package/docs/de/intlayer_with_tanstack.md +194 -266
  35. package/docs/de/intlayer_with_vite+preact.md +9 -9
  36. package/docs/de/intlayer_with_vite+react.md +9 -9
  37. package/docs/de/intlayer_with_vite+vue.md +11 -11
  38. package/docs/de/packages/vite-intlayer/index.md +3 -3
  39. package/docs/en/how_works_intlayer.md +1 -1
  40. package/docs/en/index.md +1 -1
  41. package/docs/en/intlayer_cli.md +1 -1
  42. package/docs/en/intlayer_with_angular.md +4 -4
  43. package/docs/en/intlayer_with_astro.md +246 -0
  44. package/docs/en/intlayer_with_create_react_app.md +4 -4
  45. package/docs/en/intlayer_with_express.md +3 -3
  46. package/docs/en/intlayer_with_lynx+react.md +1 -1
  47. package/docs/en/intlayer_with_nestjs.md +2 -2
  48. package/docs/en/intlayer_with_nextjs_14.md +13 -4
  49. package/docs/en/intlayer_with_nextjs_15.md +13 -4
  50. package/docs/en/intlayer_with_nextjs_page_router.md +5 -5
  51. package/docs/en/intlayer_with_nuxt.md +4 -4
  52. package/docs/en/intlayer_with_react_native+expo.md +46 -24
  53. package/docs/en/intlayer_with_react_router_v7.md +164 -211
  54. package/docs/en/intlayer_with_tanstack.md +166 -241
  55. package/docs/en/intlayer_with_vite+preact.md +12 -12
  56. package/docs/en/intlayer_with_vite+react.md +12 -12
  57. package/docs/en/intlayer_with_vite+solid.md +2 -2
  58. package/docs/en/intlayer_with_vite+svelte.md +2 -2
  59. package/docs/en/intlayer_with_vite+vue.md +12 -12
  60. package/docs/en/introduction.md +1 -1
  61. package/docs/en/packages/next-intlayer/useDictionary.md +1 -1
  62. package/docs/en/packages/next-intlayer/useIntlayer.md +1 -1
  63. package/docs/en/packages/react-intlayer/useDictionary.md +1 -1
  64. package/docs/en/packages/react-intlayer/useI18n.md +1 -1
  65. package/docs/en/packages/react-intlayer/useIntlayer.md +1 -1
  66. package/docs/en/releases/v6.md +1 -0
  67. package/docs/en/roadmap.md +1 -1
  68. package/docs/en-GB/intlayer_with_angular.md +3 -3
  69. package/docs/en-GB/intlayer_with_astro.md +246 -0
  70. package/docs/en-GB/intlayer_with_create_react_app.md +5 -4
  71. package/docs/en-GB/intlayer_with_express.md +2 -2
  72. package/docs/en-GB/intlayer_with_nestjs.md +2 -2
  73. package/docs/en-GB/intlayer_with_nextjs_14.md +4 -4
  74. package/docs/en-GB/intlayer_with_nextjs_15.md +2 -2
  75. package/docs/en-GB/intlayer_with_nextjs_page_router.md +2 -2
  76. package/docs/en-GB/intlayer_with_nuxt.md +2 -2
  77. package/docs/en-GB/intlayer_with_react_native+expo.md +11 -20
  78. package/docs/en-GB/intlayer_with_react_router_v7.md +171 -220
  79. package/docs/en-GB/intlayer_with_tanstack.md +174 -248
  80. package/docs/en-GB/intlayer_with_vite+preact.md +9 -9
  81. package/docs/en-GB/intlayer_with_vite+react.md +9 -9
  82. package/docs/en-GB/intlayer_with_vite+vue.md +11 -11
  83. package/docs/en-GB/packages/next-intlayer/useIntlayer.md +1 -1
  84. package/docs/en-GB/packages/react-intlayer/useIntlayer.md +1 -1
  85. package/docs/es/intlayer_with_angular.md +2 -2
  86. package/docs/es/intlayer_with_astro.md +246 -0
  87. package/docs/es/intlayer_with_create_react_app.md +3 -2
  88. package/docs/es/intlayer_with_express.md +2 -2
  89. package/docs/es/intlayer_with_nextjs_14.md +2 -2
  90. package/docs/es/intlayer_with_nextjs_15.md +2 -2
  91. package/docs/es/intlayer_with_react_native+expo.md +11 -20
  92. package/docs/es/intlayer_with_react_router_v7.md +188 -232
  93. package/docs/es/intlayer_with_tanstack.md +203 -273
  94. package/docs/es/intlayer_with_vite+preact.md +7 -7
  95. package/docs/es/intlayer_with_vite+react.md +7 -7
  96. package/docs/es/intlayer_with_vite+vue.md +9 -9
  97. package/docs/fr/intlayer_with_angular.md +2 -2
  98. package/docs/fr/intlayer_with_astro.md +246 -0
  99. package/docs/fr/intlayer_with_create_react_app.md +3 -2
  100. package/docs/fr/intlayer_with_express.md +2 -2
  101. package/docs/fr/intlayer_with_nestjs.md +2 -2
  102. package/docs/fr/intlayer_with_nextjs_14.md +2 -2
  103. package/docs/fr/intlayer_with_react_native+expo.md +11 -20
  104. package/docs/fr/intlayer_with_react_router_v7.md +188 -248
  105. package/docs/fr/intlayer_with_tanstack.md +192 -265
  106. package/docs/fr/intlayer_with_vite+preact.md +7 -7
  107. package/docs/fr/intlayer_with_vite+react.md +7 -7
  108. package/docs/fr/intlayer_with_vite+vue.md +9 -9
  109. package/docs/hi/intlayer_cli.md +1 -4
  110. package/docs/hi/intlayer_with_angular.md +2 -2
  111. package/docs/hi/intlayer_with_astro.md +246 -0
  112. package/docs/hi/intlayer_with_create_react_app.md +2 -2
  113. package/docs/hi/intlayer_with_express.md +2 -2
  114. package/docs/hi/intlayer_with_nestjs.md +2 -2
  115. package/docs/hi/intlayer_with_nextjs_14.md +2 -2
  116. package/docs/hi/intlayer_with_nextjs_15.md +2 -2
  117. package/docs/hi/intlayer_with_nextjs_page_router.md +2 -2
  118. package/docs/hi/intlayer_with_nuxt.md +2 -2
  119. package/docs/hi/intlayer_with_react_native+expo.md +11 -20
  120. package/docs/hi/intlayer_with_react_router_v7.md +199 -243
  121. package/docs/hi/intlayer_with_tanstack.md +210 -285
  122. package/docs/hi/intlayer_with_vite+preact.md +9 -9
  123. package/docs/hi/intlayer_with_vite+react.md +9 -9
  124. package/docs/hi/intlayer_with_vite+solid.md +1 -1
  125. package/docs/hi/intlayer_with_vite+vue.md +11 -11
  126. package/docs/it/intlayer_with_angular.md +2 -2
  127. package/docs/it/intlayer_with_astro.md +246 -0
  128. package/docs/it/intlayer_with_create_react_app.md +3 -2
  129. package/docs/it/intlayer_with_express.md +2 -2
  130. package/docs/it/intlayer_with_nestjs.md +2 -2
  131. package/docs/it/intlayer_with_nextjs_14.md +2 -2
  132. package/docs/it/intlayer_with_nextjs_15.md +2 -2
  133. package/docs/it/intlayer_with_nextjs_page_router.md +2 -2
  134. package/docs/it/intlayer_with_nuxt.md +2 -2
  135. package/docs/it/intlayer_with_react_native+expo.md +11 -21
  136. package/docs/it/intlayer_with_react_router_v7.md +195 -242
  137. package/docs/it/intlayer_with_tanstack.md +203 -267
  138. package/docs/it/intlayer_with_vite+preact.md +9 -9
  139. package/docs/it/intlayer_with_vite+react.md +13 -11
  140. package/docs/it/intlayer_with_vite+vue.md +11 -11
  141. package/docs/ja/intlayer_with_angular.md +2 -2
  142. package/docs/ja/intlayer_with_astro.md +246 -0
  143. package/docs/ja/intlayer_with_create_react_app.md +3 -2
  144. package/docs/ja/intlayer_with_express.md +2 -2
  145. package/docs/ja/intlayer_with_nestjs.md +2 -2
  146. package/docs/ja/intlayer_with_nextjs_14.md +2 -2
  147. package/docs/ja/intlayer_with_nextjs_15.md +2 -2
  148. package/docs/ja/intlayer_with_nextjs_page_router.md +2 -2
  149. package/docs/ja/intlayer_with_nuxt.md +2 -2
  150. package/docs/ja/intlayer_with_react_native+expo.md +18 -29
  151. package/docs/ja/intlayer_with_react_router_v7.md +204 -250
  152. package/docs/ja/intlayer_with_tanstack.md +218 -286
  153. package/docs/ja/intlayer_with_vite+preact.md +9 -9
  154. package/docs/ja/intlayer_with_vite+react.md +11 -11
  155. package/docs/ja/intlayer_with_vite+vue.md +11 -11
  156. package/docs/ko/intlayer_with_angular.md +2 -2
  157. package/docs/ko/intlayer_with_astro.md +246 -0
  158. package/docs/ko/intlayer_with_create_react_app.md +3 -2
  159. package/docs/ko/intlayer_with_express.md +2 -2
  160. package/docs/ko/intlayer_with_nestjs.md +2 -2
  161. package/docs/ko/intlayer_with_nextjs_14.md +2 -2
  162. package/docs/ko/intlayer_with_nextjs_15.md +2 -2
  163. package/docs/ko/intlayer_with_nextjs_page_router.md +2 -2
  164. package/docs/ko/intlayer_with_nuxt.md +2 -2
  165. package/docs/ko/intlayer_with_react_native+expo.md +19 -28
  166. package/docs/ko/intlayer_with_react_router_v7.md +190 -244
  167. package/docs/ko/intlayer_with_tanstack.md +200 -270
  168. package/docs/ko/intlayer_with_vite+preact.md +9 -9
  169. package/docs/ko/intlayer_with_vite+react.md +9 -9
  170. package/docs/ko/intlayer_with_vite+vue.md +11 -11
  171. package/docs/pt/intlayer_with_angular.md +2 -2
  172. package/docs/pt/intlayer_with_astro.md +246 -0
  173. package/docs/pt/intlayer_with_create_react_app.md +3 -2
  174. package/docs/pt/intlayer_with_express.md +2 -2
  175. package/docs/pt/intlayer_with_nestjs.md +2 -2
  176. package/docs/pt/intlayer_with_nextjs_14.md +2 -2
  177. package/docs/pt/intlayer_with_nextjs_15.md +2 -2
  178. package/docs/pt/intlayer_with_nextjs_page_router.md +2 -2
  179. package/docs/pt/intlayer_with_nuxt.md +2 -2
  180. package/docs/pt/intlayer_with_react_native+expo.md +11 -20
  181. package/docs/pt/intlayer_with_react_router_v7.md +7 -13
  182. package/docs/pt/intlayer_with_tanstack.md +183 -258
  183. package/docs/pt/intlayer_with_vite+preact.md +9 -9
  184. package/docs/pt/intlayer_with_vite+react.md +9 -9
  185. package/docs/pt/intlayer_with_vite+vue.md +9 -9
  186. package/docs/ru/intlayer_with_angular.md +2 -2
  187. package/docs/ru/intlayer_with_astro.md +246 -0
  188. package/docs/ru/intlayer_with_create_react_app.md +3 -2
  189. package/docs/ru/intlayer_with_express.md +2 -2
  190. package/docs/ru/intlayer_with_nestjs.md +2 -2
  191. package/docs/ru/intlayer_with_nextjs_14.md +2 -2
  192. package/docs/ru/intlayer_with_nextjs_15.md +2 -2
  193. package/docs/ru/intlayer_with_nextjs_page_router.md +2 -2
  194. package/docs/ru/intlayer_with_nuxt.md +2 -2
  195. package/docs/ru/intlayer_with_react_native+expo.md +11 -20
  196. package/docs/ru/intlayer_with_react_router_v7.md +192 -238
  197. package/docs/ru/intlayer_with_tanstack.md +197 -269
  198. package/docs/ru/intlayer_with_vite+preact.md +9 -9
  199. package/docs/ru/intlayer_with_vite+react.md +9 -9
  200. package/docs/ru/intlayer_with_vite+vue.md +11 -11
  201. package/docs/tr/how_works_intlayer.md +1 -1
  202. package/docs/tr/index.md +1 -1
  203. package/docs/tr/intlayer_cli.md +1 -1
  204. package/docs/tr/intlayer_with_angular.md +4 -4
  205. package/docs/tr/intlayer_with_astro.md +246 -0
  206. package/docs/tr/intlayer_with_create_react_app.md +4 -4
  207. package/docs/tr/intlayer_with_express.md +3 -3
  208. package/docs/tr/intlayer_with_lynx+react.md +1 -1
  209. package/docs/tr/intlayer_with_nestjs.md +2 -2
  210. package/docs/tr/intlayer_with_nextjs_14.md +2 -2
  211. package/docs/tr/intlayer_with_nextjs_15.md +4 -4
  212. package/docs/tr/intlayer_with_nextjs_page_router.md +5 -5
  213. package/docs/tr/intlayer_with_nuxt.md +4 -4
  214. package/docs/tr/intlayer_with_react_native+expo.md +12 -21
  215. package/docs/tr/intlayer_with_react_router_v7.md +222 -267
  216. package/docs/tr/intlayer_with_tanstack.md +400 -303
  217. package/docs/tr/intlayer_with_vite+preact.md +12 -12
  218. package/docs/tr/intlayer_with_vite+react.md +12 -12
  219. package/docs/tr/intlayer_with_vite+solid.md +2 -2
  220. package/docs/tr/intlayer_with_vite+svelte.md +2 -2
  221. package/docs/tr/intlayer_with_vite+vue.md +12 -12
  222. package/docs/tr/introduction.md +1 -1
  223. package/docs/tr/packages/react-intlayer/useDictionary.md +1 -1
  224. package/docs/tr/packages/react-intlayer/useI18n.md +1 -1
  225. package/docs/tr/roadmap.md +1 -1
  226. package/docs/zh/intlayer_with_angular.md +2 -2
  227. package/docs/zh/intlayer_with_astro.md +246 -0
  228. package/docs/zh/intlayer_with_create_react_app.md +3 -2
  229. package/docs/zh/intlayer_with_express.md +2 -2
  230. package/docs/zh/intlayer_with_nestjs.md +2 -2
  231. package/docs/zh/intlayer_with_nextjs_14.md +2 -2
  232. package/docs/zh/intlayer_with_nextjs_15.md +2 -2
  233. package/docs/zh/intlayer_with_nextjs_page_router.md +2 -2
  234. package/docs/zh/intlayer_with_nuxt.md +2 -2
  235. package/docs/zh/intlayer_with_react_native+expo.md +19 -28
  236. package/docs/zh/intlayer_with_react_router_v7.md +200 -248
  237. package/docs/zh/intlayer_with_tanstack.md +208 -283
  238. package/docs/zh/intlayer_with_vite+preact.md +9 -9
  239. package/docs/zh/intlayer_with_vite+react.md +9 -9
  240. package/docs/zh/intlayer_with_vite+vue.md +9 -9
  241. package/package.json +11 -11
  242. package/src/generated/docs.entry.ts +16 -0
@@ -15,10 +15,8 @@ keywords:
15
15
  slugs:
16
16
  - doc
17
17
  - environment
18
- - vite-and-react
19
18
  - tanstack-start
20
- applicationTemplate: https://github.com/AydinTheFirst/tanstack-start-intlayer
21
- author: AydinTheFirst
19
+ applicationTemplate: https://github.com/aymericzip/intlayer-tanstack-start-template
22
20
  ---
23
21
 
24
22
  # Getting Started Internationalising (i18n) with Intlayer and Tanstack Start
@@ -43,7 +41,7 @@ With Intlayer, you can:
43
41
 
44
42
  ### Step 1: Create Project
45
43
 
46
- Start by creating a new TanStack Start project by following the [Start new project](https://tanstack.com/start/latest/docs/framework/react/quick-start) guide on the TanStack Start website.
44
+ Start by creating a new TanStack Start project by following the [Start new project](https://tanstack.com/start/latest/docs/framework/react/quick-start) guide on the Tanstack Start website.
47
45
 
48
46
  ### Step 2: Install Intlayer Packages
49
47
 
@@ -61,7 +59,7 @@ pnpm add vite-intlayer --save-dev
61
59
 
62
60
  - **intlayer**
63
61
 
64
- The core package that provides internationalisation 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).
62
+ 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).
65
63
 
66
64
  - **react-intlayer**
67
65
  The package that integrates Intlayer with React applications. It provides context providers and hooks for React internationalisation.
@@ -73,7 +71,7 @@ pnpm add vite-intlayer --save-dev
73
71
 
74
72
  Create a config file to configure the languages of your application:
75
73
 
76
- ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
74
+ ```typescript fileName="intlayer.config.ts"
77
75
  import type { IntlayerConfig } from "intlayer";
78
76
 
79
77
  import { Locales } from "intlayer";
@@ -81,75 +79,27 @@ import { Locales } from "intlayer";
81
79
  const config: IntlayerConfig = {
82
80
  internationalization: {
83
81
  defaultLocale: Locales.ENGLISH,
84
- locales: [
85
- Locales.ENGLISH,
86
- Locales.FRENCH,
87
- Locales.SPANISH,
88
- // Your other locales
89
- ],
82
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
90
83
  },
91
84
  };
92
85
 
93
86
  export default config;
94
87
  ```
95
88
 
96
- ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
97
- import { Locales } from "intlayer";
98
-
99
- /** @type {import('intlayer').IntlayerConfig} */
100
- const config = {
101
- internationalization: {
102
- defaultLocale: Locales.ENGLISH,
103
- locales: [
104
- Locales.ENGLISH,
105
- Locales.FRENCH,
106
- Locales.SPANISH,
107
- // Your other locales
108
- ],
109
- },
110
- };
111
-
112
- export default config;
113
- ```
114
-
115
- ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
116
- const { Locales } = require("intlayer");
117
-
118
- /** @type {import('intlayer').IntlayerConfig} */
119
- const config = {
120
- internationalization: {
121
- defaultLocale: Locales.ENGLISH,
122
- locales: [
123
- Locales.ENGLISH,
124
- Locales.FRENCH,
125
- Locales.SPANISH,
126
- // Your other locales
127
- ],
128
- },
129
- };
130
-
131
- module.exports = config;
132
- ```
133
-
134
89
  > 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).
135
90
 
136
91
  ### Step 4: Integrate Intlayer in Your Vite Configuration
137
92
 
138
93
  Add the intlayer plugin into your configuration:
139
94
 
140
- ```typescript fileName="vite.config.ts" codeFormat="typescript"
95
+ ```typescript fileName="vite.config.ts"
141
96
  import { reactRouter } from "@react-router/dev/vite";
142
97
  import { defineConfig } from "vite";
143
- import { intlayerMiddlewarePlugin, intlayer } from "vite-intlayer";
98
+ import { intlayer } from "vite-intlayer";
144
99
  import tsconfigPaths from "vite-tsconfig-paths";
145
100
 
146
101
  export default defineConfig({
147
- plugins: [
148
- reactRouter(),
149
- tsconfigPaths(),
150
- intlayer(),
151
- intlayerMiddlewarePlugin(),
152
- ],
102
+ plugins: [reactRouter(), tsconfigPaths(), intlayer()],
153
103
  });
154
104
  ```
155
105
 
@@ -161,10 +111,8 @@ Set up your root layout and locale-specific layouts:
161
111
 
162
112
  #### Root Layout
163
113
 
164
- ```tsx fileName="src/routes/{-$locale}/route.tsx" codeFormat="typescript"
165
- // src/routes/{-$locale}/route.tsx
114
+ ```tsx fileName="src/routes/{-$locale}/route.tsx"
166
115
  import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router";
167
- import { configuration } from "intlayer";
168
116
  import { IntlayerProvider, useLocale } from "react-intlayer";
169
117
 
170
118
  import { useI18nHTMLAttributes } from "@/hooks/useI18nHTMLAttributes";
@@ -174,10 +122,11 @@ export const Route = createFileRoute("/{-$locale}")({
174
122
  });
175
123
 
176
124
  function LayoutComponent() {
125
+ const { defaultLocale } = useLocale();
177
126
  const { locale } = Route.useParams();
178
127
 
179
128
  return (
180
- <IntlayerProvider locale={locale}>
129
+ <IntlayerProvider locale={defaultLocale}>
181
130
  <Outlet />
182
131
  </IntlayerProvider>
183
132
  );
@@ -188,7 +137,7 @@ function LayoutComponent() {
188
137
 
189
138
  Create and manage your content declarations to store translations:
190
139
 
191
- ```tsx fileName="src/contents/page.content.ts" contentDeclarationFormat="typescript"
140
+ ```tsx fileName="src/contents/page.content.ts"
192
141
  import type { Dictionary } from "intlayer";
193
142
 
194
143
  import { t } from "intlayer";
@@ -197,6 +146,7 @@ const appContent = {
197
146
  content: {
198
147
  links: {
199
148
  about: t({
149
+ "en-GB": "About",
200
150
  en: "About",
201
151
  es: "Acerca de",
202
152
  fr: "À propos",
@@ -235,61 +185,101 @@ export default appContent;
235
185
 
236
186
  ### Step 7: Create Locale-Aware Components and Hooks
237
187
 
238
- Create a `LocalizedLink` component for locale-aware navigation:
188
+ Create a `LocalisedLink` component for locale-aware navigation:
239
189
 
240
- ```tsx fileName="src/components/localized-link.tsx" codeFormat="typescript"
241
- // src/components/localized-link.tsx
242
- // eslint-disable-next-line no-restricted-imports
243
- import { Link, type LinkProps } from "@tanstack/react-router";
244
- import { getLocalizedUrl } from "intlayer";
190
+ ```tsx fileName="src/components/localized-link.tsx"
191
+ import type { FC } from "react";
192
+
193
+ import { Link, type LinkComponentProps } from "@tanstack/react-router";
245
194
  import { useLocale } from "react-intlayer";
246
195
 
196
+ export const LOCALE_ROUTE = "{-$locale}" as const;
197
+
198
+ // Main utility
199
+ export type RemoveLocaleParam<T> = T extends string
200
+ ? RemoveLocaleFromString<T>
201
+ : T;
202
+
203
+ export type To = RemoveLocaleParam<LinkComponentProps["to"]>;
204
+
205
+ type CollapseDoubleSlashes<S extends string> =
206
+ S extends `${infer H}//${infer T}` ? CollapseDoubleSlashes<`${H}/${T}`> : S;
207
+
247
208
  type LocalizedLinkProps = {
248
- to: string;
249
- } & Omit<LinkProps, "to">;
209
+ to?: To;
210
+ } & Omit<LinkComponentProps, "to">;
250
211
 
251
- export function LocalizedLink(props: LocalizedLinkProps) {
252
- const { locale } = useLocale();
212
+ // Helpers
213
+ type RemoveAll<
214
+ S extends string,
215
+ Sub extends string,
216
+ > = S extends `${infer H}${Sub}${infer T}` ? RemoveAll<`${H}${T}`, Sub> : S;
253
217
 
254
- const isExternal = (to: string) => {
255
- return /^(https?:)?\/\//.test(to);
256
- };
218
+ type RemoveLocaleFromString<S extends string> = CollapseDoubleSlashes<
219
+ RemoveAll<S, typeof LOCALE_ROUTE>
220
+ >;
257
221
 
258
- const to = isExternal(props.to)
259
- ? props.to
260
- : getLocalizedUrl(props.to, locale);
222
+ export const LocalizedLink: FC<LocalizedLinkProps> = (props) => {
223
+ const { locale } = useLocale();
261
224
 
262
- return <Link {...props} to={to as LinkProps["to"]} />;
263
- }
225
+ return (
226
+ <Link
227
+ {...props}
228
+ params={{
229
+ locale,
230
+ ...(typeof props?.params === "object" ? props?.params : {}),
231
+ }}
232
+ to={`/${LOCALE_ROUTE}${props.to}` as LinkComponentProps["to"]}
233
+ />
234
+ );
235
+ };
264
236
  ```
265
237
 
266
- Create a `useLocalizedNavigate` hook for programme navigation:
238
+ This component has two purposes:
267
239
 
268
- ```tsx fileName="src/hooks/useLocalizedNavigate.tsx" codeFormat="typescript"
269
- // src/hooks/useLocalizedNavigate.tsx
270
- // eslint-disable-next-line no-restricted-imports
271
- import { NavigateOptions, useNavigate } from "@tanstack/react-router";
272
- import { getLocalizedUrl } from "intlayer";
273
- import { useLocale } from "react-intlayer";
240
+ - Remove the unnecessary `{-$locale}` prefix from the URL.
241
+ - Inject the locale parameter into the URL to ensure the user is directly redirected to the localised route.
274
242
 
275
- type LocalizedNavigateOptions = {
276
- to: string;
277
- } & Omit<NavigateOptions, "to">;
243
+ Then we can create a `useLocalizedNavigate` hook for programmatic navigation:
244
+
245
+ ```tsx fileName="src/hooks/useLocalizedNavigate.tsx"
246
+ import { useLocale } from "react-intlayer";
247
+ import { useNavigate } from "@tanstack/react-router";
248
+ import { LOCALE_ROUTE } from "@/components/localized-link";
249
+ import type { FileRouteTypes } from "@/routeTree.gen";
278
250
 
279
251
  export const useLocalizedNavigate = () => {
280
252
  const navigate = useNavigate();
253
+
281
254
  const { locale } = useLocale();
282
255
 
283
- const isExternal = (to: string) => {
284
- return /^(https?:)?\/\//.test(to);
285
- };
256
+ type StripLocalePrefix<T extends string> = T extends
257
+ | `/${typeof LOCALE_ROUTE}`
258
+ | `/${typeof LOCALE_ROUTE}/`
259
+ ? "/"
260
+ : T extends `/${typeof LOCALE_ROUTE}/${infer Rest}`
261
+ ? `/${Rest}`
262
+ : never;
263
+
264
+ type LocalizedTo = StripLocalePrefix<FileRouteTypes["to"]>;
265
+
266
+ interface LocalizedNavigate {
267
+ (to: LocalizedTo): ReturnType<typeof navigate>;
268
+ (
269
+ opts: { to: LocalizedTo } & Record<string, unknown>
270
+ ): ReturnType<typeof navigate>;
271
+ }
272
+
273
+ const localizedNavigate: LocalizedNavigate = (args: any) => {
274
+ if (typeof args === "string") {
275
+ return navigate({ to: `/${LOCALE_ROUTE}${args}`, params: { locale } });
276
+ }
277
+
278
+ const { to, ...rest } = args;
286
279
 
287
- const localizedNavigate = (options: LocalizedNavigateOptions) => {
288
- const to = isExternal(options.to)
289
- ? options.to
290
- : getLocalizedUrl(options.to, locale);
280
+ const localedTo = `/${LOCALE_ROUTE}${to}` as any;
291
281
 
292
- navigate({ ...options, to: to as NavigateOptions["to"] });
282
+ return navigate({ to: localedTo, params: { locale, ...rest } as any });
293
283
  };
294
284
 
295
285
  return localizedNavigate;
@@ -300,23 +290,9 @@ export const useLocalizedNavigate = () => {
300
290
 
301
291
  Access your content dictionaries throughout your application:
302
292
 
303
- #### Root Redirect Page
304
-
305
- ```tsx fileName="src/routes/page.tsx" codeFormat="typescript"
306
- // src/routes/page.tsx
307
- import { useLocale } from "react-intlayer";
308
- import { Navigate } from "react-router";
309
-
310
- export default function Page() {
311
- const { locale } = useLocale();
312
-
313
- return <Navigate replace to={locale} />;
314
- }
315
- ```
316
-
317
293
  #### Localised Home Page
318
294
 
319
- ```tsx fileName="src/routes/{-$locale}/index.tsx" codeFormat="typescript"
295
+ ```tsx fileName="src/routes/{-$locale}/index.tsx"
320
296
  import { createFileRoute } from "@tanstack/react-router";
321
297
  import { getIntlayer } from "intlayer";
322
298
  import { useIntlayer } from "react-intlayer";
@@ -345,16 +321,15 @@ function RouteComponent() {
345
321
  const navigate = useLocalizedNavigate();
346
322
 
347
323
  return (
348
- <div className="grid place-items-center h-screen">
349
- <div className="flex flex-col gap-4 items-center text-centre">
324
+ <div>
325
+ <div>
350
326
  {content.title}
351
327
  <LocaleSwitcher />
352
- <div className="flex gap-4">
353
- <a href="/">Index</a>
328
+ <div>
354
329
  <LocalizedLink to="/">{content.links.home}</LocalizedLink>
355
330
  <LocalizedLink to="/about">{content.links.about}</LocalizedLink>
356
331
  </div>
357
- <div className="flex gap-4">
332
+ <div>
358
333
  <button onClick={() => navigate({ to: "/" })}>
359
334
  {content.links.home}
360
335
  </button>
@@ -374,48 +349,56 @@ function RouteComponent() {
374
349
 
375
350
  Create a component to allow users to change languages:
376
351
 
377
- ```tsx fileName="src/components/locale-switcher.tsx" codeFormat="typescript"
352
+ ```tsx fileName="src/components/locale-switcher.tsx"
353
+ import type { FC } from "react";
354
+
378
355
  import { useLocation } from "@tanstack/react-router";
379
- import {
380
- getHTMLTextDir,
381
- getLocaleName,
382
- getLocalizedUrl,
383
- Locales,
384
- } from "intlayer";
385
- import { useIntlayer, useLocale } from "react-intlayer";
386
-
387
- export default function LocaleSwitcher() {
388
- const { pathname, searchStr } = useLocation();
389
- const content = useIntlayer("locale-switcher");
390
-
391
- const { availableLocales, locale, setLocale } = useLocale({
392
- onLocaleChange: (newLocale) => {
393
- const pathWithLocale = getLocalizedUrl(pathname + searchStr, newLocale);
394
- location.replace(pathWithLocale);
395
- },
396
- });
356
+ import { getHTMLTextDir, getLocaleName, getPathWithoutLocale } from "intlayer";
357
+ import { setLocaleCookie, useIntlayer, useLocale } from "react-intlayer";
358
+
359
+ import { LocalizedLink, To } from "./localized-link";
360
+
361
+ export const LocaleSwitcher: FC = () => {
362
+ const { localeSwitcherLabel } = useIntlayer("locale-switcher");
363
+ const { pathname } = useLocation();
364
+
365
+ const { availableLocales, locale } = useLocale();
366
+
367
+ const pathWithoutLocale = getPathWithoutLocale(pathname);
397
368
 
398
369
  return (
399
- <select
400
- aria-label={content.label.toString()}
401
- onChange={(e) => setLocale(e.target.value)}
402
- value={locale}
403
- >
404
- {availableLocales.map((localeItem) => (
405
- <option
406
- dir={getHTMLTextDir(localeItem)}
407
- key={localeItem}
408
- lang={localeItem}
409
- value={localeItem}
410
- >
411
- {/* Example: Français (French) */}
412
- {getLocaleName(localeItem, locale)} (
413
- {getLocaleName(localeItem, Locales.ENGLISH)})
414
- </option>
370
+ <ol>
371
+ {availableLocales.map((localeEl) => (
372
+ <li key={localeEl}>
373
+ <LocalizedLink
374
+ aria-current={localeEl === locale ? "page" : undefined}
375
+ aria-label={`${localeSwitcherLabel.value} ${getLocaleName(localeEl)}`}
376
+ onClick={() => setLocaleCookie(localeEl)}
377
+ params={{ locale: localeEl }}
378
+ to={pathWithoutLocale as To}
379
+ >
380
+ <span>
381
+ {/* Locale - e.g. FR */}
382
+ {localeItem}
383
+ </span>
384
+ <span>
385
+ {/* Language in its own Locale - e.g. Français */}
386
+ {getLocaleName(localeItem, locale)}
387
+ </span>
388
+ <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
389
+ {/* Language in current Locale - e.g. Francés with current locale set to Locales.SPANISH */}
390
+ {getLocaleName(localeItem)}
391
+ </span>
392
+ <span dir="ltr" lang={Locales.ENGLISH}>
393
+ {/* Language in English - e.g. French */}
394
+ {getLocaleName(localeItem, Locales.ENGLISH)}
395
+ </span>
396
+ </LocalizedLink>
397
+ </li>
415
398
  ))}
416
- </select>
399
+ </ol>
417
400
  );
418
- }
401
+ };
419
402
  ```
420
403
 
421
404
  > To learn more about the `useLocale` hook, refer to the [documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/packages/react-intlayer/useLocale.md).
@@ -424,7 +407,7 @@ export default function LocaleSwitcher() {
424
407
 
425
408
  Create a hook to manage HTML lang and dir attributes:
426
409
 
427
- ```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
410
+ ```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx"
428
411
  // src/hooks/useI18nHTMLAttributes.tsx
429
412
  import { getHTMLTextDir } from "intlayer";
430
413
  import { useEffect } from "react";
@@ -442,9 +425,8 @@ export const useI18nHTMLAttributes = () => {
442
425
 
443
426
  Then use it in your root component:
444
427
 
445
- ```tsx fileName="src/routes/{-$locale}/index.tsx" codeFormat="typescript"
428
+ ```tsx fileName="src/routes/{-$locale}/index.tsx"
446
429
  import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router";
447
- import { configuration } from "intlayer";
448
430
  import { IntlayerProvider, useLocale } from "react-intlayer";
449
431
 
450
432
  import { useI18nHTMLAttributes } from "@/hooks/useI18nHTMLAttributes"; // import the hook
@@ -456,55 +438,54 @@ export const Route = createFileRoute("/{-$locale}")({
456
438
  function LayoutComponent() {
457
439
  useI18nHTMLAttributes(); // add this line
458
440
 
441
+ const { defaultLocale } = useLocale();
459
442
  const { locale } = Route.useParams();
460
443
 
461
444
  return (
462
- <IntlayerProvider locale={locale}>
445
+ <IntlayerProvider locale={locale ?? defaultLocale}>
463
446
  <Outlet />
464
447
  </IntlayerProvider>
465
448
  );
466
449
  }
467
450
  ```
468
451
 
469
- ### Step 11: Build and Run Your Application
452
+ ---
470
453
 
471
- Build the content dictionaries and run your application:
454
+ ### Step 11: Add middleware (Optional)
472
455
 
473
- ```bash packageManager="npm"
474
- # Build Intlayer dictionaries
475
- npm run intlayer:build
456
+ You can also use the `intlayerMiddleware` to add server-side routing to your application. This plugin will automatically detect the current locale based on the URL and set the appropriate locale cookie. If no locale is specified, the plugin will determine the most appropriate locale based on the user's browser language preferences. If no locale is detected, it will redirect to the default locale.
476
457
 
477
- # Start development server
478
- npm run dev
479
- ```
458
+ > Note that to use the `intlayerMiddleware` in production, you need to switch the `vite-intlayer` package from `devDependencies` to `dependencies`.
480
459
 
481
- ```bash packageManager="pnpm"
482
- # Build Intlayer dictionaries
483
- pnpm intlayer:build
460
+ ```typescript {3,7} fileName="vite.config.ts"
461
+ import { reactRouter } from "@react-router/dev/vite";
462
+ import tailwindcss from "@tailwindcss/vite";
463
+ import { defineConfig } from "vite";
464
+ import { intlayer, intlayerMiddleware } from "vite-intlayer";
465
+ import tsconfigPaths from "vite-tsconfig-paths";
484
466
 
485
- # Start development server
486
- pnpm dev
467
+ export default defineConfig({
468
+ plugins: [
469
+ tailwindcss(),
470
+ reactRouter(),
471
+ tsconfigPaths(),
472
+ intlayer(),
473
+ intlayerMiddleware(),
474
+ ],
475
+ });
487
476
  ```
488
477
 
489
- ```bash packageManager="yarn"
490
- # Build Intlayer dictionaries
491
- yarn intlayer:build
492
-
493
- # Start development server
494
- yarn dev
495
- ```
478
+ ---
496
479
 
497
480
  ### Step 12: Configure TypeScript (Optional)
498
481
 
499
- Intlayer uses module augmentation to gain the benefits of TypeScript and strengthen your codebase.
482
+ Intlayer uses module augmentation to benefit from TypeScript and strengthen your codebase.
500
483
 
501
484
  Ensure your TypeScript configuration includes the autogenerated types:
502
485
 
503
486
  ```json5 fileName="tsconfig.json"
504
487
  {
505
- compilerOptions: {
506
- // ... your existing TypeScript configurations
507
- },
488
+ // ... your existing configurations
508
489
  include: [
509
490
  // ... your existing includes
510
491
  ".intlayer/**/*.ts", // Include the auto-generated types
@@ -512,6 +493,8 @@ Ensure your TypeScript configuration includes the autogenerated types:
512
493
  }
513
494
  ```
514
495
 
496
+ ---
497
+
515
498
  ### Git Configuration
516
499
 
517
500
  It is recommended to ignore the files generated by Intlayer. This prevents you from committing them to your Git repository.
@@ -525,67 +508,9 @@ To do this, you can add the following instructions to your `.gitignore` file:
525
508
 
526
509
  ---
527
510
 
528
- ### Step 13: Create Redirection (Optional)
529
-
530
- ```typescript fileName="src/routes/{-$locale}/rotue.tsx" codeFormat="typescript"
531
- function LayoutComponent() {
532
- useI18nHTMLAttributes();
533
-
534
- const { locale } = Route.useParams();
535
- const { locale: selectedLocale } = useLocale();
536
- const { defaultLocale } = configuration.internationalization;
537
- const { prefixDefault } = configuration.middleware;
538
-
539
- // Redirect to the default locale if no locale is present in the URL when prefixDefault is true
540
- if (selectedLocale === defaultLocale && !locale && prefixDefault) {
541
- return <Navigate replace to={defaultLocale} />;
542
- }
543
-
544
- // Redirect to the selected locale if the locale in the URL does not match the selected locale
545
- if (selectedLocale !== defaultLocale && !locale) {
546
- return <Navigate replace to={selectedLocale} />;
547
- }
548
-
549
- return (
550
- <IntlayerProvider locale={locale}>
551
- <Outlet />
552
- </IntlayerProvider>
553
- );
554
- }
555
- ```
556
-
557
- ## Production Deployment
558
-
559
- When deploying your application:
560
-
561
- 1. **Build your application:**
562
-
563
- ```bash
564
- npm run build
565
- ```
566
-
567
- 2. **Build Intlayer dictionaries:**
568
-
569
- ```bash
570
- npm run intlayer:build
571
- ```
572
-
573
- 3. **Move `vite-intlayer` to dependencies** if using middleware in production:
574
- ```bash
575
- npm install vite-intlayer --save
576
- ```
577
-
578
- Your application will now support:
579
-
580
- - **URL Structure**: `/en`, `/en/about`, `/tr`, `/tr/about`
581
- - **Automatic locale detection** based on browser preferences
582
- - **Locale-aware routing** with Tanstack Start
583
- - **TypeScript support** with auto-generated types
584
- - **Server-side rendering** with proper locale handling
585
-
586
511
  ## VS Code Extension
587
512
 
588
- To improve your development experience with Intlayer, you can install the official **Intlayer VS Code Extension**.
513
+ To enhance your development experience with Intlayer, you can install the official **Intlayer VS Code Extension**.
589
514
 
590
515
  [Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
591
516
 
@@ -602,7 +527,7 @@ For more details on how to use the extension, refer to the [Intlayer VS Code Ext
602
527
 
603
528
  ## Go Further
604
529
 
605
- 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).
530
+ To go further, you can implement the [visual editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/{{locale}}/intlayer_visual_editor.md) or externalise your content using the [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/{{locale}}/intlayer_CMS.md).
606
531
 
607
532
  ---
608
533
 
@@ -610,10 +535,10 @@ To go further, you can implement the [visual editor](https://github.com/aymericz
610
535
 
611
536
  - [Intlayer Documentation](https://intlayer.org)
612
537
  - [Tanstack Start Documentation](https://reactrouter.com/)
613
- - [useIntlayer hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/packages/react-intlayer/useIntlayer.md)
614
- - [useLocale hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/packages/react-intlayer/useLocale.md)
615
- - [Content Declaration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/dictionary/get_started.md)
616
- - [Configuration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en-GB/configuration.md)
538
+ - [useIntlayer hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/{{locale}}/packages/react-intlayer/useIntlayer.md)
539
+ - [useLocale hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/{{locale}}/packages/react-intlayer/useLocale.md)
540
+ - [Content Declaration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/{{locale}}/dictionary/get_started.md)
541
+ - [Configuration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/{{locale}}/configuration.md)
617
542
 
618
543
  This comprehensive guide provides everything you need to integrate Intlayer with Tanstack Start for a fully internationalised application with locale-aware routing and TypeScript support.
619
544
 
@@ -621,4 +546,5 @@ This comprehensive guide provides everything you need to integrate Intlayer with
621
546
 
622
547
  | Version | Date | Changes |
623
548
  | ------- | ---------- | ------------------------ |
549
+ | 6.5.2 | 2025-10-03 | Update doc |
624
550
  | 5.8.1 | 2025-09-09 | Added for Tanstack Start |