@intlayer/docs 7.0.7 → 7.0.8

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 (726) hide show
  1. package/blog/ar/i18n_using_next-i18next.md +1068 -0
  2. package/blog/ar/i18n_using_next-intl.md +768 -0
  3. package/blog/ar/intlayer_with_react-intl.md +0 -4
  4. package/blog/ar/next-i18next_vs_next-intl_vs_intlayer.md +5 -4
  5. package/blog/de/i18n_using_next-i18next.md +1107 -0
  6. package/blog/de/i18n_using_next-intl.md +760 -0
  7. package/blog/de/intlayer_with_react-intl.md +0 -4
  8. package/blog/de/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
  9. package/blog/en/i18n_using_next-i18next.md +1073 -0
  10. package/blog/en/i18n_using_next-intl.md +757 -0
  11. package/blog/en/intlayer_with_i18next.md +71 -8
  12. package/blog/en/intlayer_with_next-i18next.md +71 -8
  13. package/blog/en/intlayer_with_next-intl.md +71 -8
  14. package/blog/en/intlayer_with_react-i18next.md +69 -8
  15. package/blog/en/intlayer_with_react-intl.md +68 -9
  16. package/blog/en/intlayer_with_vue-i18n.md +68 -7
  17. package/blog/en/react-i18next_vs_react-intl_vs_intlayer.md +2 -0
  18. package/blog/en/vue-i18n_vs_intlayer.md +2 -0
  19. package/blog/en-GB/i18n_using_next-i18next.md +1074 -0
  20. package/blog/en-GB/i18n_using_next-intl.md +757 -0
  21. package/blog/en-GB/intlayer_with_i18next.md +15 -6
  22. package/blog/en-GB/intlayer_with_next-i18next.md +16 -6
  23. package/blog/en-GB/intlayer_with_next-intl.md +16 -6
  24. package/blog/en-GB/intlayer_with_react-i18next.md +16 -7
  25. package/blog/en-GB/intlayer_with_react-intl.md +14 -9
  26. package/blog/en-GB/intlayer_with_vue-i18n.md +16 -7
  27. package/blog/en-GB/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
  28. package/blog/en-GB/react-i18next_vs_react-intl_vs_intlayer.md +2 -0
  29. package/blog/en-GB/vue-i18n_vs_intlayer.md +2 -0
  30. package/blog/es/i18n_using_next-i18next.md +1066 -0
  31. package/blog/es/i18n_using_next-intl.md +757 -0
  32. package/blog/es/intlayer_with_react-intl.md +0 -4
  33. package/blog/es/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
  34. package/blog/fr/i18n_using_next-i18next.md +1078 -0
  35. package/blog/fr/i18n_using_next-intl.md +759 -0
  36. package/blog/fr/intlayer_with_react-intl.md +0 -4
  37. package/blog/fr/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
  38. package/blog/hi/i18n_using_next-i18next.md +1068 -0
  39. package/blog/hi/i18n_using_next-intl.md +758 -0
  40. package/blog/hi/intlayer_with_react-intl.md +0 -4
  41. package/blog/hi/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
  42. package/blog/id/i18n_using_next-i18next.md +1078 -0
  43. package/blog/id/i18n_using_next-intl.md +757 -0
  44. package/blog/id/index.md +69 -0
  45. package/blog/id/internationalization_and_SEO.md +364 -0
  46. package/blog/id/intlayer_with_react-intl.md +0 -4
  47. package/blog/id/list_i18n_technologies/CMS/drupal.md +143 -0
  48. package/blog/id/list_i18n_technologies/CMS/wix.md +167 -0
  49. package/blog/id/list_i18n_technologies/CMS/wordpress.md +188 -0
  50. package/blog/id/list_i18n_technologies/frameworks/angular.md +125 -0
  51. package/blog/id/list_i18n_technologies/frameworks/flutter.md +150 -0
  52. package/blog/id/list_i18n_technologies/frameworks/react-native.md +217 -0
  53. package/blog/id/list_i18n_technologies/frameworks/react.md +155 -0
  54. package/blog/id/list_i18n_technologies/frameworks/svelte.md +131 -0
  55. package/blog/id/list_i18n_technologies/frameworks/vue.md +130 -0
  56. package/blog/id/next-i18next_vs_next-intl_vs_intlayer.md +1500 -0
  57. package/blog/id/nextjs-multilingual-seo-comparison.md +361 -0
  58. package/blog/id/rag_powered_documentation_assistant.md +288 -0
  59. package/blog/id/react-i18next_vs_react-intl_vs_intlayer.md +164 -0
  60. package/blog/id/vue-i18n_vs_intlayer.md +278 -0
  61. package/blog/id/what_is_internationalization.md +166 -0
  62. package/blog/it/i18n_using_next-i18next.md +1078 -0
  63. package/blog/it/i18n_using_next-intl.md +758 -0
  64. package/blog/it/intlayer_with_react-intl.md +0 -4
  65. package/blog/it/react-i18next_vs_react-intl_vs_intlayer.md +4 -0
  66. package/blog/it/vue-i18n_vs_intlayer.md +2 -0
  67. package/blog/ja/i18n_using_next-i18next.md +1078 -0
  68. package/blog/ja/i18n_using_next-intl.md +758 -0
  69. package/blog/ja/intlayer_with_react-intl.md +0 -4
  70. package/blog/ja/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
  71. package/blog/ko/i18n_using_next-i18next.md +1075 -0
  72. package/blog/ko/i18n_using_next-intl.md +759 -0
  73. package/blog/ko/intlayer_with_react-intl.md +0 -4
  74. package/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
  75. package/blog/pl/i18n_using_next-i18next.md +1078 -0
  76. package/blog/pl/i18n_using_next-intl.md +758 -0
  77. package/blog/pl/index.md +69 -0
  78. package/blog/pl/internationalization_and_SEO.md +363 -0
  79. package/blog/pl/intlayer_with_react-intl.md +0 -4
  80. package/blog/pl/list_i18n_technologies/CMS/drupal.md +143 -0
  81. package/blog/pl/list_i18n_technologies/CMS/wix.md +167 -0
  82. package/blog/pl/list_i18n_technologies/CMS/wordpress.md +196 -0
  83. package/blog/pl/list_i18n_technologies/frameworks/angular.md +125 -0
  84. package/blog/pl/list_i18n_technologies/frameworks/flutter.md +151 -0
  85. package/blog/pl/list_i18n_technologies/frameworks/react-native.md +217 -0
  86. package/blog/pl/list_i18n_technologies/frameworks/react.md +155 -0
  87. package/blog/pl/list_i18n_technologies/frameworks/svelte.md +131 -0
  88. package/blog/pl/list_i18n_technologies/frameworks/vue.md +130 -0
  89. package/blog/pl/next-i18next_vs_next-intl_vs_intlayer.md +1501 -0
  90. package/blog/pl/nextjs-multilingual-seo-comparison.md +362 -0
  91. package/blog/pl/rag_powered_documentation_assistant.md +288 -0
  92. package/blog/pl/react-i18next_vs_react-intl_vs_intlayer.md +164 -0
  93. package/blog/pl/vue-i18n_vs_intlayer.md +278 -0
  94. package/blog/pl/what_is_internationalization.md +167 -0
  95. package/blog/pt/i18n_using_next-i18next.md +1067 -0
  96. package/blog/pt/i18n_using_next-intl.md +760 -0
  97. package/blog/pt/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
  98. package/blog/ru/i18n_using_next-i18next.md +1106 -0
  99. package/blog/ru/i18n_using_next-intl.md +759 -0
  100. package/blog/ru/intlayer_with_react-intl.md +0 -4
  101. package/blog/ru/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
  102. package/blog/tr/i18n_using_next-i18next.md +1078 -0
  103. package/blog/tr/i18n_using_next-intl.md +760 -0
  104. package/blog/tr/intlayer_with_react-intl.md +0 -4
  105. package/blog/tr/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
  106. package/blog/tr/react-i18next_vs_react-intl_vs_intlayer.md +2 -0
  107. package/blog/tr/vue-i18n_vs_intlayer.md +2 -0
  108. package/blog/vi/i18n_using_next-i18next.md +1080 -0
  109. package/blog/vi/i18n_using_next-intl.md +758 -0
  110. package/blog/vi/index.md +69 -0
  111. package/blog/vi/internationalization_and_SEO.md +363 -0
  112. package/blog/vi/intlayer_with_react-intl.md +0 -4
  113. package/blog/vi/list_i18n_technologies/CMS/drupal.md +143 -0
  114. package/blog/vi/list_i18n_technologies/CMS/wix.md +167 -0
  115. package/blog/vi/list_i18n_technologies/CMS/wordpress.md +188 -0
  116. package/blog/vi/list_i18n_technologies/frameworks/angular.md +125 -0
  117. package/blog/vi/list_i18n_technologies/frameworks/flutter.md +150 -0
  118. package/blog/vi/list_i18n_technologies/frameworks/react-native.md +217 -0
  119. package/blog/vi/list_i18n_technologies/frameworks/react.md +155 -0
  120. package/blog/vi/list_i18n_technologies/frameworks/svelte.md +131 -0
  121. package/blog/vi/list_i18n_technologies/frameworks/vue.md +130 -0
  122. package/blog/vi/next-i18next_vs_next-intl_vs_intlayer.md +1520 -0
  123. package/blog/vi/nextjs-multilingual-seo-comparison.md +362 -0
  124. package/blog/vi/rag_powered_documentation_assistant.md +288 -0
  125. package/blog/vi/react-i18next_vs_react-intl_vs_intlayer.md +164 -0
  126. package/blog/vi/vue-i18n_vs_intlayer.md +278 -0
  127. package/blog/vi/what_is_internationalization.md +168 -0
  128. package/blog/zh/i18n_using_next-i18next.md +1105 -0
  129. package/blog/zh/i18n_using_next-intl.md +758 -0
  130. package/blog/zh/intlayer_with_react-intl.md +0 -4
  131. package/blog/zh/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
  132. package/blog/zh/react-i18next_vs_react-intl_vs_intlayer.md +2 -0
  133. package/dist/cjs/common.cjs +0 -4
  134. package/dist/cjs/common.cjs.map +1 -1
  135. package/dist/cjs/generated/blog.entry.cjs +38 -6
  136. package/dist/cjs/generated/blog.entry.cjs.map +1 -1
  137. package/dist/cjs/generated/docs.entry.cjs +0 -6
  138. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  139. package/dist/cjs/generated/frequentQuestions.entry.cjs +0 -6
  140. package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
  141. package/dist/cjs/generated/legal.entry.cjs +0 -6
  142. package/dist/cjs/generated/legal.entry.cjs.map +1 -1
  143. package/dist/esm/generated/blog.entry.mjs +38 -0
  144. package/dist/esm/generated/blog.entry.mjs.map +1 -1
  145. package/dist/types/generated/blog.entry.d.ts +2 -0
  146. package/dist/types/generated/blog.entry.d.ts.map +1 -1
  147. package/docs/ar/component_i18n.md +1 -1
  148. package/docs/ar/configuration.md +6 -0
  149. package/docs/ar/intlayer_cli.md +8 -3
  150. package/docs/ar/intlayer_with_next-i18next.md +619 -0
  151. package/docs/ar/intlayer_with_next-intl.md +446 -0
  152. package/docs/ar/intlayer_with_nextjs_16.md +21 -0
  153. package/docs/ar/intlayer_with_tanstack.md +4 -0
  154. package/docs/ar/intlayer_with_vite+react.md +4 -0
  155. package/docs/de/component_i18n.md +1 -1
  156. package/docs/de/configuration.md +6 -0
  157. package/docs/de/intlayer_cli.md +8 -3
  158. package/docs/de/intlayer_with_next-i18next.md +627 -0
  159. package/docs/de/intlayer_with_next-intl.md +451 -0
  160. package/docs/de/intlayer_with_nextjs_16.md +21 -0
  161. package/docs/de/intlayer_with_tanstack.md +4 -0
  162. package/docs/de/intlayer_with_vite+react.md +4 -0
  163. package/docs/en/component_i18n.md +1 -1
  164. package/docs/en/intlayer_cli.md +8 -1
  165. package/docs/en/intlayer_with_astro.md +10 -2
  166. package/docs/en/intlayer_with_create_react_app.md +8 -0
  167. package/docs/en/intlayer_with_lynx+react.md +8 -0
  168. package/docs/en/intlayer_with_nestjs.md +10 -0
  169. package/docs/en/intlayer_with_nextjs_14.md +10 -2
  170. package/docs/en/intlayer_with_nextjs_15.md +21 -4
  171. package/docs/en/intlayer_with_nextjs_16.md +17 -0
  172. package/docs/en/intlayer_with_nuxt.md +8 -0
  173. package/docs/en/intlayer_with_react_native+expo.md +10 -2
  174. package/docs/en/intlayer_with_react_router_v7.md +8 -0
  175. package/docs/en/intlayer_with_tanstack.md +10 -0
  176. package/docs/en/intlayer_with_vite+preact.md +10 -2
  177. package/docs/en/intlayer_with_vite+react.md +21 -4
  178. package/docs/en/intlayer_with_vite+vue.md +10 -2
  179. package/docs/en-GB/component_i18n.md +1 -1
  180. package/docs/en-GB/configuration.md +6 -0
  181. package/docs/en-GB/intlayer_cli.md +8 -3
  182. package/docs/en-GB/intlayer_with_angular.md +4 -4
  183. package/docs/en-GB/intlayer_with_express.md +4 -4
  184. package/docs/en-GB/intlayer_with_lynx+react.md +12 -12
  185. package/{blog/en/_intlayer_with_next-i18next.md → docs/en-GB/intlayer_with_next-i18next.md} +241 -42
  186. package/{blog/en/_intlayer_with_next-intl.md → docs/en-GB/intlayer_with_next-intl.md} +144 -29
  187. package/docs/en-GB/intlayer_with_nextjs_16.md +21 -0
  188. package/docs/en-GB/intlayer_with_tanstack.md +5 -1
  189. package/docs/en-GB/intlayer_with_vite+react.md +4 -0
  190. package/docs/en-GB/packages/next-intlayer/t.md +2 -2
  191. package/docs/es/component_i18n.md +1 -1
  192. package/docs/es/configuration.md +6 -0
  193. package/docs/es/intlayer_cli.md +8 -3
  194. package/docs/es/intlayer_with_next-i18next.md +628 -0
  195. package/docs/es/intlayer_with_next-intl.md +446 -0
  196. package/docs/es/intlayer_with_nextjs_16.md +21 -0
  197. package/docs/es/intlayer_with_tanstack.md +4 -0
  198. package/docs/es/intlayer_with_vite+react.md +4 -0
  199. package/docs/fr/configuration.md +6 -0
  200. package/docs/fr/intlayer_cli.md +8 -3
  201. package/docs/fr/intlayer_with_next-i18next.md +628 -0
  202. package/docs/fr/intlayer_with_next-intl.md +446 -0
  203. package/docs/fr/intlayer_with_nextjs_16.md +23 -2
  204. package/docs/fr/intlayer_with_tanstack.md +4 -0
  205. package/docs/fr/intlayer_with_vite+react.md +4 -0
  206. package/docs/hi/component_i18n.md +1 -1
  207. package/docs/hi/configuration.md +6 -0
  208. package/docs/hi/intlayer_cli.md +8 -0
  209. package/docs/hi/intlayer_with_next-i18next.md +628 -0
  210. package/docs/hi/intlayer_with_next-intl.md +446 -0
  211. package/docs/hi/intlayer_with_nextjs_16.md +21 -0
  212. package/docs/hi/intlayer_with_tanstack.md +4 -0
  213. package/docs/hi/intlayer_with_vite+react.md +4 -0
  214. package/docs/id/CI_CD.md +198 -0
  215. package/docs/id/autoFill.md +284 -0
  216. package/docs/id/component_i18n.md +186 -0
  217. package/docs/id/configuration.md +710 -0
  218. package/docs/id/dictionary/condition.md +231 -0
  219. package/docs/id/dictionary/content_file.md +1092 -0
  220. package/docs/id/dictionary/enumeration.md +245 -0
  221. package/docs/id/dictionary/file.md +237 -0
  222. package/docs/id/dictionary/function_fetching.md +214 -0
  223. package/docs/id/dictionary/gender.md +273 -0
  224. package/docs/id/dictionary/insertion.md +192 -0
  225. package/docs/id/dictionary/markdown.md +381 -0
  226. package/docs/id/dictionary/nesting.md +273 -0
  227. package/docs/id/dictionary/translation.md +310 -0
  228. package/docs/id/formatters.md +596 -0
  229. package/docs/id/how_works_intlayer.md +256 -0
  230. package/docs/id/index.md +176 -0
  231. package/docs/id/interest_of_intlayer.md +293 -0
  232. package/docs/id/intlayer_CMS.md +549 -0
  233. package/docs/id/intlayer_cli.md +850 -0
  234. package/docs/id/intlayer_visual_editor.md +288 -0
  235. package/docs/id/intlayer_with_angular.md +694 -0
  236. package/docs/id/intlayer_with_astro.md +252 -0
  237. package/docs/id/intlayer_with_create_react_app.md +1233 -0
  238. package/docs/id/intlayer_with_express.md +411 -0
  239. package/docs/id/intlayer_with_lynx+react.md +518 -0
  240. package/docs/id/intlayer_with_nestjs.md +272 -0
  241. package/docs/id/intlayer_with_next-i18next.md +628 -0
  242. package/docs/id/intlayer_with_next-intl.md +446 -0
  243. package/docs/id/intlayer_with_nextjs_14.md +1617 -0
  244. package/docs/id/intlayer_with_nextjs_15.md +1698 -0
  245. package/docs/id/intlayer_with_nextjs_16.md +21 -0
  246. package/docs/id/intlayer_with_nextjs_page_router.md +1478 -0
  247. package/docs/id/intlayer_with_nuxt.md +808 -0
  248. package/docs/id/intlayer_with_react_native+expo.md +699 -0
  249. package/docs/id/intlayer_with_react_router_v7.md +496 -0
  250. package/docs/id/intlayer_with_tanstack.md +564 -0
  251. package/docs/id/intlayer_with_vite+preact.md +1737 -0
  252. package/docs/id/intlayer_with_vite+react.md +1413 -0
  253. package/docs/id/intlayer_with_vite+solid.md +289 -0
  254. package/docs/id/intlayer_with_vite+svelte.md +289 -0
  255. package/docs/id/intlayer_with_vite+vue.md +1088 -0
  256. package/docs/id/introduction.md +218 -0
  257. package/docs/id/locale_mapper.md +242 -0
  258. package/docs/id/mcp_server.md +211 -0
  259. package/docs/id/packages/express-intlayer/t.md +458 -0
  260. package/docs/id/packages/intlayer/getConfiguration.md +145 -0
  261. package/docs/id/packages/intlayer/getEnumeration.md +159 -0
  262. package/docs/id/packages/intlayer/getHTMLTextDir.md +122 -0
  263. package/docs/id/packages/intlayer/getLocaleLang.md +81 -0
  264. package/docs/id/packages/intlayer/getLocaleName.md +119 -0
  265. package/docs/id/packages/intlayer/getLocalizedUrl.md +309 -0
  266. package/docs/id/packages/intlayer/getMultilingualUrls.md +223 -0
  267. package/docs/id/packages/intlayer/getPathWithoutLocale.md +75 -0
  268. package/docs/id/packages/intlayer/getTranslation.md +190 -0
  269. package/docs/id/packages/intlayer/getTranslationContent.md +188 -0
  270. package/docs/id/packages/next-intlayer/t.md +352 -0
  271. package/docs/id/packages/next-intlayer/useDictionary.md +271 -0
  272. package/docs/id/packages/next-intlayer/useIntlayer.md +264 -0
  273. package/docs/id/packages/next-intlayer/useLocale.md +166 -0
  274. package/docs/id/packages/react-intlayer/t.md +303 -0
  275. package/docs/id/packages/react-intlayer/useDictionary.md +287 -0
  276. package/docs/id/packages/react-intlayer/useI18n.md +267 -0
  277. package/docs/id/packages/react-intlayer/useIntlayer.md +254 -0
  278. package/docs/id/packages/react-intlayer/useLocale.md +210 -0
  279. package/docs/id/per_locale_file.md +323 -0
  280. package/docs/id/readme.md +261 -0
  281. package/docs/id/releases/v6.md +305 -0
  282. package/docs/id/roadmap.md +362 -0
  283. package/docs/id/testing.md +202 -0
  284. package/docs/id/vs_code_extension.md +126 -0
  285. package/docs/it/component_i18n.md +1 -1
  286. package/docs/it/configuration.md +6 -0
  287. package/docs/it/intlayer_cli.md +8 -3
  288. package/docs/it/intlayer_with_next-i18next.md +628 -0
  289. package/docs/it/intlayer_with_next-intl.md +446 -0
  290. package/docs/it/intlayer_with_nextjs_16.md +21 -0
  291. package/docs/it/intlayer_with_tanstack.md +4 -0
  292. package/docs/it/intlayer_with_vite+react.md +4 -0
  293. package/docs/ja/component_i18n.md +1 -1
  294. package/docs/ja/configuration.md +6 -0
  295. package/docs/ja/intlayer_cli.md +8 -3
  296. package/docs/ja/intlayer_with_next-i18next.md +627 -0
  297. package/docs/ja/intlayer_with_next-intl.md +446 -0
  298. package/docs/ja/intlayer_with_nextjs_16.md +21 -0
  299. package/docs/ja/intlayer_with_tanstack.md +4 -0
  300. package/docs/ja/intlayer_with_vite+react.md +4 -0
  301. package/docs/ko/configuration.md +6 -0
  302. package/docs/ko/intlayer_cli.md +8 -3
  303. package/docs/ko/intlayer_with_next-i18next.md +627 -0
  304. package/docs/ko/intlayer_with_next-intl.md +446 -0
  305. package/docs/ko/intlayer_with_nextjs_16.md +21 -0
  306. package/docs/ko/intlayer_with_tanstack.md +4 -0
  307. package/docs/ko/intlayer_with_vite+react.md +4 -0
  308. package/docs/pl/CI_CD.md +198 -0
  309. package/docs/pl/autoFill.md +284 -0
  310. package/docs/pl/component_i18n.md +186 -0
  311. package/docs/pl/configuration.md +710 -0
  312. package/docs/pl/dictionary/condition.md +232 -0
  313. package/docs/pl/dictionary/content_file.md +1130 -0
  314. package/docs/pl/dictionary/enumeration.md +245 -0
  315. package/docs/pl/dictionary/file.md +234 -0
  316. package/docs/pl/dictionary/function_fetching.md +214 -0
  317. package/docs/pl/dictionary/gender.md +276 -0
  318. package/docs/pl/dictionary/insertion.md +188 -0
  319. package/docs/pl/dictionary/markdown.md +408 -0
  320. package/docs/pl/dictionary/nesting.md +273 -0
  321. package/docs/pl/dictionary/translation.md +310 -0
  322. package/docs/pl/formatters.md +596 -0
  323. package/docs/pl/how_works_intlayer.md +256 -0
  324. package/docs/pl/index.md +176 -0
  325. package/docs/pl/interest_of_intlayer.md +291 -0
  326. package/docs/pl/intlayer_CMS.md +549 -0
  327. package/docs/pl/intlayer_cli.md +857 -0
  328. package/docs/pl/intlayer_visual_editor.md +288 -0
  329. package/docs/pl/intlayer_with_angular.md +690 -0
  330. package/docs/pl/intlayer_with_astro.md +280 -0
  331. package/docs/pl/intlayer_with_create_react_app.md +1235 -0
  332. package/docs/pl/intlayer_with_express.md +411 -0
  333. package/docs/pl/intlayer_with_lynx+react.md +518 -0
  334. package/docs/pl/intlayer_with_nestjs.md +272 -0
  335. package/docs/pl/intlayer_with_next-i18next.md +628 -0
  336. package/docs/pl/intlayer_with_next-intl.md +446 -0
  337. package/docs/pl/intlayer_with_nextjs_14.md +1594 -0
  338. package/docs/pl/intlayer_with_nextjs_15.md +1701 -0
  339. package/docs/pl/intlayer_with_nextjs_16.md +21 -0
  340. package/docs/pl/intlayer_with_nextjs_page_router.md +1513 -0
  341. package/docs/pl/intlayer_with_nuxt.md +885 -0
  342. package/docs/pl/intlayer_with_react_native+expo.md +698 -0
  343. package/docs/pl/intlayer_with_react_router_v7.md +503 -0
  344. package/docs/pl/intlayer_with_tanstack.md +562 -0
  345. package/docs/pl/intlayer_with_vite+preact.md +1736 -0
  346. package/docs/pl/intlayer_with_vite+react.md +1438 -0
  347. package/docs/pl/intlayer_with_vite+solid.md +290 -0
  348. package/docs/pl/intlayer_with_vite+svelte.md +289 -0
  349. package/docs/pl/intlayer_with_vite+vue.md +1116 -0
  350. package/docs/pl/introduction.md +209 -0
  351. package/docs/pl/locale_mapper.md +242 -0
  352. package/docs/pl/mcp_server.md +211 -0
  353. package/docs/pl/packages/express-intlayer/t.md +458 -0
  354. package/docs/pl/packages/intlayer/getConfiguration.md +146 -0
  355. package/docs/pl/packages/intlayer/getEnumeration.md +160 -0
  356. package/docs/pl/packages/intlayer/getHTMLTextDir.md +121 -0
  357. package/docs/pl/packages/intlayer/getLocaleLang.md +81 -0
  358. package/docs/pl/packages/intlayer/getLocaleName.md +118 -0
  359. package/docs/pl/packages/intlayer/getLocalizedUrl.md +300 -0
  360. package/docs/pl/packages/intlayer/getMultilingualUrls.md +221 -0
  361. package/docs/pl/packages/intlayer/getPathWithoutLocale.md +75 -0
  362. package/docs/pl/packages/intlayer/getTranslation.md +190 -0
  363. package/docs/pl/packages/intlayer/getTranslationContent.md +189 -0
  364. package/docs/pl/packages/next-intlayer/t.md +353 -0
  365. package/docs/pl/packages/next-intlayer/useDictionary.md +270 -0
  366. package/docs/pl/packages/next-intlayer/useIntlayer.md +263 -0
  367. package/docs/pl/packages/next-intlayer/useLocale.md +166 -0
  368. package/docs/pl/packages/react-intlayer/t.md +303 -0
  369. package/docs/pl/packages/react-intlayer/useDictionary.md +289 -0
  370. package/docs/pl/packages/react-intlayer/useI18n.md +249 -0
  371. package/docs/pl/packages/react-intlayer/useIntlayer.md +256 -0
  372. package/docs/pl/packages/react-intlayer/useLocale.md +210 -0
  373. package/docs/pl/per_locale_file.md +321 -0
  374. package/docs/pl/readme.md +261 -0
  375. package/docs/pl/releases/v6.md +305 -0
  376. package/docs/pl/roadmap.md +362 -0
  377. package/docs/pl/testing.md +202 -0
  378. package/docs/pl/vs_code_extension.md +126 -0
  379. package/docs/pt/component_i18n.md +1 -1
  380. package/docs/pt/configuration.md +6 -0
  381. package/docs/pt/intlayer_cli.md +8 -3
  382. package/docs/pt/intlayer_with_next-i18next.md +627 -0
  383. package/docs/pt/intlayer_with_next-intl.md +446 -0
  384. package/docs/pt/intlayer_with_nextjs_16.md +21 -0
  385. package/docs/pt/intlayer_with_tanstack.md +4 -0
  386. package/docs/pt/intlayer_with_vite+react.md +4 -0
  387. package/docs/ru/component_i18n.md +1 -1
  388. package/docs/ru/configuration.md +6 -0
  389. package/docs/ru/intlayer_cli.md +301 -22
  390. package/docs/ru/intlayer_with_next-i18next.md +629 -0
  391. package/docs/ru/intlayer_with_next-intl.md +448 -0
  392. package/docs/ru/intlayer_with_nextjs_16.md +21 -0
  393. package/docs/ru/intlayer_with_tanstack.md +4 -0
  394. package/docs/ru/intlayer_with_vite+react.md +4 -0
  395. package/docs/tr/component_i18n.md +1 -1
  396. package/docs/tr/configuration.md +6 -0
  397. package/docs/tr/intlayer_cli.md +8 -0
  398. package/docs/tr/intlayer_with_next-i18next.md +627 -0
  399. package/docs/tr/intlayer_with_next-intl.md +446 -0
  400. package/docs/tr/intlayer_with_nextjs_16.md +21 -0
  401. package/docs/tr/intlayer_with_tanstack.md +4 -0
  402. package/docs/tr/intlayer_with_vite+react.md +4 -0
  403. package/docs/vi/CI_CD.md +198 -0
  404. package/docs/vi/autoFill.md +284 -0
  405. package/docs/vi/component_i18n.md +186 -0
  406. package/docs/vi/configuration.md +710 -0
  407. package/docs/vi/dictionary/condition.md +237 -0
  408. package/docs/vi/dictionary/content_file.md +1115 -0
  409. package/docs/vi/dictionary/enumeration.md +255 -0
  410. package/docs/vi/dictionary/file.md +234 -0
  411. package/docs/vi/dictionary/function_fetching.md +212 -0
  412. package/docs/vi/dictionary/gender.md +275 -0
  413. package/docs/vi/dictionary/insertion.md +191 -0
  414. package/docs/vi/dictionary/markdown.md +381 -0
  415. package/docs/vi/dictionary/nesting.md +273 -0
  416. package/docs/vi/dictionary/translation.md +309 -0
  417. package/docs/vi/formatters.md +595 -0
  418. package/docs/vi/how_works_intlayer.md +256 -0
  419. package/docs/vi/index.md +174 -0
  420. package/docs/vi/interest_of_intlayer.md +292 -0
  421. package/docs/vi/intlayer_CMS.md +549 -0
  422. package/docs/vi/intlayer_cli.md +850 -0
  423. package/docs/vi/intlayer_visual_editor.md +288 -0
  424. package/docs/vi/intlayer_with_angular.md +692 -0
  425. package/docs/vi/intlayer_with_astro.md +252 -0
  426. package/docs/vi/intlayer_with_create_react_app.md +1230 -0
  427. package/docs/vi/intlayer_with_express.md +409 -0
  428. package/docs/vi/intlayer_with_lynx+react.md +520 -0
  429. package/docs/vi/intlayer_with_nestjs.md +272 -0
  430. package/docs/vi/intlayer_with_next-i18next.md +628 -0
  431. package/docs/vi/intlayer_with_next-intl.md +446 -0
  432. package/docs/vi/intlayer_with_nextjs_14.md +1584 -0
  433. package/docs/vi/intlayer_with_nextjs_15.md +1738 -0
  434. package/docs/vi/intlayer_with_nextjs_16.md +21 -0
  435. package/docs/vi/intlayer_with_nextjs_page_router.md +1504 -0
  436. package/docs/vi/intlayer_with_nuxt.md +821 -0
  437. package/docs/vi/intlayer_with_react_native+expo.md +700 -0
  438. package/docs/vi/intlayer_with_react_router_v7.md +498 -0
  439. package/docs/vi/intlayer_with_tanstack.md +562 -0
  440. package/docs/vi/intlayer_with_vite+preact.md +1722 -0
  441. package/docs/vi/intlayer_with_vite+react.md +1407 -0
  442. package/docs/vi/intlayer_with_vite+solid.md +287 -0
  443. package/docs/vi/intlayer_with_vite+svelte.md +289 -0
  444. package/docs/vi/intlayer_with_vite+vue.md +1071 -0
  445. package/docs/vi/introduction.md +215 -0
  446. package/docs/vi/locale_mapper.md +242 -0
  447. package/docs/vi/mcp_server.md +211 -0
  448. package/docs/vi/packages/express-intlayer/t.md +457 -0
  449. package/docs/vi/packages/intlayer/getConfiguration.md +145 -0
  450. package/docs/vi/packages/intlayer/getEnumeration.md +162 -0
  451. package/docs/vi/packages/intlayer/getHTMLTextDir.md +121 -0
  452. package/docs/vi/packages/intlayer/getLocaleLang.md +81 -0
  453. package/docs/vi/packages/intlayer/getLocaleName.md +129 -0
  454. package/docs/vi/packages/intlayer/getLocalizedUrl.md +309 -0
  455. package/docs/vi/packages/intlayer/getMultilingualUrls.md +221 -0
  456. package/docs/vi/packages/intlayer/getPathWithoutLocale.md +75 -0
  457. package/docs/vi/packages/intlayer/getTranslation.md +201 -0
  458. package/docs/vi/packages/intlayer/getTranslationContent.md +188 -0
  459. package/docs/vi/packages/next-intlayer/t.md +352 -0
  460. package/docs/vi/packages/next-intlayer/useDictionary.md +273 -0
  461. package/docs/vi/packages/next-intlayer/useIntlayer.md +264 -0
  462. package/docs/vi/packages/next-intlayer/useLocale.md +166 -0
  463. package/docs/vi/packages/react-intlayer/t.md +304 -0
  464. package/docs/vi/packages/react-intlayer/useDictionary.md +288 -0
  465. package/docs/vi/packages/react-intlayer/useI18n.md +295 -0
  466. package/docs/vi/packages/react-intlayer/useIntlayer.md +256 -0
  467. package/docs/vi/packages/react-intlayer/useLocale.md +210 -0
  468. package/docs/vi/per_locale_file.md +326 -0
  469. package/docs/vi/readme.md +261 -0
  470. package/docs/vi/releases/v6.md +305 -0
  471. package/docs/vi/roadmap.md +346 -0
  472. package/docs/vi/testing.md +202 -0
  473. package/docs/vi/vs_code_extension.md +126 -0
  474. package/docs/zh/configuration.md +6 -0
  475. package/docs/zh/intlayer_cli.md +8 -3
  476. package/docs/zh/intlayer_with_next-i18next.md +628 -0
  477. package/docs/zh/intlayer_with_next-intl.md +448 -0
  478. package/docs/zh/intlayer_with_nextjs_16.md +21 -0
  479. package/docs/zh/intlayer_with_tanstack.md +4 -0
  480. package/docs/zh/intlayer_with_vite+react.md +4 -0
  481. package/frequent_questions/ar/SSR_Next_no_[locale].md +1 -2
  482. package/frequent_questions/ar/array_as_content_declaration.md +1 -2
  483. package/frequent_questions/ar/build_dictionaries.md +1 -2
  484. package/frequent_questions/ar/build_error_CI_CD.md +1 -2
  485. package/frequent_questions/ar/bun_set_up.md +1 -2
  486. package/frequent_questions/ar/customized_locale_list.md +1 -2
  487. package/frequent_questions/ar/domain_routing.md +1 -2
  488. package/frequent_questions/ar/esbuild_error.md +1 -2
  489. package/frequent_questions/ar/get_locale_cookie.md +1 -2
  490. package/frequent_questions/ar/intlayer_command_undefined.md +1 -2
  491. package/frequent_questions/ar/locale_incorect_in_url.md +1 -2
  492. package/frequent_questions/ar/static_rendering.md +1 -3
  493. package/frequent_questions/ar/translated_path_url.md +1 -2
  494. package/frequent_questions/ar/unknown_command.md +1 -2
  495. package/frequent_questions/de/SSR_Next_no_[locale].md +1 -2
  496. package/frequent_questions/de/array_as_content_declaration.md +1 -2
  497. package/frequent_questions/de/build_dictionaries.md +1 -2
  498. package/frequent_questions/de/build_error_CI_CD.md +1 -2
  499. package/frequent_questions/de/bun_set_up.md +1 -2
  500. package/frequent_questions/de/customized_locale_list.md +1 -2
  501. package/frequent_questions/de/domain_routing.md +1 -2
  502. package/frequent_questions/de/esbuild_error.md +1 -2
  503. package/frequent_questions/de/get_locale_cookie.md +1 -2
  504. package/frequent_questions/de/intlayer_command_undefined.md +1 -2
  505. package/frequent_questions/de/locale_incorect_in_url.md +1 -2
  506. package/frequent_questions/de/static_rendering.md +1 -3
  507. package/frequent_questions/de/translated_path_url.md +1 -2
  508. package/frequent_questions/de/unknown_command.md +1 -2
  509. package/frequent_questions/en/SSR_Next_no_[locale].md +1 -2
  510. package/frequent_questions/en/array_as_content_declaration.md +1 -2
  511. package/frequent_questions/en/build_dictionaries.md +1 -2
  512. package/frequent_questions/en/build_error_CI_CD.md +1 -2
  513. package/frequent_questions/en/bun_set_up.md +1 -2
  514. package/frequent_questions/en/customized_locale_list.md +1 -2
  515. package/frequent_questions/en/domain_routing.md +1 -2
  516. package/frequent_questions/en/esbuild_error.md +1 -2
  517. package/frequent_questions/en/get_locale_cookie.md +1 -2
  518. package/frequent_questions/en/intlayer_command_undefined.md +1 -2
  519. package/frequent_questions/en/locale_incorect_in_url.md +1 -2
  520. package/frequent_questions/en/static_rendering.md +1 -3
  521. package/frequent_questions/en/translated_path_url.md +1 -2
  522. package/frequent_questions/en/unknown_command.md +1 -2
  523. package/frequent_questions/en-GB/SSR_Next_no_[locale].md +1 -2
  524. package/frequent_questions/en-GB/array_as_content_declaration.md +1 -2
  525. package/frequent_questions/en-GB/build_dictionaries.md +1 -2
  526. package/frequent_questions/en-GB/build_error_CI_CD.md +1 -2
  527. package/frequent_questions/en-GB/bun_set_up.md +1 -2
  528. package/frequent_questions/en-GB/customized_locale_list.md +1 -2
  529. package/frequent_questions/en-GB/domain_routing.md +1 -2
  530. package/frequent_questions/en-GB/esbuild_error.md +1 -2
  531. package/frequent_questions/en-GB/get_locale_cookie.md +1 -2
  532. package/frequent_questions/en-GB/intlayer_command_undefined.md +1 -2
  533. package/frequent_questions/en-GB/locale_incorect_in_url.md +1 -2
  534. package/frequent_questions/en-GB/static_rendering.md +1 -3
  535. package/frequent_questions/en-GB/translated_path_url.md +1 -2
  536. package/frequent_questions/en-GB/unknown_command.md +1 -2
  537. package/frequent_questions/es/SSR_Next_no_[locale].md +1 -2
  538. package/frequent_questions/es/array_as_content_declaration.md +1 -2
  539. package/frequent_questions/es/build_dictionaries.md +1 -2
  540. package/frequent_questions/es/build_error_CI_CD.md +1 -2
  541. package/frequent_questions/es/bun_set_up.md +1 -2
  542. package/frequent_questions/es/customized_locale_list.md +1 -2
  543. package/frequent_questions/es/domain_routing.md +1 -2
  544. package/frequent_questions/es/esbuild_error.md +1 -2
  545. package/frequent_questions/es/get_locale_cookie.md +1 -2
  546. package/frequent_questions/es/intlayer_command_undefined.md +1 -2
  547. package/frequent_questions/es/locale_incorect_in_url.md +1 -2
  548. package/frequent_questions/es/static_rendering.md +1 -3
  549. package/frequent_questions/es/translated_path_url.md +1 -2
  550. package/frequent_questions/es/unknown_command.md +1 -2
  551. package/frequent_questions/fr/SSR_Next_no_[locale].md +1 -2
  552. package/frequent_questions/fr/array_as_content_declaration.md +1 -2
  553. package/frequent_questions/fr/build_dictionaries.md +1 -2
  554. package/frequent_questions/fr/build_error_CI_CD.md +1 -2
  555. package/frequent_questions/fr/bun_set_up.md +1 -2
  556. package/frequent_questions/fr/customized_locale_list.md +1 -2
  557. package/frequent_questions/fr/domain_routing.md +1 -2
  558. package/frequent_questions/fr/esbuild_error.md +1 -2
  559. package/frequent_questions/fr/get_locale_cookie.md +1 -2
  560. package/frequent_questions/fr/intlayer_command_undefined.md +1 -2
  561. package/frequent_questions/fr/locale_incorect_in_url.md +1 -2
  562. package/frequent_questions/fr/static_rendering.md +1 -3
  563. package/frequent_questions/fr/translated_path_url.md +1 -2
  564. package/frequent_questions/fr/unknown_command.md +1 -2
  565. package/frequent_questions/hi/SSR_Next_no_[locale].md +1 -2
  566. package/frequent_questions/hi/array_as_content_declaration.md +1 -2
  567. package/frequent_questions/hi/build_dictionaries.md +1 -2
  568. package/frequent_questions/hi/build_error_CI_CD.md +1 -2
  569. package/frequent_questions/hi/bun_set_up.md +1 -2
  570. package/frequent_questions/hi/customized_locale_list.md +1 -2
  571. package/frequent_questions/hi/domain_routing.md +1 -2
  572. package/frequent_questions/hi/esbuild_error.md +1 -2
  573. package/frequent_questions/hi/get_locale_cookie.md +1 -2
  574. package/frequent_questions/hi/intlayer_command_undefined.md +1 -2
  575. package/frequent_questions/hi/locale_incorect_in_url.md +1 -2
  576. package/frequent_questions/hi/static_rendering.md +1 -3
  577. package/frequent_questions/hi/translated_path_url.md +1 -2
  578. package/frequent_questions/hi/unknown_command.md +1 -2
  579. package/frequent_questions/id/SSR_Next_no_[locale].md +104 -0
  580. package/frequent_questions/id/array_as_content_declaration.md +71 -0
  581. package/frequent_questions/id/build_dictionaries.md +58 -0
  582. package/frequent_questions/id/build_error_CI_CD.md +74 -0
  583. package/frequent_questions/id/bun_set_up.md +53 -0
  584. package/frequent_questions/id/customized_locale_list.md +64 -0
  585. package/frequent_questions/id/domain_routing.md +113 -0
  586. package/frequent_questions/id/esbuild_error.md +29 -0
  587. package/frequent_questions/id/get_locale_cookie.md +142 -0
  588. package/frequent_questions/id/intlayer_command_undefined.md +155 -0
  589. package/frequent_questions/id/locale_incorect_in_url.md +73 -0
  590. package/frequent_questions/id/static_rendering.md +44 -0
  591. package/frequent_questions/id/translated_path_url.md +55 -0
  592. package/frequent_questions/id/unknown_command.md +97 -0
  593. package/frequent_questions/it/SSR_Next_no_[locale].md +1 -2
  594. package/frequent_questions/it/array_as_content_declaration.md +1 -2
  595. package/frequent_questions/it/build_dictionaries.md +1 -2
  596. package/frequent_questions/it/build_error_CI_CD.md +1 -2
  597. package/frequent_questions/it/bun_set_up.md +1 -2
  598. package/frequent_questions/it/customized_locale_list.md +1 -2
  599. package/frequent_questions/it/domain_routing.md +1 -2
  600. package/frequent_questions/it/esbuild_error.md +1 -2
  601. package/frequent_questions/it/get_locale_cookie.md +1 -2
  602. package/frequent_questions/it/intlayer_command_undefined.md +1 -2
  603. package/frequent_questions/it/locale_incorect_in_url.md +1 -2
  604. package/frequent_questions/it/static_rendering.md +1 -3
  605. package/frequent_questions/it/translated_path_url.md +1 -2
  606. package/frequent_questions/it/unknown_command.md +1 -2
  607. package/frequent_questions/ja/SSR_Next_no_[locale].md +1 -2
  608. package/frequent_questions/ja/array_as_content_declaration.md +1 -2
  609. package/frequent_questions/ja/build_dictionaries.md +1 -2
  610. package/frequent_questions/ja/build_error_CI_CD.md +1 -2
  611. package/frequent_questions/ja/bun_set_up.md +1 -2
  612. package/frequent_questions/ja/customized_locale_list.md +1 -2
  613. package/frequent_questions/ja/domain_routing.md +1 -2
  614. package/frequent_questions/ja/esbuild_error.md +1 -2
  615. package/frequent_questions/ja/get_locale_cookie.md +1 -2
  616. package/frequent_questions/ja/intlayer_command_undefined.md +1 -2
  617. package/frequent_questions/ja/locale_incorect_in_url.md +1 -2
  618. package/frequent_questions/ja/static_rendering.md +1 -3
  619. package/frequent_questions/ja/translated_path_url.md +1 -2
  620. package/frequent_questions/ja/unknown_command.md +1 -2
  621. package/frequent_questions/ko/SSR_Next_no_[locale].md +1 -2
  622. package/frequent_questions/ko/array_as_content_declaration.md +1 -2
  623. package/frequent_questions/ko/build_dictionaries.md +1 -2
  624. package/frequent_questions/ko/build_error_CI_CD.md +1 -2
  625. package/frequent_questions/ko/bun_set_up.md +1 -2
  626. package/frequent_questions/ko/customized_locale_list.md +1 -2
  627. package/frequent_questions/ko/domain_routing.md +1 -2
  628. package/frequent_questions/ko/esbuild_error.md +1 -2
  629. package/frequent_questions/ko/get_locale_cookie.md +1 -2
  630. package/frequent_questions/ko/intlayer_command_undefined.md +1 -2
  631. package/frequent_questions/ko/locale_incorect_in_url.md +1 -2
  632. package/frequent_questions/ko/static_rendering.md +1 -3
  633. package/frequent_questions/ko/translated_path_url.md +1 -2
  634. package/frequent_questions/ko/unknown_command.md +1 -2
  635. package/frequent_questions/pl/SSR_Next_no_[locale].md +104 -0
  636. package/frequent_questions/pl/array_as_content_declaration.md +71 -0
  637. package/frequent_questions/pl/build_dictionaries.md +58 -0
  638. package/frequent_questions/pl/build_error_CI_CD.md +74 -0
  639. package/frequent_questions/pl/bun_set_up.md +54 -0
  640. package/frequent_questions/pl/customized_locale_list.md +64 -0
  641. package/frequent_questions/pl/domain_routing.md +113 -0
  642. package/frequent_questions/pl/esbuild_error.md +29 -0
  643. package/frequent_questions/pl/get_locale_cookie.md +142 -0
  644. package/frequent_questions/pl/intlayer_command_undefined.md +155 -0
  645. package/frequent_questions/pl/locale_incorect_in_url.md +73 -0
  646. package/frequent_questions/pl/static_rendering.md +44 -0
  647. package/frequent_questions/pl/translated_path_url.md +55 -0
  648. package/frequent_questions/pl/unknown_command.md +97 -0
  649. package/frequent_questions/pt/SSR_Next_no_[locale].md +1 -2
  650. package/frequent_questions/pt/array_as_content_declaration.md +1 -2
  651. package/frequent_questions/pt/build_dictionaries.md +1 -2
  652. package/frequent_questions/pt/build_error_CI_CD.md +1 -2
  653. package/frequent_questions/pt/bun_set_up.md +1 -2
  654. package/frequent_questions/pt/customized_locale_list.md +1 -2
  655. package/frequent_questions/pt/domain_routing.md +1 -2
  656. package/frequent_questions/pt/esbuild_error.md +1 -2
  657. package/frequent_questions/pt/get_locale_cookie.md +1 -2
  658. package/frequent_questions/pt/intlayer_command_undefined.md +1 -2
  659. package/frequent_questions/pt/locale_incorect_in_url.md +1 -2
  660. package/frequent_questions/pt/static_rendering.md +1 -3
  661. package/frequent_questions/pt/translated_path_url.md +1 -2
  662. package/frequent_questions/pt/unknown_command.md +1 -2
  663. package/frequent_questions/ru/SSR_Next_no_[locale].md +1 -2
  664. package/frequent_questions/ru/array_as_content_declaration.md +1 -2
  665. package/frequent_questions/ru/build_dictionaries.md +1 -2
  666. package/frequent_questions/ru/build_error_CI_CD.md +1 -2
  667. package/frequent_questions/ru/bun_set_up.md +1 -2
  668. package/frequent_questions/ru/customized_locale_list.md +1 -2
  669. package/frequent_questions/ru/domain_routing.md +1 -2
  670. package/frequent_questions/ru/esbuild_error.md +1 -2
  671. package/frequent_questions/ru/get_locale_cookie.md +1 -2
  672. package/frequent_questions/ru/intlayer_command_undefined.md +1 -2
  673. package/frequent_questions/ru/locale_incorect_in_url.md +1 -2
  674. package/frequent_questions/ru/static_rendering.md +1 -2
  675. package/frequent_questions/ru/translated_path_url.md +1 -2
  676. package/frequent_questions/ru/unknown_command.md +1 -2
  677. package/frequent_questions/tr/SSR_Next_no_[locale].md +1 -2
  678. package/frequent_questions/tr/array_as_content_declaration.md +1 -2
  679. package/frequent_questions/tr/build_dictionaries.md +1 -2
  680. package/frequent_questions/tr/build_error_CI_CD.md +1 -2
  681. package/frequent_questions/tr/bun_set_up.md +1 -2
  682. package/frequent_questions/tr/customized_locale_list.md +1 -2
  683. package/frequent_questions/tr/domain_routing.md +1 -2
  684. package/frequent_questions/tr/esbuild_error.md +1 -2
  685. package/frequent_questions/tr/get_locale_cookie.md +1 -2
  686. package/frequent_questions/tr/intlayer_command_undefined.md +1 -2
  687. package/frequent_questions/tr/locale_incorect_in_url.md +1 -2
  688. package/frequent_questions/tr/static_rendering.md +1 -2
  689. package/frequent_questions/tr/translated_path_url.md +1 -2
  690. package/frequent_questions/tr/unknown_command.md +1 -2
  691. package/frequent_questions/vi/SSR_Next_no_[locale].md +106 -0
  692. package/frequent_questions/vi/array_as_content_declaration.md +71 -0
  693. package/frequent_questions/vi/build_dictionaries.md +58 -0
  694. package/frequent_questions/vi/build_error_CI_CD.md +74 -0
  695. package/frequent_questions/vi/bun_set_up.md +53 -0
  696. package/frequent_questions/vi/customized_locale_list.md +64 -0
  697. package/frequent_questions/vi/domain_routing.md +113 -0
  698. package/frequent_questions/vi/esbuild_error.md +29 -0
  699. package/frequent_questions/vi/get_locale_cookie.md +142 -0
  700. package/frequent_questions/vi/intlayer_command_undefined.md +155 -0
  701. package/frequent_questions/vi/locale_incorect_in_url.md +73 -0
  702. package/frequent_questions/vi/static_rendering.md +44 -0
  703. package/frequent_questions/vi/translated_path_url.md +55 -0
  704. package/frequent_questions/vi/unknown_command.md +97 -0
  705. package/frequent_questions/zh/SSR_Next_no_[locale].md +1 -2
  706. package/frequent_questions/zh/array_as_content_declaration.md +1 -2
  707. package/frequent_questions/zh/build_dictionaries.md +1 -2
  708. package/frequent_questions/zh/build_error_CI_CD.md +1 -2
  709. package/frequent_questions/zh/bun_set_up.md +1 -2
  710. package/frequent_questions/zh/customized_locale_list.md +1 -2
  711. package/frequent_questions/zh/domain_routing.md +1 -2
  712. package/frequent_questions/zh/esbuild_error.md +1 -2
  713. package/frequent_questions/zh/get_locale_cookie.md +1 -2
  714. package/frequent_questions/zh/intlayer_command_undefined.md +1 -2
  715. package/frequent_questions/zh/locale_incorect_in_url.md +1 -2
  716. package/frequent_questions/zh/static_rendering.md +1 -3
  717. package/frequent_questions/zh/translated_path_url.md +1 -2
  718. package/frequent_questions/zh/unknown_command.md +1 -2
  719. package/legal/id/privacy_notice.md +83 -0
  720. package/legal/id/terms_of_service.md +55 -0
  721. package/legal/pl/privacy_notice.md +83 -0
  722. package/legal/pl/terms_of_service.md +55 -0
  723. package/legal/vi/privacy_notice.md +83 -0
  724. package/legal/vi/terms_of_service.md +55 -0
  725. package/package.json +19 -18
  726. package/src/generated/blog.entry.ts +38 -0
