@intlayer/docs 5.5.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.
- package/LICENSE +202 -0
- package/ar/CI_CD.md +149 -0
- package/ar/autoFill.md +157 -0
- package/ar/concept/content/file.md +1 -0
- package/ar/configuration.md +492 -0
- package/ar/dictionary/condition.md +213 -0
- package/ar/dictionary/content_extention_customization.md +81 -0
- package/ar/dictionary/enumeration.md +221 -0
- package/ar/dictionary/file.md +209 -0
- package/ar/dictionary/function_fetching.md +190 -0
- package/ar/dictionary/get_started.md +490 -0
- package/ar/dictionary/insertion.md +161 -0
- package/ar/dictionary/markdown.md +343 -0
- package/ar/dictionary/nesting.md +249 -0
- package/ar/dictionary/translation.md +307 -0
- package/ar/header.md +7 -0
- package/ar/how_works_intlayer.md +219 -0
- package/ar/index.md +125 -0
- package/ar/interest_of_intlayer.md +132 -0
- package/ar/intlayer_CMS.md +328 -0
- package/ar/intlayer_cli.md +258 -0
- package/ar/intlayer_visual_editor.md +210 -0
- package/ar/intlayer_with_angular.md +3 -0
- package/ar/intlayer_with_create_react_app.md +1196 -0
- package/ar/intlayer_with_express.md +270 -0
- package/ar/intlayer_with_lynx+react.md +482 -0
- package/ar/intlayer_with_nextjs_14.md +1260 -0
- package/ar/intlayer_with_nextjs_15.md +1311 -0
- package/ar/intlayer_with_nextjs_page_router.md +1099 -0
- package/ar/intlayer_with_react_native+expo.md +539 -0
- package/ar/intlayer_with_vite+preact.md +1679 -0
- package/ar/intlayer_with_vite+react.md +1582 -0
- package/ar/intlayer_with_vite+solid.md +3 -0
- package/ar/intlayer_with_vite+svelte.md +3 -0
- package/ar/intlayer_with_vite+vue.md +989 -0
- package/ar/introduction.md +190 -0
- package/ar/mcp_server.md +150 -0
- package/ar/packages/@intlayer/api/index.md +31 -0
- package/ar/packages/@intlayer/chokidar/index.md +31 -0
- package/ar/packages/@intlayer/cli/index.md +1 -0
- package/ar/packages/@intlayer/config/index.md +116 -0
- package/ar/packages/@intlayer/core/index.md +25 -0
- package/ar/packages/@intlayer/design-system/index.md +21 -0
- package/ar/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/ar/packages/@intlayer/editor/index.md +21 -0
- package/ar/packages/@intlayer/editor-react/index.md +21 -0
- package/ar/packages/@intlayer/webpack/index.md +35 -0
- package/ar/packages/angular-intlayer/index.md +3 -0
- package/ar/packages/express-intlayer/index.md +232 -0
- package/ar/packages/express-intlayer/t.md +448 -0
- package/ar/packages/intlayer/getConfiguration.md +120 -0
- package/ar/packages/intlayer/getEnumeration.md +138 -0
- package/ar/packages/intlayer/getHTMLTextDir.md +97 -0
- package/ar/packages/intlayer/getLocaleLang.md +61 -0
- package/ar/packages/intlayer/getLocaleName.md +93 -0
- package/ar/packages/intlayer/getLocalizedUrl.md +221 -0
- package/ar/packages/intlayer/getMultilingualUrls.md +198 -0
- package/ar/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/ar/packages/intlayer/getTranslation.md +175 -0
- package/ar/packages/intlayer/getTranslationContent.md +175 -0
- package/ar/packages/intlayer/index.md +254 -0
- package/ar/packages/intlayer-cli/index.md +41 -0
- package/ar/packages/intlayer-editor/index.md +113 -0
- package/ar/packages/lynx-intlayer/index.md +58 -0
- package/ar/packages/next-intlayer/index.md +267 -0
- package/ar/packages/next-intlayer/t.md +341 -0
- package/ar/packages/next-intlayer/useDictionary.md +248 -0
- package/ar/packages/next-intlayer/useIntlayer.md +237 -0
- package/ar/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/ar/packages/next-intlayer/useLocale.md +105 -0
- package/ar/packages/preact-intlayer/index.md +3 -0
- package/ar/packages/react-intlayer/index.md +261 -0
- package/ar/packages/react-intlayer/t.md +283 -0
- package/ar/packages/react-intlayer/useDictionary.md +268 -0
- package/ar/packages/react-intlayer/useIntlayer.md +225 -0
- package/ar/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/ar/packages/react-intlayer/useLocale.md +184 -0
- package/ar/packages/react-native-intlayer/index.md +57 -0
- package/ar/packages/react-scripts-intlayer/index.md +57 -0
- package/ar/packages/solid-intlayer/index.md +3 -0
- package/ar/packages/svelte-intlayer/index.md +3 -0
- package/ar/packages/vite-intlayer/index.md +53 -0
- package/ar/packages/vue-intlayer/index.md +3 -0
- package/ar/per_locale_file.md +298 -0
- package/ar/privacy_notice.md +61 -0
- package/ar/roadmap.md +208 -0
- package/ar/terms_of_service.md +33 -0
- package/ar/vs_code_extension.md +139 -0
- package/de/CI_CD.md +149 -0
- package/de/angular-intlayer/index.md +3 -0
- package/de/autoFill.md +157 -0
- package/de/configuration.md +501 -0
- package/de/dictionary/condition.md +213 -0
- package/de/dictionary/content_extention_customization.md +81 -0
- package/de/dictionary/enumeration.md +221 -0
- package/de/dictionary/file.md +207 -0
- package/de/dictionary/function_fetching.md +190 -0
- package/de/dictionary/get_started.md +466 -0
- package/de/dictionary/insertion.md +167 -0
- package/de/dictionary/markdown.md +345 -0
- package/de/dictionary/nesting.md +252 -0
- package/de/dictionary/translation.md +287 -0
- package/de/header.md +5 -0
- package/de/how_works_intlayer.md +216 -0
- package/de/index.md +125 -0
- package/de/insertion.md +0 -0
- package/de/interest_of_intlayer.md +132 -0
- package/de/intlayer_CMS.md +334 -0
- package/de/intlayer_cli.md +274 -0
- package/de/intlayer_visual_editor.md +210 -0
- package/de/intlayer_with_angular.md +3 -0
- package/de/intlayer_with_create_react_app.md +1200 -0
- package/de/intlayer_with_express.md +268 -0
- package/de/intlayer_with_lynx+react.md +482 -0
- package/de/intlayer_with_nextjs_14.md +1258 -0
- package/de/intlayer_with_nextjs_15.md +1306 -0
- package/de/intlayer_with_nextjs_page_router.md +1087 -0
- package/de/intlayer_with_react_native+expo.md +539 -0
- package/de/intlayer_with_vite+preact.md +1701 -0
- package/de/intlayer_with_vite+react.md +1584 -0
- package/de/intlayer_with_vite+solid.md +3 -0
- package/de/intlayer_with_vite+svelte.md +3 -0
- package/de/intlayer_with_vite+vue.md +989 -0
- package/de/introduction.md +186 -0
- package/de/mcp_server.md +150 -0
- package/de/packages/@intlayer/api/index.md +31 -0
- package/de/packages/@intlayer/chokidar/index.md +31 -0
- package/de/packages/@intlayer/cli/index.md +21 -0
- package/de/packages/@intlayer/config/index.md +116 -0
- package/de/packages/@intlayer/core/index.md +25 -0
- package/de/packages/@intlayer/design-system/index.md +21 -0
- package/de/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/de/packages/@intlayer/editor/index.md +21 -0
- package/de/packages/@intlayer/editor-react/index.md +21 -0
- package/de/packages/@intlayer/webpack/index.md +35 -0
- package/de/packages/angular-intlayer/index.md +31 -0
- package/de/packages/express-intlayer/index.md +229 -0
- package/de/packages/express-intlayer/t.md +432 -0
- package/de/packages/intlayer/getConfiguration.md +120 -0
- package/de/packages/intlayer/getEnumeration.md +140 -0
- package/de/packages/intlayer/getHTMLTextDir.md +97 -0
- package/de/packages/intlayer/getLocaleLang.md +57 -0
- package/de/packages/intlayer/getLocaleName.md +93 -0
- package/de/packages/intlayer/getLocalizedUrl.md +221 -0
- package/de/packages/intlayer/getMultilingualUrls.md +198 -0
- package/de/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/de/packages/intlayer/getTranslation.md +166 -0
- package/de/packages/intlayer/getTranslationContent.md +166 -0
- package/de/packages/intlayer/index.md +478 -0
- package/de/packages/intlayer-cli/index.md +41 -0
- package/de/packages/intlayer-editor/index.md +113 -0
- package/de/packages/lynx-intlayer/index.md +58 -0
- package/de/packages/next-intlayer/index.md +263 -0
- package/de/packages/next-intlayer/t.md +325 -0
- package/de/packages/next-intlayer/useDictionary.md +242 -0
- package/de/packages/next-intlayer/useIntlayer.md +237 -0
- package/de/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/de/packages/next-intlayer/useLocale.md +105 -0
- package/de/packages/preact-intlayer/index.md +3 -0
- package/de/packages/react-intlayer/index.md +260 -0
- package/de/packages/react-intlayer/t.md +277 -0
- package/de/packages/react-intlayer/useDictionary.md +260 -0
- package/de/packages/react-intlayer/useIntlayer.md +225 -0
- package/de/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/de/packages/react-intlayer/useLocale.md +184 -0
- package/de/packages/react-native-intlayer/index.md +57 -0
- package/de/packages/react-scripts-intlayer/index.md +57 -0
- package/de/packages/solid-intlayer/index.md +3 -0
- package/de/packages/svelte-intlayer/index.md +3 -0
- package/de/packages/vite-intlayer/index.md +53 -0
- package/de/packages/vue-intlayer/index.md +3 -0
- package/de/per_locale_file.md +298 -0
- package/de/privacy_notice.md +61 -0
- package/de/roadmap.md +206 -0
- package/de/terms_of_service.md +33 -0
- package/de/vs_code_extension.md +139 -0
- package/en/CI_CD.md +149 -0
- package/en/autoFill.md +157 -0
- package/en/configuration.md +506 -0
- package/en/dictionary/condition.md +213 -0
- package/en/dictionary/content_extention_customization.md +81 -0
- package/en/dictionary/enumeration.md +221 -0
- package/en/dictionary/file.md +198 -0
- package/en/dictionary/function_fetching.md +190 -0
- package/en/dictionary/get_started.md +504 -0
- package/en/dictionary/insertion.md +167 -0
- package/en/dictionary/markdown.md +355 -0
- package/en/dictionary/nesting.md +249 -0
- package/en/dictionary/translation.md +285 -0
- package/en/frequent_questions/build_dictionaries.md +37 -0
- package/en/frequent_questions/domain_routing.md +92 -0
- package/en/frequent_questions/esbuild_error.md +9 -0
- package/en/frequent_questions/get_locale_cookie.md +121 -0
- package/en/frequent_questions/intlayer_command_undefined.md +135 -0
- package/en/frequent_questions/locale_incorect_in_url.md +52 -0
- package/en/frequent_questions/static_rendering.md +24 -0
- package/en/frequent_questions/unknown_command.md +76 -0
- package/en/header.md +5 -0
- package/en/how_works_intlayer.md +219 -0
- package/en/index.md +139 -0
- package/en/interest_of_intlayer.md +133 -0
- package/en/intlayer_CMS.md +334 -0
- package/en/intlayer_cli.md +309 -0
- package/en/intlayer_visual_editor.md +244 -0
- package/en/intlayer_with_angular.md +139 -0
- package/en/intlayer_with_create_react_app.md +1209 -0
- package/en/intlayer_with_express.md +391 -0
- package/en/intlayer_with_lynx+react.md +483 -0
- package/en/intlayer_with_nextjs_14.md +1298 -0
- package/en/intlayer_with_nextjs_15.md +1347 -0
- package/en/intlayer_with_nextjs_page_router.md +1126 -0
- package/en/intlayer_with_react_native+expo.md +630 -0
- package/en/intlayer_with_vite+preact.md +1659 -0
- package/en/intlayer_with_vite+react.md +1605 -0
- package/en/intlayer_with_vite+solid.md +254 -0
- package/en/intlayer_with_vite+svelte.md +254 -0
- package/en/intlayer_with_vite+vue.md +1000 -0
- package/en/introduction.md +185 -0
- package/en/mcp_server.md +150 -0
- package/en/packages/@intlayer/api/index.md +31 -0
- package/en/packages/@intlayer/chokidar/index.md +31 -0
- package/en/packages/@intlayer/cli/index.md +21 -0
- package/en/packages/@intlayer/config/index.md +116 -0
- package/en/packages/@intlayer/core/index.md +25 -0
- package/en/packages/@intlayer/design-system/index.md +21 -0
- package/en/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/en/packages/@intlayer/editor/index.md +21 -0
- package/en/packages/@intlayer/editor-react/index.md +21 -0
- package/en/packages/@intlayer/webpack/index.md +35 -0
- package/en/packages/angular-intlayer/index.md +31 -0
- package/en/packages/express-intlayer/index.md +229 -0
- package/en/packages/express-intlayer/t.md +432 -0
- package/en/packages/intlayer/getConfiguration.md +120 -0
- package/en/packages/intlayer/getEnumeration.md +138 -0
- package/en/packages/intlayer/getHTMLTextDir.md +97 -0
- package/en/packages/intlayer/getLocaleLang.md +57 -0
- package/en/packages/intlayer/getLocaleName.md +93 -0
- package/en/packages/intlayer/getLocalizedUrl.md +221 -0
- package/en/packages/intlayer/getMultilingualUrls.md +198 -0
- package/en/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/en/packages/intlayer/getTranslation.md +166 -0
- package/en/packages/intlayer/getTranslationContent.md +166 -0
- package/en/packages/intlayer/index.md +476 -0
- package/en/packages/intlayer-cli/index.md +41 -0
- package/en/packages/intlayer-editor/index.md +113 -0
- package/en/packages/lynx-intlayer/index.md +60 -0
- package/en/packages/next-intlayer/index.md +263 -0
- package/en/packages/next-intlayer/t.md +326 -0
- package/en/packages/next-intlayer/useDictionary.md +242 -0
- package/en/packages/next-intlayer/useIntlayer.md +237 -0
- package/en/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/en/packages/next-intlayer/useLocale.md +105 -0
- package/en/packages/preact-intlayer/index.md +31 -0
- package/en/packages/react-intlayer/index.md +257 -0
- package/en/packages/react-intlayer/t.md +277 -0
- package/en/packages/react-intlayer/useDictionary.md +260 -0
- package/en/packages/react-intlayer/useIntlayer.md +225 -0
- package/en/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/en/packages/react-intlayer/useLocale.md +184 -0
- package/en/packages/react-native-intlayer/index.md +59 -0
- package/en/packages/react-scripts-intlayer/index.md +57 -0
- package/en/packages/solid-intlayer/index.md +31 -0
- package/en/packages/svelte-intlayer/index.md +31 -0
- package/en/packages/vite-intlayer/index.md +53 -0
- package/en/packages/vue-intlayer/index.md +31 -0
- package/en/per_locale_file.md +297 -0
- package/en/privacy_notice.md +61 -0
- package/en/roadmap.md +270 -0
- package/en/t.md +163 -0
- package/en/terms_of_service.md +33 -0
- package/en/vs_code_extension.md +129 -0
- package/en-GB/CI_CD.md +149 -0
- package/en-GB/autoFill.md +0 -0
- package/en-GB/configuration.md +490 -0
- package/en-GB/dictionary/condition.md +213 -0
- package/en-GB/dictionary/content_extention_customization.md +83 -0
- package/en-GB/dictionary/enumeration.md +221 -0
- package/en-GB/dictionary/file.md +201 -0
- package/en-GB/dictionary/function_fetching.md +190 -0
- package/en-GB/dictionary/get_started.md +466 -0
- package/en-GB/dictionary/insertion.md +167 -0
- package/en-GB/dictionary/markdown.md +343 -0
- package/en-GB/dictionary/nesting.md +249 -0
- package/en-GB/dictionary/translation.md +285 -0
- package/en-GB/header.md +1 -0
- package/en-GB/how_works_intlayer.md +217 -0
- package/en-GB/index.md +142 -0
- package/en-GB/interest_of_intlayer.md +123 -0
- package/en-GB/intlayer_CMS.md +334 -0
- package/en-GB/intlayer_cli.md +239 -0
- package/en-GB/intlayer_visual_editor.md +210 -0
- package/en-GB/intlayer_with_angular.md +3 -0
- package/en-GB/intlayer_with_create_react_app.md +1192 -0
- package/en-GB/intlayer_with_express.md +267 -0
- package/en-GB/intlayer_with_lynx+react.md +484 -0
- package/en-GB/intlayer_with_nextjs_14.md +1267 -0
- package/en-GB/intlayer_with_nextjs_15.md +1308 -0
- package/en-GB/intlayer_with_nextjs_page_router.md +1087 -0
- package/en-GB/intlayer_with_react_native+expo.md +539 -0
- package/en-GB/intlayer_with_vite+preact.md +1648 -0
- package/en-GB/intlayer_with_vite+react.md +1430 -0
- package/en-GB/intlayer_with_vite+solid.md +3 -0
- package/en-GB/intlayer_with_vite+svelte.md +3 -0
- package/en-GB/intlayer_with_vite+vue.md +993 -0
- package/en-GB/introduction.md +201 -0
- package/en-GB/mcp_server.md +150 -0
- package/en-GB/packages/@intlayer/api/index.md +31 -0
- package/en-GB/packages/@intlayer/chokidar/index.md +31 -0
- package/en-GB/packages/@intlayer/cli/index.md +21 -0
- package/en-GB/packages/@intlayer/config/index.md +116 -0
- package/en-GB/packages/@intlayer/core/index.md +25 -0
- package/en-GB/packages/@intlayer/design-system/index.md +21 -0
- package/en-GB/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/en-GB/packages/@intlayer/editor/index.md +21 -0
- package/en-GB/packages/@intlayer/editor-react/index.md +21 -0
- package/en-GB/packages/@intlayer/webpack/index.md +35 -0
- package/en-GB/packages/angular-intlayer/index.md +3 -0
- package/en-GB/packages/express-intlayer/index.md +229 -0
- package/en-GB/packages/express-intlayer/t.md +432 -0
- package/en-GB/packages/intlayer/getConfiguration.md +120 -0
- package/en-GB/packages/intlayer/getEnumeration.md +140 -0
- package/en-GB/packages/intlayer/getHTMLTextDir.md +97 -0
- package/en-GB/packages/intlayer/getLocaleLang.md +57 -0
- package/en-GB/packages/intlayer/getLocaleName.md +93 -0
- package/en-GB/packages/intlayer/getLocalizedUrl.md +221 -0
- package/en-GB/packages/intlayer/getMultilingualUrls.md +198 -0
- package/en-GB/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/en-GB/packages/intlayer/getTranslation.md +166 -0
- package/en-GB/packages/intlayer/getTranslationContent.md +166 -0
- package/en-GB/packages/intlayer/index.md +476 -0
- package/en-GB/packages/intlayer-cli/index.md +41 -0
- package/en-GB/packages/intlayer-editor/index.md +113 -0
- package/en-GB/packages/lynx-intlayer/index.md +58 -0
- package/en-GB/packages/next-intlayer/index.md +263 -0
- package/en-GB/packages/next-intlayer/t.md +326 -0
- package/en-GB/packages/next-intlayer/useDictionary.md +242 -0
- package/en-GB/packages/next-intlayer/useIntlayer.md +237 -0
- package/en-GB/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/en-GB/packages/next-intlayer/useLocale.md +105 -0
- package/en-GB/packages/preact-intlayer/index.md +3 -0
- package/en-GB/packages/react-intlayer/index.md +257 -0
- package/en-GB/packages/react-intlayer/t.md +277 -0
- package/en-GB/packages/react-intlayer/useDictionary.md +260 -0
- package/en-GB/packages/react-intlayer/useIntlayer.md +225 -0
- package/en-GB/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/en-GB/packages/react-intlayer/useLocale.md +184 -0
- package/en-GB/packages/react-native-intlayer/index.md +57 -0
- package/en-GB/packages/react-scripts-intlayer/index.md +57 -0
- package/en-GB/packages/solid-intlayer/index.md +3 -0
- package/en-GB/packages/svelte-intlayer/index.md +3 -0
- package/en-GB/packages/vite-intlayer/index.md +53 -0
- package/en-GB/packages/vue-intlayer/index.md +3 -0
- package/en-GB/per_locale_file.md +298 -0
- package/en-GB/privacy_notice.md +57 -0
- package/en-GB/roadmap.md +206 -0
- package/en-GB/terms_of_service.md +33 -0
- package/en-GB/vs_code_extension.md +139 -0
- package/es/CI_CD.md +149 -0
- package/es/autoFill.md +157 -0
- package/es/configuration.md +503 -0
- package/es/dictionary/condition.md +213 -0
- package/es/dictionary/content_extention_customization.md +81 -0
- package/es/dictionary/enumeration.md +221 -0
- package/es/dictionary/file.md +206 -0
- package/es/dictionary/function_fetching.md +190 -0
- package/es/dictionary/get_started.md +466 -0
- package/es/dictionary/insertion.md +161 -0
- package/es/dictionary/markdown.md +338 -0
- package/es/dictionary/nesting.md +249 -0
- package/es/dictionary/translation.md +287 -0
- package/es/header.md +5 -0
- package/es/how_works_intlayer.md +217 -0
- package/es/index.md +122 -0
- package/es/interest_of_intlayer.md +132 -0
- package/es/intlayer_CMS.md +334 -0
- package/es/intlayer_cli.md +274 -0
- package/es/intlayer_visual_editor.md +210 -0
- package/es/intlayer_with_angular.md +3 -0
- package/es/intlayer_with_create_react_app.md +1192 -0
- package/es/intlayer_with_express.md +276 -0
- package/es/intlayer_with_lynx+react.md +475 -0
- package/es/intlayer_with_nextjs_14.md +1258 -0
- package/es/intlayer_with_nextjs_15.md +1308 -0
- package/es/intlayer_with_nextjs_page_router.md +1088 -0
- package/es/intlayer_with_react_native+expo.md +180 -0
- package/es/intlayer_with_vite+preact.md +1637 -0
- package/es/intlayer_with_vite+react.md +1592 -0
- package/es/intlayer_with_vite+solid.md +3 -0
- package/es/intlayer_with_vite+svelte.md +3 -0
- package/es/intlayer_with_vite+vue.md +947 -0
- package/es/introduction.md +184 -0
- package/es/mcp_server.md +150 -0
- package/es/packages/@intlayer/api/index.md +31 -0
- package/es/packages/@intlayer/chokidar/index.md +31 -0
- package/es/packages/@intlayer/cli/index.md +21 -0
- package/es/packages/@intlayer/config/index.md +116 -0
- package/es/packages/@intlayer/core/index.md +25 -0
- package/es/packages/@intlayer/design-system/index.md +21 -0
- package/es/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/es/packages/@intlayer/editor/index.md +21 -0
- package/es/packages/@intlayer/editor-react/index.md +21 -0
- package/es/packages/@intlayer/webpack/index.md +35 -0
- package/es/packages/angular-intlayer/index.md +3 -0
- package/es/packages/express-intlayer/index.md +229 -0
- package/es/packages/express-intlayer/t.md +432 -0
- package/es/packages/intlayer/getConfiguration.md +120 -0
- package/es/packages/intlayer/getEnumeration.md +138 -0
- package/es/packages/intlayer/getHTMLTextDir.md +97 -0
- package/es/packages/intlayer/getLocaleLang.md +57 -0
- package/es/packages/intlayer/getLocaleName.md +93 -0
- package/es/packages/intlayer/getLocalizedUrl.md +221 -0
- package/es/packages/intlayer/getMultilingualUrls.md +198 -0
- package/es/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/es/packages/intlayer/getTranslation.md +166 -0
- package/es/packages/intlayer/getTranslationContent.md +166 -0
- package/es/packages/intlayer/index.md +478 -0
- package/es/packages/intlayer-cli/index.md +41 -0
- package/es/packages/intlayer-editor/index.md +115 -0
- package/es/packages/lynx-intlayer/index.md +58 -0
- package/es/packages/next-intlayer/index.md +263 -0
- package/es/packages/next-intlayer/t.md +325 -0
- package/es/packages/next-intlayer/useDictionary.md +242 -0
- package/es/packages/next-intlayer/useIntlayer.md +237 -0
- package/es/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/es/packages/next-intlayer/useLocale.md +105 -0
- package/es/packages/preact-intlayer/index.md +3 -0
- package/es/packages/react-intlayer/index.md +263 -0
- package/es/packages/react-intlayer/t.md +277 -0
- package/es/packages/react-intlayer/useDictionary.md +270 -0
- package/es/packages/react-intlayer/useIntlayer.md +225 -0
- package/es/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/es/packages/react-intlayer/useLocale.md +184 -0
- package/es/packages/react-native-intlayer/index.md +57 -0
- package/es/packages/react-scripts-intlayer/index.md +57 -0
- package/es/packages/solid-intlayer/index.md +3 -0
- package/es/packages/svelte-intlayer/index.md +5 -0
- package/es/packages/vite-intlayer/index.md +53 -0
- package/es/packages/vue-intlayer/index.md +3 -0
- package/es/per_locale_file.md +293 -0
- package/es/privacy_notice.md +61 -0
- package/es/roadmap.md +157 -0
- package/es/terms_of_service.md +33 -0
- package/es/vs_code_extension.md +139 -0
- package/fr/CI_CD.md +149 -0
- package/fr/autoFill.md +157 -0
- package/fr/configuration.md +481 -0
- package/fr/dictionary/condition.md +213 -0
- package/fr/dictionary/content_extention_customization.md +81 -0
- package/fr/dictionary/enumeration.md +221 -0
- package/fr/dictionary/file.md +206 -0
- package/fr/dictionary/function_fetching.md +190 -0
- package/fr/dictionary/get_started.md +466 -0
- package/fr/dictionary/insertion.md +161 -0
- package/fr/dictionary/markdown.md +335 -0
- package/fr/dictionary/nesting.md +249 -0
- package/fr/dictionary/translation.md +287 -0
- package/fr/header.md +5 -0
- package/fr/how_works_intlayer.md +217 -0
- package/fr/index.md +122 -0
- package/fr/interest_of_intlayer.md +132 -0
- package/fr/intlayer_CMS.md +334 -0
- package/fr/intlayer_cli.md +274 -0
- package/fr/intlayer_visual_editor.md +210 -0
- package/fr/intlayer_with_angular.md +3 -0
- package/fr/intlayer_with_create_react_app.md +1192 -0
- package/fr/intlayer_with_express.md +270 -0
- package/fr/intlayer_with_lynx+react.md +466 -0
- package/fr/intlayer_with_nextjs_14.md +1258 -0
- package/fr/intlayer_with_nextjs_15.md +1308 -0
- package/fr/intlayer_with_nextjs_page_router.md +1085 -0
- package/fr/intlayer_with_react_native+expo.md +535 -0
- package/fr/intlayer_with_vite+preact.md +1621 -0
- package/fr/intlayer_with_vite+react.md +1589 -0
- package/fr/intlayer_with_vite+solid.md +3 -0
- package/fr/intlayer_with_vite+svelte.md +3 -0
- package/fr/intlayer_with_vite+vue.md +947 -0
- package/fr/introduction.md +190 -0
- package/fr/mcp_server.md +152 -0
- package/fr/packages/@intlayer/api/index.md +31 -0
- package/fr/packages/@intlayer/chokidar/index.md +31 -0
- package/fr/packages/@intlayer/cli/index.md +21 -0
- package/fr/packages/@intlayer/config/index.md +116 -0
- package/fr/packages/@intlayer/core/index.md +25 -0
- package/fr/packages/@intlayer/design-system/index.md +21 -0
- package/fr/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/fr/packages/@intlayer/editor/index.md +21 -0
- package/fr/packages/@intlayer/editor-react/index.md +21 -0
- package/fr/packages/@intlayer/webpack/index.md +35 -0
- package/fr/packages/angular-intlayer/index.md +3 -0
- package/fr/packages/express-intlayer/index.md +238 -0
- package/fr/packages/express-intlayer/t.md +432 -0
- package/fr/packages/intlayer/getConfiguration.md +120 -0
- package/fr/packages/intlayer/getEnumeration.md +138 -0
- package/fr/packages/intlayer/getHTMLTextDir.md +97 -0
- package/fr/packages/intlayer/getLocaleLang.md +57 -0
- package/fr/packages/intlayer/getLocaleName.md +93 -0
- package/fr/packages/intlayer/getLocalizedUrl.md +221 -0
- package/fr/packages/intlayer/getMultilingualUrls.md +198 -0
- package/fr/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/fr/packages/intlayer/getTranslation.md +166 -0
- package/fr/packages/intlayer/getTranslationContent.md +166 -0
- package/fr/packages/intlayer/index.md +476 -0
- package/fr/packages/intlayer-cli/index.md +41 -0
- package/fr/packages/intlayer-editor/index.md +115 -0
- package/fr/packages/lynx-intlayer/index.md +58 -0
- package/fr/packages/next-intlayer/index.md +266 -0
- package/fr/packages/next-intlayer/t.md +325 -0
- package/fr/packages/next-intlayer/useDictionary.md +242 -0
- package/fr/packages/next-intlayer/useIntlayer.md +237 -0
- package/fr/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/fr/packages/next-intlayer/useLocale.md +105 -0
- package/fr/packages/preact-intlayer/index.md +3 -0
- package/fr/packages/react-intlayer/index.md +257 -0
- package/fr/packages/react-intlayer/t.md +277 -0
- package/fr/packages/react-intlayer/useDictionary.md +269 -0
- package/fr/packages/react-intlayer/useIntlayer.md +234 -0
- package/fr/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/fr/packages/react-intlayer/useLocale.md +184 -0
- package/fr/packages/react-native-intlayer/index.md +57 -0
- package/fr/packages/react-scripts-intlayer/index.md +57 -0
- package/fr/packages/solid-intlayer/index.md +3 -0
- package/fr/packages/svelte-intlayer/index.md +3 -0
- package/fr/packages/vite-intlayer/index.md +53 -0
- package/fr/packages/vue-intlayer/index.md +3 -0
- package/fr/per_locale_file.md +297 -0
- package/fr/privacy_notice.md +57 -0
- package/fr/roadmap.md +206 -0
- package/fr/terms_of_service.md +33 -0
- package/fr/vs_code_extension.md +139 -0
- package/hi/CI_CD.md +149 -0
- package/hi/autoFill.md +157 -0
- package/hi/configuration.md +509 -0
- package/hi/dictionary/condition.md +213 -0
- package/hi/dictionary/content_extention_customization.md +81 -0
- package/hi/dictionary/enumeration.md +221 -0
- package/hi/dictionary/file.md +209 -0
- package/hi/dictionary/function_fetching.md +188 -0
- package/hi/dictionary/get_started.md +490 -0
- package/hi/dictionary/insertion.md +167 -0
- package/hi/dictionary/markdown.md +344 -0
- package/hi/dictionary/nesting.md +249 -0
- package/hi/dictionary/translation.md +307 -0
- package/hi/header.md +7 -0
- package/hi/how_works_intlayer.md +217 -0
- package/hi/index.md +125 -0
- package/hi/interest_of_intlayer.md +132 -0
- package/hi/intlayer_CMS.md +334 -0
- package/hi/intlayer_cli.md +274 -0
- package/hi/intlayer_visual_editor.md +210 -0
- package/hi/intlayer_with_angular.md +3 -0
- package/hi/intlayer_with_create_react_app.md +1395 -0
- package/hi/intlayer_with_express.md +273 -0
- package/hi/intlayer_with_lynx+react.md +456 -0
- package/hi/intlayer_with_nextjs_14.md +1283 -0
- package/hi/intlayer_with_nextjs_15.md +1319 -0
- package/hi/intlayer_with_nextjs_page_router.md +1097 -0
- package/hi/intlayer_with_react_native+expo.md +554 -0
- package/hi/intlayer_with_vite+preact.md +1538 -0
- package/hi/intlayer_with_vite+react.md +1540 -0
- package/hi/intlayer_with_vite+solid.md +3 -0
- package/hi/intlayer_with_vite+svelte.md +3 -0
- package/hi/intlayer_with_vite+vue.md +840 -0
- package/hi/introduction.md +190 -0
- package/hi/mcp_server.md +150 -0
- package/hi/packages/@intlayer/api/index.md +31 -0
- package/hi/packages/@intlayer/chokidar/index.md +31 -0
- package/hi/packages/@intlayer/cli/index.md +21 -0
- package/hi/packages/@intlayer/config/index.md +116 -0
- package/hi/packages/@intlayer/core/index.md +25 -0
- package/hi/packages/@intlayer/design-system/index.md +21 -0
- package/hi/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/hi/packages/@intlayer/editor/index.md +21 -0
- package/hi/packages/@intlayer/editor-react/index.md +21 -0
- package/hi/packages/@intlayer/webpack/index.md +35 -0
- package/hi/packages/angular-intlayer/index.md +3 -0
- package/hi/packages/express-intlayer/index.md +232 -0
- package/hi/packages/express-intlayer/t.md +445 -0
- package/hi/packages/intlayer/getConfiguration.md +120 -0
- package/hi/packages/intlayer/getEnumeration.md +138 -0
- package/hi/packages/intlayer/getHTMLTextDir.md +97 -0
- package/hi/packages/intlayer/getLocaleLang.md +57 -0
- package/hi/packages/intlayer/getLocaleName.md +93 -0
- package/hi/packages/intlayer/getLocalizedUrl.md +221 -0
- package/hi/packages/intlayer/getMultilingualUrls.md +198 -0
- package/hi/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/hi/packages/intlayer/getTranslation.md +175 -0
- package/hi/packages/intlayer/getTranslationContent.md +175 -0
- package/hi/packages/intlayer/index.md +314 -0
- package/hi/packages/intlayer-cli/index.md +41 -0
- package/hi/packages/intlayer-editor/index.md +113 -0
- package/hi/packages/lynx-intlayer/index.md +58 -0
- package/hi/packages/next-intlayer/index.md +270 -0
- package/hi/packages/next-intlayer/t.md +337 -0
- package/hi/packages/next-intlayer/useDictionary.md +248 -0
- package/hi/packages/next-intlayer/useIntlayer.md +237 -0
- package/hi/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/hi/packages/next-intlayer/useLocale.md +105 -0
- package/hi/packages/preact-intlayer/index.md +3 -0
- package/hi/packages/react-intlayer/index.md +261 -0
- package/hi/packages/react-intlayer/t.md +283 -0
- package/hi/packages/react-intlayer/useDictionary.md +268 -0
- package/hi/packages/react-intlayer/useIntlayer.md +225 -0
- package/hi/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/hi/packages/react-intlayer/useLocale.md +184 -0
- package/hi/packages/react-native-intlayer/index.md +57 -0
- package/hi/packages/react-scripts-intlayer/index.md +57 -0
- package/hi/packages/solid-intlayer/index.md +3 -0
- package/hi/packages/svelte-intlayer/index.md +3 -0
- package/hi/packages/vite-intlayer/index.md +53 -0
- package/hi/packages/vue-intlayer/index.md +3 -0
- package/hi/per_locale_file.md +298 -0
- package/hi/privacy_notice.md +61 -0
- package/hi/roadmap.md +206 -0
- package/hi/terms_of_service.md +33 -0
- package/hi/vs_code_extension.md +139 -0
- package/index.cjs +1265 -0
- package/index.d.ts +100 -0
- package/it/CI_CD.md +149 -0
- package/it/autoFill.md +157 -0
- package/it/configuration.md +503 -0
- package/it/dictionary/condition.md +213 -0
- package/it/dictionary/content_extention_customization.md +81 -0
- package/it/dictionary/enumeration.md +221 -0
- package/it/dictionary/file.md +207 -0
- package/it/dictionary/function_fetching.md +190 -0
- package/it/dictionary/get_started.md +466 -0
- package/it/dictionary/insertion.md +161 -0
- package/it/dictionary/markdown.md +343 -0
- package/it/dictionary/nesting.md +249 -0
- package/it/dictionary/translation.md +287 -0
- package/it/header.md +7 -0
- package/it/how_works_intlayer.md +217 -0
- package/it/index.md +125 -0
- package/it/interest_of_intlayer.md +132 -0
- package/it/intlayer_CMS.md +334 -0
- package/it/intlayer_cli.md +274 -0
- package/it/intlayer_visual_editor.md +210 -0
- package/it/intlayer_with_angular.md +3 -0
- package/it/intlayer_with_create_react_app.md +413 -0
- package/it/intlayer_with_express.md +267 -0
- package/it/intlayer_with_lynx+react.md +482 -0
- package/it/intlayer_with_nextjs_14.md +1269 -0
- package/it/intlayer_with_nextjs_15.md +1319 -0
- package/it/intlayer_with_nextjs_page_router.md +1095 -0
- package/it/intlayer_with_react_native+expo.md +261 -0
- package/it/intlayer_with_vite+preact.md +1681 -0
- package/it/intlayer_with_vite+react.md +1580 -0
- package/it/intlayer_with_vite+solid.md +3 -0
- package/it/intlayer_with_vite+svelte.md +3 -0
- package/it/intlayer_with_vite+vue.md +989 -0
- package/it/introduction.md +192 -0
- package/it/mcp_server.md +152 -0
- package/it/packages/@intlayer/api/index.md +31 -0
- package/it/packages/@intlayer/chokidar/index.md +31 -0
- package/it/packages/@intlayer/cli/index.md +21 -0
- package/it/packages/@intlayer/config/index.md +116 -0
- package/it/packages/@intlayer/core/index.md +25 -0
- package/it/packages/@intlayer/design-system/index.md +21 -0
- package/it/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/it/packages/@intlayer/editor/index.md +21 -0
- package/it/packages/@intlayer/editor-react/index.md +21 -0
- package/it/packages/@intlayer/webpack/index.md +35 -0
- package/it/packages/angular-intlayer/index.md +3 -0
- package/it/packages/express-intlayer/index.md +229 -0
- package/it/packages/express-intlayer/t.md +432 -0
- package/it/packages/intlayer/getConfiguration.md +120 -0
- package/it/packages/intlayer/getEnumeration.md +138 -0
- package/it/packages/intlayer/getHTMLTextDir.md +97 -0
- package/it/packages/intlayer/getLocaleLang.md +57 -0
- package/it/packages/intlayer/getLocaleName.md +93 -0
- package/it/packages/intlayer/getLocalizedUrl.md +221 -0
- package/it/packages/intlayer/getMultilingualUrls.md +200 -0
- package/it/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/it/packages/intlayer/getTranslation.md +166 -0
- package/it/packages/intlayer/getTranslationContent.md +166 -0
- package/it/packages/intlayer/index.md +479 -0
- package/it/packages/intlayer-cli/index.md +41 -0
- package/it/packages/intlayer-editor/index.md +113 -0
- package/it/packages/lynx-intlayer/index.md +58 -0
- package/it/packages/next-intlayer/index.md +267 -0
- package/it/packages/next-intlayer/t.md +326 -0
- package/it/packages/next-intlayer/useDictionary.md +242 -0
- package/it/packages/next-intlayer/useIntlayer.md +237 -0
- package/it/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/it/packages/next-intlayer/useLocale.md +105 -0
- package/it/packages/preact-intlayer/index.md +3 -0
- package/it/packages/react-intlayer/index.md +260 -0
- package/it/packages/react-intlayer/t.md +277 -0
- package/it/packages/react-intlayer/useDictionary.md +260 -0
- package/it/packages/react-intlayer/useIntlayer.md +225 -0
- package/it/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/it/packages/react-intlayer/useLocale.md +184 -0
- package/it/packages/react-native-intlayer/index.md +57 -0
- package/it/packages/react-scripts-intlayer/index.md +57 -0
- package/it/packages/solid-intlayer/index.md +5 -0
- package/it/packages/svelte-intlayer/index.md +3 -0
- package/it/packages/vite-intlayer/index.md +53 -0
- package/it/packages/vue-intlayer/index.md +5 -0
- package/it/per_locale_file.md +298 -0
- package/it/privacy_notice.md +61 -0
- package/it/roadmap.md +206 -0
- package/it/terms_of_service.md +33 -0
- package/it/vs_code_extension.md +139 -0
- package/ja/CI_CD.md +149 -0
- package/ja/autoFill.md +157 -0
- package/ja/configuration.md +507 -0
- package/ja/dictionary/condition.md +213 -0
- package/ja/dictionary/content_extention_customization.md +81 -0
- package/ja/dictionary/enumeration.md +221 -0
- package/ja/dictionary/file.md +209 -0
- package/ja/dictionary/function_fetching.md +190 -0
- package/ja/dictionary/get_started.md +466 -0
- package/ja/dictionary/insertion.md +161 -0
- package/ja/dictionary/markdown.md +343 -0
- package/ja/dictionary/nesting.md +249 -0
- package/ja/dictionary/translation.md +287 -0
- package/ja/header.md +7 -0
- package/ja/how_works_intlayer.md +217 -0
- package/ja/index.md +125 -0
- package/ja/interest_of_intlayer.md +132 -0
- package/ja/intlayer_CMS.md +334 -0
- package/ja/intlayer_cli.md +274 -0
- package/ja/intlayer_visual_editor.md +213 -0
- package/ja/intlayer_with_angular.md +3 -0
- package/ja/intlayer_with_create_react_app.md +1186 -0
- package/ja/intlayer_with_express.md +267 -0
- package/ja/intlayer_with_lynx+react.md +482 -0
- package/ja/intlayer_with_nextjs_14.md +1256 -0
- package/ja/intlayer_with_nextjs_15.md +1308 -0
- package/ja/intlayer_with_nextjs_page_router.md +1085 -0
- package/ja/intlayer_with_react_native+expo.md +537 -0
- package/ja/intlayer_with_vite+preact.md +1601 -0
- package/ja/intlayer_with_vite+react.md +1555 -0
- package/ja/intlayer_with_vite+solid.md +3 -0
- package/ja/intlayer_with_vite+svelte.md +3 -0
- package/ja/intlayer_with_vite+vue.md +990 -0
- package/ja/introduction.md +186 -0
- package/ja/mcp_server.md +150 -0
- package/ja/packages/@intlayer/api/index.md +31 -0
- package/ja/packages/@intlayer/chokidar/index.md +31 -0
- package/ja/packages/@intlayer/cli/index.md +21 -0
- package/ja/packages/@intlayer/config/index.md +116 -0
- package/ja/packages/@intlayer/core/index.md +25 -0
- package/ja/packages/@intlayer/design-system/index.md +21 -0
- package/ja/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/ja/packages/@intlayer/editor/index.md +21 -0
- package/ja/packages/@intlayer/editor-react/index.md +21 -0
- package/ja/packages/@intlayer/webpack/index.md +35 -0
- package/ja/packages/angular-intlayer/index.md +3 -0
- package/ja/packages/express-intlayer/index.md +229 -0
- package/ja/packages/express-intlayer/t.md +432 -0
- package/ja/packages/intlayer/getConfiguration.md +120 -0
- package/ja/packages/intlayer/getEnumeration.md +140 -0
- package/ja/packages/intlayer/getHTMLTextDir.md +97 -0
- package/ja/packages/intlayer/getLocaleLang.md +59 -0
- package/ja/packages/intlayer/getLocaleName.md +93 -0
- package/ja/packages/intlayer/getLocalizedUrl.md +221 -0
- package/ja/packages/intlayer/getMultilingualUrls.md +198 -0
- package/ja/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/ja/packages/intlayer/getTranslation.md +166 -0
- package/ja/packages/intlayer/getTranslationContent.md +166 -0
- package/ja/packages/intlayer/index.md +479 -0
- package/ja/packages/intlayer-cli/index.md +41 -0
- package/ja/packages/intlayer-editor/index.md +115 -0
- package/ja/packages/lynx-intlayer/index.md +58 -0
- package/ja/packages/next-intlayer/index.md +263 -0
- package/ja/packages/next-intlayer/t.md +326 -0
- package/ja/packages/next-intlayer/useDictionary.md +242 -0
- package/ja/packages/next-intlayer/useIntlayer.md +237 -0
- package/ja/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/ja/packages/next-intlayer/useLocale.md +105 -0
- package/ja/packages/preact-intlayer/index.md +3 -0
- package/ja/packages/react-intlayer/index.md +257 -0
- package/ja/packages/react-intlayer/t.md +277 -0
- package/ja/packages/react-intlayer/useDictionary.md +260 -0
- package/ja/packages/react-intlayer/useIntlayer.md +225 -0
- package/ja/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/ja/packages/react-intlayer/useLocale.md +184 -0
- package/ja/packages/react-native-intlayer/index.md +57 -0
- package/ja/packages/react-scripts-intlayer/index.md +57 -0
- package/ja/packages/solid-intlayer/index.md +3 -0
- package/ja/packages/svelte-intlayer/index.md +3 -0
- package/ja/packages/vite-intlayer/index.md +53 -0
- package/ja/packages/vue-intlayer/index.md +3 -0
- package/ja/per_locale_file.md +298 -0
- package/ja/privacy_notice.md +57 -0
- package/ja/roadmap.md +206 -0
- package/ja/terms_of_service.md +33 -0
- package/ja/vs_code_extension.md +139 -0
- package/ko/CI_CD.md +149 -0
- package/ko/autoFill.md +157 -0
- package/ko/configuration.md +507 -0
- package/ko/dictionary/condition.md +213 -0
- package/ko/dictionary/content_extention_customization.md +81 -0
- package/ko/dictionary/enumeration.md +221 -0
- package/ko/dictionary/file.md +207 -0
- package/ko/dictionary/function_fetching.md +190 -0
- package/ko/dictionary/get_started.md +466 -0
- package/ko/dictionary/insertion.md +167 -0
- package/ko/dictionary/markdown.md +343 -0
- package/ko/dictionary/nesting.md +249 -0
- package/ko/dictionary/translation.md +287 -0
- package/ko/header.md +7 -0
- package/ko/how_works_intlayer.md +216 -0
- package/ko/index.md +125 -0
- package/ko/interest_of_intlayer.md +132 -0
- package/ko/intlayer_CMS.md +334 -0
- package/ko/intlayer_cli.md +274 -0
- package/ko/intlayer_visual_editor.md +210 -0
- package/ko/intlayer_with_angular.md +3 -0
- package/ko/intlayer_with_create_react_app.md +1186 -0
- package/ko/intlayer_with_express.md +267 -0
- package/ko/intlayer_with_lynx+react.md +482 -0
- package/ko/intlayer_with_nextjs_14.md +1267 -0
- package/ko/intlayer_with_nextjs_15.md +1319 -0
- package/ko/intlayer_with_nextjs_page_router.md +1097 -0
- package/ko/intlayer_with_react_native+expo.md +537 -0
- package/ko/intlayer_with_vite+preact.md +1682 -0
- package/ko/intlayer_with_vite+react.md +1582 -0
- package/ko/intlayer_with_vite+solid.md +3 -0
- package/ko/intlayer_with_vite+svelte.md +3 -0
- package/ko/intlayer_with_vite+vue.md +988 -0
- package/ko/introduction.md +186 -0
- package/ko/mcp_server.md +150 -0
- package/ko/packages/@intlayer/api/index.md +31 -0
- package/ko/packages/@intlayer/chokidar/index.md +31 -0
- package/ko/packages/@intlayer/cli/index.md +21 -0
- package/ko/packages/@intlayer/config/index.md +116 -0
- package/ko/packages/@intlayer/core/index.md +25 -0
- package/ko/packages/@intlayer/design-system/index.md +21 -0
- package/ko/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/ko/packages/@intlayer/editor/index.md +21 -0
- package/ko/packages/@intlayer/editor-react/index.md +21 -0
- package/ko/packages/@intlayer/webpack/index.md +35 -0
- package/ko/packages/angular-intlayer/index.md +5 -0
- package/ko/packages/express-intlayer/index.md +229 -0
- package/ko/packages/express-intlayer/t.md +432 -0
- package/ko/packages/intlayer/getConfiguration.md +120 -0
- package/ko/packages/intlayer/getEnumeration.md +138 -0
- package/ko/packages/intlayer/getHTMLTextDir.md +97 -0
- package/ko/packages/intlayer/getLocaleLang.md +57 -0
- package/ko/packages/intlayer/getLocaleName.md +93 -0
- package/ko/packages/intlayer/getLocalizedUrl.md +221 -0
- package/ko/packages/intlayer/getMultilingualUrls.md +198 -0
- package/ko/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/ko/packages/intlayer/getTranslation.md +166 -0
- package/ko/packages/intlayer/getTranslationContent.md +166 -0
- package/ko/packages/intlayer/index.md +480 -0
- package/ko/packages/intlayer-cli/index.md +41 -0
- package/ko/packages/intlayer-editor/index.md +113 -0
- package/ko/packages/lynx-intlayer/index.md +58 -0
- package/ko/packages/next-intlayer/index.md +267 -0
- package/ko/packages/next-intlayer/t.md +337 -0
- package/ko/packages/next-intlayer/useDictionary.md +242 -0
- package/ko/packages/next-intlayer/useIntlayer.md +237 -0
- package/ko/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/ko/packages/next-intlayer/useLocale.md +105 -0
- package/ko/packages/preact-intlayer/index.md +3 -0
- package/ko/packages/react-intlayer/index.md +260 -0
- package/ko/packages/react-intlayer/t.md +277 -0
- package/ko/packages/react-intlayer/useDictionary.md +268 -0
- package/ko/packages/react-intlayer/useIntlayer.md +225 -0
- package/ko/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/ko/packages/react-intlayer/useLocale.md +184 -0
- package/ko/packages/react-native-intlayer/index.md +57 -0
- package/ko/packages/react-scripts-intlayer/index.md +57 -0
- package/ko/packages/solid-intlayer/index.md +3 -0
- package/ko/packages/svelte-intlayer/index.md +3 -0
- package/ko/packages/vite-intlayer/index.md +53 -0
- package/ko/packages/vue-intlayer/index.md +3 -0
- package/ko/per_locale_file.md +300 -0
- package/ko/privacy_notice.md +61 -0
- package/ko/roadmap.md +206 -0
- package/ko/terms_of_service.md +33 -0
- package/ko/vs_code_extension.md +139 -0
- package/package.json +96 -0
- package/pt/CI_CD.md +149 -0
- package/pt/autoFill.md +157 -0
- package/pt/configuration.md +503 -0
- package/pt/dictionary/condition.md +213 -0
- package/pt/dictionary/content_extention_customization.md +81 -0
- package/pt/dictionary/enumeration.md +221 -0
- package/pt/dictionary/file.md +210 -0
- package/pt/dictionary/function_fetching.md +190 -0
- package/pt/dictionary/get_started.md +490 -0
- package/pt/dictionary/insertion.md +161 -0
- package/pt/dictionary/markdown.md +339 -0
- package/pt/dictionary/nesting.md +249 -0
- package/pt/dictionary/translation.md +322 -0
- package/pt/header.md +7 -0
- package/pt/how_works_intlayer.md +216 -0
- package/pt/index.md +125 -0
- package/pt/interest_of_intlayer.md +132 -0
- package/pt/intlayer_CMS.md +334 -0
- package/pt/intlayer_cli.md +274 -0
- package/pt/intlayer_visual_editor.md +210 -0
- package/pt/intlayer_with_angular.md +3 -0
- package/pt/intlayer_with_create_react_app.md +1204 -0
- package/pt/intlayer_with_express.md +270 -0
- package/pt/intlayer_with_lynx+react.md +467 -0
- package/pt/intlayer_with_nextjs_14.md +1269 -0
- package/pt/intlayer_with_nextjs_15.md +1319 -0
- package/pt/intlayer_with_nextjs_page_router.md +1109 -0
- package/pt/intlayer_with_react_native+expo.md +259 -0
- package/pt/intlayer_with_vite+preact.md +1663 -0
- package/pt/intlayer_with_vite+react.md +1621 -0
- package/pt/intlayer_with_vite+solid.md +3 -0
- package/pt/intlayer_with_vite+svelte.md +3 -0
- package/pt/intlayer_with_vite+vue.md +989 -0
- package/pt/introduction.md +193 -0
- package/pt/mcp_server.md +150 -0
- package/pt/packages/@intlayer/api/index.md +31 -0
- package/pt/packages/@intlayer/chokidar/index.md +31 -0
- package/pt/packages/@intlayer/cli/index.md +21 -0
- package/pt/packages/@intlayer/config/index.md +116 -0
- package/pt/packages/@intlayer/core/index.md +25 -0
- package/pt/packages/@intlayer/design-system/index.md +21 -0
- package/pt/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/pt/packages/@intlayer/editor/index.md +21 -0
- package/pt/packages/@intlayer/editor-react/index.md +21 -0
- package/pt/packages/@intlayer/webpack/index.md +35 -0
- package/pt/packages/angular-intlayer/index.md +3 -0
- package/pt/packages/express-intlayer/index.md +232 -0
- package/pt/packages/express-intlayer/t.md +267 -0
- package/pt/packages/intlayer/getConfiguration.md +120 -0
- package/pt/packages/intlayer/getEnumeration.md +138 -0
- package/pt/packages/intlayer/getHTMLTextDir.md +97 -0
- package/pt/packages/intlayer/getLocaleLang.md +57 -0
- package/pt/packages/intlayer/getLocaleName.md +93 -0
- package/pt/packages/intlayer/getLocalizedUrl.md +221 -0
- package/pt/packages/intlayer/getMultilingualUrls.md +198 -0
- package/pt/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/pt/packages/intlayer/getTranslation.md +175 -0
- package/pt/packages/intlayer/getTranslationContent.md +177 -0
- package/pt/packages/intlayer/index.md +484 -0
- package/pt/packages/intlayer-cli/index.md +41 -0
- package/pt/packages/intlayer-editor/index.md +113 -0
- package/pt/packages/lynx-intlayer/index.md +58 -0
- package/pt/packages/next-intlayer/index.md +270 -0
- package/pt/packages/next-intlayer/t.md +341 -0
- package/pt/packages/next-intlayer/useDictionary.md +248 -0
- package/pt/packages/next-intlayer/useIntlayer.md +237 -0
- package/pt/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/pt/packages/next-intlayer/useLocale.md +105 -0
- package/pt/packages/preact-intlayer/index.md +3 -0
- package/pt/packages/react-intlayer/index.md +261 -0
- package/pt/packages/react-intlayer/t.md +289 -0
- package/pt/packages/react-intlayer/useDictionary.md +268 -0
- package/pt/packages/react-intlayer/useIntlayer.md +225 -0
- package/pt/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/pt/packages/react-intlayer/useLocale.md +184 -0
- package/pt/packages/react-native-intlayer/index.md +57 -0
- package/pt/packages/react-scripts-intlayer/index.md +57 -0
- package/pt/packages/solid-intlayer/index.md +3 -0
- package/pt/packages/svelte-intlayer/index.md +3 -0
- package/pt/packages/vite-intlayer/index.md +53 -0
- package/pt/packages/vue-intlayer/index.md +3 -0
- package/pt/per_locale_file.md +298 -0
- package/pt/privacy_notice.md +61 -0
- package/pt/roadmap.md +206 -0
- package/pt/terms_of_service.md +33 -0
- package/pt/vs_code_extension.md +139 -0
- package/ru/CI_CD.md +149 -0
- package/ru/autoFill.md +157 -0
- package/ru/configuration.md +507 -0
- package/ru/dictionary/condition.md +213 -0
- package/ru/dictionary/content_extention_customization.md +81 -0
- package/ru/dictionary/enumeration.md +221 -0
- package/ru/dictionary/file.md +209 -0
- package/ru/dictionary/function_fetching.md +188 -0
- package/ru/dictionary/get_started.md +311 -0
- package/ru/dictionary/insertion.md +161 -0
- package/ru/dictionary/markdown.md +339 -0
- package/ru/dictionary/nesting.md +249 -0
- package/ru/dictionary/translation.md +322 -0
- package/ru/environment/angular.md +3 -0
- package/ru/header.md +7 -0
- package/ru/how_works_intlayer.md +217 -0
- package/ru/index.md +125 -0
- package/ru/interest_of_intlayer.md +132 -0
- package/ru/intlayer_CMS.md +334 -0
- package/ru/intlayer_cli.md +274 -0
- package/ru/intlayer_visual_editor.md +210 -0
- package/ru/intlayer_with_angular.md +3 -0
- package/ru/intlayer_with_create_react_app.md +1196 -0
- package/ru/intlayer_with_express.md +273 -0
- package/ru/intlayer_with_lynx+react.md +482 -0
- package/ru/intlayer_with_nextjs_14.md +1274 -0
- package/ru/intlayer_with_nextjs_15.md +1318 -0
- package/ru/intlayer_with_nextjs_page_router.md +1100 -0
- package/ru/intlayer_with_react_native+expo.md +537 -0
- package/ru/intlayer_with_vite+preact.md +1663 -0
- package/ru/intlayer_with_vite+react.md +1546 -0
- package/ru/intlayer_with_vite+solid.md +3 -0
- package/ru/intlayer_with_vite+svelte.md +3 -0
- package/ru/intlayer_with_vite+vue.md +987 -0
- package/ru/introduction.md +190 -0
- package/ru/mcp_server.md +152 -0
- package/ru/packages/@intlayer/api/index.md +31 -0
- package/ru/packages/@intlayer/chokidar/index.md +31 -0
- package/ru/packages/@intlayer/cli/index.md +23 -0
- package/ru/packages/@intlayer/config/index.md +116 -0
- package/ru/packages/@intlayer/core/index.md +25 -0
- package/ru/packages/@intlayer/design-system/index.md +21 -0
- package/ru/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/ru/packages/@intlayer/editor/index.md +21 -0
- package/ru/packages/@intlayer/editor-react/index.md +21 -0
- package/ru/packages/@intlayer/webpack/index.md +35 -0
- package/ru/packages/angular-intlayer/index.md +3 -0
- package/ru/packages/express-intlayer/index.md +235 -0
- package/ru/packages/express-intlayer/t.md +445 -0
- package/ru/packages/intlayer/getConfiguration.md +120 -0
- package/ru/packages/intlayer/getEnumeration.md +140 -0
- package/ru/packages/intlayer/getHTMLTextDir.md +97 -0
- package/ru/packages/intlayer/getLocaleLang.md +59 -0
- package/ru/packages/intlayer/getLocaleName.md +93 -0
- package/ru/packages/intlayer/getLocalizedUrl.md +221 -0
- package/ru/packages/intlayer/getMultilingualUrls.md +198 -0
- package/ru/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/ru/packages/intlayer/getTranslation.md +177 -0
- package/ru/packages/intlayer/getTranslationContent.md +175 -0
- package/ru/packages/intlayer/index.md +275 -0
- package/ru/packages/intlayer-cli/index.md +41 -0
- package/ru/packages/intlayer-editor/index.md +115 -0
- package/ru/packages/lynx-intlayer/index.md +58 -0
- package/ru/packages/next-intlayer/index.md +267 -0
- package/ru/packages/next-intlayer/t.md +340 -0
- package/ru/packages/next-intlayer/useDictionary.md +248 -0
- package/ru/packages/next-intlayer/useIntlayer.md +237 -0
- package/ru/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/ru/packages/next-intlayer/useLocale.md +105 -0
- package/ru/packages/preact-intlayer/index.md +3 -0
- package/ru/packages/react-intlayer/index.md +261 -0
- package/ru/packages/react-intlayer/t.md +289 -0
- package/ru/packages/react-intlayer/useDictionary.md +268 -0
- package/ru/packages/react-intlayer/useIntlayer.md +225 -0
- package/ru/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/ru/packages/react-intlayer/useLocale.md +184 -0
- package/ru/packages/react-native-intlayer/index.md +57 -0
- package/ru/packages/react-scripts-intlayer/index.md +57 -0
- package/ru/packages/solid-intlayer/index.md +3 -0
- package/ru/packages/svelte-intlayer/index.md +3 -0
- package/ru/packages/vite-intlayer/index.md +53 -0
- package/ru/packages/vue-intlayer/index.md +3 -0
- package/ru/per_locale_file.md +298 -0
- package/ru/privacy_notice.md +61 -0
- package/ru/roadmap.md +206 -0
- package/ru/terms_of_service.md +33 -0
- package/ru/vs_code_extension.md +139 -0
- package/zh/CI_CD.md +149 -0
- package/zh/autoFill.md +157 -0
- package/zh/configuration.md +484 -0
- package/zh/dictionary/condition.md +213 -0
- package/zh/dictionary/content_extention_customization.md +81 -0
- package/zh/dictionary/enumeration.md +221 -0
- package/zh/dictionary/file.md +209 -0
- package/zh/dictionary/function_fetching.md +188 -0
- package/zh/dictionary/get_started.md +490 -0
- package/zh/dictionary/insertion.md +161 -0
- package/zh/dictionary/markdown.md +342 -0
- package/zh/dictionary/nesting.md +249 -0
- package/zh/dictionary/translation.md +287 -0
- package/zh/header.md +7 -0
- package/zh/how_works_intlayer.md +217 -0
- package/zh/index.md +125 -0
- package/zh/interest_of_intlayer.md +132 -0
- package/zh/intlayer_CMS.md +334 -0
- package/zh/intlayer_cli.md +274 -0
- package/zh/intlayer_visual_editor.md +210 -0
- package/zh/intlayer_with_angular.md +3 -0
- package/zh/intlayer_with_create_react_app.md +1196 -0
- package/zh/intlayer_with_express.md +267 -0
- package/zh/intlayer_with_lynx+react.md +484 -0
- package/zh/intlayer_with_nextjs_14.md +1286 -0
- package/zh/intlayer_with_nextjs_15.md +1322 -0
- package/zh/intlayer_with_nextjs_page_router.md +1097 -0
- package/zh/intlayer_with_react_native+expo.md +539 -0
- package/zh/intlayer_with_vite+preact.md +1681 -0
- package/zh/intlayer_with_vite+react.md +1577 -0
- package/zh/intlayer_with_vite+solid.md +3 -0
- package/zh/intlayer_with_vite+svelte.md +3 -0
- package/zh/intlayer_with_vite+vue.md +988 -0
- package/zh/introduction.md +186 -0
- package/zh/mcp_server.md +152 -0
- package/zh/packages/@intlayer/api/index.md +31 -0
- package/zh/packages/@intlayer/chokidar/index.md +31 -0
- package/zh/packages/@intlayer/cli/index.md +21 -0
- package/zh/packages/@intlayer/config/index.md +116 -0
- package/zh/packages/@intlayer/core/index.md +25 -0
- package/zh/packages/@intlayer/design-system/index.md +21 -0
- package/zh/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/zh/packages/@intlayer/editor/index.md +21 -0
- package/zh/packages/@intlayer/editor-react/index.md +21 -0
- package/zh/packages/@intlayer/webpack/index.md +35 -0
- package/zh/packages/angular-intlayer/index.md +3 -0
- package/zh/packages/express-intlayer/index.md +229 -0
- package/zh/packages/express-intlayer/t.md +432 -0
- package/zh/packages/intlayer/getConfiguration.md +120 -0
- package/zh/packages/intlayer/getEnumeration.md +140 -0
- package/zh/packages/intlayer/getHTMLTextDir.md +97 -0
- package/zh/packages/intlayer/getLocaleLang.md +57 -0
- package/zh/packages/intlayer/getLocaleName.md +93 -0
- package/zh/packages/intlayer/getLocalizedUrl.md +221 -0
- package/zh/packages/intlayer/getMultilingualUrls.md +198 -0
- package/zh/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/zh/packages/intlayer/getTranslation.md +166 -0
- package/zh/packages/intlayer/getTranslationContent.md +166 -0
- package/zh/packages/intlayer/index.md +360 -0
- package/zh/packages/intlayer-cli/index.md +41 -0
- package/zh/packages/intlayer-editor/index.md +113 -0
- package/zh/packages/lynx-intlayer/index.md +60 -0
- package/zh/packages/next-intlayer/index.md +267 -0
- package/zh/packages/next-intlayer/t.md +338 -0
- package/zh/packages/next-intlayer/useDictionary.md +242 -0
- package/zh/packages/next-intlayer/useIntlayer.md +237 -0
- package/zh/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/zh/packages/next-intlayer/useLocale.md +105 -0
- package/zh/packages/preact-intlayer/index.md +3 -0
- package/zh/packages/react-intlayer/index.md +257 -0
- package/zh/packages/react-intlayer/t.md +271 -0
- package/zh/packages/react-intlayer/useDictionary.md +260 -0
- package/zh/packages/react-intlayer/useIntlayer.md +225 -0
- package/zh/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/zh/packages/react-intlayer/useLocale.md +184 -0
- package/zh/packages/react-native-intlayer/index.md +57 -0
- package/zh/packages/react-scripts-intlayer/index.md +57 -0
- package/zh/packages/solid-intlayer/index.md +3 -0
- package/zh/packages/svelte-intlayer/index.md +3 -0
- package/zh/packages/vite-intlayer/index.md +53 -0
- package/zh/packages/vue-intlayer/index.md +3 -0
- package/zh/per_locale_file.md +298 -0
- package/zh/privacy_notice.md +61 -0
- package/zh/roadmap.md +206 -0
- package/zh/terms_of_service.md +33 -0
- package/zh/vs_code_extension.md +139 -0
|
@@ -0,0 +1,1648 @@
|
|
|
1
|
+
# Getting Started Internationalising (i18n) with Intlayer and Vite and Preact
|
|
2
|
+
|
|
3
|
+
> This package is in development. See the [issue](https://github.com/aymericzip/intlayer/issues/118) for more information. Show your interest in Intlayer for Preact by liking the issue.
|
|
4
|
+
|
|
5
|
+
See [Application Template](https://github.com/aymericzip/intlayer-vite-preact-template) on GitHub.
|
|
6
|
+
|
|
7
|
+
## What is Intlayer?
|
|
8
|
+
|
|
9
|
+
**Intlayer** is an innovative, open-source internationalisation (i18n) library designed to simplify multilingual support in modern web applications.
|
|
10
|
+
|
|
11
|
+
With Intlayer, you can:
|
|
12
|
+
|
|
13
|
+
- **Easily manage translations** using declarative dictionaries at the component level.
|
|
14
|
+
- **Dynamically localise metadata**, routes, and content.
|
|
15
|
+
- **Ensure TypeScript support** with autogenerated types, improving autocompletion and error detection.
|
|
16
|
+
- **Benefit from advanced features**, like dynamic locale detection and switching.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Step-by-Step Guide to Set Up Intlayer in a Vite and Preact Application
|
|
21
|
+
|
|
22
|
+
### Step 1: Install Dependencies
|
|
23
|
+
|
|
24
|
+
Install the necessary packages using npm:
|
|
25
|
+
|
|
26
|
+
```bash packageManager="npm"
|
|
27
|
+
npm install intlayer preact-intlayer vite-intlayer
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```bash packageManager="pnpm"
|
|
31
|
+
pnpm add intlayer preact-intlayer vite-intlayer
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```bash packageManager="yarn"
|
|
35
|
+
yarn add intlayer preact-intlayer vite-intlayer
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- **intlayer**
|
|
39
|
+
|
|
40
|
+
The core package that provides internationalisation tools for configuration management, translation, [content declaration](https://github.com/aymericzip/intlayer/blob/main/docs/en-GB/dictionary/get_started.md), transpilation, and [CLI commands](https://github.com/aymericzip/intlayer/blob/main/docs/en-GB/intlayer_cli.md).
|
|
41
|
+
|
|
42
|
+
- **preact-intlayer**
|
|
43
|
+
The package that integrates Intlayer with Preact application. It provides context providers and hooks for Preact internationalisation.
|
|
44
|
+
|
|
45
|
+
- **vite-intlayer**
|
|
46
|
+
Includes the Vite plugin for integrating Intlayer with the [Vite bundler](https://vite.dev/guide/why.html#why-bundle-for-production), as well as middleware for detecting the user's preferred locale, managing cookies, and handling URL redirection.
|
|
47
|
+
|
|
48
|
+
### Step 2: Configuration of your project
|
|
49
|
+
|
|
50
|
+
Create a config file to configure the languages of your application:
|
|
51
|
+
|
|
52
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
53
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
54
|
+
|
|
55
|
+
const config: IntlayerConfig = {
|
|
56
|
+
internationalisation: {
|
|
57
|
+
locales: [
|
|
58
|
+
Locales.ENGLISH,
|
|
59
|
+
Locales.FRENCH,
|
|
60
|
+
Locales.SPANISH,
|
|
61
|
+
// Your other locales
|
|
62
|
+
],
|
|
63
|
+
defaultLocale: Locales.ENGLISH,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default config;
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
71
|
+
import { Locales } from "intlayer";
|
|
72
|
+
|
|
73
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
74
|
+
const config = {
|
|
75
|
+
internationalisation: {
|
|
76
|
+
locales: [
|
|
77
|
+
Locales.ENGLISH,
|
|
78
|
+
Locales.FRENCH,
|
|
79
|
+
Locales.SPANISH,
|
|
80
|
+
// Your other locales
|
|
81
|
+
],
|
|
82
|
+
defaultLocale: Locales.ENGLISH,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default config;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
90
|
+
const { Locales } = require("intlayer");
|
|
91
|
+
|
|
92
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
93
|
+
const config = {
|
|
94
|
+
internationalisation: {
|
|
95
|
+
locales: [
|
|
96
|
+
Locales.ENGLISH,
|
|
97
|
+
Locales.FRENCH,
|
|
98
|
+
Locales.SPANISH,
|
|
99
|
+
// Your other locales
|
|
100
|
+
],
|
|
101
|
+
defaultLocale: Locales.ENGLISH,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
module.exports = config;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
> Through this configuration file, you can set up localised URLs, middleware redirection, cookie names, the location and extension of your content declarations, disable Intlayer logs in the console, and more. For a complete list of available parameters, refer to the [configuration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/en-GB/configuration.md).
|
|
109
|
+
|
|
110
|
+
### Step 3: Integrate Intlayer in Your Vite Configuration
|
|
111
|
+
|
|
112
|
+
Add the intlayer plugin into your configuration.
|
|
113
|
+
|
|
114
|
+
```typescript fileName="vite.config.ts" codeFormat="typescript"
|
|
115
|
+
import { defineConfig } from "vite";
|
|
116
|
+
import preact from "@preact/preset-vite";
|
|
117
|
+
import { intlayerPlugin } from "vite-intlayer";
|
|
118
|
+
|
|
119
|
+
// https://vitejs.dev/config/
|
|
120
|
+
export default defineConfig({
|
|
121
|
+
plugins: [preact(), intlayerPlugin()],
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```javascript fileName="vite.config.mjs" codeFormat="esm"
|
|
126
|
+
import { defineConfig } from "vite";
|
|
127
|
+
import preact from "@preact/preset-vite";
|
|
128
|
+
import { intlayerPlugin } from "vite-intlayer";
|
|
129
|
+
|
|
130
|
+
// https://vitejs.dev/config/
|
|
131
|
+
export default defineConfig({
|
|
132
|
+
plugins: [preact(), intlayerPlugin()],
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```javascript fileName="vite.config.cjs" codeFormat="commonjs"
|
|
137
|
+
const { defineConfig } = require("vite");
|
|
138
|
+
const preact = require("@preact/preset-vite");
|
|
139
|
+
const { intlayerPlugin } = require("vite-intlayer");
|
|
140
|
+
|
|
141
|
+
// https://vitejs.dev/config/
|
|
142
|
+
module.exports = defineConfig({
|
|
143
|
+
plugins: [preact(), intlayerPlugin()],
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
> The `intlayerPlugin()` Vite plugin is used to integrate Intlayer with Vite. It ensures the building of content declaration files and monitors them in development mode. It defines Intlayer environment variables within the Vite application. Additionally, it provides aliases to optimise performance.
|
|
148
|
+
|
|
149
|
+
### Step 4: Declare Your Content
|
|
150
|
+
|
|
151
|
+
Create and manage your content declarations to store translations:
|
|
152
|
+
|
|
153
|
+
```tsx fileName="src/app.content.tsx" contentDeclarationFormat="typescript"
|
|
154
|
+
import { t, type Dictionary } from "intlayer";
|
|
155
|
+
import type { ComponentChildren } from "preact";
|
|
156
|
+
|
|
157
|
+
const appContent = {
|
|
158
|
+
key: "app",
|
|
159
|
+
content: {
|
|
160
|
+
viteLogo: t({
|
|
161
|
+
"en-GB": "Vite logo",
|
|
162
|
+
en: "Vite logo",
|
|
163
|
+
fr: "Logo Vite",
|
|
164
|
+
es: "Logo Vite",
|
|
165
|
+
}),
|
|
166
|
+
preactLogo: t({
|
|
167
|
+
"en-GB": "Preact logo",
|
|
168
|
+
en: "Preact logo",
|
|
169
|
+
fr: "Logo Preact",
|
|
170
|
+
es: "Logo Preact",
|
|
171
|
+
}),
|
|
172
|
+
|
|
173
|
+
title: "Vite + Preact",
|
|
174
|
+
|
|
175
|
+
count: t({
|
|
176
|
+
"en-GB": "count is ",
|
|
177
|
+
en: "count is ",
|
|
178
|
+
fr: "le compte est ",
|
|
179
|
+
es: "el recuento es ",
|
|
180
|
+
}),
|
|
181
|
+
|
|
182
|
+
edit: t<ComponentChildren>({
|
|
183
|
+
"en-GB": "Edit src/app.tsx and save to test HMR",
|
|
184
|
+
en: "Edit src/app.tsx and save to test HMR",
|
|
185
|
+
fr: "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
186
|
+
es: "Edita src/app.tsx y guarda para probar HMR",
|
|
187
|
+
}),
|
|
188
|
+
|
|
189
|
+
readTheDocs: t({
|
|
190
|
+
"en-GB": "Click on the Vite and Preact logos to learn more",
|
|
191
|
+
en: "Click on the Vite and Preact logos to learn more",
|
|
192
|
+
fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
193
|
+
es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
194
|
+
}),
|
|
195
|
+
},
|
|
196
|
+
} satisfies Dictionary;
|
|
197
|
+
|
|
198
|
+
export default appContent;
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
```javascript fileName="src/app.content.mjs" contentDeclarationFormat="esm"
|
|
202
|
+
import { t } from "intlayer";
|
|
203
|
+
// import { h } from 'preact'; // Needed if you use JSX directly in .mjs
|
|
204
|
+
|
|
205
|
+
/** @type {import('intlayer').Dictionary} */
|
|
206
|
+
const appContent = {
|
|
207
|
+
key: "app",
|
|
208
|
+
content: {
|
|
209
|
+
viteLogo: t({
|
|
210
|
+
"en-GB": "Vite logo",
|
|
211
|
+
en: "Vite logo",
|
|
212
|
+
fr: "Logo Vite",
|
|
213
|
+
es: "Logo Vite",
|
|
214
|
+
}),
|
|
215
|
+
preactLogo: t({
|
|
216
|
+
"en-GB": "Preact logo",
|
|
217
|
+
en: "Preact logo",
|
|
218
|
+
fr: "Logo Preact",
|
|
219
|
+
es: "Logo Preact",
|
|
220
|
+
}),
|
|
221
|
+
|
|
222
|
+
title: "Vite + Preact",
|
|
223
|
+
|
|
224
|
+
count: t({
|
|
225
|
+
"en-GB": "count is ",
|
|
226
|
+
en: "count is ",
|
|
227
|
+
fr: "le compte est ",
|
|
228
|
+
es: "el recuento es ",
|
|
229
|
+
}),
|
|
230
|
+
|
|
231
|
+
edit: t({
|
|
232
|
+
"en-GB": "Edit src/app.tsx and save to test HMR",
|
|
233
|
+
en: "Edit src/app.tsx and save to test HMR",
|
|
234
|
+
fr: "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
235
|
+
es: "Edita src/app.tsx y guarda para probar HMR",
|
|
236
|
+
}),
|
|
237
|
+
|
|
238
|
+
readTheDocs: t({
|
|
239
|
+
"en-GB": "Click on the Vite and Preact logos to learn more",
|
|
240
|
+
en: "Click on the Vite and Preact logos to learn more",
|
|
241
|
+
fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
242
|
+
es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
243
|
+
}),
|
|
244
|
+
},
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export default appContent;
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
```javascript fileName="src/app.content.cjs" contentDeclarationFormat="commonjs"
|
|
251
|
+
const { t } = require("intlayer");
|
|
252
|
+
|
|
253
|
+
// const { h } = require('preact'); // Needed if you use JSX directly in .cjs
|
|
254
|
+
|
|
255
|
+
/** @type {import('intlayer').Dictionary} */
|
|
256
|
+
const appContent = {
|
|
257
|
+
key: "app",
|
|
258
|
+
content: {
|
|
259
|
+
viteLogo: t({
|
|
260
|
+
"en-GB": "Vite logo",
|
|
261
|
+
en: "Vite logo",
|
|
262
|
+
fr: "Logo Vite",
|
|
263
|
+
es: "Logo Vite",
|
|
264
|
+
}),
|
|
265
|
+
preactLogo: t({
|
|
266
|
+
"en-GB": "Preact logo",
|
|
267
|
+
en: "Preact logo",
|
|
268
|
+
fr: "Logo Preact",
|
|
269
|
+
es: "Logo Preact",
|
|
270
|
+
}),
|
|
271
|
+
|
|
272
|
+
title: "Vite + Preact",
|
|
273
|
+
|
|
274
|
+
count: t({
|
|
275
|
+
"en-GB": "count is ",
|
|
276
|
+
en: "count is ",
|
|
277
|
+
fr: "le compte est ",
|
|
278
|
+
es: "el recuento es ",
|
|
279
|
+
}),
|
|
280
|
+
|
|
281
|
+
edit: t({
|
|
282
|
+
"en-GB": "Edit src/app.tsx and save to test HMR",
|
|
283
|
+
en: "Edit src/app.tsx and save to test HMR",
|
|
284
|
+
fr: "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
285
|
+
es: "Edita src/app.tsx y guarda para probar HMR",
|
|
286
|
+
}),
|
|
287
|
+
|
|
288
|
+
readTheDocs: t({
|
|
289
|
+
"en-GB": "Click on the Vite and Preact logos to learn more",
|
|
290
|
+
en: "Click on the Vite and Preact logos to learn more",
|
|
291
|
+
fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
292
|
+
es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
293
|
+
}),
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
module.exports = appContent;
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
```json fileName="src/app.content.json" contentDeclarationFormat="json"
|
|
301
|
+
{
|
|
302
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
303
|
+
"key": "app",
|
|
304
|
+
"content": {
|
|
305
|
+
"viteLogo": {
|
|
306
|
+
"nodeType": "translation",
|
|
307
|
+
"translation": {
|
|
308
|
+
"en-GB": "Vite logo",
|
|
309
|
+
"en": "Vite logo",
|
|
310
|
+
"fr": "Logo Vite",
|
|
311
|
+
"es": "Logo Vite"
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
"preactLogo": {
|
|
315
|
+
"nodeType": "translation",
|
|
316
|
+
"translation": {
|
|
317
|
+
"en-GB": "Preact logo",
|
|
318
|
+
"en": "Preact logo",
|
|
319
|
+
"fr": "Logo Preact",
|
|
320
|
+
"es": "Logo Preact"
|
|
321
|
+
}
|
|
322
|
+
},
|
|
323
|
+
"title": {
|
|
324
|
+
"nodeType": "translation",
|
|
325
|
+
"translation": {
|
|
326
|
+
"en-GB": "Vite + Preact",
|
|
327
|
+
"en": "Vite + Preact",
|
|
328
|
+
"fr": "Vite + Preact",
|
|
329
|
+
"es": "Vite + Preact"
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
"count": {
|
|
333
|
+
"nodeType": "translation",
|
|
334
|
+
"translation": {
|
|
335
|
+
"en-GB": "count is ",
|
|
336
|
+
"en": "count is ",
|
|
337
|
+
"fr": "le compte est ",
|
|
338
|
+
"es": "el recuento es "
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
"edit": {
|
|
342
|
+
"nodeType": "translation",
|
|
343
|
+
"translation": {
|
|
344
|
+
"en-GB": "Edit src/app.tsx and save to test HMR",
|
|
345
|
+
"en": "Edit src/app.tsx and save to test HMR",
|
|
346
|
+
"fr": "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
347
|
+
"es": "Edita src/app.tsx y guarda para probar HMR"
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
"readTheDocs": {
|
|
351
|
+
"nodeType": "translation",
|
|
352
|
+
"translation": {
|
|
353
|
+
"en-GB": "Click on the Vite and Preact logos to learn more",
|
|
354
|
+
"en": "Click on the Vite and Preact logos to learn more",
|
|
355
|
+
"fr": "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
356
|
+
"es": "Haga clic en los logotipos de Vite y Preact para obtener más información"
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
> Your content declarations can be defined anywhere in your application as soon they are included into the `contentDir` directory (by default, `./src`). And match the content declaration file extension (by default, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
364
|
+
|
|
365
|
+
> For more details, refer to the [content declaration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/en-GB/dictionary/get_started.md).
|
|
366
|
+
|
|
367
|
+
> If your content file includes TSX code, you might need to import `import { h } from "preact";` or ensure your JSX pragma is correctly set for Preact.
|
|
368
|
+
|
|
369
|
+
### Step 5: Utilise Intlayer in Your Code
|
|
370
|
+
|
|
371
|
+
Access your content dictionaries throughout your application:
|
|
372
|
+
|
|
373
|
+
```tsx {6,10} fileName="src/app.tsx" codeFormat="typescript"
|
|
374
|
+
import { useState } from "preact/hooks";
|
|
375
|
+
import type { FunctionalComponent } from "preact";
|
|
376
|
+
import preactLogo from "./assets/preact.svg"; // Assuming you have a preact.svg
|
|
377
|
+
import viteLogo from "/vite.svg";
|
|
378
|
+
import "./app.css"; // Assuming your CSS file is named app.css
|
|
379
|
+
import { IntlayerProvider, useIntlayer } from "preact-intlayer";
|
|
380
|
+
|
|
381
|
+
const AppContent: FunctionalComponent = () => {
|
|
382
|
+
const [count, setCount] = useState(0);
|
|
383
|
+
const content = useIntlayer("app");
|
|
384
|
+
|
|
385
|
+
return (
|
|
386
|
+
<>
|
|
387
|
+
<div>
|
|
388
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
389
|
+
<img src={viteLogo} class="logo" alt={content.viteLogo.value} />
|
|
390
|
+
</a>
|
|
391
|
+
<a href="https://preactjs.com" target="_blank">
|
|
392
|
+
<img
|
|
393
|
+
src={preactLogo}
|
|
394
|
+
class="logo preact"
|
|
395
|
+
alt={content.preactLogo.value}
|
|
396
|
+
/>
|
|
397
|
+
</a>
|
|
398
|
+
</div>
|
|
399
|
+
<h1>{content.title}</h1>
|
|
400
|
+
<div class="card">
|
|
401
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
402
|
+
{content.count}
|
|
403
|
+
{count}
|
|
404
|
+
</button>
|
|
405
|
+
<p>{content.edit}</p>
|
|
406
|
+
</div>
|
|
407
|
+
<p class="read-the-docs">{content.readTheDocs}</p>
|
|
408
|
+
</>
|
|
409
|
+
);
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
const App: FunctionalComponent = () => (
|
|
413
|
+
<IntlayerProvider>
|
|
414
|
+
<AppContent />
|
|
415
|
+
</IntlayerProvider>
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
export default App;
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
```jsx {5,9} fileName="src/app.jsx" codeFormat="esm"
|
|
422
|
+
import { useState } from "preact/hooks";
|
|
423
|
+
import preactLogo from "./assets/preact.svg";
|
|
424
|
+
import viteLogo from "/vite.svg";
|
|
425
|
+
import "./app.css";
|
|
426
|
+
import { IntlayerProvider, useIntlayer } from "preact-intlayer";
|
|
427
|
+
|
|
428
|
+
const AppContent = () => {
|
|
429
|
+
const [count, setCount] = useState(0);
|
|
430
|
+
const content = useIntlayer("app");
|
|
431
|
+
|
|
432
|
+
return (
|
|
433
|
+
<>
|
|
434
|
+
<div>
|
|
435
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
436
|
+
<img src={viteLogo} class="logo" alt={content.viteLogo.value} />
|
|
437
|
+
</a>
|
|
438
|
+
<a href="https://preactjs.com" target="_blank">
|
|
439
|
+
<img
|
|
440
|
+
src={preactLogo}
|
|
441
|
+
class="logo preact"
|
|
442
|
+
alt={content.preactLogo.value}
|
|
443
|
+
/>
|
|
444
|
+
</a>
|
|
445
|
+
</div>
|
|
446
|
+
<h1>{content.title}</h1>
|
|
447
|
+
<div class="card">
|
|
448
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
449
|
+
{content.count}
|
|
450
|
+
{count}
|
|
451
|
+
</button>
|
|
452
|
+
<p>{content.edit}</p>
|
|
453
|
+
</div>
|
|
454
|
+
<p class="read-the-docs">{content.readTheDocs}</p>
|
|
455
|
+
</>
|
|
456
|
+
);
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
const App = () => (
|
|
460
|
+
<IntlayerProvider>
|
|
461
|
+
<AppContent />
|
|
462
|
+
</IntlayerProvider>
|
|
463
|
+
);
|
|
464
|
+
|
|
465
|
+
export default App;
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
```jsx {5,9} fileName="src/app.cjsx" codeFormat="commonjs"
|
|
469
|
+
const { useState } = require("preact/hooks");
|
|
470
|
+
const preactLogo = require("./assets/preact.svg");
|
|
471
|
+
const viteLogo = require("/vite.svg");
|
|
472
|
+
require("./app.css");
|
|
473
|
+
const { IntlayerProvider, useIntlayer } = require("preact-intlayer");
|
|
474
|
+
|
|
475
|
+
const AppContent = () => {
|
|
476
|
+
const [count, setCount] = useState(0);
|
|
477
|
+
const content = useIntlayer("app");
|
|
478
|
+
|
|
479
|
+
return (
|
|
480
|
+
<>
|
|
481
|
+
<div>
|
|
482
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
483
|
+
<img src={viteLogo} class="logo" alt={content.viteLogo.value} />
|
|
484
|
+
</a>
|
|
485
|
+
<a href="https://preactjs.com" target="_blank">
|
|
486
|
+
<img
|
|
487
|
+
src={preactLogo}
|
|
488
|
+
class="logo preact"
|
|
489
|
+
alt={content.preactLogo.value}
|
|
490
|
+
/>
|
|
491
|
+
</a>
|
|
492
|
+
</div>
|
|
493
|
+
<h1>{content.title}</h1>
|
|
494
|
+
<div class="card">
|
|
495
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
496
|
+
{content.count}
|
|
497
|
+
{count}
|
|
498
|
+
</button>
|
|
499
|
+
<p>{content.edit}</p>
|
|
500
|
+
</div>
|
|
501
|
+
<p class="read-the-docs">{content.readTheDocs}</p>
|
|
502
|
+
</>
|
|
503
|
+
);
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
const App = () => (
|
|
507
|
+
<IntlayerProvider>
|
|
508
|
+
<AppContent />
|
|
509
|
+
</IntlayerProvider>
|
|
510
|
+
);
|
|
511
|
+
|
|
512
|
+
module.exports = App;
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
> If you want to use your content in a `string` attribute, such as `alt`, `title`, `href`, `aria-label`, etc., you must call the value of the function, like:
|
|
516
|
+
|
|
517
|
+
> ```jsx
|
|
518
|
+
>
|
|
519
|
+
> ```
|
|
520
|
+
|
|
521
|
+
> <img src={content.image.src.value} alt={content.image.value} />
|
|
522
|
+
|
|
523
|
+
> ```
|
|
524
|
+
>
|
|
525
|
+
> ```
|
|
526
|
+
|
|
527
|
+
> Note: In Preact, `className` is typically written as `class`.
|
|
528
|
+
|
|
529
|
+
> To Learn more about the `useIntlayer` hook, refer to the [documentation](https://github.com/aymericzip/intlayer/blob/main/docs/en-GB/packages/react-intlayer/useIntlayer.md) (The API is similar for `preact-intlayer`).
|
|
530
|
+
|
|
531
|
+
### (Optional) Step 6: Change the language of your content
|
|
532
|
+
|
|
533
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
534
|
+
import type { FunctionalComponent } from "preact";
|
|
535
|
+
import { Locales } from "intlayer";
|
|
536
|
+
import { useLocale } from "preact-intlayer";
|
|
537
|
+
|
|
538
|
+
const LocaleSwitcher: FunctionalComponent = () => {
|
|
539
|
+
const { setLocale } = useLocale();
|
|
540
|
+
|
|
541
|
+
return (
|
|
542
|
+
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
543
|
+
Change Language to English
|
|
544
|
+
</button>
|
|
545
|
+
);
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
export default LocaleSwitcher;
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
```jsx fileName="src/components/LocaleSwitcher.jsx" codeFormat="esm"
|
|
552
|
+
import { Locales } from "intlayer";
|
|
553
|
+
import { useLocale } from "preact-intlayer";
|
|
554
|
+
|
|
555
|
+
const LocaleSwitcher = () => {
|
|
556
|
+
const { setLocale } = useLocale();
|
|
557
|
+
|
|
558
|
+
return (
|
|
559
|
+
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
560
|
+
Change Language to English
|
|
561
|
+
</button>
|
|
562
|
+
);
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
export default LocaleSwitcher;
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
```jsx fileName="src/components/LocaleSwitcher.cjsx" codeFormat="commonjs"
|
|
569
|
+
const { Locales } = require("intlayer");
|
|
570
|
+
const { useLocale } = require("preact-intlayer");
|
|
571
|
+
|
|
572
|
+
const LocaleSwitcher = () => {
|
|
573
|
+
const { setLocale } = useLocale();
|
|
574
|
+
|
|
575
|
+
return (
|
|
576
|
+
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
577
|
+
Change Language to English
|
|
578
|
+
</button>
|
|
579
|
+
);
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
module.exports = LocaleSwitcher;
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
> To Learn more about the `useLocale` hook, refer to the [documentation](https://github.com/aymericzip/intlayer/blob/main/docs/en-GB/packages/react-intlayer/useLocale.md) (The API is similar for `preact-intlayer`).
|
|
586
|
+
|
|
587
|
+
### (Optional) Step 7: Add localised Routing to your application
|
|
588
|
+
|
|
589
|
+
The purpose of this step is to make unique routes for each language. This is useful for SEO and SEO-friendly URLs.
|
|
590
|
+
Example:
|
|
591
|
+
|
|
592
|
+
```plaintext
|
|
593
|
+
- https://example.com/about
|
|
594
|
+
- https://example.com/es/about
|
|
595
|
+
- https://example.com/fr/about
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
> By default, the routes are not prefixed for the default locale. If you want to prefix the default locale, you can set the `middleware.prefixDefault` option to `true` in your configuration. See the [configuration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/en-GB/configuration.md) for more information.
|
|
599
|
+
|
|
600
|
+
To add localised routing to your application, you can create a `LocaleRouter` component that wraps your application's routes and handles locale-based routing. Here is an example using [preact-iso](https://github.com/preactjs/preact-iso):
|
|
601
|
+
|
|
602
|
+
First, install `preact-iso`:
|
|
603
|
+
|
|
604
|
+
```bash packageManager="npm"
|
|
605
|
+
npm install preact-iso
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
```bash packageManager="pnpm"
|
|
609
|
+
pnpm add preact-iso
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
```bash packageManager="yarn"
|
|
613
|
+
yarn add preact-iso
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
|
|
617
|
+
import { type Locales, configuration, getPathWithoutLocale } from "intlayer";
|
|
618
|
+
import { ComponentChildren, FunctionalComponent } from "preact";
|
|
619
|
+
import { IntlayerProvider } from "preact-intlayer";
|
|
620
|
+
import { LocationProvider, useLocation } from "preact-iso";
|
|
621
|
+
import { useEffect } from "preact/hooks";
|
|
622
|
+
|
|
623
|
+
const { internationalisation, middleware } = configuration;
|
|
624
|
+
const { locales, defaultLocale } = internationalisation;
|
|
625
|
+
|
|
626
|
+
const Navigate: FunctionalComponent<{ to: string; replace?: boolean }> = ({
|
|
627
|
+
to,
|
|
628
|
+
replace,
|
|
629
|
+
}) => {
|
|
630
|
+
const { route } = useLocation();
|
|
631
|
+
useEffect(() => {
|
|
632
|
+
route(to, replace);
|
|
633
|
+
}, [to, replace, route]);
|
|
634
|
+
return null;
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* A component that handles localisation and wraps children with the appropriate locale context.
|
|
639
|
+
* It manages URL-based locale detection and validation.
|
|
640
|
+
*/
|
|
641
|
+
const AppLocalised: FunctionalComponent<{
|
|
642
|
+
children: ComponentChildren;
|
|
643
|
+
locale?: Locales;
|
|
644
|
+
}> = ({ children, locale }) => {
|
|
645
|
+
const { path: pathname, url } = useLocation();
|
|
646
|
+
|
|
647
|
+
if (!url) {
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
const search = url.substring(pathname.length);
|
|
652
|
+
|
|
653
|
+
// Determine the current locale, falling back to the default if not provided
|
|
654
|
+
const currentLocale = locale ?? defaultLocale;
|
|
655
|
+
|
|
656
|
+
// Remove the locale prefix from the path to construct a base path
|
|
657
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
658
|
+
pathname // Current URL path
|
|
659
|
+
);
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* If middleware.prefixDefault is true, the default locale should always be prefixed.
|
|
663
|
+
*/
|
|
664
|
+
if (middleware.prefixDefault) {
|
|
665
|
+
// Validate the locale
|
|
666
|
+
if (!locale || !locales.includes(locale)) {
|
|
667
|
+
// Redirect to the default locale with the updated path
|
|
668
|
+
return (
|
|
669
|
+
<Navigate
|
|
670
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
671
|
+
replace // Replace the current history entry with the new one
|
|
672
|
+
/>
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
// Wrap children with the IntlayerProvider and set the current locale
|
|
677
|
+
return (
|
|
678
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
679
|
+
);
|
|
680
|
+
} else {
|
|
681
|
+
/**
|
|
682
|
+
* When middleware.prefixDefault is false, the default locale is not prefixed.
|
|
683
|
+
* Ensure that the current locale is valid and not the default locale.
|
|
684
|
+
*/
|
|
685
|
+
if (
|
|
686
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
687
|
+
!locales
|
|
688
|
+
.filter(
|
|
689
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Exclude the default locale
|
|
690
|
+
)
|
|
691
|
+
.includes(currentLocale) // Check if the current locale is in the list of valid locales
|
|
692
|
+
) {
|
|
693
|
+
// Redirect to the path without locale prefix
|
|
694
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
// Wrap children with the IntlayerProvider and set the current locale
|
|
698
|
+
return (
|
|
699
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
700
|
+
);
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
const RouterContent: FunctionalComponent<{
|
|
705
|
+
children: ComponentChildren;
|
|
706
|
+
}> = ({ children }) => {
|
|
707
|
+
const { path } = useLocation();
|
|
708
|
+
|
|
709
|
+
if (!path) {
|
|
710
|
+
return null;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
const pathLocale = path.split("/")[1] as Locales;
|
|
714
|
+
|
|
715
|
+
const isLocaleRoute = locales
|
|
716
|
+
.filter((locale) => middleware.prefixDefault || locale !== defaultLocale)
|
|
717
|
+
.some((locale) => locale.toString() === pathLocale);
|
|
718
|
+
|
|
719
|
+
if (isLocaleRoute) {
|
|
720
|
+
return <AppLocalised locale={pathLocale}>{children}</AppLocalised>;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
return (
|
|
724
|
+
<AppLocalised
|
|
725
|
+
locale={!middleware.prefixDefault ? defaultLocale : undefined}
|
|
726
|
+
>
|
|
727
|
+
{children}
|
|
728
|
+
</AppLocalised>
|
|
729
|
+
);
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* A router component that sets up locale-specific routes.
|
|
734
|
+
* It uses preact-iso to manage navigation and render localised components.
|
|
735
|
+
*/
|
|
736
|
+
export const LocaleRouter: FunctionalComponent<{
|
|
737
|
+
children: ComponentChildren;
|
|
738
|
+
}> = ({ children }) => (
|
|
739
|
+
<LocationProvider>
|
|
740
|
+
<RouterContent>{children}</RouterContent>
|
|
741
|
+
</LocationProvider>
|
|
742
|
+
);
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
```jsx fileName="src/components/LocaleRouter.jsx" codeFormat="esm"
|
|
746
|
+
// Importing necessary dependencies and functions
|
|
747
|
+
import { configuration, getPathWithoutLocale } from "intlayer";
|
|
748
|
+
import { IntlayerProvider } from "preact-intlayer";
|
|
749
|
+
import { LocationProvider, useLocation } from "preact-iso";
|
|
750
|
+
import { useEffect } from "preact/hooks";
|
|
751
|
+
import { h } from "preact"; // Required for JSX
|
|
752
|
+
|
|
753
|
+
// Destructuring configuration from Intlayer
|
|
754
|
+
const { internationalisation, middleware } = configuration;
|
|
755
|
+
const { locales, defaultLocale } = internationalisation;
|
|
756
|
+
|
|
757
|
+
const Navigate = ({ to, replace }) => {
|
|
758
|
+
const { route } = useLocation();
|
|
759
|
+
useEffect(() => {
|
|
760
|
+
route(to, replace);
|
|
761
|
+
}, [to, replace, route]);
|
|
762
|
+
return null;
|
|
763
|
+
};
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* A component that handles localisation and wraps children with the appropriate locale context.
|
|
767
|
+
* It manages URL-based locale detection and validation.
|
|
768
|
+
*/
|
|
769
|
+
const AppLocalised = ({ children, locale }) => {
|
|
770
|
+
const { path: pathname, url } = useLocation();
|
|
771
|
+
|
|
772
|
+
if (!url) {
|
|
773
|
+
return null;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
const search = url.substring(pathname.length);
|
|
777
|
+
|
|
778
|
+
// Determine the current locale, falling back to the default if not provided
|
|
779
|
+
const currentLocale = locale ?? defaultLocale;
|
|
780
|
+
|
|
781
|
+
// Remove the locale prefix from the path to construct a base path
|
|
782
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
783
|
+
pathname // Current URL path
|
|
784
|
+
);
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
|
|
788
|
+
* If middleware.prefixDefault is true, the default locale should always be prefixed.
|
|
789
|
+
*/
|
|
790
|
+
if (middleware.prefixDefault) {
|
|
791
|
+
// Validate the locale
|
|
792
|
+
if (!locale || !locales.includes(locale)) {
|
|
793
|
+
// Redirect to the default locale with the updated path
|
|
794
|
+
return (
|
|
795
|
+
<Navigate
|
|
796
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
797
|
+
replace // Replace the current history entry with the new one
|
|
798
|
+
/>
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
// Wrap children with the IntlayerProvider and set the current locale
|
|
803
|
+
return (
|
|
804
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
805
|
+
);
|
|
806
|
+
} else {
|
|
807
|
+
/**
|
|
808
|
+
* When middleware.prefixDefault is false, the default locale is not prefixed.
|
|
809
|
+
* Ensure that the current locale is valid and not the default locale.
|
|
810
|
+
*/
|
|
811
|
+
if (
|
|
812
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
813
|
+
!locales
|
|
814
|
+
.filter(
|
|
815
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Exclude the default locale
|
|
816
|
+
)
|
|
817
|
+
.includes(currentLocale) // Check if the current locale is in the list of valid locales
|
|
818
|
+
) {
|
|
819
|
+
// Redirect to the path without locale prefix
|
|
820
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
// Wrap children with the IntlayerProvider and set the current locale
|
|
824
|
+
return (
|
|
825
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
const RouterContent = ({ children }) => {
|
|
831
|
+
const { path } = useLocation();
|
|
832
|
+
|
|
833
|
+
if (!path) {
|
|
834
|
+
return null;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
const pathLocale = path.split("/")[1];
|
|
838
|
+
|
|
839
|
+
const isLocaleRoute = locales
|
|
840
|
+
.filter((locale) => middleware.prefixDefault || locale !== defaultLocale)
|
|
841
|
+
.some((locale) => locale.toString() === pathLocale);
|
|
842
|
+
|
|
843
|
+
if (isLocaleRoute) {
|
|
844
|
+
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
return (
|
|
848
|
+
<AppLocalized
|
|
849
|
+
locale={!middleware.prefixDefault ? defaultLocale : undefined}
|
|
850
|
+
>
|
|
851
|
+
{children}
|
|
852
|
+
</AppLocalized>
|
|
853
|
+
);
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* A router component that sets up locale-specific routes.
|
|
858
|
+
* It uses preact-iso to manage navigation and render localised components.
|
|
859
|
+
*/
|
|
860
|
+
export const LocaleRouter = ({ children }) => (
|
|
861
|
+
<LocationProvider>
|
|
862
|
+
<RouterContent>{children}</RouterContent>
|
|
863
|
+
</LocationProvider>
|
|
864
|
+
);
|
|
865
|
+
```
|
|
866
|
+
|
|
867
|
+
```jsx fileName="src/components/LocaleRouter.cjsx" codeFormat="commonjs"
|
|
868
|
+
// Importing necessary dependencies and functions
|
|
869
|
+
const { configuration, getPathWithoutLocale } = require("intlayer");
|
|
870
|
+
const { IntlayerProvider } = require("preact-intlayer");
|
|
871
|
+
const { LocationProvider, useLocation } = require("preact-iso");
|
|
872
|
+
const { useEffect } = require("preact/hooks");
|
|
873
|
+
const { h } = require("preact"); // Required for JSX
|
|
874
|
+
|
|
875
|
+
// Destructuring configuration from Intlayer
|
|
876
|
+
const { internationalisation, middleware } = configuration;
|
|
877
|
+
const { locales, defaultLocale } = internationalisation;
|
|
878
|
+
|
|
879
|
+
const Navigate = ({ to, replace }) => {
|
|
880
|
+
const { route } = useLocation();
|
|
881
|
+
useEffect(() => {
|
|
882
|
+
route(to, replace);
|
|
883
|
+
}, [to, replace, route]);
|
|
884
|
+
return null;
|
|
885
|
+
};
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* A component that handles localisation and wraps children with the appropriate locale context.
|
|
889
|
+
* It manages URL-based locale detection and validation.
|
|
890
|
+
*/
|
|
891
|
+
const AppLocalized = ({ children, locale }) => {
|
|
892
|
+
const { path: pathname, url } = useLocation();
|
|
893
|
+
|
|
894
|
+
if (!url) {
|
|
895
|
+
return null;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
const search = url.substring(pathname.length);
|
|
899
|
+
|
|
900
|
+
// Determine the current locale, falling back to the default if not provided
|
|
901
|
+
const currentLocale = locale ?? defaultLocale;
|
|
902
|
+
|
|
903
|
+
// Remove the locale prefix from the path to construct a base path
|
|
904
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
905
|
+
pathname // Current URL path
|
|
906
|
+
);
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* If middleware.prefixDefault is true, the default locale should always be prefixed.
|
|
910
|
+
*/
|
|
911
|
+
if (middleware.prefixDefault) {
|
|
912
|
+
// Validate the locale
|
|
913
|
+
if (!locale || !locales.includes(locale)) {
|
|
914
|
+
// Redirect to the default locale with the updated path
|
|
915
|
+
return (
|
|
916
|
+
<Navigate
|
|
917
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
918
|
+
replace // Replace the current history entry with the new one
|
|
919
|
+
/>
|
|
920
|
+
);
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
// Wrap children with the IntlayerProvider and set the current locale
|
|
924
|
+
return (
|
|
925
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
926
|
+
);
|
|
927
|
+
} else {
|
|
928
|
+
/**
|
|
929
|
+
* When middleware.prefixDefault is false, the default locale is not prefixed.
|
|
930
|
+
* Ensure that the current locale is valid and not the default locale.
|
|
931
|
+
*/
|
|
932
|
+
if (
|
|
933
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
934
|
+
!locales
|
|
935
|
+
.filter(
|
|
936
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Exclude the default locale
|
|
937
|
+
)
|
|
938
|
+
.includes(currentLocale) // Check if the current locale is in the list of valid locales
|
|
939
|
+
) {
|
|
940
|
+
// Redirect to the path without locale prefix
|
|
941
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
// Wrap children with the IntlayerProvider and set the current locale
|
|
945
|
+
return (
|
|
946
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
947
|
+
);
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
|
|
951
|
+
const RouterContent = ({ children }) => {
|
|
952
|
+
const { path } = useLocation();
|
|
953
|
+
|
|
954
|
+
if (!path) {
|
|
955
|
+
return null;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
const pathLocale = path.split("/")[1];
|
|
959
|
+
|
|
960
|
+
const isLocaleRoute = locales
|
|
961
|
+
.filter((locale) => middleware.prefixDefault || locale !== defaultLocale)
|
|
962
|
+
.some((locale) => locale.toString() === pathLocale);
|
|
963
|
+
|
|
964
|
+
if (isLocaleRoute) {
|
|
965
|
+
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
return (
|
|
969
|
+
<AppLocalized
|
|
970
|
+
locale={!middleware.prefixDefault ? defaultLocale : undefined}
|
|
971
|
+
>
|
|
972
|
+
{children}
|
|
973
|
+
</AppLocalized>
|
|
974
|
+
);
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
* A router component that sets up locale-specific routes.
|
|
979
|
+
* It uses preact-iso to manage navigation and render localised components.
|
|
980
|
+
*/
|
|
981
|
+
const LocaleRouter = ({ children }) => (
|
|
982
|
+
<LocationProvider>
|
|
983
|
+
<RouterContent>{children}</RouterContent>
|
|
984
|
+
</LocationProvider>
|
|
985
|
+
);
|
|
986
|
+
|
|
987
|
+
module.exports = { LocaleRouter };
|
|
988
|
+
```
|
|
989
|
+
|
|
990
|
+
Then, you can use the `LocaleRouter` component in your application:
|
|
991
|
+
|
|
992
|
+
```tsx fileName="src/app.tsx" codeFormat="typescript"
|
|
993
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
994
|
+
import type { FunctionalComponent } from "preact";
|
|
995
|
+
// ... Your AppContent component (defined in Step 5)
|
|
996
|
+
|
|
997
|
+
const App: FunctionalComponent = () => (
|
|
998
|
+
<LocaleRouter>
|
|
999
|
+
<AppContent />
|
|
1000
|
+
</LocaleRouter>
|
|
1001
|
+
);
|
|
1002
|
+
|
|
1003
|
+
export default App;
|
|
1004
|
+
```
|
|
1005
|
+
|
|
1006
|
+
```jsx fileName="src/app.jsx" codeFormat="esm"
|
|
1007
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
1008
|
+
// ... Your AppContent component (defined in Step 5)
|
|
1009
|
+
|
|
1010
|
+
const App = () => (
|
|
1011
|
+
<LocaleRouter>
|
|
1012
|
+
<AppContent />
|
|
1013
|
+
</LocaleRouter>
|
|
1014
|
+
);
|
|
1015
|
+
|
|
1016
|
+
export default App;
|
|
1017
|
+
```
|
|
1018
|
+
|
|
1019
|
+
```jsx fileName="src/app.cjsx" codeFormat="commonjs"
|
|
1020
|
+
const { LocaleRouter } = require("./components/LocaleRouter");
|
|
1021
|
+
// ... Your AppContent component (defined in Step 5)
|
|
1022
|
+
|
|
1023
|
+
const App = () => (
|
|
1024
|
+
<LocaleRouter>
|
|
1025
|
+
<AppContent />
|
|
1026
|
+
</LocaleRouter>
|
|
1027
|
+
);
|
|
1028
|
+
|
|
1029
|
+
module.exports = App;
|
|
1030
|
+
```
|
|
1031
|
+
|
|
1032
|
+
In parallel, you can also use the `intLayerMiddlewarePlugin` to add server-side routing to your application. This plugin will automatically detect the current locale based on the URL and set the appropriate locale cookie. If no locale is specified, the plugin will determine the most appropriate locale based on the user's browser language preferences. If no locale is detected, it will redirect to the default locale.
|
|
1033
|
+
|
|
1034
|
+
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
1035
|
+
import { defineConfig } from "vite";
|
|
1036
|
+
import preact from "@preact/preset-vite";
|
|
1037
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
1038
|
+
|
|
1039
|
+
// https://vitejs.dev/config/
|
|
1040
|
+
export default defineConfig({
|
|
1041
|
+
plugins: [preact(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1042
|
+
});
|
|
1043
|
+
```
|
|
1044
|
+
|
|
1045
|
+
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
1046
|
+
import { defineConfig } from "vite";
|
|
1047
|
+
import preact from "@preact/preset-vite";
|
|
1048
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
1049
|
+
|
|
1050
|
+
// https://vitejs.dev/config/
|
|
1051
|
+
|
|
1052
|
+
export default defineConfig({
|
|
1053
|
+
plugins: [preact(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1054
|
+
});
|
|
1055
|
+
```
|
|
1056
|
+
|
|
1057
|
+
```javascript {3,7} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
1058
|
+
const { defineConfig } = require("vite");
|
|
1059
|
+
const preact = require("@preact/preset-vite");
|
|
1060
|
+
const { intlayerPlugin, intLayerMiddlewarePlugin } = require("vite-intlayer");
|
|
1061
|
+
|
|
1062
|
+
// https://vitejs.dev/config/
|
|
1063
|
+
module.exports = defineConfig({
|
|
1064
|
+
plugins: [preact(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1065
|
+
});
|
|
1066
|
+
```
|
|
1067
|
+
|
|
1068
|
+
### (Optional) Step 8: Change the URL when the locale changes
|
|
1069
|
+
|
|
1070
|
+
To change the URL when the locale changes, you can use the `onLocaleChange` prop provided by the `useLocale` hook. In parallel, you can use `useLocation` and `route` from `preact-iso` to update the URL path.
|
|
1071
|
+
|
|
1072
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
1073
|
+
import { useLocation, route } from "preact-iso";
|
|
1074
|
+
import {
|
|
1075
|
+
Locales,
|
|
1076
|
+
getHTMLTextDir,
|
|
1077
|
+
getLocaleName,
|
|
1078
|
+
getLocalizedUrl,
|
|
1079
|
+
} from "intlayer";
|
|
1080
|
+
import { useLocale } from "preact-intlayer";
|
|
1081
|
+
import type { FunctionalComponent } from "preact";
|
|
1082
|
+
|
|
1083
|
+
const LocaleSwitcher: FunctionalComponent = () => {
|
|
1084
|
+
const location = useLocation();
|
|
1085
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1086
|
+
onLocaleChange: (newLocale) => {
|
|
1087
|
+
const currentFullPath = location.url; // preact-iso provides the full URL
|
|
1088
|
+
// Construct the URL with the updated locale
|
|
1089
|
+
// Example: /es/about?foo=bar
|
|
1090
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1091
|
+
|
|
1092
|
+
// Update the URL path
|
|
1093
|
+
route(pathWithLocale, true); // true for replace
|
|
1094
|
+
},
|
|
1095
|
+
});
|
|
1096
|
+
|
|
1097
|
+
return (
|
|
1098
|
+
<div>
|
|
1099
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1100
|
+
<div id="localePopover" popover="auto">
|
|
1101
|
+
{availableLocales.map((localeItem) => (
|
|
1102
|
+
<a
|
|
1103
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1104
|
+
hreflang={localeItem}
|
|
1105
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1106
|
+
onClick={(e) => {
|
|
1107
|
+
e.preventDefault();
|
|
1108
|
+
setLocale(localeItem);
|
|
1109
|
+
// Programmatic navigation after setting locale will be handled by onLocaleChange
|
|
1110
|
+
}}
|
|
1111
|
+
key={localeItem}
|
|
1112
|
+
>
|
|
1113
|
+
<span>
|
|
1114
|
+
{/* Locale - e.g. FR */}
|
|
1115
|
+
{localeItem}
|
|
1116
|
+
</span>
|
|
1117
|
+
<span>
|
|
1118
|
+
{/* Language in its own Locale - e.g. Français */}
|
|
1119
|
+
{getLocaleName(localeItem, localeItem)}
|
|
1120
|
+
</span>
|
|
1121
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1122
|
+
{/* Language in current Locale - e.g. Francés with current locale set to Locales.SPANISH */}
|
|
1123
|
+
{getLocaleName(localeItem, locale)}
|
|
1124
|
+
</span>
|
|
1125
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1126
|
+
{/* Language in English - e.g. French */}
|
|
1127
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1128
|
+
</span>
|
|
1129
|
+
</a>
|
|
1130
|
+
))}
|
|
1131
|
+
</div>
|
|
1132
|
+
</div>
|
|
1133
|
+
);
|
|
1134
|
+
};
|
|
1135
|
+
|
|
1136
|
+
export default LocaleSwitcher;
|
|
1137
|
+
```
|
|
1138
|
+
|
|
1139
|
+
```jsx fileName="src/components/LocaleSwitcher.jsx" codeFormat="esm"
|
|
1140
|
+
import { useLocation, route } from "preact-iso";
|
|
1141
|
+
import {
|
|
1142
|
+
Locales,
|
|
1143
|
+
getHTMLTextDir,
|
|
1144
|
+
getLocaleName,
|
|
1145
|
+
getLocalizedUrl,
|
|
1146
|
+
} from "intlayer";
|
|
1147
|
+
import { useLocale } from "preact-intlayer";
|
|
1148
|
+
import { h } from "preact"; // For JSX
|
|
1149
|
+
|
|
1150
|
+
const LocaleSwitcher = () => {
|
|
1151
|
+
const location = useLocation();
|
|
1152
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1153
|
+
onLocaleChange: (newLocale) => {
|
|
1154
|
+
const currentFullPath = location.url;
|
|
1155
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1156
|
+
route(pathWithLocale, true);
|
|
1157
|
+
},
|
|
1158
|
+
});
|
|
1159
|
+
|
|
1160
|
+
return (
|
|
1161
|
+
<div>
|
|
1162
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1163
|
+
<div id="localePopover" popover="auto">
|
|
1164
|
+
{availableLocales.map((localeItem) => (
|
|
1165
|
+
<a
|
|
1166
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1167
|
+
hreflang={localeItem}
|
|
1168
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1169
|
+
onClick={(e) => {
|
|
1170
|
+
e.preventDefault();
|
|
1171
|
+
setLocale(localeItem);
|
|
1172
|
+
}}
|
|
1173
|
+
key={localeItem}
|
|
1174
|
+
>
|
|
1175
|
+
<span>{localeItem}</span>
|
|
1176
|
+
<span>{getLocaleName(localeItem, localeItem)}</span>
|
|
1177
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1178
|
+
{getLocaleName(localeItem, locale)}
|
|
1179
|
+
</span>
|
|
1180
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1181
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1182
|
+
</span>
|
|
1183
|
+
</a>
|
|
1184
|
+
))}
|
|
1185
|
+
</div>
|
|
1186
|
+
</div>
|
|
1187
|
+
);
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1190
|
+
export default LocaleSwitcher;
|
|
1191
|
+
```
|
|
1192
|
+
|
|
1193
|
+
```jsx fileName="src/components/LocaleSwitcher.cjsx" codeFormat="commonjs"
|
|
1194
|
+
const { useLocation, route } = require("preact-iso");
|
|
1195
|
+
const {
|
|
1196
|
+
Locales,
|
|
1197
|
+
getHTMLTextDir,
|
|
1198
|
+
getLocaleName,
|
|
1199
|
+
getLocalizedUrl,
|
|
1200
|
+
} = require("intlayer");
|
|
1201
|
+
const { useLocale } = require("preact-intlayer");
|
|
1202
|
+
const { h } = require("preact"); // For JSX
|
|
1203
|
+
|
|
1204
|
+
const LocaleSwitcher = () => {
|
|
1205
|
+
const location = useLocation();
|
|
1206
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1207
|
+
onLocaleChange: (newLocale) => {
|
|
1208
|
+
const currentFullPath = location.url;
|
|
1209
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1210
|
+
route(pathWithLocale, true);
|
|
1211
|
+
},
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
return (
|
|
1215
|
+
<div>
|
|
1216
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1217
|
+
<div id="localePopover" popover="auto">
|
|
1218
|
+
{availableLocales.map((localeItem) => (
|
|
1219
|
+
<a
|
|
1220
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1221
|
+
hreflang={localeItem}
|
|
1222
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1223
|
+
onClick={(e) => {
|
|
1224
|
+
e.preventDefault();
|
|
1225
|
+
setLocale(localeItem);
|
|
1226
|
+
}}
|
|
1227
|
+
key={localeItem}
|
|
1228
|
+
>
|
|
1229
|
+
<span>{localeItem}</span>
|
|
1230
|
+
<span>{getLocaleName(localeItem, localeItem)}</span>
|
|
1231
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1232
|
+
{getLocaleName(localeItem, locale)}
|
|
1233
|
+
</span>
|
|
1234
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1235
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1236
|
+
</span>
|
|
1237
|
+
</a>
|
|
1238
|
+
))}
|
|
1239
|
+
</div>
|
|
1240
|
+
</div>
|
|
1241
|
+
);
|
|
1242
|
+
};
|
|
1243
|
+
|
|
1244
|
+
module.exports = LocaleSwitcher;
|
|
1245
|
+
```
|
|
1246
|
+
|
|
1247
|
+
> Documentation references:
|
|
1248
|
+
|
|
1249
|
+
> - [`useLocale` hook](https://github.com/aymericzip/intlayer/blob/main/docs/en-GB/packages/react-intlayer/useLocale.md) (API is similar for `preact-intlayer`)
|
|
1250
|
+
|
|
1251
|
+
> - [`getLocaleName` hook](https://github.com/aymericzip/intlayer/blob/main/docs/en-GB/packages/intlayer/getLocaleName.md)
|
|
1252
|
+
|
|
1253
|
+
> - [`getLocalizedUrl` hook](https://github.com/aymericzip/intlayer/blob/main/docs/en-GB/packages/intlayer/getLocalizedUrl.md)
|
|
1254
|
+
|
|
1255
|
+
> - [`getHTMLTextDir` hook](https://github.com/aymericzip/intlayer/blob/main/docs/en-GB/packages/intlayer/getHTMLTextDir.md)
|
|
1256
|
+
|
|
1257
|
+
> - [`hreflang` attribute](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
|
|
1258
|
+
|
|
1259
|
+
> - [`lang` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
|
|
1260
|
+
|
|
1261
|
+
> - [`dir` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
|
|
1262
|
+
|
|
1263
|
+
> - [`aria-current` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1264
|
+
|
|
1265
|
+
> - [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
1266
|
+
|
|
1267
|
+
Below is the updated **Step 9** with added explanations and refined code examples:
|
|
1268
|
+
|
|
1269
|
+
---
|
|
1270
|
+
|
|
1271
|
+
### (Optional) Step 9: Switch the HTML Language and Direction Attributes
|
|
1272
|
+
|
|
1273
|
+
When your application supports multiple languages, it's crucial to update the `<html>` tag's `lang` and `dir` attributes to match the current locale. Doing so ensures:
|
|
1274
|
+
|
|
1275
|
+
- **Accessibility**: Screen readers and assistive technologies rely on the correct `lang` attribute to pronounce and interpret content accurately.
|
|
1276
|
+
|
|
1277
|
+
- **Text Rendering**: The `dir` (direction) attribute ensures that text is rendered in the proper order (e.g., left-to-right for English, right-to-left for Arabic or Hebrew), which is essential for readability.
|
|
1278
|
+
- **SEO**: Search engines use the `lang` attribute to determine the language of your page, helping to serve the right localised content in search results.
|
|
1279
|
+
|
|
1280
|
+
By updating these attributes dynamically when the locale changes, you guarantee a consistent and accessible experience for users across all supported languages.
|
|
1281
|
+
|
|
1282
|
+
#### Implementing the Hook
|
|
1283
|
+
|
|
1284
|
+
Create a custom hook to manage the HTML attributes. The hook listens for locale changes and updates the attributes accordingly:
|
|
1285
|
+
|
|
1286
|
+
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
|
|
1287
|
+
import { useEffect } from "preact/hooks";
|
|
1288
|
+
import { useLocale } from "preact-intlayer";
|
|
1289
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1290
|
+
|
|
1291
|
+
/**
|
|
1292
|
+
* Updates the HTML <html> element's `lang` and `dir` attributes based on the current locale.
|
|
1293
|
+
* - `lang`: Informs browsers and search engines of the page's language.
|
|
1294
|
+
* - `dir`: Ensures the correct reading order (e.g., 'ltr' for English, 'rtl' for Arabic).
|
|
1295
|
+
*
|
|
1296
|
+
* This dynamic update is essential for proper text rendering, accessibility, and SEO.
|
|
1297
|
+
*/
|
|
1298
|
+
export const useI18nHTMLAttributes = () => {
|
|
1299
|
+
const { locale } = useLocale();
|
|
1300
|
+
|
|
1301
|
+
useEffect(() => {
|
|
1302
|
+
// Update the language attribute to the current locale.
|
|
1303
|
+
document.documentElement.lang = locale;
|
|
1304
|
+
|
|
1305
|
+
// Set the text direction based on the current locale.
|
|
1306
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1307
|
+
}, [locale]);
|
|
1308
|
+
};
|
|
1309
|
+
```
|
|
1310
|
+
|
|
1311
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.jsx" codeFormat="esm"
|
|
1312
|
+
import { useEffect } from "preact/hooks";
|
|
1313
|
+
import { useLocale } from "preact-intlayer";
|
|
1314
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1315
|
+
|
|
1316
|
+
/**
|
|
1317
|
+
* Updates the HTML <html> element's `lang` and `dir` attributes based on the current locale.
|
|
1318
|
+
*/
|
|
1319
|
+
export const useI18nHTMLAttributes = () => {
|
|
1320
|
+
const { locale } = useLocale();
|
|
1321
|
+
|
|
1322
|
+
useEffect(() => {
|
|
1323
|
+
document.documentElement.lang = locale;
|
|
1324
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1325
|
+
}, [locale]);
|
|
1326
|
+
};
|
|
1327
|
+
```
|
|
1328
|
+
|
|
1329
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.cjsx" codeFormat="commonjs"
|
|
1330
|
+
const { useEffect } = require("preact/hooks");
|
|
1331
|
+
const { useLocale } = require("preact-intlayer");
|
|
1332
|
+
const { getHTMLTextDir } = require("intlayer");
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* Updates the HTML <html> element's `lang` and `dir` attributes based on the current locale.
|
|
1336
|
+
*/
|
|
1337
|
+
const useI18nHTMLAttributes = () => {
|
|
1338
|
+
const { locale } = useLocale();
|
|
1339
|
+
|
|
1340
|
+
useEffect(() => {
|
|
1341
|
+
document.documentElement.lang = locale;
|
|
1342
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1343
|
+
}, [locale]);
|
|
1344
|
+
};
|
|
1345
|
+
|
|
1346
|
+
module.exports = { useI18nHTMLAttributes };
|
|
1347
|
+
```
|
|
1348
|
+
|
|
1349
|
+
#### Using the Hook in Your Application
|
|
1350
|
+
|
|
1351
|
+
Integrate the hook into your main component so that the HTML attributes update whenever the locale changes:
|
|
1352
|
+
|
|
1353
|
+
```tsx fileName="src/app.tsx" codeFormat="typescript"
|
|
1354
|
+
import type { FunctionalComponent } from "preact";
|
|
1355
|
+
import { IntlayerProvider } from "preact-intlayer"; // useIntlayer already imported if AppContent needs it
|
|
1356
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1357
|
+
import "./app.css";
|
|
1358
|
+
// AppContent definition from Step 5
|
|
1359
|
+
|
|
1360
|
+
const AppWithHooks: FunctionalComponent = () => {
|
|
1361
|
+
// Apply the hook to update the <html> tag's lang and dir attributes based on the locale.
|
|
1362
|
+
useI18nHTMLAttributes();
|
|
1363
|
+
|
|
1364
|
+
// Assuming AppContent is your main content display component from Step 5
|
|
1365
|
+
return <AppContent />;
|
|
1366
|
+
};
|
|
1367
|
+
|
|
1368
|
+
const App: FunctionalComponent = () => (
|
|
1369
|
+
<IntlayerProvider>
|
|
1370
|
+
<AppWithHooks />
|
|
1371
|
+
</IntlayerProvider>
|
|
1372
|
+
);
|
|
1373
|
+
|
|
1374
|
+
export default App;
|
|
1375
|
+
```
|
|
1376
|
+
|
|
1377
|
+
```jsx fileName="src/app.jsx" codeFormat="esm"
|
|
1378
|
+
import { IntlayerProvider } from "preact-intlayer";
|
|
1379
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1380
|
+
import "./app.css";
|
|
1381
|
+
// AppContent definition from Step 5
|
|
1382
|
+
|
|
1383
|
+
const AppWithHooks = () => {
|
|
1384
|
+
useI18nHTMLAttributes();
|
|
1385
|
+
return <AppContent />;
|
|
1386
|
+
};
|
|
1387
|
+
|
|
1388
|
+
const App = () => (
|
|
1389
|
+
<IntlayerProvider>
|
|
1390
|
+
<AppWithHooks />
|
|
1391
|
+
</IntlayerProvider>
|
|
1392
|
+
);
|
|
1393
|
+
|
|
1394
|
+
export default App;
|
|
1395
|
+
```
|
|
1396
|
+
|
|
1397
|
+
```jsx fileName="src/app.cjsx" codeFormat="commonjs"
|
|
1398
|
+
const { IntlayerProvider } = require("preact-intlayer");
|
|
1399
|
+
const { useI18nHTMLAttributes } = require("./hooks/useI18nHTMLAttributes");
|
|
1400
|
+
require("./app.css");
|
|
1401
|
+
// AppContent definition from Step 5
|
|
1402
|
+
|
|
1403
|
+
const AppWithHooks = () => {
|
|
1404
|
+
useI18nHTMLAttributes();
|
|
1405
|
+
return <AppContent />;
|
|
1406
|
+
};
|
|
1407
|
+
|
|
1408
|
+
const App = () => (
|
|
1409
|
+
<IntlayerProvider>
|
|
1410
|
+
<AppWithHooks />
|
|
1411
|
+
</IntlayerProvider>
|
|
1412
|
+
);
|
|
1413
|
+
|
|
1414
|
+
module.exports = App;
|
|
1415
|
+
```
|
|
1416
|
+
|
|
1417
|
+
By applying these changes, your application will:
|
|
1418
|
+
|
|
1419
|
+
- Ensure the **language** (`lang`) attribute correctly reflects the current locale, which is important for SEO and browser behaviour.
|
|
1420
|
+
- Adjust the **text direction** (`dir`) according to the locale, enhancing readability and usability for languages with different reading orders.
|
|
1421
|
+
- Provide a more **accessible** experience, as assistive technologies depend on these attributes to function optimally.
|
|
1422
|
+
|
|
1423
|
+
### (Optional) Step 10: Creating a Localised Link Component
|
|
1424
|
+
|
|
1425
|
+
To ensure that your application's navigation respects the current locale, you can create a custom `Link` component. This component automatically prefixes internal URLs with the current language.
|
|
1426
|
+
|
|
1427
|
+
This behaviour is useful for several reasons:
|
|
1428
|
+
|
|
1429
|
+
- **SEO and User Experience**: Localised URLs help search engines index language-specific pages correctly and provide users with content in their preferred language.
|
|
1430
|
+
- **Consistency**: By using a localised link throughout your application, you guarantee that navigation stays within the current locale, preventing unexpected language switches.
|
|
1431
|
+
- **Maintainability**: Centralising the localisation logic in a single component simplifies the management of URLs.
|
|
1432
|
+
|
|
1433
|
+
For Preact with `preact-iso`, standard `<a>` tags are typically used for navigation, and `preact-iso` handles the routing. If you need programmatic navigation on click (e.g., to perform actions before navigating), you can use the `route` function from `useLocation`. Here's how you can create a custom anchor component that localises URLs:
|
|
1434
|
+
|
|
1435
|
+
```tsx fileName="src/components/LocalizedLink.tsx" codeFormat="typescript"
|
|
1436
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1437
|
+
import { useLocale, useLocation, route } from "preact-intlayer"; // Assuming useLocation and route can be from preact-iso via preact-intlayer if re-exported, or import directly
|
|
1438
|
+
// If not re-exported, import directly: import { useLocation, route } from "preact-iso";
|
|
1439
|
+
import type { JSX } from "preact"; // For HTMLAttributes
|
|
1440
|
+
import { forwardRef } from "preact/compat"; // For forwarding refs
|
|
1441
|
+
|
|
1442
|
+
export interface LocalizedLinkProps
|
|
1443
|
+
extends JSX.HTMLAttributes<HTMLAnchorElement> {
|
|
1444
|
+
href: string;
|
|
1445
|
+
replace?: boolean; // Optional: to replace history state
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
/**
|
|
1449
|
+
* Utility function to check whether a given URL is external.
|
|
1450
|
+
* If the URL starts with http:// or https://, it's considered external.
|
|
1451
|
+
*/
|
|
1452
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1453
|
+
/^https?:\/\//.test(href ?? "");
|
|
1454
|
+
|
|
1455
|
+
/**
|
|
1456
|
+
* A custom Link component that adapts the href attribute based on the current locale.
|
|
1457
|
+
* For internal links, it uses `getLocalizedUrl` to prefix the URL with the locale (e.g., /fr/about).
|
|
1458
|
+
* This ensures that navigation stays within the same locale context.
|
|
1459
|
+
* It uses a standard <a> tag but can trigger client-side navigation using preact-iso's `route`.
|
|
1460
|
+
*/
|
|
1461
|
+
export const LocalizedLink = forwardRef<HTMLAnchorElement, LocalizedLinkProps>(
|
|
1462
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1463
|
+
const { locale } = useLocale();
|
|
1464
|
+
const location = useLocation(); // from preact-iso
|
|
1465
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1466
|
+
|
|
1467
|
+
const hrefI18n =
|
|
1468
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1469
|
+
|
|
1470
|
+
const handleClick = (event: JSX.TargetedMouseEvent<HTMLAnchorElement>) => {
|
|
1471
|
+
if (onClick) {
|
|
1472
|
+
onClick(event);
|
|
1473
|
+
}
|
|
1474
|
+
if (
|
|
1475
|
+
!isExternalLink &&
|
|
1476
|
+
href && // Ensure href is defined
|
|
1477
|
+
event.button === 0 && // Left click
|
|
1478
|
+
!event.metaKey &&
|
|
1479
|
+
|
|
1480
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1481
|
+
import { useLocale } from "preact-intlayer";
|
|
1482
|
+
import { useLocation, route } from "preact-iso"; // Import from preact-iso
|
|
1483
|
+
import { forwardRef } from "preact/compat";
|
|
1484
|
+
import { h } from "preact"; // For JSX
|
|
1485
|
+
|
|
1486
|
+
export const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1487
|
+
|
|
1488
|
+
export const LocalizedLink = forwardRef(
|
|
1489
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1490
|
+
const { locale } = useLocale();
|
|
1491
|
+
const location = useLocation();
|
|
1492
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1493
|
+
|
|
1494
|
+
const hrefI18n =
|
|
1495
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1496
|
+
|
|
1497
|
+
const handleClick = (event) => {
|
|
1498
|
+
if (onClick) {
|
|
1499
|
+
onClick(event);
|
|
1500
|
+
}
|
|
1501
|
+
if (
|
|
1502
|
+
!isExternalLink &&
|
|
1503
|
+
href &&
|
|
1504
|
+
event.button === 0 &&
|
|
1505
|
+
!event.metaKey &&
|
|
1506
|
+
!event.ctrlKey &&
|
|
1507
|
+
!event.shiftKey &&
|
|
1508
|
+
!event.altKey &&
|
|
1509
|
+
!props.target
|
|
1510
|
+
) {
|
|
1511
|
+
event.preventDefault();
|
|
1512
|
+
if (location.url !== hrefI18n) {
|
|
1513
|
+
route(hrefI18n, replace);
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1518
|
+
return (
|
|
1519
|
+
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1520
|
+
{children}
|
|
1521
|
+
</a>
|
|
1522
|
+
);
|
|
1523
|
+
}
|
|
1524
|
+
);
|
|
1525
|
+
```
|
|
1526
|
+
|
|
1527
|
+
```jsx fileName="src/components/LocalizedLink.cjsx" codeFormat="commonjs"
|
|
1528
|
+
const { getLocalizedUrl } = require("intlayer");
|
|
1529
|
+
const { useLocale } = require("preact-intlayer");
|
|
1530
|
+
const { useLocation, route } = require("preact-iso"); // Import from preact-iso
|
|
1531
|
+
const { forwardRef } = require("preact/compat");
|
|
1532
|
+
const { h } = require("preact"); // For JSX
|
|
1533
|
+
|
|
1534
|
+
const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1535
|
+
|
|
1536
|
+
const LocalizedLink = forwardRef(
|
|
1537
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1538
|
+
const { locale } = useLocale();
|
|
1539
|
+
const location = useLocation();
|
|
1540
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1541
|
+
|
|
1542
|
+
const hrefI18n =
|
|
1543
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1544
|
+
|
|
1545
|
+
const handleClick = (event) => {
|
|
1546
|
+
if (onClick) {
|
|
1547
|
+
onClick(event);
|
|
1548
|
+
}
|
|
1549
|
+
if (
|
|
1550
|
+
!isExternalLink &&
|
|
1551
|
+
href &&
|
|
1552
|
+
event.button === 0 &&
|
|
1553
|
+
!event.metaKey &&
|
|
1554
|
+
!event.ctrlKey &&
|
|
1555
|
+
!event.shiftKey &&
|
|
1556
|
+
!event.altKey &&
|
|
1557
|
+
!props.target
|
|
1558
|
+
) {
|
|
1559
|
+
event.preventDefault();
|
|
1560
|
+
if (location.url !== hrefI18n) {
|
|
1561
|
+
route(hrefI18n, replace);
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
};
|
|
1565
|
+
|
|
1566
|
+
return (
|
|
1567
|
+
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1568
|
+
{children}
|
|
1569
|
+
</a>
|
|
1570
|
+
);
|
|
1571
|
+
}
|
|
1572
|
+
);
|
|
1573
|
+
|
|
1574
|
+
module.exports = { LocalizedLink, checkIsExternalLink };
|
|
1575
|
+
```
|
|
1576
|
+
|
|
1577
|
+
#### How It Works
|
|
1578
|
+
|
|
1579
|
+
- **Detecting External Links**:
|
|
1580
|
+
The helper function `checkIsExternalLink` determines whether a URL is external. External links are left unchanged.
|
|
1581
|
+
- **Retrieving the Current Locale**:
|
|
1582
|
+
The `useLocale` hook provides the current locale.
|
|
1583
|
+
- **Localising the URL**:
|
|
1584
|
+
For internal links, `getLocalizedUrl` prefixes the URL with the current locale.
|
|
1585
|
+
- **Client-Side Navigation**:
|
|
1586
|
+
The `handleClick` function checks if it's an internal link and if standard navigation should be prevented. If so, it uses `preact-iso`'s `route` function (obtained via `useLocation` or directly imported) to perform client-side navigation. This provides SPA-like behaviour without full page reloads.
|
|
1587
|
+
- **Returning the Link**:
|
|
1588
|
+
The component returns an `<a>` element with the localised URL and the custom click handler.
|
|
1589
|
+
|
|
1590
|
+
### Configure TypeScript
|
|
1591
|
+
|
|
1592
|
+
Intlayer uses module augmentation to get the benefits of TypeScript and make your codebase stronger.
|
|
1593
|
+
|
|
1594
|
+

|
|
1595
|
+
|
|
1596
|
+

|
|
1597
|
+
|
|
1598
|
+
Ensure your TypeScript configuration includes the autogenerated types.
|
|
1599
|
+
|
|
1600
|
+
```json5 fileName="tsconfig.json"
|
|
1601
|
+
{
|
|
1602
|
+
// ... Your existing TypeScript configurations
|
|
1603
|
+
"compilerOptions": {
|
|
1604
|
+
// ...
|
|
1605
|
+
"jsx": "react-jsx",
|
|
1606
|
+
"jsxImportSource": "preact", // Recommended for Preact 10+
|
|
1607
|
+
// ...
|
|
1608
|
+
},
|
|
1609
|
+
"include": [
|
|
1610
|
+
// ... Your existing TypeScript configurations
|
|
1611
|
+
".intlayer/**/*.ts", // Include the auto-generated types
|
|
1612
|
+
],
|
|
1613
|
+
}
|
|
1614
|
+
```
|
|
1615
|
+
|
|
1616
|
+
> Ensure your `tsconfig.json` is set up for Preact, especially `jsx` and `jsxImportSource` or `jsxFactory`/`jsxFragmentFactory` for older Preact versions if not using `preset-vite`'s defaults.
|
|
1617
|
+
|
|
1618
|
+
### Git Configuration
|
|
1619
|
+
|
|
1620
|
+
It is recommended to ignore the files generated by Intlayer. This allows you to avoid committing them to your Git repository.
|
|
1621
|
+
|
|
1622
|
+
To do this, you can add the following instructions to your `.gitignore` file:
|
|
1623
|
+
|
|
1624
|
+
```plaintext
|
|
1625
|
+
# Ignore the files generated by Intlayer
|
|
1626
|
+
.intlayer
|
|
1627
|
+
```
|
|
1628
|
+
|
|
1629
|
+
### VS Code Extension
|
|
1630
|
+
|
|
1631
|
+
To improve your development experience with Intlayer, you can install the official **Intlayer VS Code Extension**.
|
|
1632
|
+
|
|
1633
|
+
[Install from the VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
1634
|
+
|
|
1635
|
+
This extension provides:
|
|
1636
|
+
|
|
1637
|
+
- **Autocompletion** for translation keys.
|
|
1638
|
+
- **Real-time error detection** for missing translations.
|
|
1639
|
+
- **Inline previews** of translated content.
|
|
1640
|
+
- **Quick actions** to easily create and update translations.
|
|
1641
|
+
|
|
1642
|
+
For more details on how to use the extension, refer to the [Intlayer VS Code Extension documentation](https://intlayer.org/doc/vs-code-extension).
|
|
1643
|
+
|
|
1644
|
+
---
|
|
1645
|
+
|
|
1646
|
+
### Go Further
|
|
1647
|
+
|
|
1648
|
+
To go further, you can implement the [visual editor](https://github.com/aymericzip/intlayer/blob/main/docs/en-GB/intlayer_visual_editor.md) or externalise your content using the [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/en-GB/intlayer_CMS.md).
|