@@ -0,0 +1,1722 @@
1
+ ---
2
+ createdAt: 2025-04-18
3
+ updatedAt: 2025-10-28
4
+ title: Cách dịch ứng dụng Vite và Preact của bạn – Hướng dẫn i18n 2025
5
+ description: Khám phá cách làm cho trang web Vite và Preact của bạn đa ngôn ngữ. Theo dõi tài liệu để quốc tế hóa (i18n) và dịch nó.
6
+ keywords:
7
+ - Quốc tế hóa
8
+ - Tài liệu
9
+ - Intlayer
10
+ - Vite
11
+ - Preact
12
+ - JavaScript
13
+ slugs:
14
+ - doc
15
+ - environment
16
+ - vite-and-preact
17
+ applicationTemplate: https://github.com/aymericzip/intlayer-vite-preact-template
18
+ history:
19
+ - version: 7.0.0
20
+ date: 2025-10-28
21
+ changes: Cập nhật component LocaleRouter để sử dụng cấu hình route mới
22
+ - version: 5.5.10
23
+ date: 2025-06-29
24
+ changes: Khởi tạo lịch sử
25
+ ---
26
+
27
+ # Dịch trang web Vite và Preact của bạn bằng Intlayer | Quốc tế hóa (i18n)
28
+
29
+ > Gói này đang trong quá trình phát triển. Xem [vấn đề](https://github.com/aymericzip/intlayer/issues/118) để biết thêm thông tin. Thể hiện sự quan tâm của bạn đến Intlayer cho Preact bằng cách thích vấn đề này
30
+
31
+ ## Mục lục
32
+
33
+ <TOC/>
34
+
35
+ ## Intlayer là gì?
36
+
37
+ **Intlayer** là một thư viện quốc tế hóa (i18n) mã nguồn mở sáng tạo, được thiết kế để đơn giản hóa việc hỗ trợ đa ngôn ngữ trong các ứng dụng web hiện đại.
38
+
39
+ Với Intlayer, bạn có thể:
40
+
41
+ - **Dễ dàng quản lý bản dịch** bằng cách sử dụng các từ điển khai báo ở cấp độ component.
42
+ - **Địa phương hóa động metadata**, các route và nội dung.
43
+ - **Đảm bảo hỗ trợ TypeScript** với các kiểu được tạo tự động, cải thiện tính năng tự hoàn thành và phát hiện lỗi.
44
+ - **Tận hưởng các tính năng nâng cao**, như phát hiện và chuyển đổi locale động.
45
+
46
+ ---
47
+
48
+ ## Hướng Dẫn Từng Bước Để Cài Đặt Intlayer Trong Ứng Dụng Vite và Preact
49
+
50
+ <iframe
51
+ src="https://stackblitz.com/github/aymericzip/intlayer-vite-preact-template?embed=1&ctl=1&file=intlayer.config.ts"
52
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
53
+ title="Demo CodeSandbox - Cách Quốc tế hóa ứng dụng của bạn bằng Intlayer"
54
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
55
+ loading="lazy"
56
+ />
57
+
58
+ Xem [Mẫu Ứng Dụng](https://github.com/aymericzip/intlayer-vite-preact-template) trên GitHub.
59
+
60
+ ### Bước 1: Cài Đặt Các Phụ Thuộc
61
+
62
+ Cài đặt các gói cần thiết bằng npm:
63
+
64
+ ```bash packageManager="npm"
65
+ npm install intlayer preact-intlayer
66
+ npm install vite-intlayer --save-dev
67
+ ```
68
+
69
+ ```bash packageManager="pnpm"
70
+ pnpm add intlayer preact-intlayer
71
+ pnpm add vite-intlayer --save-dev
72
+ ```
73
+
74
+ ```bash packageManager="yarn"
75
+ yarn add intlayer preact-intlayer
76
+ yarn add vite-intlayer --save-dev
77
+ ```
78
+
79
+ - **intlayer**
80
+
81
+ Gói cốt lõi cung cấp các công cụ quốc tế hóa cho quản lý cấu hình, dịch thuật, [khai báo nội dung](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/dictionary/content_file.md), chuyển đổi mã, và các [lệnh CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/intlayer_cli.md).
82
+
83
+ - **preact-intlayer**
84
+ Gói tích hợp Intlayer với ứng dụng Preact. Nó cung cấp các context provider và hook cho việc quốc tế hóa trong Preact.
85
+
86
+ - **vite-intlayer**
87
+ Bao gồm plugin Vite để tích hợp Intlayer với [Vite bundler](https://vite.dev/guide/why.html#why-bundle-for-production), cũng như middleware để phát hiện ngôn ngữ ưu tiên của người dùng, quản lý cookie và xử lý chuyển hướng URL.
88
+
89
+ ### Bước 2: Cấu hình dự án của bạn
90
+
91
+ Tạo một file cấu hình để cấu hình các ngôn ngữ của ứng dụng của bạn:
92
+
93
+ ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
94
+ import { Locales, type IntlayerConfig } from "intlayer";
95
+
96
+ const config: IntlayerConfig = {
97
+ internationalization: {
98
+ locales: [
99
+ Locales.ENGLISH,
100
+ Locales.FRENCH,
101
+ Locales.SPANISH,
102
+ // Các ngôn ngữ khác của bạn
103
+ ],
104
+ defaultLocale: Locales.ENGLISH,
105
+ },
106
+ routing: {
107
+ mode: "prefix-no-default", // Mặc định: thêm tiền tố cho tất cả các ngôn ngữ ngoại trừ ngôn ngữ mặc định
108
+ storage: ["cookie", "header"], // Mặc định: lưu ngôn ngữ trong cookie và phát hiện từ header
109
+ },
110
+ };
111
+
112
+ export default config;
113
+ ```
114
+
115
+ ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
116
+ import { Locales } from "intlayer";
117
+
118
+ /** @type {import('intlayer').IntlayerConfig} */
119
+ const config = {
120
+ internationalization: {
121
+ locales: [
122
+ Locales.ENGLISH,
123
+ Locales.FRENCH,
124
+ Locales.SPANISH,
125
+ // Các ngôn ngữ khác của bạn
126
+ ],
127
+ defaultLocale: Locales.ENGLISH,
128
+ },
129
+ routing: {
130
+ mode: "prefix-no-default", // Mặc định: thêm tiền tố cho tất cả các ngôn ngữ ngoại trừ ngôn ngữ mặc định
131
+ storage: ["cookie", "header"], // Mặc định: lưu ngôn ngữ trong cookie và phát hiện từ header
132
+ },
133
+ };
134
+
135
+ export default config;
136
+ ```
137
+
138
+ ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
139
+ const { Locales } = require("intlayer");
140
+
141
+ /** @type {import('intlayer').IntlayerConfig} */
142
+ const config = {
143
+ internationalization: {
144
+ locales: [
145
+ Locales.ENGLISH,
146
+ Locales.FRENCH,
147
+ Locales.SPANISH,
148
+ // Các ngôn ngữ khác của bạn
149
+ ],
150
+ defaultLocale: Locales.ENGLISH,
151
+ },
152
+ routing: {
153
+ mode: "prefix-no-default", // Mặc định: thêm tiền tố cho tất cả các ngôn ngữ ngoại trừ ngôn ngữ mặc định
154
+ storage: ["cookie", "header"], // Mặc định: lưu ngôn ngữ trong cookie và phát hiện từ header
155
+ },
156
+ };
157
+
158
+ module.exports = config;
159
+ ```
160
+
161
+ > Thông qua tệp cấu hình này, bạn có thể thiết lập URL đa ngôn ngữ, chế độ định tuyến, tùy chọn lưu trữ, tên cookie, vị trí và phần mở rộng của các khai báo nội dung, tắt các log của Intlayer trên console, và nhiều hơn nữa. Để xem danh sách đầy đủ các tham số có sẵn, hãy tham khảo [tài liệu cấu hình](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/configuration.md).
162
+
163
+ ### Bước 3: Tích hợp Intlayer vào cấu hình Vite của bạn
164
+
165
+ Thêm plugin intlayer vào cấu hình của bạn.
166
+
167
+ ```typescript fileName="vite.config.ts" codeFormat="typescript"
168
+ import { defineConfig } from "vite";
169
+ import preact from "@preact/preset-vite";
170
+ import { intlayer } from "vite-intlayer";
171
+
172
+ // https://vitejs.dev/config/
173
+ export default defineConfig({
174
+ plugins: [preact(), intlayer()],
175
+ });
176
+ ```
177
+
178
+ ```javascript fileName="vite.config.mjs" codeFormat="esm"
179
+ import { defineConfig } from "vite";
180
+ import preact from "@preact/preset-vite";
181
+ import { intlayer } from "vite-intlayer";
182
+
183
+ // https://vitejs.dev/config/
184
+ export default defineConfig({
185
+ plugins: [preact(), intlayer()],
186
+ });
187
+ ```
188
+
189
+ ```javascript fileName="vite.config.cjs" codeFormat="commonjs"
190
+ const { defineConfig } = require("vite");
191
+ const preact = require("@preact/preset-vite");
192
+ const { intlayer } = require("vite-intlayer");
193
+
194
+ // https://vitejs.dev/config/
195
+ module.exports = defineConfig({
196
+ plugins: [preact(), intlayer()],
197
+ });
198
+ ```
199
+
200
+ > Plugin Vite `intlayer()` được sử dụng để tích hợp Intlayer với Vite. Nó đảm bảo việc xây dựng các file khai báo nội dung và giám sát chúng trong chế độ phát triển. Nó định nghĩa các biến môi trường Intlayer trong ứng dụng Vite. Ngoài ra, nó còn cung cấp các bí danh để tối ưu hiệu suất.
201
+
202
+ ### Bước 4: Khai báo Nội dung của Bạn
203
+
204
+ Tạo và quản lý các khai báo nội dung để lưu trữ bản dịch:
205
+
206
+ ```tsx fileName="src/app.content.tsx" contentDeclarationFormat="typescript"
207
+ import { t, type Dictionary } from "intlayer";
208
+ import type { ComponentChildren } from "preact";
209
+
210
+ const appContent = {
211
+ key: "app",
212
+ content: {
213
+ viteLogo: t({
214
+ en: "Vite logo",
215
+ fr: "Logo Vite",
216
+ es: "Logo Vite",
217
+ }),
218
+ preactLogo: t({
219
+ en: "Preact logo",
220
+ fr: "Logo Preact",
221
+ es: "Logo Preact",
222
+ }),
223
+
224
+ title: "Vite + Preact",
225
+
226
+ count: t({
227
+ en: "count is ",
228
+ fr: "le compte est ",
229
+ es: "el recuento es ",
230
+ }),
231
+
232
+ edit: t<ComponentChildren>({
233
+ en: (
234
+ <>
235
+ Chỉnh sửa <code>src/app.tsx</code> và lưu để thử HMR
236
+ </>
237
+ ),
238
+ fr: (
239
+ <>
240
+ Éditez <code>src/app.tsx</code> et enregistrez pour tester HMR
241
+ </>
242
+ ),
243
+ es: (
244
+ <>
245
+ Edita <code>src/app.tsx</code> y guarda para probar HMR
246
+ </>
247
+ ),
248
+ }),
249
+
250
+ readTheDocs: t({
251
+ en: "Nhấn vào logo Vite và Preact để tìm hiểu thêm",
252
+ fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
253
+ es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
254
+ }),
255
+ },
256
+ } satisfies Dictionary;
257
+
258
+ export default appContent;
259
+ ```
260
+
261
+ ```javascript fileName="src/app.content.mjs" contentDeclarationFormat="esm"
262
+ import { t } from "intlayer";
263
+ // import { h } from 'preact'; // Cần thiết nếu bạn sử dụng JSX trực tiếp trong .mjs
264
+
265
+ /** @type {import('intlayer').Dictionary} */
266
+ const appContent = {
267
+ key: "app",
268
+ content: {
269
+ viteLogo: t({
270
+ en: "Vite logo",
271
+ fr: "Logo Vite",
272
+ es: "Logo Vite",
273
+ }),
274
+ preactLogo: t({
275
+ en: "Preact logo",
276
+ fr: "Logo Preact",
277
+ es: "Logo Preact",
278
+ }),
279
+
280
+ title: "Vite + Preact",
281
+
282
+ count: t({
283
+ en: "count is ",
284
+ fr: "le compte est ",
285
+ es: "el recuento es ",
286
+ }),
287
+
288
+ edit: t({
289
+ en: "Chỉnh sửa src/app.jsx và lưu để thử HMR",
290
+ fr: "Éditez src/app.jsx et enregistrez pour tester HMR",
291
+ es: "Edita src/app.jsx y guarda para probar HMR",
292
+ }),
293
+
294
+ readTheDocs: t({
295
+ en: "Nhấn vào logo Vite và Preact để tìm hiểu thêm",
296
+ fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
297
+ es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
298
+ }),
299
+ },
300
+ };
301
+
302
+ export default appContent;
303
+ ```
304
+
305
+ ```javascript fileName="src/app.content.cjs" contentDeclarationFormat="commonjs"
306
+ const { t } = require("intlayer");
307
+ // const { h } = require('preact'); // Cần thiết nếu bạn sử dụng JSX trực tiếp trong .cjs
308
+
309
+ /** @type {import('intlayer').Dictionary} */
310
+ const appContent = {
311
+ key: "app",
312
+ content: {
313
+ viteLogo: t({
314
+ en: "Vite logo",
315
+ fr: "Logo Vite",
316
+ es: "Logo Vite",
317
+ }),
318
+ preactLogo: t({
319
+ en: "Preact logo",
320
+ fr: "Logo Preact",
321
+ es: "Logo Preact",
322
+ }),
323
+
324
+ title: "Vite + Preact",
325
+
326
+ count: t({
327
+ en: "count is ",
328
+ fr: "le compte est ",
329
+ es: "el recuento es ",
330
+ vi: "số đếm là ",
331
+ }),
332
+
333
+ edit: t({
334
+ en: "Edit src/app.tsx and save to test HMR",
335
+ fr: "Éditez src/app.tsx et enregistrez pour tester HMR",
336
+ es: "Edita src/app.tsx y guarda para probar HMR",
337
+ vi: "Chỉnh sửa src/app.tsx và lưu để thử HMR",
338
+ }),
339
+
340
+ readTheDocs: t({
341
+ en: "Click on the Vite and Preact logos to learn more",
342
+ fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
343
+ es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
344
+ vi: "Nhấn vào logo Vite và Preact để tìm hiểu thêm",
345
+ }),
346
+ },
347
+ };
348
+
349
+ module.exports = appContent;
350
+ ```
351
+
352
+ ```json fileName="src/app.content.json" contentDeclarationFormat="json"
353
+ {
354
+ "$schema": "https://intlayer.org/schema.json",
355
+ "key": "app",
356
+ "content": {
357
+ "viteLogo": {
358
+ "nodeType": "translation",
359
+ "translation": {
360
+ "en": "Vite logo",
361
+ "fr": "Logo Vite",
362
+ "es": "Logo Vite",
363
+ "vi": "Logo Vite"
364
+ }
365
+ },
366
+ "preactLogo": {
367
+ "nodeType": "translation",
368
+ "translation": {
369
+ "en": "Preact logo",
370
+ "fr": "Logo Preact",
371
+ "es": "Logo Preact",
372
+ "vi": "Logo Preact"
373
+ }
374
+ },
375
+ "title": {
376
+ "nodeType": "translation",
377
+ "translation": {
378
+ "en": "Vite + Preact",
379
+ "fr": "Vite + Preact",
380
+ "es": "Vite + Preact",
381
+ "vi": "Vite + Preact"
382
+ }
383
+ },
384
+ "count": {
385
+ "nodeType": "translation",
386
+ "translation": {
387
+ "en": "count is ",
388
+ "fr": "le compte est ",
389
+ "es": "el recuento es ",
390
+ "vi": "số đếm là "
391
+ }
392
+ },
393
+ "edit": {
394
+ "nodeType": "translation",
395
+ "translation": {
396
+ "en": "Edit src/app.tsx and save to test HMR",
397
+ "fr": "Éditez src/app.tsx et enregistrez pour tester HMR",
398
+ "es": "Edita src/app.tsx y guarda para probar HMR",
399
+ "vi": "Chỉnh sửa src/app.tsx và lưu để kiểm tra HMR"
400
+ }
401
+ },
402
+ "readTheDocs": {
403
+ "nodeType": "translation",
404
+ "translation": {
405
+ "en": "Click on the Vite and Preact logos to learn more",
406
+ "fr": "Cliquez sur les logos Vite et Preact pour en savoir plus",
407
+ "es": "Haga clic en los logotipos de Vite y Preact para obtener más información",
408
+ "vi": "Nhấp vào logo Vite và Preact để tìm hiểu thêm"
409
+ }
410
+ }
411
+ }
412
+ }
413
+ ```
414
+
415
+ > Các khai báo nội dung của bạn có thể được định nghĩa ở bất kỳ đâu trong ứng dụng của bạn miễn là chúng được đưa vào thư mục `contentDir` (mặc định là `./src`). Và phải phù hợp với phần mở rộng của file khai báo nội dung (mặc định là `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
416
+
417
+ > Để biết thêm chi tiết, hãy tham khảo [tài liệu khai báo nội dung](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/dictionary/content_file.md).
418
+
419
+ > Nếu file nội dung của bạn bao gồm mã TSX, bạn có thể cần import `import { h } from "preact";` hoặc đảm bảo pragma JSX của bạn được thiết lập đúng cho Preact.
420
+
421
+ ### Bước 5: Sử dụng Intlayer trong Code của Bạn
422
+
423
+ Truy cập các từ điển nội dung trong toàn bộ ứng dụng của bạn:
424
+
425
+ ```tsx {6,10} fileName="src/app.tsx" codeFormat="typescript"
426
+ import { useState } from "preact/hooks";
427
+ import type { FunctionalComponent } from "preact";
428
+ import preactLogo from "./assets/preact.svg"; // Giả sử bạn có file preact.svg
429
+ import viteLogo from "/vite.svg";
430
+ import "./app.css"; // Giả sử file CSS của bạn tên là app.css
431
+ import { IntlayerProvider, useIntlayer } from "preact-intlayer";
432
+
433
+ const AppContent: FunctionalComponent = () => {
434
+ const [count, setCount] = useState(0);
435
+ const content = useIntlayer("app");
436
+
437
+ return (
438
+ <>
439
+ <div>
440
+ <a href="https://vitejs.dev" target="_blank">
441
+ <img src={viteLogo} class="logo" alt={content.viteLogo.value} />
442
+ </a>
443
+ <a href="https://preactjs.com" target="_blank">
444
+ <img
445
+ src={preactLogo}
446
+ class="logo preact"
447
+ alt={content.preactLogo.value}
448
+ />
449
+ </a>
450
+ </div>
451
+ <h1>{content.title}</h1>
452
+ <div class="card">
453
+ <button onClick={() => setCount((count) => count + 1)}>
454
+ {content.count}
455
+ {count}
456
+ </button>
457
+ <p>{content.edit}</p>
458
+ </div>
459
+ <p class="read-the-docs">{content.readTheDocs}</p>
460
+ </>
461
+ );
462
+ };
463
+
464
+ const App: FunctionalComponent = () => (
465
+ <IntlayerProvider>
466
+ <AppContent />
467
+ </IntlayerProvider>
468
+ );
469
+
470
+ export default App;
471
+ ```
472
+
473
+ ```jsx {5,9} fileName="src/app.jsx" codeFormat="esm"
474
+ import { useState } from "preact/hooks";
475
+ import preactLogo from "./assets/preact.svg";
476
+ import viteLogo from "/vite.svg";
477
+ import "./app.css";
478
+ import { IntlayerProvider, useIntlayer } from "preact-intlayer";
479
+
480
+ const AppContent = () => {
481
+ const [count, setCount] = useState(0);
482
+ const content = useIntlayer("app");
483
+
484
+ return (
485
+ <>
486
+ <div>
487
+ <a href="https://vitejs.dev" target="_blank">
488
+ <img src={viteLogo} class="logo" alt={content.viteLogo.value} />
489
+ </a>
490
+ <a href="https://preactjs.com" target="_blank">
491
+ <img
492
+ src={preactLogo}
493
+ class="logo preact"
494
+ alt={content.preactLogo.value}
495
+ />
496
+ </a>
497
+ </div>
498
+ <h1>{content.title}</h1>
499
+ <div class="card">
500
+ <button onClick={() => setCount((count) => count + 1)}>
501
+ {content.count}
502
+ {count}
503
+ </button>
504
+ <p>{content.edit}</p>
505
+ </div>
506
+ <p class="read-the-docs">{content.readTheDocs}</p>
507
+ </>
508
+ );
509
+ };
510
+
511
+ const App = () => (
512
+ <IntlayerProvider>
513
+ <AppContent />
514
+ </IntlayerProvider>
515
+ );
516
+
517
+ export default App;
518
+ ```
519
+
520
+ ```jsx {5,9} fileName="src/app.cjsx" codeFormat="commonjs"
521
+ const { useState } = require("preact/hooks");
522
+ const preactLogo = require("./assets/preact.svg");
523
+ const viteLogo = require("/vite.svg");
524
+ require("./app.css");
525
+ const { IntlayerProvider, useIntlayer } = require("preact-intlayer");
526
+
527
+ const AppContent = () => {
528
+ const [count, setCount] = useState(0);
529
+ const content = useIntlayer("app");
530
+
531
+ return (
532
+ <>
533
+ <div>
534
+ <a href="https://vitejs.dev" target="_blank">
535
+ <img src={viteLogo} class="logo" alt={content.viteLogo.value} />
536
+ </a>
537
+ <a href="https://preactjs.com" target="_blank">
538
+ <img
539
+ src={preactLogo}
540
+ class="logo preact"
541
+ alt={content.preactLogo.value}
542
+ />
543
+ </a>
544
+ </div>
545
+ <h1>{content.title}</h1>
546
+ <div class="card">
547
+ <button onClick={() => setCount((count) => count + 1)}>
548
+ {content.count}
549
+ {count}
550
+ </button>
551
+ <p>{content.edit}</p>
552
+ </div>
553
+ <p class="read-the-docs">{content.readTheDocs}</p>
554
+ </>
555
+ );
556
+ };
557
+
558
+ const App = () => (
559
+ <IntlayerProvider>
560
+ <AppContent />
561
+ </IntlayerProvider>
562
+ );
563
+
564
+ module.exports = App;
565
+ ```
566
+
567
+ > Nếu bạn muốn sử dụng nội dung của mình trong một thuộc tính `string`, chẳng hạn như `alt`, `title`, `href`, `aria-label`, v.v., bạn phải gọi giá trị của hàm, ví dụ:
568
+
569
+ > ```jsx
570
+ > <img src={content.image.src.value} alt={content.image.value} />
571
+ > ```
572
+
573
+ > Lưu ý: Trong Preact, `className` thường được viết là `class`.
574
+
575
+ > Để tìm hiểu thêm về hook `useIntlayer`, hãy tham khảo [tài liệu](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/react-intlayer/useIntlayer.md) (API tương tự cho `preact-intlayer`).
576
+
577
+ ### (Tùy chọn) Bước 6: Thay đổi ngôn ngữ của nội dung
578
+
579
+ Để thay đổi ngôn ngữ của nội dung, bạn có thể sử dụng hàm `setLocale` được cung cấp bởi hook `useLocale`. Hàm này cho phép bạn thiết lập locale của ứng dụng và cập nhật nội dung tương ứng.
580
+
581
+ ```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
582
+ import type { FunctionalComponent } from "preact";
583
+ import { Locales } from "intlayer";
584
+ import { useLocale } from "preact-intlayer";
585
+
586
+ const LocaleSwitcher: FunctionalComponent = () => {
587
+ const { setLocale } = useLocale();
588
+
589
+ return (
590
+ <button onClick={() => setLocale(Locales.ENGLISH)}>
591
+ Thay đổi ngôn ngữ sang tiếng Anh
592
+ </button>
593
+ );
594
+ };
595
+
596
+ export default LocaleSwitcher;
597
+ ```
598
+
599
+ ```jsx fileName="src/components/LocaleSwitcher.jsx" codeFormat="esm"
600
+ import { Locales } from "intlayer";
601
+ import { useLocale } from "preact-intlayer";
602
+
603
+ const LocaleSwitcher = () => {
604
+ const { setLocale } = useLocale();
605
+
606
+ return (
607
+ <button onClick={() => setLocale(Locales.ENGLISH)}>
608
+ Thay đổi ngôn ngữ sang tiếng Anh
609
+ </button>
610
+ );
611
+ };
612
+
613
+ export default LocaleSwitcher;
614
+ ```
615
+
616
+ ```jsx fileName="src/components/LocaleSwitcher.cjsx" codeFormat="commonjs"
617
+ const { Locales } = require("intlayer");
618
+ const { useLocale } = require("preact-intlayer");
619
+
620
+ const LocaleSwitcher = () => {
621
+ const { setLocale } = useLocale();
622
+
623
+ return (
624
+ <button onClick={() => setLocale(Locales.ENGLISH)}>
625
+ Thay đổi ngôn ngữ sang tiếng Anh
626
+ </button>
627
+ );
628
+ };
629
+
630
+ module.exports = LocaleSwitcher;
631
+ ```
632
+
633
+ > Để tìm hiểu thêm về hook `useLocale`, hãy tham khảo [tài liệu](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/react-intlayer/useLocale.md) (API tương tự cho `preact-intlayer`).
634
+
635
+ ### (Tùy chọn) Bước 7: Thêm định tuyến có bản địa hóa vào ứng dụng của bạn
636
+
637
+ Mục đích của bước này là tạo các tuyến đường duy nhất cho mỗi ngôn ngữ. Điều này hữu ích cho SEO và các URL thân thiện với SEO.
638
+ Ví dụ:
639
+
640
+ ```plaintext
641
+ - https://example.com/about
642
+ - https://example.com/es/about
643
+ - https://example.com/fr/about
644
+ ```
645
+
646
+ > Mặc định, các route không được thêm tiền tố cho locale mặc định (`routing.mode: "prefix-no-default"`). Nếu bạn muốn thêm tiền tố cho locale mặc định, bạn có thể đặt tùy chọn `routing.mode` thành `"prefix-all"` trong cấu hình của bạn. Xem thêm tại [tài liệu cấu hình](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/configuration.md) để biết thêm thông tin.
647
+
648
+ Để thêm routing theo locale vào ứng dụng của bạn, bạn có thể tạo một component `LocaleRouter` bao bọc các route của ứng dụng và xử lý routing dựa trên locale. Dưới đây là ví dụ sử dụng [preact-iso](https://github.com/preactjs/preact-iso):
649
+
650
+ Đầu tiên, cài đặt `preact-iso`:
651
+
652
+ ```bash packageManager="npm"
653
+ npm install preact-iso
654
+ ```
655
+
656
+ ```bash packageManager="pnpm"
657
+ pnpm add preact-iso
658
+ ```
659
+
660
+ ```bash packageManager="yarn"
661
+ yarn add preact-iso
662
+ ```
663
+
664
+ ```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
665
+ import { configuration, getPathWithoutLocale, type Locale } from "intlayer";
666
+ import type { ComponentChildren, FunctionalComponent } from "preact";
667
+ import { useEffect } from "preact/hooks";
668
+ import { IntlayerProvider } from "preact-intlayer";
669
+ import { LocationProvider, useLocation } from "preact-iso";
670
+
671
+ const { internationalization, routing } = configuration;
672
+ const { locales, defaultLocale } = internationalization;
673
+
674
+ const Navigate: FunctionalComponent<{ to: string; replace?: boolean }> = ({
675
+ to,
676
+ replace,
677
+ }) => {
678
+ const { route } = useLocation();
679
+ useEffect(() => {
680
+ route(to, replace);
681
+ }, [to, replace, route]);
682
+ return null;
683
+ };
684
+
685
+ /**
686
+ /**
687
+ * Một component xử lý việc địa phương hóa và bao bọc các phần tử con với ngữ cảnh locale phù hợp.
688
+ * Nó quản lý việc phát hiện và xác thực locale dựa trên URL.
689
+ */
690
+ const AppLocalized: FunctionalComponent<{
691
+ children: ComponentChildren;
692
+ locale?: Locale;
693
+ }> = ({ children, locale }) => {
694
+ const { path: pathname, url } = useLocation();
695
+
696
+ if (!url) {
697
+ return null;
698
+ }
699
+
700
+ const search = url.substring(pathname.length);
701
+
702
+ // Xác định locale hiện tại, nếu không có thì sử dụng locale mặc định
703
+ const currentLocale = locale ?? defaultLocale;
704
+
705
+ // Loại bỏ tiền tố locale khỏi đường dẫn để tạo đường dẫn cơ sở
706
+ const pathWithoutLocale = getPathWithoutLocale(
707
+ pathname // Đường dẫn URL hiện tại
708
+ );
709
+
710
+ /**
711
+ * Nếu routing.mode là 'prefix-all', locale mặc định luôn phải được thêm tiền tố.
712
+ */
713
+ if (routing.mode === "prefix-all") {
714
+ // Xác thực locale
715
+ if (!locale || !locales.includes(locale)) {
716
+ // Chuyển hướng đến locale mặc định với đường dẫn đã cập nhật
717
+ return (
718
+ <Navigate
719
+ to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
720
+ replace // Thay thế mục lịch sử hiện tại bằng mục mới
721
+ />
722
+ );
723
+ }
724
+
725
+ // Bao bọc các phần tử con với IntlayerProvider và thiết lập locale hiện tại
726
+ return (
727
+ <IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
728
+ );
729
+ } else {
730
+ /**
731
+ * Khi routing.mode không phải 'prefix-all', locale mặc định sẽ không có tiền tố.
732
+ * Đảm bảo rằng locale hiện tại hợp lệ và không phải là locale mặc định.
733
+ */
734
+ if (
735
+ currentLocale.toString() !== defaultLocale.toString() &&
736
+ !locales
737
+ .filter(
738
+ (loc) => loc.toString() !== defaultLocale.toString() // Loại trừ locale mặc định
739
+ )
740
+ .includes(currentLocale) // Kiểm tra xem locale hiện tại có trong danh sách các locale hợp lệ không
741
+ ) {
742
+ // Chuyển hướng đến đường dẫn không có tiền tố locale
743
+ return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
744
+ }
745
+
746
+ // Bao bọc children với IntlayerProvider và đặt locale hiện tại
747
+ return (
748
+ <IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
749
+ );
750
+ }
751
+ };
752
+
753
+ const RouterContent: FunctionalComponent<{
754
+ children: ComponentChildren;
755
+ }> = ({ children }) => {
756
+ const { path } = useLocation();
757
+
758
+ if (!path) {
759
+ return null;
760
+ }
761
+
762
+ const pathLocale = path.split("/")[1] as Locale;
763
+
764
+ const isLocaleRoute = locales
765
+ .filter(
766
+ (locale) => routing.mode === "prefix-all" || locale !== defaultLocale
767
+ )
768
+ .some((locale) => locale.toString() === pathLocale);
769
+
770
+ if (isLocaleRoute) {
771
+ return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
772
+ }
773
+
774
+ return (
775
+ <AppLocalized
776
+ locale={routing.mode !== "prefix-all" ? defaultLocale : undefined}
777
+ >
778
+ {children}
779
+ </AppLocalized>
780
+ );
781
+ };
782
+
783
+ /**
784
+ * Một component router thiết lập các route theo locale cụ thể.
785
+ * Nó sử dụng preact-iso để quản lý điều hướng và render các component theo locale.
786
+ */
787
+ export const LocaleRouter: FunctionalComponent<{
788
+ children: ComponentChildren;
789
+ }> = ({ children }) => (
790
+ <LocationProvider>
791
+ <RouterContent>{children}</RouterContent>
792
+ </LocationProvider>
793
+ );
794
+ ```
795
+
796
+ ```jsx fileName="src/components/LocaleRouter.jsx" codeFormat="esm"
797
+ // Nhập các phụ thuộc và hàm cần thiết
798
+ import { configuration, getPathWithoutLocale } from "intlayer";
799
+ import { IntlayerProvider } from "preact-intlayer";
800
+ import { LocationProvider, useLocation } from "preact-iso";
801
+ import { useEffect } from "preact/hooks";
802
+ import { h } from "preact"; // Cần thiết cho JSX
803
+
804
+ // Lấy cấu hình từ Intlayer
805
+ const { internationalization, routing } = configuration;
806
+ const { locales, defaultLocale } = internationalization;
807
+
808
+ const Navigate = ({ to, replace }) => {
809
+ const { route } = useLocation();
810
+ useEffect(() => {
811
+ route(to, replace);
812
+ }, [to, replace, route]);
813
+ return null;
814
+ };
815
+
816
+ /**
817
+ /**
818
+ * Một component xử lý việc địa phương hóa và bao bọc các phần tử con với ngữ cảnh locale phù hợp.
819
+ * Nó quản lý việc phát hiện và xác thực locale dựa trên URL.
820
+ */
821
+ const AppLocalized = ({ children, locale }) => {
822
+ const { path: pathname, url } = useLocation();
823
+
824
+ if (!url) {
825
+ return null;
826
+ }
827
+
828
+ const search = url.substring(pathname.length);
829
+
830
+ // Xác định locale hiện tại, sử dụng locale mặc định nếu không được cung cấp
831
+ const currentLocale = locale ?? defaultLocale;
832
+
833
+ // Loại bỏ tiền tố locale khỏi đường dẫn để tạo đường dẫn cơ sở
834
+ const pathWithoutLocale = getPathWithoutLocale(
835
+ pathname // Đường dẫn URL hiện tại
836
+ );
837
+
838
+ /**
839
+ * Nếu routing.mode là 'prefix-all', locale mặc định luôn phải được thêm tiền tố.
840
+ */
841
+ if (routing.mode === "prefix-all") {
842
+ // Xác thực locale
843
+ if (!locale || !locales.includes(locale)) {
844
+ // Chuyển hướng đến locale mặc định với đường dẫn đã được cập nhật
845
+ return (
846
+ <Navigate
847
+ to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
848
+ replace // Thay thế mục lịch sử hiện tại bằng mục mới
849
+ />
850
+ );
851
+ }
852
+
853
+ // Bao bọc các phần tử con với IntlayerProvider và đặt locale hiện tại
854
+ return (
855
+ <IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
856
+ );
857
+ } else {
858
+ /**
859
+ * Khi routing.mode không phải là 'prefix-all', locale mặc định sẽ không được thêm tiền tố.
860
+ * Đảm bảo rằng locale hiện tại hợp lệ và không phải là locale mặc định.
861
+ */
862
+ if (
863
+ currentLocale.toString() !== defaultLocale.toString() &&
864
+ !locales
865
+ .filter(
866
+ (loc) => loc.toString() !== defaultLocale.toString() // Loại trừ locale mặc định
867
+ )
868
+ .includes(currentLocale) // Kiểm tra xem locale hiện tại có nằm trong danh sách các locale hợp lệ không
869
+ ) {
870
+ // Chuyển hướng đến đường dẫn không có tiền tố locale
871
+ return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
872
+ }
873
+
874
+ // Bao bọc children với IntlayerProvider và đặt locale hiện tại
875
+ return (
876
+ <IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
877
+ );
878
+ }
879
+ };
880
+
881
+ const RouterContent = ({ children }) => {
882
+ const { path } = useLocation();
883
+
884
+ if (!path) {
885
+ return null;
886
+ }
887
+
888
+ const pathLocale = path.split("/")[1];
889
+
890
+ const isLocaleRoute = locales
891
+ .filter(
892
+ (locale) => routing.mode === "prefix-all" || locale !== defaultLocale
893
+ )
894
+ .some((locale) => locale.toString() === pathLocale);
895
+
896
+ if (isLocaleRoute) {
897
+ return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
898
+ }
899
+
900
+ return (
901
+ <AppLocalized
902
+ locale={routing.mode !== "prefix-all" ? defaultLocale : undefined}
903
+ >
904
+ {children}
905
+ </AppLocalized>
906
+ );
907
+ };
908
+
909
+ /**
910
+ * Một component router thiết lập các route theo từng locale cụ thể.
911
+ * Nó sử dụng preact-iso để quản lý điều hướng và render các component theo locale.
912
+ */
913
+ export const LocaleRouter = ({ children }) => (
914
+ <LocationProvider>
915
+ <RouterContent>{children}</RouterContent>
916
+ </LocationProvider>
917
+ );
918
+ ```
919
+
920
+ ```jsx fileName="src/components/LocaleRouter.cjsx" codeFormat="commonjs"
921
+ // Import các dependencies và hàm cần thiết
922
+ const { configuration, getPathWithoutLocale } = require("intlayer");
923
+ const { IntlayerProvider } = require("preact-intlayer");
924
+ const { LocationProvider, useLocation } = require("preact-iso");
925
+ const { useEffect } = require("preact/hooks");
926
+ const { h } = require("preact"); // Cần thiết cho JSX
927
+
928
+ // Phân rã cấu hình từ Intlayer
929
+ const { internationalization, routing } = configuration;
930
+ const { locales, defaultLocale } = internationalization;
931
+
932
+ const Navigate = ({ to, replace }) => {
933
+ const { route } = useLocation();
934
+ useEffect(() => {
935
+ route(to, replace);
936
+ }, [to, replace, route]);
937
+ return null;
938
+ };
939
+
940
+ /**
941
+ * Một component xử lý việc bản địa hóa và bao bọc các phần tử con với ngữ cảnh locale phù hợp.
942
+ * Nó quản lý việc phát hiện và xác thực locale dựa trên URL.
943
+ */
944
+ const AppLocalized = ({ children, locale }) => {
945
+ const { path: pathname, url } = useLocation();
946
+
947
+ if (!url) {
948
+ return null;
949
+ }
950
+
951
+ const search = url.substring(pathname.length);
952
+
953
+ // Xác định locale hiện tại, nếu không có thì dùng locale mặc định
954
+ const currentLocale = locale ?? defaultLocale;
955
+
956
+ // Loại bỏ tiền tố locale khỏi đường dẫn để tạo đường dẫn cơ sở
957
+ const pathWithoutLocale = getPathWithoutLocale(
958
+ pathname // Đường dẫn URL hiện tại
959
+ );
960
+
961
+ /**
962
+ * Nếu routing.mode là 'prefix-all', locale mặc định luôn phải có tiền tố.
963
+ */
964
+ if (routing.mode === "prefix-all") {
965
+ // Kiểm tra tính hợp lệ của locale
966
+ if (!locale || !locales.includes(locale)) {
967
+ // Chuyển hướng đến locale mặc định với đường dẫn đã cập nhật
968
+ return (
969
+ <Navigate
970
+ to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
971
+ replace // Thay thế mục lịch sử hiện tại bằng mục mới
972
+ />
973
+ );
974
+ }
975
+
976
+ // Bao bọc các phần tử con với IntlayerProvider và thiết lập locale hiện tại
977
+ return (
978
+ <IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
979
+ );
980
+ } else {
981
+ /**
982
+ * Khi routing.mode không phải là 'prefix-all', locale mặc định sẽ không có tiền tố.
983
+ * Đảm bảo rằng locale hiện tại hợp lệ và không phải là locale mặc định.
984
+ */
985
+ if (
986
+ currentLocale.toString() !== defaultLocale.toString() &&
987
+ !locales
988
+ .filter(
989
+ (loc) => loc.toString() !== defaultLocale.toString() // Loại trừ locale mặc định
990
+ )
991
+ .includes(currentLocale) // Kiểm tra xem locale hiện tại có trong danh sách các locale hợp lệ không
992
+ ) {
993
+ // Chuyển hướng đến đường dẫn không có tiền tố locale
994
+ return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
995
+ }
996
+
997
+ // Bao bọc các phần tử con với IntlayerProvider và thiết lập locale hiện tại
998
+ return (
999
+ <IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
1000
+ );
1001
+ }
1002
+ };
1003
+
1004
+ const RouterContent = ({ children }) => {
1005
+ const { path } = useLocation();
1006
+
1007
+ if (!path) {
1008
+ return null;
1009
+ }
1010
+
1011
+ const pathLocale = path.split("/")[1];
1012
+
1013
+ const isLocaleRoute = locales
1014
+ .filter(
1015
+ (locale) => routing.mode === "prefix-all" || locale !== defaultLocale
1016
+ )
1017
+ .some((locale) => locale.toString() === pathLocale);
1018
+
1019
+ if (isLocaleRoute) {
1020
+ return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
1021
+ }
1022
+
1023
+ return (
1024
+ <AppLocalized
1025
+ locale={routing.mode !== "prefix-all" ? defaultLocale : undefined}
1026
+ >
1027
+ {children}
1028
+ </AppLocalized>
1029
+ );
1030
+ };
1031
+
1032
+ /**
1033
+ * Một component router thiết lập các route theo locale cụ thể.
1034
+ * Nó sử dụng preact-iso để quản lý điều hướng và render các component theo locale.
1035
+ */
1036
+ const LocaleRouter = ({ children }) => (
1037
+ <LocationProvider>
1038
+ <RouterContent>{children}</RouterContent>
1039
+ </LocationProvider>
1040
+ );
1041
+
1042
+ module.exports = { LocaleRouter };
1043
+ ```
1044
+
1045
+ Sau đó, bạn có thể sử dụng component `LocaleRouter` trong ứng dụng của mình:
1046
+
1047
+ ```tsx fileName="src/app.tsx" codeFormat="typescript"
1048
+ import { LocaleRouter } from "./components/LocaleRouter";
1049
+ import type { FunctionalComponent } from "preact";
1050
+ // ... Component AppContent của bạn (được định nghĩa trong Bước 5)
1051
+
1052
+ const App: FunctionalComponent = () => (
1053
+ <LocaleRouter>
1054
+ <AppContent />
1055
+ </LocaleRouter>
1056
+ );
1057
+
1058
+ export default App;
1059
+ ```
1060
+
1061
+ ```jsx fileName="src/app.jsx" codeFormat="esm"
1062
+ import { LocaleRouter } from "./components/LocaleRouter";
1063
+ // ... Component AppContent của bạn (được định nghĩa ở Bước 5)
1064
+
1065
+ const App = () => (
1066
+ <LocaleRouter>
1067
+ <AppContent />
1068
+ </LocaleRouter>
1069
+ );
1070
+
1071
+ export default App;
1072
+ ```
1073
+
1074
+ ```jsx fileName="src/app.cjsx" codeFormat="commonjs"
1075
+ const { LocaleRouter } = require("./components/LocaleRouter");
1076
+ // ... Component AppContent của bạn (được định nghĩa ở Bước 5)
1077
+
1078
+ const App = () => (
1079
+ <LocaleRouter>
1080
+ <AppContent />
1081
+ </LocaleRouter>
1082
+ );
1083
+
1084
+ module.exports = App;
1085
+ ```
1086
+
1087
+ Trong khi đó, bạn cũng có thể sử dụng `intlayerMiddleware` để thêm routing phía server vào ứng dụng của bạn. Plugin này sẽ tự động phát hiện locale hiện tại dựa trên URL và thiết lập cookie locale phù hợp. Nếu không có locale nào được chỉ định, plugin sẽ xác định locale phù hợp nhất dựa trên ngôn ngữ trình duyệt của người dùng. Nếu không phát hiện được locale nào, nó sẽ chuyển hướng đến locale mặc định.
1088
+
1089
+ > Lưu ý rằng để sử dụng `intlayerMiddleware` trong môi trường production, bạn cần chuyển gói `vite-intlayer` từ `devDependencies` sang `dependencies`.
1090
+
1091
+ ```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
1092
+ import { defineConfig } from "vite";
1093
+ import preact from "@preact/preset-vite";
1094
+ import { intlayer, intlayerMiddleware } from "vite-intlayer";
1095
+
1096
+ // https://vitejs.dev/config/
1097
+ export default defineConfig({
1098
+ plugins: [preact(), intlayer(), intlayerMiddleware()],
1099
+ });
1100
+ ```
1101
+
1102
+ ```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
1103
+ import { defineConfig } from "vite";
1104
+ import preact from "@preact/preset-vite";
1105
+ import { intlayer, intlayerMiddleware } from "vite-intlayer";
1106
+
1107
+ // https://vitejs.dev/config/
1108
+ export default defineConfig({
1109
+ plugins: [preact(), intlayer(), intlayerMiddleware()],
1110
+ });
1111
+ ```
1112
+
1113
+ ```javascript {3,7} fileName="vite.config.cjs" codeFormat="commonjs"
1114
+ const { defineConfig } = require("vite");
1115
+ const preact = require("@preact/preset-vite");
1116
+ const { intlayer, intlayerMiddleware } = require("vite-intlayer");
1117
+
1118
+ // https://vitejs.dev/config/
1119
+ module.exports = defineConfig({
1120
+ plugins: [preact(), intlayer(), intlayerMiddleware()],
1121
+ });
1122
+ ```
1123
+
1124
+ ### (Tùy chọn) Bước 8: Thay đổi URL khi locale thay đổi
1125
+
1126
+ Để thay đổi URL khi locale thay đổi, bạn có thể sử dụng prop `onLocaleChange` được cung cấp bởi hook `useLocale`. Đồng thời, bạn có thể sử dụng `useLocation` và `route` từ `preact-iso` để cập nhật đường dẫn URL.
1127
+
1128
+ ```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
1129
+ import { useLocation, route } from "preact-iso";
1130
+ import {
1131
+ Locales,
1132
+ getHTMLTextDir,
1133
+ getLocaleName,
1134
+ getLocalizedUrl,
1135
+ } from "intlayer";
1136
+ import { useLocale } from "preact-intlayer";
1137
+ import type { FunctionalComponent } from "preact";
1138
+
1139
+ const LocaleSwitcher: FunctionalComponent = () => {
1140
+ const location = useLocation();
1141
+ plugins: [preact(), intlayer(), intlayerMiddleware()],
1142
+ });
1143
+ ```
1144
+
1145
+ ### (Tùy chọn) Bước 8: Thay đổi URL khi thay đổi locale
1146
+
1147
+ Để thay đổi URL khi locale thay đổi, bạn có thể sử dụng prop `onLocaleChange` được cung cấp bởi hook `useLocale`. Đồng thời, bạn có thể sử dụng `useLocation` và `route` từ `preact-iso` để cập nhật đường dẫn URL.
1148
+
1149
+ ```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
1150
+ import { useLocation, route } from "preact-iso";
1151
+ import {
1152
+ Locales,
1153
+ getHTMLTextDir,
1154
+ getLocaleName,
1155
+ getLocalizedUrl,
1156
+ } from "intlayer";
1157
+ import { useLocale } from "preact-intlayer";
1158
+ import type { FunctionalComponent } from "preact";
1159
+
1160
+ const LocaleSwitcher: FunctionalComponent = () => {
1161
+ const location = useLocation();
1162
+ const { locale, availableLocales, setLocale } = useLocale({
1163
+ onLocaleChange: (newLocale) => {
1164
+ const currentFullPath = location.url; // preact-iso cung cấp URL đầy đủ
1165
+ // Xây dựng URL với locale được cập nhật
1166
+ // Ví dụ: /es/about?foo=bar
1167
+ const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
1168
+
1169
+ // Cập nhật đường dẫn URL
1170
+ route(pathWithLocale, true); // true để thay thế
1171
+ },
1172
+ });
1173
+
1174
+ return (
1175
+ <div>
1176
+ <button popovertarget="localePopover">{getLocaleName(locale)}</button>
1177
+ <div id="localePopover" popover="auto">
1178
+ {availableLocales.map((localeItem) => (
1179
+ <a
1180
+ href={getLocalizedUrl(location.url, localeItem)}
1181
+ hreflang={localeItem}
1182
+ aria-current={locale === localeItem ? "page" : undefined}
1183
+ onClick={(e) => {
1184
+ e.preventDefault();
1185
+ setLocale(localeItem);
1186
+ // Điều hướng lập trình sau khi đặt locale sẽ được xử lý bởi onLocaleChange
1187
+ }}
1188
+ key={localeItem}
1189
+ >
1190
+ <span>
1191
+ {/* Locale - ví dụ: FR */}
1192
+ {localeItem}
1193
+ </span>
1194
+ <span>
1195
+ {/* Ngôn ngữ trong chính Locale của nó - ví dụ: Français */}
1196
+ {getLocaleName(localeItem, localeItem)}
1197
+ </span>
1198
+ <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
1199
+ {/* Ngôn ngữ trong Locale hiện tại - ví dụ: Francés với locale hiện tại được đặt thành Locales.SPANISH */}
1200
+ {getLocaleName(localeItem, locale)}
1201
+ </span>
1202
+ <span dir="ltr" lang={Locales.ENGLISH}>
1203
+ {/* Ngôn ngữ bằng tiếng Anh - ví dụ: French */}
1204
+ {getLocaleName(localeItem, Locales.ENGLISH)}
1205
+ </span>
1206
+ </a>
1207
+ ))}
1208
+ </div>
1209
+ </div>
1210
+ );
1211
+ };
1212
+
1213
+ export default LocaleSwitcher;
1214
+ ```
1215
+
1216
+ ```jsx fileName="src/components/LocaleSwitcher.jsx" codeFormat="esm"
1217
+ import { useLocation, route } from "preact-iso";
1218
+ import {
1219
+ Locales,
1220
+ getHTMLTextDir,
1221
+ getLocaleName,
1222
+ getLocalizedUrl,
1223
+ } from "intlayer";
1224
+ import { useLocale } from "preact-intlayer";
1225
+ import { h } from "preact"; // Dùng cho JSX
1226
+
1227
+ const LocaleSwitcher = () => {
1228
+ const location = useLocation();
1229
+ const { locale, availableLocales, setLocale } = useLocale({
1230
+ onLocaleChange: (newLocale) => {
1231
+ const currentFullPath = location.url;
1232
+ const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
1233
+ route(pathWithLocale, true);
1234
+ },
1235
+ });
1236
+
1237
+ return (
1238
+ <div>
1239
+ <button popovertarget="localePopover">{getLocaleName(locale)}</button>
1240
+ <div id="localePopover" popover="auto">
1241
+ {availableLocales.map((localeItem) => (
1242
+ <a
1243
+ href={getLocalizedUrl(location.url, localeItem)}
1244
+ hreflang={localeItem}
1245
+ aria-current={locale === localeItem ? "page" : undefined}
1246
+ onClick={(e) => {
1247
+ e.preventDefault();
1248
+ setLocale(localeItem);
1249
+ }}
1250
+ key={localeItem}
1251
+ >
1252
+ <span>{localeItem}</span>
1253
+ <span>{getLocaleName(localeItem, localeItem)}</span>
1254
+ <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
1255
+ {getLocaleName(localeItem, locale)}
1256
+ </span>
1257
+ <span dir="ltr" lang={Locales.ENGLISH}>
1258
+ {getLocaleName(localeItem, Locales.ENGLISH)}
1259
+ </span>
1260
+ </a>
1261
+ ))}
1262
+ </div>
1263
+ </div>
1264
+ );
1265
+ };
1266
+
1267
+ export default LocaleSwitcher;
1268
+ ```
1269
+
1270
+ ```jsx fileName="src/components/LocaleSwitcher.cjsx" codeFormat="commonjs"
1271
+ const { useLocation, route } = require("preact-iso");
1272
+ const {
1273
+ Locales,
1274
+ getHTMLTextDir,
1275
+ getLocaleName,
1276
+ getLocalizedUrl,
1277
+ } = require("intlayer");
1278
+ const { useLocale } = require("preact-intlayer");
1279
+ const { h } = require("preact"); // Dùng cho JSX
1280
+
1281
+ const LocaleSwitcher = () => {
1282
+ const location = useLocation();
1283
+ const { locale, availableLocales, setLocale } = useLocale({
1284
+ onLocaleChange: (newLocale) => {
1285
+ const currentFullPath = location.url;
1286
+ const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
1287
+ route(pathWithLocale, true);
1288
+ },
1289
+ });
1290
+
1291
+ return (
1292
+ <div>
1293
+ <button popovertarget="localePopover">{getLocaleName(locale)}</button>
1294
+ <div id="localePopover" popover="auto">
1295
+ {availableLocales.map((localeItem) => (
1296
+ <a
1297
+ href={getLocalizedUrl(location.url, localeItem)}
1298
+ hreflang={localeItem}
1299
+ aria-current={locale === localeItem ? "page" : undefined}
1300
+ onClick={(e) => {
1301
+ e.preventDefault();
1302
+ setLocale(localeItem);
1303
+ }}
1304
+ key={localeItem}
1305
+ >
1306
+ <span>{localeItem}</span>
1307
+ <span>{getLocaleName(localeItem, localeItem)}</span>
1308
+ <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
1309
+ {getLocaleName(localeItem, locale)}
1310
+ </span>
1311
+ <span dir="ltr" lang={Locales.ENGLISH}>
1312
+ {getLocaleName(localeItem, Locales.ENGLISH)}
1313
+ </span>
1314
+ </a>
1315
+ ))}
1316
+ </div>
1317
+ </div>
1318
+ );
1319
+ };
1320
+
1321
+ module.exports = LocaleSwitcher;
1322
+ ```
1323
+
1324
+ > Tham khảo tài liệu:
1325
+ >
1326
+ > > - [`useLocale` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/react-intlayer/useLocale.md) (API tương tự cho `preact-intlayer`) > - [`getLocaleName` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/intlayer/getLocaleName.md) > - [`getLocalizedUrl` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/intlayer/getLocalizedUrl.md) > - [`getHTMLTextDir` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/packages/intlayer/getHTMLTextDir.md) > - Thuộc tính [`hreflang`](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr) > - Thuộc tính [`lang`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang) > - Thuộc tính [`dir`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir) > - Thuộc tính [`aria-current`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current) > - [API Popover](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)la.org/en-US/docs/Web/HTML/Global_attributes/dir)> - [`aria-current` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)> - [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
1327
+
1328
+ Dưới đây là **Bước 9** được cập nhật với các giải thích bổ sung và ví dụ mã được tinh chỉnh:
1329
+
1330
+ ---
1331
+
1332
+ ### (Tùy chọn) Bước 9: Chuyển đổi thuộc tính Ngôn ngữ và Hướng của thẻ HTML
1333
+
1334
+ Khi ứng dụng của bạn hỗ trợ nhiều ngôn ngữ, việc cập nhật các thuộc tính `lang` và `dir` của thẻ `<html>` để phù hợp với locale hiện tại là rất quan trọng. Việc này đảm bảo:
1335
+
1336
+ - **Khả năng truy cập**: Các trình đọc màn hình và công nghệ hỗ trợ dựa vào thuộc tính `lang` chính xác để phát âm và hiểu nội dung một cách chính xác.
1337
+ - **Hiển thị văn bản**: Thuộc tính `dir` (hướng) đảm bảo văn bản được hiển thị theo đúng thứ tự (ví dụ: từ trái sang phải cho tiếng Anh, từ phải sang trái cho tiếng Ả Rập hoặc tiếng Do Thái), điều này rất cần thiết cho khả năng đọc.
1338
+ - **SEO**: Các công cụ tìm kiếm sử dụng thuộc tính `lang` để xác định ngôn ngữ của trang, giúp phục vụ nội dung địa phương hóa phù hợp trong kết quả tìm kiếm.
1339
+
1340
+ Bằng cách cập nhật các thuộc tính này một cách động khi locale thay đổi, bạn đảm bảo trải nghiệm nhất quán và dễ tiếp cận cho người dùng trên tất cả các ngôn ngữ được hỗ trợ.
1341
+
1342
+ #### Triển khai Hook
1343
+
1344
+ Tạo một hook tùy chỉnh để quản lý các thuộc tính HTML. Hook này lắng nghe sự thay đổi của locale và cập nhật các thuộc tính tương ứng:
1345
+
1346
+ ```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
1347
+ import { useEffect } from "preact/hooks";
1348
+ import { useLocale } from "preact-intlayer";
1349
+ import { getHTMLTextDir } from "intlayer";
1350
+
1351
+ /**
1352
+ * Cập nhật thuộc tính `lang` và `dir` của phần tử <html> dựa trên locale hiện tại.
1353
+ * - `lang`: Thông báo cho trình duyệt và công cụ tìm kiếm về ngôn ngữ của trang.
1354
+ * - `dir`: Đảm bảo thứ tự đọc đúng (ví dụ: 'ltr' cho tiếng Anh, 'rtl' cho tiếng Ả Rập).
1355
+ *
1356
+ * Việc cập nhật động này rất quan trọng để hiển thị văn bản đúng cách, hỗ trợ truy cập và SEO.
1357
+ */
1358
+ export const useI18nHTMLAttributes = () => {
1359
+ const { locale } = useLocale();
1360
+
1361
+ useEffect(() => {
1362
+ // Cập nhật thuộc tính ngôn ngữ thành locale hiện tại.
1363
+ document.documentElement.lang = locale;
1364
+
1365
+ // Đặt hướng văn bản dựa trên locale hiện tại.
1366
+ document.documentElement.dir = getHTMLTextDir(locale);
1367
+ }, [locale]);
1368
+ };
1369
+ ```
1370
+
1371
+ ```jsx fileName="src/hooks/useI18nHTMLAttributes.jsx" codeFormat="esm"
1372
+ import { useEffect } from "preact/hooks";
1373
+ import { useLocale } from "preact-intlayer";
1374
+ import { getHTMLTextDir } from "intlayer";
1375
+
1376
+ /**
1377
+ * Cập nhật các thuộc tính `lang` và `dir` của phần tử HTML <html> dựa trên locale hiện tại.
1378
+ */
1379
+ export const useI18nHTMLAttributes = () => {
1380
+ const { locale } = useLocale();
1381
+
1382
+ useEffect(() => {
1383
+ document.documentElement.lang = locale;
1384
+ document.documentElement.dir = getHTMLTextDir(locale);
1385
+ }, [locale]);
1386
+ };
1387
+ ```
1388
+
1389
+ ```jsx fileName="src/hooks/useI18nHTMLAttributes.cjsx" codeFormat="commonjs"
1390
+ const { useEffect } = require("preact/hooks");
1391
+ const { useLocale } = require("preact-intlayer");
1392
+ const { getHTMLTextDir } = require("intlayer");
1393
+
1394
+ /**
1395
+ * Cập nhật các thuộc tính `lang` và `dir` của phần tử HTML <html> dựa trên locale hiện tại.
1396
+ */
1397
+ const useI18nHTMLAttributes = () => {
1398
+ const { locale } = useLocale();
1399
+
1400
+ useEffect(() => {
1401
+ document.documentElement.lang = locale;
1402
+ document.documentElement.dir = getHTMLTextDir(locale);
1403
+ }, [locale]);
1404
+ };
1405
+
1406
+ module.exports = { useI18nHTMLAttributes };
1407
+ ```
1408
+
1409
+ #### Sử dụng Hook trong Ứng dụng của Bạn
1410
+
1411
+ Tích hợp hook vào thành phần chính của bạn để các thuộc tính HTML được cập nhật mỗi khi locale thay đổi:
1412
+
1413
+ ```tsx fileName="src/app.tsx" codeFormat="typescript"
1414
+ import type { FunctionalComponent } from "preact";
1415
+ import { IntlayerProvider } from "preact-intlayer"; // useIntlayer đã được import nếu AppContent cần
1416
+ import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
1417
+ import "./app.css";
1418
+ // Định nghĩa AppContent từ Bước 5
1419
+
1420
+ const AppWithHooks: FunctionalComponent = () => {
1421
+ // Áp dụng hook để cập nhật các thuộc tính lang và dir của thẻ <html> dựa trên locale.
1422
+ useI18nHTMLAttributes();
1423
+
1424
+ // Giả sử AppContent là thành phần hiển thị nội dung chính của bạn từ Bước 5
1425
+ return <AppContent />;
1426
+ };
1427
+
1428
+ const App: FunctionalComponent = () => (
1429
+ <IntlayerProvider>
1430
+ <AppWithHooks />
1431
+ </IntlayerProvider>
1432
+ );
1433
+
1434
+ export default App;
1435
+ ```
1436
+
1437
+ ```jsx fileName="src/app.jsx" codeFormat="esm"
1438
+ import { IntlayerProvider } from "preact-intlayer";
1439
+ import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
1440
+ import "./app.css";
1441
+ // Định nghĩa AppContent từ Bước 5
1442
+
1443
+ const AppWithHooks = () => {
1444
+ useI18nHTMLAttributes();
1445
+ return <AppContent />;
1446
+ };
1447
+
1448
+ const App = () => (
1449
+ <IntlayerProvider>
1450
+ <AppWithHooks />
1451
+ </IntlayerProvider>
1452
+ );
1453
+
1454
+ export default App;
1455
+ ```
1456
+
1457
+ ```jsx fileName="src/app.cjsx" codeFormat="commonjs"
1458
+ const { IntlayerProvider } = require("preact-intlayer");
1459
+ const { useI18nHTMLAttributes } = require("./hooks/useI18nHTMLAttributes");
1460
+ require("./app.css");
1461
+ // Định nghĩa AppContent từ Bước 5
1462
+
1463
+ const AppWithHooks = () => {
1464
+ useI18nHTMLAttributes();
1465
+ return <AppContent />;
1466
+ };
1467
+
1468
+ const App = () => (
1469
+ <IntlayerProvider>
1470
+ <AppWithHooks />
1471
+ </IntlayerProvider>
1472
+ );
1473
+
1474
+ module.exports = App;
1475
+ ```
1476
+
1477
+ Bằng cách áp dụng những thay đổi này, ứng dụng của bạn sẽ:
1478
+
1479
+ - Đảm bảo thuộc tính **ngôn ngữ** (`lang`) phản ánh chính xác locale hiện tại, điều này quan trọng cho SEO và hành vi của trình duyệt.
1480
+ - Điều chỉnh **hướng văn bản** (`dir`) theo locale, nâng cao khả năng đọc và tính tiện dụng cho các ngôn ngữ có thứ tự đọc khác nhau.
1481
+ - Cung cấp trải nghiệm **dễ tiếp cận** hơn, vì các công nghệ hỗ trợ phụ thuộc vào các thuộc tính này để hoạt động tối ưu.
1482
+
1483
+ ### (Tùy chọn) Bước 10: Tạo thành phần Link có địa phương hóa
1484
+
1485
+ Để đảm bảo điều hướng trong ứng dụng của bạn tôn trọng ngôn ngữ hiện tại, bạn có thể tạo một thành phần `Link` tùy chỉnh. Thành phần này tự động thêm tiền tố ngôn ngữ hiện tại vào các URL nội bộ.
1486
+
1487
+ Hành vi này hữu ích vì một số lý do:
1488
+
1489
+ - **SEO và Trải nghiệm người dùng**: URL có địa phương hóa giúp các công cụ tìm kiếm lập chỉ mục chính xác các trang theo ngôn ngữ và cung cấp nội dung cho người dùng theo ngôn ngữ ưu tiên của họ.
1490
+ - **Tính nhất quán**: Bằng cách sử dụng liên kết có địa phương hóa trong toàn bộ ứng dụng, bạn đảm bảo điều hướng luôn nằm trong ngôn ngữ hiện tại, tránh việc chuyển đổi ngôn ngữ không mong muốn.
1491
+ - **Dễ bảo trì**: Tập trung logic địa phương hóa trong một component duy nhất giúp đơn giản hóa việc quản lý các URL.
1492
+
1493
+ Đối với Preact khi dùng `preact-iso`, bạn thường dùng thẻ `<a>` cho điều hướng nội bộ. Để đảm bảo các liên kết phù hợp với locale hiện tại, bạn nên tạo một component anchor tùy chỉnh tự động thêm tiền tố locale và xử lý điều hướng phía client bằng `route` từ `preact-iso`. Dưới đây là ví dụ hoàn chỉnh:
1494
+
1495
+ ```tsx fileName="src/components/LocalizedLink.tsx" codeFormat="typescript"
1496
+ import { getLocalizedUrl } from "intlayer";
1497
+ import { useLocale } from "preact-intlayer";
1498
+ import { useLocation, route } from "preact-iso";
1499
+ import type { JSX } from "preact";
1500
+ import { forwardRef } from "preact/compat";
1501
+
1502
+ /** Kiểm tra một đường dẫn có phải là liên kết ngoài không */
1503
+ export const checkIsExternalLink = (href?: string) =>
1504
+ /^https?:\/\//.test(href ?? "");
1505
+
1506
+ export interface LocalizedLinkProps
1507
+ extends JSX.HTMLAttributes<HTMLAnchorElement> {
1508
+ href: string;
1509
+ replace?: boolean;
1510
+ }
1511
+
1512
+ /**
1513
+ * LocalizedLink là một thẻ <a> tự động nối locale hiện tại vào đường dẫn nội bộ
1514
+ * và điều hướng route phía client mà không load lại trang.
1515
+ */
1516
+ export const LocalizedLink = forwardRef<HTMLAnchorElement, LocalizedLinkProps>(
1517
+ ({ href, children, onClick, replace = false, ...props }, ref) => {
1518
+ const { locale } = useLocale();
1519
+ const location = useLocation();
1520
+ const isExternal = checkIsExternalLink(href);
1521
+
1522
+ const hrefLocalized =
1523
+ href && !isExternal ? getLocalizedUrl(href, locale) : href;
1524
+
1525
+ const handleClick = (event: JSX.TargetedMouseEvent<HTMLAnchorElement>) => {
1526
+ if (onClick) onClick(event);
1527
+ if (
1528
+ !isExternal &&
1529
+ href &&
1530
+ event.button === 0 &&
1531
+ !event.metaKey &&
1532
+ !event.ctrlKey &&
1533
+ !event.shiftKey &&
1534
+ !event.altKey &&
1535
+ !props.target
1536
+ ) {
1537
+ event.preventDefault();
1538
+ if (location.url !== hrefLocalized) {
1539
+ route(hrefLocalized, replace);
1540
+ }
1541
+ }
1542
+ };
1543
+
1544
+ return (
1545
+ <a href={hrefLocalized} ref={ref} onClick={handleClick} {...props}>
1546
+ {children}
1547
+ </a>
1548
+ );
1549
+ }
1550
+ );
1551
+ ```
1552
+
1553
+ ```jsx fileName="src/components/LocalizedLink.jsx" codeFormat="esm"
1554
+ import { getLocalizedUrl } from "intlayer";
1555
+ import { useLocale } from "preact-intlayer";
1556
+ import { useLocation, route } from "preact-iso"; // Nhập từ preact-iso
1557
+ import { forwardRef } from "preact/compat";
1558
+ import { h } from "preact"; // Dùng cho JSX
1559
+
1560
+ export const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
1561
+
1562
+ export const LocalizedLink = forwardRef(
1563
+ ({ href, children, onClick, replace = false, ...props }, ref) => {
1564
+ const { locale } = useLocale();
1565
+ const location = useLocation();
1566
+ const isExternalLink = checkIsExternalLink(href);
1567
+
1568
+ const hrefI18n =
1569
+ href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
1570
+
1571
+ const handleClick = (event) => {
1572
+ if (onClick) {
1573
+ onClick(event);
1574
+ }
1575
+ if (
1576
+ !isExternalLink &&
1577
+ href &&
1578
+ event.button === 0 &&
1579
+ !event.metaKey &&
1580
+ !event.ctrlKey &&
1581
+ !event.shiftKey &&
1582
+ !event.altKey &&
1583
+ !props.target
1584
+ ) {
1585
+ event.preventDefault();
1586
+ if (location.url !== hrefI18n) {
1587
+ route(hrefI18n, replace);
1588
+ }
1589
+ }
1590
+ };
1591
+
1592
+ return (
1593
+ <a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
1594
+ {children}
1595
+ </a>
1596
+ );
1597
+ }
1598
+ );
1599
+ ```
1600
+
1601
+ ```jsx fileName="src/components/LocalizedLink.cjsx" codeFormat="commonjs"
1602
+ const { getLocalizedUrl } = require("intlayer");
1603
+ const { useLocale } = require("preact-intlayer");
1604
+ const { useLocation, route } = require("preact-iso"); // Nhập từ preact-iso
1605
+ const { forwardRef } = require("preact/compat");
1606
+ const { h } = require("preact"); // Dùng cho JSX
1607
+
1608
+ const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
1609
+
1610
+ const LocalizedLink = forwardRef(
1611
+ ({ href, children, onClick, replace = false, ...props }, ref) => {
1612
+ const { locale } = useLocale(); // Lấy locale hiện tại
1613
+ const location = useLocation(); // Lấy vị trí hiện tại
1614
+ const isExternalLink = checkIsExternalLink(href); // Kiểm tra xem có phải liên kết ngoài không
1615
+
1616
+ const hrefI18n =
1617
+ href && !isExternalLink ? getLocalizedUrl(href, locale) : href; // Lấy URL đã được địa phương hóa nếu không phải liên kết ngoài
1618
+
1619
+ const handleClick = (event) => {
1620
+ if (onClick) {
1621
+ onClick(event); // Gọi hàm onClick nếu có
1622
+ }
1623
+ if (
1624
+ !isExternalLink &&
1625
+ href &&
1626
+ event.button === 0 &&
1627
+ !event.metaKey &&
1628
+ !event.ctrlKey &&
1629
+ !event.shiftKey &&
1630
+ !event.altKey &&
1631
+ !props.target
1632
+ ) {
1633
+ event.preventDefault(); // Ngăn hành vi mặc định của trình duyệt
1634
+ if (location.url !== hrefI18n) {
1635
+ route(hrefI18n, replace);
1636
+ }
1637
+ }
1638
+ };
1639
+
1640
+ return (
1641
+ <a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
1642
+ {children}
1643
+ </a>
1644
+ );
1645
+ }
1646
+ );
1647
+
1648
+ module.exports = { LocalizedLink, checkIsExternalLink };
1649
+ ```
1650
+
1651
+ #### Cách Hoạt Động
1652
+
1653
+ - **Phát hiện Liên kết Ngoài**:
1654
+ Hàm trợ giúp `checkIsExternalLink` xác định xem một URL có phải là liên kết ngoài hay không. Các liên kết ngoài sẽ không bị thay đổi.
1655
+ - **Lấy Ngôn ngữ Hiện tại**:
1656
+ Hook `useLocale` cung cấp ngôn ngữ hiện tại.
1657
+ - **Địa phương hóa URL**:
1658
+ Đối với các liên kết nội bộ, `getLocalizedUrl` sẽ thêm tiền tố ngôn ngữ hiện tại vào URL.
1659
+ - **Điều hướng phía Client**:
1660
+ Hàm `handleClick` kiểm tra xem đó có phải là liên kết nội bộ và liệu điều hướng tiêu chuẩn có nên bị ngăn chặn hay không. Nếu đúng, nó sử dụng hàm `route` của `preact-iso` (lấy qua `useLocation` hoặc nhập trực tiếp) để thực hiện điều hướng phía client. Điều này cung cấp hành vi giống SPA mà không cần tải lại toàn bộ trang.
1661
+ - **Trả về Liên kết**:
1662
+ Component trả về một phần tử `<a>` với URL đã được địa phương hóa và trình xử lý sự kiện click tùy chỉnh.
1663
+
1664
+ ### Cấu hình TypeScript
1665
+
1666
+ Intlayer sử dụng module augmentation để tận dụng lợi ích của TypeScript và làm cho codebase của bạn mạnh mẽ hơn.
1667
+
1668
+ ![Tự động hoàn thành](https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true)
1669
+
1670
+ ![Lỗi dịch thuật](https://github.com/aymericzip/intlayer/blob/main/docs/assets/translation_error.png?raw=true)
1671
+
1672
+ Đảm bảo cấu hình TypeScript của bạn bao gồm các kiểu được tạo tự động.
1673
+
1674
+ ```json5 fileName="tsconfig.json"
1675
+ {
1676
+ // ... Các cấu hình TypeScript hiện có của bạn
1677
+ "compilerOptions": {
1678
+ // ...
1679
+ "jsx": "react-jsx",
1680
+ "jsxImportSource": "preact", // Khuyến nghị cho Preact 10+
1681
+ // ...
1682
+ },
1683
+ "include": [
1684
+ // ... Các cấu hình TypeScript hiện có của bạn
1685
+ ".intlayer/**/*.ts", // Bao gồm các kiểu được tạo tự động
1686
+ ],
1687
+ }
1688
+ ```
1689
+
1690
+ > Đảm bảo `tsconfig.json` của bạn được thiết lập cho Preact, đặc biệt là `jsx` và `jsxImportSource` hoặc `jsxFactory`/`jsxFragmentFactory` cho các phiên bản Preact cũ hơn nếu không sử dụng mặc định của `preset-vite`.
1691
+
1692
+ ### Cấu hình Git
1693
+
1694
+ Khuyến nghị bỏ qua các tệp được tạo bởi Intlayer. Điều này giúp bạn tránh việc commit chúng vào kho Git của mình.
1695
+
1696
+ Để làm điều này, bạn có thể thêm các hướng dẫn sau vào tệp `.gitignore` của mình:
1697
+
1698
+ ```plaintext
1699
+ # Bỏ qua các tệp được tạo bởi Intlayer
1700
+ .intlayer
1701
+ ```
1702
+
1703
+ ### Tiện ích mở rộng VS Code
1704
+
1705
+ Để cải thiện trải nghiệm phát triển với Intlayer, bạn có thể cài đặt **Tiện ích mở rộng Intlayer cho VS Code** chính thức.
1706
+
1707
+ [Cài đặt từ VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
1708
+
1709
+ Tiện ích mở rộng này cung cấp:
1710
+
1711
+ - **Tự động hoàn thành** cho các khóa dịch.
1712
+ - **Phát hiện lỗi thời gian thực** cho các bản dịch bị thiếu.
1713
+ - **Xem trước nội tuyến** của nội dung đã dịch.
1714
+ - **Hành động nhanh** để dễ dàng tạo và cập nhật bản dịch.
1715
+
1716
+ Để biết thêm chi tiết về cách sử dụng tiện ích mở rộng, hãy tham khảo [tài liệu Tiện ích mở rộng Intlayer cho VS Code](https://intlayer.org/doc/vs-code-extension).
1717
+
1718
+ ---
1719
+
1720
+ ### Đi xa hơn
1721
+
1722
+ Để đi xa hơn, bạn có thể triển khai [trình soạn thảo trực quan](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/intlayer_visual_editor.md) hoặc tách nội dung của bạn ra bên ngoài bằng cách sử dụng [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/vi/intlayer_CMS.md).