@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,1621 @@
|
|
|
1
|
+
# Commencer avec l'internationalisation (i18n) avec Intlayer, Vite et Preact
|
|
2
|
+
|
|
3
|
+
> Ce package est en développement. Voir le [problème](https://github.com/aymericzip/intlayer/issues/118) pour plus d'informations. Montrez votre intérêt pour Intlayer pour Preact en aimant le problème.
|
|
4
|
+
|
|
5
|
+
Voir le [Modèle d'application](https://github.com/aymericzip/intlayer-vite-preact-template) sur GitHub.
|
|
6
|
+
|
|
7
|
+
## Qu'est-ce qu'Intlayer ?
|
|
8
|
+
|
|
9
|
+
**Intlayer** est une bibliothèque innovante et open-source d'internationalisation (i18n) conçue pour simplifier le support multilingue dans les applications web modernes.
|
|
10
|
+
|
|
11
|
+
Avec Intlayer, vous pouvez :
|
|
12
|
+
|
|
13
|
+
- **Gérer facilement les traductions** en utilisant des dictionnaires déclaratifs au niveau des composants.
|
|
14
|
+
- **Localiser dynamiquement les métadonnées**, les routes et le contenu.
|
|
15
|
+
- **Assurer la prise en charge de TypeScript** avec des types générés automatiquement, améliorant l'autocomplétion et la détection des erreurs.
|
|
16
|
+
- **Bénéficier de fonctionnalités avancées**, comme la détection et le changement dynamiques de la langue.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Guide étape par étape pour configurer Intlayer dans une application Vite et Preact
|
|
21
|
+
|
|
22
|
+
### Étape 1 : Installer les dépendances
|
|
23
|
+
|
|
24
|
+
Installez les packages nécessaires en utilisant 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
|
+
Le package principal qui fournit des outils d'internationalisation pour la gestion de la configuration, la traduction, [la déclaration de contenu](https://github.com/aymericzip/intlayer/blob/main/docs/fr/dictionary/get_started.md), la transpilation et les [commandes CLI](https://github.com/aymericzip/intlayer/blob/main/docs/fr/intlayer_cli.md).
|
|
41
|
+
|
|
42
|
+
- **preact-intlayer**
|
|
43
|
+
Le package qui intègre Intlayer avec une application Preact. Il fournit des fournisseurs de contexte et des hooks pour l'internationalisation avec Preact.
|
|
44
|
+
|
|
45
|
+
- **vite-intlayer**
|
|
46
|
+
Inclut le plugin Vite pour intégrer Intlayer avec le [bundler Vite](https://vite.dev/guide/why.html#why-bundle-for-production), ainsi qu'un middleware pour détecter la langue préférée de l'utilisateur, gérer les cookies et gérer la redirection des URL.
|
|
47
|
+
|
|
48
|
+
### Étape 2 : Configuration de votre projet
|
|
49
|
+
|
|
50
|
+
Créez un fichier de configuration pour configurer les langues de votre 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
|
+
// Vos autres langues
|
|
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
|
+
// Vos autres langues
|
|
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
|
+
// Vos autres langues
|
|
100
|
+
],
|
|
101
|
+
defaultLocale: Locales.ENGLISH,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
module.exports = config;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
> Grâce à ce fichier de configuration, vous pouvez configurer les URL localisées, la redirection via middleware, les noms de cookies, l'emplacement et l'extension de vos déclarations de contenu, désactiver les journaux Intlayer dans la console, et plus encore. Pour une liste complète des paramètres disponibles, consultez la [documentation de configuration](https://github.com/aymericzip/intlayer/blob/main/docs/fr/configuration.md).
|
|
109
|
+
|
|
110
|
+
### Étape 3 : Intégrer Intlayer dans votre configuration Vite
|
|
111
|
+
|
|
112
|
+
Ajoutez le plugin intlayer dans votre 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
|
+
> Le plugin `intlayerPlugin()` de Vite est utilisé pour intégrer Intlayer avec Vite. Il garantit la construction des fichiers de déclaration de contenu et les surveille en mode développement. Il définit les variables d'environnement Intlayer dans l'application Vite. De plus, il fournit des alias pour optimiser les performances.
|
|
148
|
+
|
|
149
|
+
### Étape 4 : Déclarez votre contenu
|
|
150
|
+
|
|
151
|
+
Créez et gérez vos déclarations de contenu pour stocker les traductions :
|
|
152
|
+
|
|
153
|
+
```tsx fileName="src/app.content.tsx" contentDeclarationFormat="typescript"
|
|
154
|
+
import { t, type Dictionary } from "intlayer";
|
|
155
|
+
|
|
156
|
+
const appContent = {
|
|
157
|
+
key: "app",
|
|
158
|
+
content: {
|
|
159
|
+
viteLogo: t({
|
|
160
|
+
fr: "Logo Vite",
|
|
161
|
+
en: "Vite logo",
|
|
162
|
+
es: "Logo Vite",
|
|
163
|
+
}),
|
|
164
|
+
preactLogo: t({
|
|
165
|
+
fr: "Logo Preact",
|
|
166
|
+
en: "Preact logo",
|
|
167
|
+
es: "Logo Preact",
|
|
168
|
+
}),
|
|
169
|
+
|
|
170
|
+
title: "Vite + Preact",
|
|
171
|
+
|
|
172
|
+
count: t({
|
|
173
|
+
fr: "le compte est ",
|
|
174
|
+
en: "count is ",
|
|
175
|
+
es: "el recuento es ",
|
|
176
|
+
}),
|
|
177
|
+
|
|
178
|
+
edit: t({
|
|
179
|
+
en: "Edit src/app.tsx and save to test HMR",
|
|
180
|
+
fr: "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
181
|
+
es: "Edita src/app.tsx y guarda para probar HMR",
|
|
182
|
+
}),
|
|
183
|
+
|
|
184
|
+
readTheDocs: t({
|
|
185
|
+
fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
186
|
+
en: "Click on the Vite and Preact logos to learn more",
|
|
187
|
+
es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
188
|
+
}),
|
|
189
|
+
},
|
|
190
|
+
} satisfies Dictionary;
|
|
191
|
+
|
|
192
|
+
export default appContent;
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
```javascript fileName="src/app.content.mjs" contentDeclarationFormat="esm"
|
|
196
|
+
import { t } from "intlayer";
|
|
197
|
+
// import { h } from 'preact'; // Nécessaire si vous utilisez JSX directement dans .mjs
|
|
198
|
+
|
|
199
|
+
/** @type {import('intlayer').Dictionary} */
|
|
200
|
+
const appContent = {
|
|
201
|
+
key: "app",
|
|
202
|
+
content: {
|
|
203
|
+
viteLogo: t({
|
|
204
|
+
fr: "Logo Vite",
|
|
205
|
+
en: "Vite logo",
|
|
206
|
+
es: "Logo Vite",
|
|
207
|
+
}),
|
|
208
|
+
preactLogo: t({
|
|
209
|
+
fr: "Logo Preact",
|
|
210
|
+
en: "Preact logo",
|
|
211
|
+
es: "Logo Preact",
|
|
212
|
+
}),
|
|
213
|
+
|
|
214
|
+
title: "Vite + Preact",
|
|
215
|
+
|
|
216
|
+
count: t({
|
|
217
|
+
fr: "le compte est ",
|
|
218
|
+
en: "count is ",
|
|
219
|
+
es: "el recuento es ",
|
|
220
|
+
}),
|
|
221
|
+
|
|
222
|
+
edit: t({
|
|
223
|
+
en: "Edit src/app.tsx and save to test HMR",
|
|
224
|
+
fr: "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
225
|
+
es: "Edita src/app.tsx y guarda para probar HMR",
|
|
226
|
+
}),
|
|
227
|
+
|
|
228
|
+
readTheDocs: t({
|
|
229
|
+
fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
230
|
+
en: "Click on the Vite and Preact logos to learn more",
|
|
231
|
+
es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
232
|
+
}),
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export default appContent;
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
```javascript fileName="src/app.content.cjs" contentDeclarationFormat="commonjs"
|
|
240
|
+
const { t } = require("intlayer");
|
|
241
|
+
|
|
242
|
+
// const { h } = require('preact'); // Nécessaire si vous utilisez JSX directement dans .cjs
|
|
243
|
+
|
|
244
|
+
/** @type {import('intlayer').Dictionary} */
|
|
245
|
+
const appContent = {
|
|
246
|
+
key: "app",
|
|
247
|
+
content: {
|
|
248
|
+
viteLogo: t({
|
|
249
|
+
fr: "Logo Vite",
|
|
250
|
+
en: "Vite logo",
|
|
251
|
+
es: "Logo Vite",
|
|
252
|
+
}),
|
|
253
|
+
preactLogo: t({
|
|
254
|
+
fr: "Logo Preact",
|
|
255
|
+
en: "Preact logo",
|
|
256
|
+
es: "Logo Preact",
|
|
257
|
+
}),
|
|
258
|
+
|
|
259
|
+
title: "Vite + Preact",
|
|
260
|
+
|
|
261
|
+
count: t({
|
|
262
|
+
fr: "le compte est ",
|
|
263
|
+
en: "count is ",
|
|
264
|
+
es: "el recuento es ",
|
|
265
|
+
}),
|
|
266
|
+
|
|
267
|
+
edit: t({
|
|
268
|
+
en: "Edit src/app.tsx and save to test HMR",
|
|
269
|
+
fr: "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
270
|
+
es: "Edita src/app.tsx y guarda para probar HMR",
|
|
271
|
+
}),
|
|
272
|
+
|
|
273
|
+
readTheDocs: t({
|
|
274
|
+
fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
275
|
+
en: "Click on the Vite and Preact logos to learn more",
|
|
276
|
+
es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
277
|
+
}),
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
module.exports = appContent;
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
```json fileName="src/app.content.json" contentDeclarationFormat="json"
|
|
285
|
+
{
|
|
286
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
287
|
+
"key": "app",
|
|
288
|
+
"content": {
|
|
289
|
+
"viteLogo": {
|
|
290
|
+
"nodeType": "translation",
|
|
291
|
+
"translation": {
|
|
292
|
+
"fr": "Logo Vite",
|
|
293
|
+
"en": "Vite logo",
|
|
294
|
+
"es": "Logo Vite"
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
"preactLogo": {
|
|
298
|
+
"nodeType": "translation",
|
|
299
|
+
"translation": {
|
|
300
|
+
"fr": "Logo Preact",
|
|
301
|
+
"en": "Preact logo",
|
|
302
|
+
"es": "Logo Preact"
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
"title": {
|
|
306
|
+
"nodeType": "translation",
|
|
307
|
+
"translation": {
|
|
308
|
+
"fr": "Vite + Preact",
|
|
309
|
+
"en": "Vite + Preact",
|
|
310
|
+
"es": "Vite + Preact"
|
|
311
|
+
}
|
|
312
|
+
},
|
|
313
|
+
"count": {
|
|
314
|
+
"nodeType": "translation",
|
|
315
|
+
"translation": {
|
|
316
|
+
"fr": "le compte est ",
|
|
317
|
+
"en": "count is ",
|
|
318
|
+
"es": "el recuento es "
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
"edit": {
|
|
322
|
+
"nodeType": "translation",
|
|
323
|
+
"translation": {
|
|
324
|
+
"fr": "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
325
|
+
"en": "Edit src/app.tsx and save to test HMR",
|
|
326
|
+
"es": "Edita src/app.tsx y guarda para probar HMR"
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
"readTheDocs": {
|
|
330
|
+
"nodeType": "translation",
|
|
331
|
+
"translation": {
|
|
332
|
+
"fr": "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
333
|
+
"en": "Click on the Vite and Preact logos to learn more",
|
|
334
|
+
"es": "Haga clic en los logotipos de Vite y Preact para obtener más información"
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
> Vos déclarations de contenu peuvent être définies n'importe où dans votre application tant qu'elles sont incluses dans le répertoire `contentDir` (par défaut, `./src`). Et correspondent à l'extension de fichier de déclaration de contenu (par défaut, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
342
|
+
|
|
343
|
+
> Pour plus de détails, consultez la [documentation sur les déclarations de contenu](https://github.com/aymericzip/intlayer/blob/main/docs/fr/dictionary/get_started.md).
|
|
344
|
+
|
|
345
|
+
> Si votre fichier de contenu inclut du code TSX, vous devrez peut-être importer `import { h } from "preact";` ou vous assurer que votre pragma JSX est correctement configuré pour Preact.
|
|
346
|
+
|
|
347
|
+
### Étape 5 : Utilisez Intlayer dans votre code
|
|
348
|
+
|
|
349
|
+
Accédez à vos dictionnaires de contenu dans toute votre application :
|
|
350
|
+
|
|
351
|
+
```tsx {6,10} fileName="src/app.tsx" codeFormat="typescript"
|
|
352
|
+
import { useState } from "preact/hooks";
|
|
353
|
+
import type { FunctionalComponent } from "preact";
|
|
354
|
+
import preactLogo from "./assets/preact.svg"; // Supposons que vous avez un fichier preact.svg
|
|
355
|
+
import viteLogo from "/vite.svg";
|
|
356
|
+
import "./app.css"; // Supposons que votre fichier CSS s'appelle app.css
|
|
357
|
+
import { IntlayerProvider, useIntlayer } from "preact-intlayer";
|
|
358
|
+
|
|
359
|
+
const AppContent: FunctionalComponent = () => {
|
|
360
|
+
const [count, setCount] = useState(0);
|
|
361
|
+
const content = useIntlayer("app");
|
|
362
|
+
|
|
363
|
+
return (
|
|
364
|
+
<>
|
|
365
|
+
<div>
|
|
366
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
367
|
+
<img src={viteLogo} class="logo" alt={content.viteLogo.value} />
|
|
368
|
+
</a>
|
|
369
|
+
<a href="https://preactjs.com" target="_blank">
|
|
370
|
+
<img
|
|
371
|
+
src={preactLogo}
|
|
372
|
+
class="logo preact"
|
|
373
|
+
alt={content.preactLogo.value}
|
|
374
|
+
/>
|
|
375
|
+
</a>
|
|
376
|
+
</div>
|
|
377
|
+
<h1>{content.title}</h1>
|
|
378
|
+
<div class="card">
|
|
379
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
380
|
+
{content.count}
|
|
381
|
+
{count}
|
|
382
|
+
</button>
|
|
383
|
+
<p>{content.edit}</p>
|
|
384
|
+
</div>
|
|
385
|
+
<p class="read-the-docs">{content.readTheDocs}</p>
|
|
386
|
+
</>
|
|
387
|
+
);
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
const App: FunctionalComponent = () => (
|
|
391
|
+
<IntlayerProvider>
|
|
392
|
+
<AppContent />
|
|
393
|
+
</IntlayerProvider>
|
|
394
|
+
);
|
|
395
|
+
|
|
396
|
+
export default App;
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
```jsx {5,9} fileName="src/app.jsx" codeFormat="esm"
|
|
400
|
+
import { useState } from "preact/hooks";
|
|
401
|
+
import preactLogo from "./assets/preact.svg";
|
|
402
|
+
import viteLogo from "/vite.svg";
|
|
403
|
+
import "./app.css";
|
|
404
|
+
import { IntlayerProvider, useIntlayer } from "preact-intlayer";
|
|
405
|
+
|
|
406
|
+
const AppContent = () => {
|
|
407
|
+
const [count, setCount] = useState(0);
|
|
408
|
+
const content = useIntlayer("app");
|
|
409
|
+
|
|
410
|
+
return (
|
|
411
|
+
<>
|
|
412
|
+
<div>
|
|
413
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
414
|
+
<img src={viteLogo} class="logo" alt={content.viteLogo.value} />
|
|
415
|
+
</a>
|
|
416
|
+
<a href="https://preactjs.com" target="_blank">
|
|
417
|
+
<img
|
|
418
|
+
src={preactLogo}
|
|
419
|
+
class="logo preact"
|
|
420
|
+
alt={content.preactLogo.value}
|
|
421
|
+
/>
|
|
422
|
+
</a>
|
|
423
|
+
</div>
|
|
424
|
+
<h1>{content.title}</h1>
|
|
425
|
+
<div class="card">
|
|
426
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
427
|
+
{content.count}
|
|
428
|
+
{count}
|
|
429
|
+
</button>
|
|
430
|
+
<p>{content.edit}</p>
|
|
431
|
+
</div>
|
|
432
|
+
<p class="read-the-docs">{content.readTheDocs}</p>
|
|
433
|
+
</>
|
|
434
|
+
);
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
const App = () => (
|
|
438
|
+
<IntlayerProvider>
|
|
439
|
+
<AppContent />
|
|
440
|
+
</IntlayerProvider>
|
|
441
|
+
);
|
|
442
|
+
|
|
443
|
+
export default App;
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
```jsx {5,9} fileName="src/app.cjsx" codeFormat="commonjs"
|
|
447
|
+
const { useState } = require("preact/hooks");
|
|
448
|
+
const preactLogo = require("./assets/preact.svg");
|
|
449
|
+
const viteLogo = require("/vite.svg");
|
|
450
|
+
require("./app.css");
|
|
451
|
+
const { IntlayerProvider, useIntlayer } = require("preact-intlayer");
|
|
452
|
+
|
|
453
|
+
const AppContent = () => {
|
|
454
|
+
const [count, setCount] = useState(0);
|
|
455
|
+
const content = useIntlayer("app");
|
|
456
|
+
|
|
457
|
+
return (
|
|
458
|
+
<>
|
|
459
|
+
<div>
|
|
460
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
461
|
+
<img src={viteLogo} class="logo" alt={content.viteLogo.value} />
|
|
462
|
+
</a>
|
|
463
|
+
<a href="https://preactjs.com" target="_blank">
|
|
464
|
+
<img
|
|
465
|
+
src={preactLogo}
|
|
466
|
+
class="logo preact"
|
|
467
|
+
alt={content.preactLogo.value}
|
|
468
|
+
/>
|
|
469
|
+
</a>
|
|
470
|
+
</div>
|
|
471
|
+
<h1>{content.title}</h1>
|
|
472
|
+
<div class="card">
|
|
473
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
474
|
+
{content.count}
|
|
475
|
+
{count}
|
|
476
|
+
</button>
|
|
477
|
+
<p>{content.edit}</p>
|
|
478
|
+
</div>
|
|
479
|
+
<p class="read-the-docs">{content.readTheDocs}</p>
|
|
480
|
+
</>
|
|
481
|
+
);
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
const App = () => (
|
|
485
|
+
<IntlayerProvider>
|
|
486
|
+
<AppContent />
|
|
487
|
+
</IntlayerProvider>
|
|
488
|
+
);
|
|
489
|
+
|
|
490
|
+
module.exports = App;
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
> Si vous souhaitez utiliser votre contenu dans un attribut `string`, tel que `alt`, `title`, `href`, `aria-label`, etc., vous devez appeler la valeur de la fonction, comme :
|
|
494
|
+
|
|
495
|
+
> ```jsx
|
|
496
|
+
>
|
|
497
|
+
> ```
|
|
498
|
+
|
|
499
|
+
> <img src={content.image.src.value} alt={content.image.value} />
|
|
500
|
+
|
|
501
|
+
> ```
|
|
502
|
+
>
|
|
503
|
+
> ```
|
|
504
|
+
|
|
505
|
+
> Remarque : Dans Preact, `className` est généralement écrit comme `class`.
|
|
506
|
+
|
|
507
|
+
> Pour en savoir plus sur le hook `useIntlayer`, consultez la [documentation](https://github.com/aymericzip/intlayer/blob/main/docs/fr/packages/react-intlayer/useIntlayer.md) (L'API est similaire pour `preact-intlayer`).
|
|
508
|
+
|
|
509
|
+
### (Optionnel) Étape 6 : Changez la langue de votre contenu
|
|
510
|
+
|
|
511
|
+
Pour changer la langue de votre contenu, vous pouvez utiliser la fonction `setLocale` fournie par le hook `useLocale`. Cette fonction vous permet de définir la langue de l'application et de mettre à jour le contenu en conséquence.
|
|
512
|
+
|
|
513
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
514
|
+
import type { FunctionalComponent } from "preact";
|
|
515
|
+
import { Locales } from "intlayer";
|
|
516
|
+
import { useLocale } from "preact-intlayer";
|
|
517
|
+
|
|
518
|
+
const LocaleSwitcher: FunctionalComponent = () => {
|
|
519
|
+
const { setLocale } = useLocale();
|
|
520
|
+
|
|
521
|
+
return (
|
|
522
|
+
<button onClick={() => setLocale(Locales.FRENCH)}>
|
|
523
|
+
Changer la langue en Français
|
|
524
|
+
</button>
|
|
525
|
+
);
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
export default LocaleSwitcher;
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
```jsx fileName="src/components/LocaleSwitcher.jsx" codeFormat="esm"
|
|
532
|
+
import { Locales } from "intlayer";
|
|
533
|
+
import { useLocale } from "preact-intlayer";
|
|
534
|
+
|
|
535
|
+
const LocaleSwitcher = () => {
|
|
536
|
+
const { setLocale } = useLocale();
|
|
537
|
+
|
|
538
|
+
return (
|
|
539
|
+
<button onClick={() => setLocale(Locales.FRENCH)}>
|
|
540
|
+
Changer la langue en Français
|
|
541
|
+
</button>
|
|
542
|
+
);
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
export default LocaleSwitcher;
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
```jsx fileName="src/components/LocaleSwitcher.cjsx" codeFormat="commonjs"
|
|
549
|
+
const { Locales } = require("intlayer");
|
|
550
|
+
const { useLocale } = require("preact-intlayer");
|
|
551
|
+
|
|
552
|
+
const LocaleSwitcher = () => {
|
|
553
|
+
const { setLocale } = useLocale();
|
|
554
|
+
|
|
555
|
+
return (
|
|
556
|
+
<button onClick={() => setLocale(Locales.FRENCH)}>
|
|
557
|
+
Changer la langue en Français
|
|
558
|
+
</button>
|
|
559
|
+
);
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
module.exports = LocaleSwitcher;
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
> Pour en savoir plus sur le hook `useLocale`, consultez la [documentation](https://github.com/aymericzip/intlayer/blob/main/docs/fr/packages/react-intlayer/useLocale.md) (L'API est similaire pour `preact-intlayer`).
|
|
566
|
+
|
|
567
|
+
### (Optionnel) Étape 7 : Ajouter un routage localisé à votre application
|
|
568
|
+
|
|
569
|
+
L'objectif de cette étape est de créer des routes uniques pour chaque langue. Cela est utile pour le SEO et les URL adaptées au référencement.
|
|
570
|
+
Exemple :
|
|
571
|
+
|
|
572
|
+
```plaintext
|
|
573
|
+
- https://example.com/about
|
|
574
|
+
- https://example.com/es/about
|
|
575
|
+
- https://example.com/fr/about
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
> Par défaut, les routes ne sont pas préfixées pour la langue par défaut. Si vous souhaitez préfixer la langue par défaut, vous pouvez définir l'option `middleware.prefixDefault` sur `true` dans votre configuration. Consultez la [documentation de configuration](https://github.com/aymericzip/intlayer/blob/main/docs/fr/configuration.md) pour plus d'informations.
|
|
579
|
+
|
|
580
|
+
Pour ajouter un routage localisé à votre application, vous pouvez créer un composant `LocaleRouter` qui enveloppe les routes de votre application et gère le routage basé sur la langue. Voici un exemple utilisant [preact-iso](https://github.com/preactjs/preact-iso) :
|
|
581
|
+
|
|
582
|
+
Tout d'abord, installez `preact-iso` :
|
|
583
|
+
|
|
584
|
+
```bash packageManager="npm"
|
|
585
|
+
npm install preact-iso
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
```bash packageManager="pnpm"
|
|
589
|
+
pnpm add preact-iso
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
```bash packageManager="yarn"
|
|
593
|
+
yarn add preact-iso
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
|
|
597
|
+
import { type Locales, configuration, getPathWithoutLocale } from "intlayer";
|
|
598
|
+
import { ComponentChildren, FunctionalComponent } from "preact";
|
|
599
|
+
import { IntlayerProvider } from "preact-intlayer";
|
|
600
|
+
import { LocationProvider, useLocation } from "preact-iso";
|
|
601
|
+
import { useEffect } from "preact/hooks";
|
|
602
|
+
|
|
603
|
+
const { internationalization, middleware } = configuration;
|
|
604
|
+
const { locales, defaultLocale } = internationalization;
|
|
605
|
+
|
|
606
|
+
const Navigate: FunctionalComponent<{ to: string; replace?: boolean }> = ({
|
|
607
|
+
to,
|
|
608
|
+
replace,
|
|
609
|
+
}) => {
|
|
610
|
+
const { route } = useLocation();
|
|
611
|
+
useEffect(() => {
|
|
612
|
+
route(to, replace);
|
|
613
|
+
}, [to, replace, route]);
|
|
614
|
+
return null;
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Un composant qui gère la localisation et enveloppe les enfants avec le contexte de langue approprié.
|
|
619
|
+
* Il gère la détection et la validation de la langue basée sur l'URL.
|
|
620
|
+
*/
|
|
621
|
+
const AppLocalized: FunctionalComponent<{
|
|
622
|
+
children: ComponentChildren;
|
|
623
|
+
locale?: Locales;
|
|
624
|
+
}> = ({ children, locale }) => {
|
|
625
|
+
const { path: pathname, url } = useLocation();
|
|
626
|
+
|
|
627
|
+
if (!url) {
|
|
628
|
+
return null;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
const search = url.substring(pathname.length);
|
|
632
|
+
|
|
633
|
+
// Détermine la langue actuelle, en utilisant la langue par défaut si non fournie
|
|
634
|
+
const currentLocale = locale ?? defaultLocale;
|
|
635
|
+
|
|
636
|
+
// Supprime le préfixe de langue du chemin pour construire un chemin de base
|
|
637
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
638
|
+
pathname // Chemin actuel de l'URL
|
|
639
|
+
);
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Si middleware.prefixDefault est vrai, la langue par défaut doit toujours être préfixée.
|
|
643
|
+
*/
|
|
644
|
+
if (middleware.prefixDefault) {
|
|
645
|
+
// Valide la langue
|
|
646
|
+
if (!locale || !locales.includes(locale)) {
|
|
647
|
+
// Redirige vers la langue par défaut avec le chemin mis à jour
|
|
648
|
+
return (
|
|
649
|
+
<Navigate
|
|
650
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
651
|
+
replace // Remplace l'entrée actuelle de l'historique par la nouvelle
|
|
652
|
+
/>
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// Enveloppe les enfants avec IntlayerProvider et définit la langue actuelle
|
|
657
|
+
return (
|
|
658
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
659
|
+
);
|
|
660
|
+
} else {
|
|
661
|
+
/**
|
|
662
|
+
* Lorsque middleware.prefixDefault est faux, la langue par défaut n'est pas préfixée.
|
|
663
|
+
* Assurez-vous que la langue actuelle est valide et n'est pas la langue par défaut.
|
|
664
|
+
*/
|
|
665
|
+
if (
|
|
666
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
667
|
+
!locales
|
|
668
|
+
.filter(
|
|
669
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Exclut la langue par défaut
|
|
670
|
+
)
|
|
671
|
+
.includes(currentLocale) // Vérifie si la langue actuelle est dans la liste des langues valides
|
|
672
|
+
) {
|
|
673
|
+
// Redirige vers le chemin sans préfixe de langue
|
|
674
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
// Enveloppe les enfants avec IntlayerProvider et définit la langue actuelle
|
|
678
|
+
return (
|
|
679
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
const RouterContent: FunctionalComponent<{
|
|
685
|
+
children: ComponentChildren;
|
|
686
|
+
}> = ({ children }) => {
|
|
687
|
+
const { path } = useLocation();
|
|
688
|
+
|
|
689
|
+
if (!path) {
|
|
690
|
+
return null;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
const pathLocale = path.split("/")[1] as Locales;
|
|
694
|
+
|
|
695
|
+
const isLocaleRoute = locales
|
|
696
|
+
.filter((locale) => middleware.prefixDefault || locale !== defaultLocale)
|
|
697
|
+
.some((locale) => locale.toString() === pathLocale);
|
|
698
|
+
|
|
699
|
+
if (isLocaleRoute) {
|
|
700
|
+
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
return (
|
|
704
|
+
<AppLocalized
|
|
705
|
+
locale={!middleware.prefixDefault ? defaultLocale : undefined}
|
|
706
|
+
>
|
|
707
|
+
{children}
|
|
708
|
+
</AppLocalized>
|
|
709
|
+
);
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Un composant de routeur qui configure des routes spécifiques à la langue.
|
|
714
|
+
* Il utilise preact-iso pour gérer la navigation et rendre des composants localisés.
|
|
715
|
+
*/
|
|
716
|
+
export const LocaleRouter: FunctionalComponent<{
|
|
717
|
+
children: ComponentChildren;
|
|
718
|
+
}> = ({ children }) => (
|
|
719
|
+
<LocationProvider>
|
|
720
|
+
<RouterContent>{children}</RouterContent>
|
|
721
|
+
</LocationProvider>
|
|
722
|
+
);
|
|
723
|
+
```
|
|
724
|
+
|
|
725
|
+
```jsx fileName="src/components/LocaleRouter.jsx" codeFormat="esm"
|
|
726
|
+
// Importation des dépendances et fonctions nécessaires
|
|
727
|
+
import { configuration, getPathWithoutLocale } from "intlayer";
|
|
728
|
+
import { IntlayerProvider } from "preact-intlayer";
|
|
729
|
+
import { LocationProvider, useLocation } from "preact-iso";
|
|
730
|
+
import { useEffect } from "preact/hooks";
|
|
731
|
+
import { h } from "preact"; // Requis pour JSX
|
|
732
|
+
|
|
733
|
+
// Déstructuration de la configuration depuis Intlayer
|
|
734
|
+
const { internationalization, middleware } = configuration;
|
|
735
|
+
const { locales, defaultLocale } = internationalization;
|
|
736
|
+
|
|
737
|
+
const Navigate = ({ to, replace }) => {
|
|
738
|
+
const { route } = useLocation();
|
|
739
|
+
useEffect(() => {
|
|
740
|
+
route(to, replace);
|
|
741
|
+
}, [to, replace, route]);
|
|
742
|
+
return null;
|
|
743
|
+
};
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Un composant qui gère la localisation et enveloppe les enfants avec le contexte de langue approprié.
|
|
747
|
+
* Il gère la détection et la validation de la langue basée sur l'URL.
|
|
748
|
+
*/
|
|
749
|
+
const AppLocalized = ({ children, locale }) => {
|
|
750
|
+
const { path: pathname, url } = useLocation();
|
|
751
|
+
|
|
752
|
+
if (!url) {
|
|
753
|
+
return null;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
const search = url.substring(pathname.length);
|
|
757
|
+
|
|
758
|
+
// Détermine la langue actuelle, en utilisant la langue par défaut si non fournie
|
|
759
|
+
const currentLocale = locale ?? defaultLocale;
|
|
760
|
+
|
|
761
|
+
// Supprime le préfixe de langue du chemin pour construire un chemin de base
|
|
762
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
763
|
+
pathname // Chemin actuel de l'URL
|
|
764
|
+
);
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
...
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Si middleware.prefixDefault est vrai, la locale par défaut doit toujours être préfixée.
|
|
771
|
+
*/
|
|
772
|
+
if (middleware.prefixDefault) {
|
|
773
|
+
// Valider la locale
|
|
774
|
+
if (!locale || !locales.includes(locale)) {
|
|
775
|
+
// Rediriger vers la locale par défaut avec le chemin mis à jour
|
|
776
|
+
return (
|
|
777
|
+
<Navigate
|
|
778
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
779
|
+
replace // Remplacer l'entrée actuelle de l'historique par la nouvelle
|
|
780
|
+
/>
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
// Envelopper les enfants avec IntlayerProvider et définir la locale actuelle
|
|
785
|
+
return (
|
|
786
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
787
|
+
);
|
|
788
|
+
} else {
|
|
789
|
+
/**
|
|
790
|
+
* Lorsque middleware.prefixDefault est faux, la locale par défaut n'est pas préfixée.
|
|
791
|
+
* Assurez-vous que la locale actuelle est valide et n'est pas la locale par défaut.
|
|
792
|
+
*/
|
|
793
|
+
if (
|
|
794
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
795
|
+
!locales
|
|
796
|
+
.filter(
|
|
797
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Exclure la locale par défaut
|
|
798
|
+
)
|
|
799
|
+
.includes(currentLocale) // Vérifier si la locale actuelle est dans la liste des locales valides
|
|
800
|
+
) {
|
|
801
|
+
// Rediriger vers le chemin sans préfixe de locale
|
|
802
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// Envelopper les enfants avec IntlayerProvider et définir la locale actuelle
|
|
806
|
+
return (
|
|
807
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
808
|
+
);
|
|
809
|
+
}
|
|
810
|
+
};
|
|
811
|
+
|
|
812
|
+
const RouterContent = ({ children }) => {
|
|
813
|
+
const { path } = useLocation();
|
|
814
|
+
|
|
815
|
+
if (!path) {
|
|
816
|
+
return null;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
const pathLocale = path.split("/")[1];
|
|
820
|
+
|
|
821
|
+
const isLocaleRoute = locales
|
|
822
|
+
.filter((locale) => middleware.prefixDefault || locale !== defaultLocale)
|
|
823
|
+
.some((locale) => locale.toString() === pathLocale);
|
|
824
|
+
|
|
825
|
+
if (isLocaleRoute) {
|
|
826
|
+
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
return (
|
|
830
|
+
<AppLocalized
|
|
831
|
+
locale={!middleware.prefixDefault ? defaultLocale : undefined}
|
|
832
|
+
>
|
|
833
|
+
{children}
|
|
834
|
+
</AppLocalized>
|
|
835
|
+
);
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* Un composant routeur qui configure des routes spécifiques à la locale.
|
|
840
|
+
* Il utilise preact-iso pour gérer la navigation et rendre des composants localisés.
|
|
841
|
+
*/
|
|
842
|
+
export const LocaleRouter = ({ children }) => (
|
|
843
|
+
<LocationProvider>
|
|
844
|
+
<RouterContent>{children}</RouterContent>
|
|
845
|
+
</LocationProvider>
|
|
846
|
+
);
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
```jsx fileName="src/components/LocaleRouter.cjsx" codeFormat="commonjs"
|
|
850
|
+
// Importation des dépendances et fonctions nécessaires
|
|
851
|
+
const { configuration, getPathWithoutLocale } = require("intlayer");
|
|
852
|
+
const { IntlayerProvider } = require("preact-intlayer");
|
|
853
|
+
const { LocationProvider, useLocation } = require("preact-iso");
|
|
854
|
+
const { useEffect } = require("preact/hooks");
|
|
855
|
+
const { h } = require("preact"); // Requis pour JSX
|
|
856
|
+
|
|
857
|
+
// Déstructuration de la configuration depuis Intlayer
|
|
858
|
+
const { internationalization, middleware } = configuration;
|
|
859
|
+
const { locales, defaultLocale } = internationalization;
|
|
860
|
+
|
|
861
|
+
const Navigate = ({ to, replace }) => {
|
|
862
|
+
const { route } = useLocation();
|
|
863
|
+
useEffect(() => {
|
|
864
|
+
route(to, replace);
|
|
865
|
+
}, [to, replace, route]);
|
|
866
|
+
return null;
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Un composant qui gère la localisation et enveloppe les enfants avec le contexte de locale approprié.
|
|
871
|
+
* Il gère la détection et la validation de la locale basée sur l'URL.
|
|
872
|
+
*/
|
|
873
|
+
const AppLocalized = ({ children, locale }) => {
|
|
874
|
+
const { path: pathname, url } = useLocation();
|
|
875
|
+
|
|
876
|
+
if (!url) {
|
|
877
|
+
return null;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
const search = url.substring(pathname.length);
|
|
881
|
+
|
|
882
|
+
// Déterminer la locale actuelle, en revenant à la locale par défaut si non fournie
|
|
883
|
+
const currentLocale = locale ?? defaultLocale;
|
|
884
|
+
|
|
885
|
+
// Supprimer le préfixe de locale du chemin pour construire un chemin de base
|
|
886
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
887
|
+
pathname // Chemin URL actuel
|
|
888
|
+
);
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Si middleware.prefixDefault est vrai, la locale par défaut doit toujours être préfixée.
|
|
892
|
+
*/
|
|
893
|
+
if (middleware.prefixDefault) {
|
|
894
|
+
// Valider la locale
|
|
895
|
+
if (!locale || !locales.includes(locale)) {
|
|
896
|
+
// Rediriger vers la locale par défaut avec le chemin mis à jour
|
|
897
|
+
return (
|
|
898
|
+
<Navigate
|
|
899
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
900
|
+
replace // Remplacer l'entrée actuelle de l'historique par la nouvelle
|
|
901
|
+
/>
|
|
902
|
+
);
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
// Envelopper les enfants avec IntlayerProvider et définir la locale actuelle
|
|
906
|
+
return (
|
|
907
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
908
|
+
);
|
|
909
|
+
} else {
|
|
910
|
+
/**
|
|
911
|
+
* Lorsque middleware.prefixDefault est faux, la locale par défaut n'est pas préfixée.
|
|
912
|
+
* Assurez-vous que la locale actuelle est valide et n'est pas la locale par défaut.
|
|
913
|
+
*/
|
|
914
|
+
if (
|
|
915
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
916
|
+
!locales
|
|
917
|
+
.filter(
|
|
918
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Exclure la locale par défaut
|
|
919
|
+
)
|
|
920
|
+
.includes(currentLocale) // Vérifier si la locale actuelle est dans la liste des locales valides
|
|
921
|
+
) {
|
|
922
|
+
// Rediriger vers le chemin sans préfixe de locale
|
|
923
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// Envelopper les enfants avec IntlayerProvider et définir la locale actuelle
|
|
927
|
+
return (
|
|
928
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
929
|
+
);
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
|
|
933
|
+
const RouterContent = ({ children }) => {
|
|
934
|
+
const { path } = useLocation();
|
|
935
|
+
|
|
936
|
+
if (!path) {
|
|
937
|
+
return null;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
const pathLocale = path.split("/")[1];
|
|
941
|
+
|
|
942
|
+
const isLocaleRoute = locales
|
|
943
|
+
.filter((locale) => middleware.prefixDefault || locale !== defaultLocale)
|
|
944
|
+
.some((locale) => locale.toString() === pathLocale);
|
|
945
|
+
|
|
946
|
+
if (isLocaleRoute) {
|
|
947
|
+
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
return (
|
|
951
|
+
<AppLocalized
|
|
952
|
+
locale={!middleware.prefixDefault ? defaultLocale : undefined}
|
|
953
|
+
>
|
|
954
|
+
{children}
|
|
955
|
+
</AppLocalized>
|
|
956
|
+
);
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* Un composant routeur qui configure des routes spécifiques à la locale.
|
|
961
|
+
* Il utilise preact-iso pour gérer la navigation et rendre des composants localisés.
|
|
962
|
+
*/
|
|
963
|
+
const LocaleRouter = ({ children }) => (
|
|
964
|
+
<LocationProvider>
|
|
965
|
+
<RouterContent>{children}</RouterContent>
|
|
966
|
+
</LocationProvider>
|
|
967
|
+
);
|
|
968
|
+
|
|
969
|
+
module.exports = { LocaleRouter };
|
|
970
|
+
```
|
|
971
|
+
|
|
972
|
+
Ensuite, vous pouvez utiliser le composant `LocaleRouter` dans votre application :
|
|
973
|
+
|
|
974
|
+
```tsx fileName="src/app.tsx" codeFormat="typescript"
|
|
975
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
976
|
+
import type { FunctionalComponent } from "preact";
|
|
977
|
+
// ... Votre composant AppContent (défini à l'étape 5)
|
|
978
|
+
|
|
979
|
+
const App: FunctionalComponent = () => (
|
|
980
|
+
<LocaleRouter>
|
|
981
|
+
<AppContent />
|
|
982
|
+
</LocaleRouter>
|
|
983
|
+
);
|
|
984
|
+
|
|
985
|
+
export default App;
|
|
986
|
+
```
|
|
987
|
+
|
|
988
|
+
```jsx fileName="src/app.jsx" codeFormat="esm"
|
|
989
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
990
|
+
// ... Votre composant AppContent (défini à l'étape 5)
|
|
991
|
+
|
|
992
|
+
const App = () => (
|
|
993
|
+
<LocaleRouter>
|
|
994
|
+
<AppContent />
|
|
995
|
+
</LocaleRouter>
|
|
996
|
+
);
|
|
997
|
+
|
|
998
|
+
export default App;
|
|
999
|
+
```
|
|
1000
|
+
|
|
1001
|
+
```jsx fileName="src/app.cjsx" codeFormat="commonjs"
|
|
1002
|
+
const { LocaleRouter } = require("./components/LocaleRouter");
|
|
1003
|
+
// ... Votre composant AppContent (défini à l'étape 5)
|
|
1004
|
+
|
|
1005
|
+
const App = () => (
|
|
1006
|
+
<LocaleRouter>
|
|
1007
|
+
<AppContent />
|
|
1008
|
+
</LocaleRouter>
|
|
1009
|
+
);
|
|
1010
|
+
|
|
1011
|
+
module.exports = App;
|
|
1012
|
+
```
|
|
1013
|
+
|
|
1014
|
+
En parallèle, vous pouvez également utiliser le `intLayerMiddlewarePlugin` pour ajouter un routage côté serveur à votre application. Ce plugin détectera automatiquement la locale actuelle en fonction de l'URL et définira le cookie de locale approprié. Si aucune locale n'est spécifiée, le plugin déterminera la locale la plus appropriée en fonction des préférences linguistiques du navigateur de l'utilisateur. Si aucune locale n'est détectée, il redirigera vers la locale par défaut.
|
|
1015
|
+
|
|
1016
|
+
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
1017
|
+
import { defineConfig } from "vite";
|
|
1018
|
+
import preact from "@preact/preset-vite";
|
|
1019
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
1020
|
+
|
|
1021
|
+
// https://vitejs.dev/config/
|
|
1022
|
+
export default defineConfig({
|
|
1023
|
+
plugins: [preact(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1024
|
+
});
|
|
1025
|
+
```
|
|
1026
|
+
|
|
1027
|
+
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
1028
|
+
import { defineConfig } from "vite";
|
|
1029
|
+
import preact from "@preact/preset-vite";
|
|
1030
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
1031
|
+
|
|
1032
|
+
// https://vitejs.dev/config/
|
|
1033
|
+
|
|
1034
|
+
const { defineConfig } = require("vite");
|
|
1035
|
+
const preact = require("@preact/preset-vite");
|
|
1036
|
+
const { intlayerPlugin, intLayerMiddlewarePlugin } = require("vite-intlayer");
|
|
1037
|
+
|
|
1038
|
+
// https://vitejs.dev/config/
|
|
1039
|
+
module.exports = defineConfig({
|
|
1040
|
+
plugins: [preact(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1041
|
+
});
|
|
1042
|
+
```
|
|
1043
|
+
|
|
1044
|
+
### (Optionnel) Étape 8 : Modifier l'URL lorsque la langue change
|
|
1045
|
+
|
|
1046
|
+
Pour modifier l'URL lorsque la langue change, vous pouvez utiliser la propriété `onLocaleChange` fournie par le hook `useLocale`. En parallèle, vous pouvez utiliser `useLocation` et `route` de `preact-iso` pour mettre à jour le chemin de l'URL.
|
|
1047
|
+
|
|
1048
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
1049
|
+
import { useLocation, route } from "preact-iso";
|
|
1050
|
+
import {
|
|
1051
|
+
Locales,
|
|
1052
|
+
getHTMLTextDir,
|
|
1053
|
+
getLocaleName,
|
|
1054
|
+
getLocalizedUrl,
|
|
1055
|
+
} from "intlayer";
|
|
1056
|
+
import { useLocale } from "preact-intlayer";
|
|
1057
|
+
import type { FunctionalComponent } from "preact";
|
|
1058
|
+
|
|
1059
|
+
const LocaleSwitcher: FunctionalComponent = () => {
|
|
1060
|
+
const location = useLocation();
|
|
1061
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1062
|
+
onLocaleChange: (newLocale) => {
|
|
1063
|
+
const currentFullPath = location.url; // preact-iso fournit l'URL complète
|
|
1064
|
+
// Construire l'URL avec la langue mise à jour
|
|
1065
|
+
// Exemple : /fr/about?foo=bar
|
|
1066
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1067
|
+
|
|
1068
|
+
// Mettre à jour le chemin de l'URL
|
|
1069
|
+
route(pathWithLocale, true); // true pour remplacer
|
|
1070
|
+
},
|
|
1071
|
+
});
|
|
1072
|
+
|
|
1073
|
+
return (
|
|
1074
|
+
<div>
|
|
1075
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1076
|
+
<div id="localePopover" popover="auto">
|
|
1077
|
+
{availableLocales.map((localeItem) => (
|
|
1078
|
+
<a
|
|
1079
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1080
|
+
hreflang={localeItem}
|
|
1081
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1082
|
+
onClick={(e) => {
|
|
1083
|
+
e.preventDefault();
|
|
1084
|
+
setLocale(localeItem);
|
|
1085
|
+
// La navigation programmatique après avoir défini la langue sera gérée par onLocaleChange
|
|
1086
|
+
}}
|
|
1087
|
+
key={localeItem}
|
|
1088
|
+
>
|
|
1089
|
+
<span>
|
|
1090
|
+
{/* Langue - ex. FR */}
|
|
1091
|
+
{localeItem}
|
|
1092
|
+
</span>
|
|
1093
|
+
<span>
|
|
1094
|
+
{/* Langue dans sa propre locale - ex. Français */}
|
|
1095
|
+
{getLocaleName(localeItem, localeItem)}
|
|
1096
|
+
</span>
|
|
1097
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1098
|
+
{/* Langue dans la locale actuelle - ex. Francés avec la locale actuelle définie sur Locales.SPANISH */}
|
|
1099
|
+
{getLocaleName(localeItem, locale)}
|
|
1100
|
+
</span>
|
|
1101
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1102
|
+
{/* Langue en anglais - ex. French */}
|
|
1103
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1104
|
+
</span>
|
|
1105
|
+
</a>
|
|
1106
|
+
))}
|
|
1107
|
+
</div>
|
|
1108
|
+
</div>
|
|
1109
|
+
);
|
|
1110
|
+
};
|
|
1111
|
+
|
|
1112
|
+
export default LocaleSwitcher;
|
|
1113
|
+
```
|
|
1114
|
+
|
|
1115
|
+
```jsx fileName="src/components/LocaleSwitcher.jsx" codeFormat="esm"
|
|
1116
|
+
import { useLocation, route } from "preact-iso";
|
|
1117
|
+
import {
|
|
1118
|
+
Locales,
|
|
1119
|
+
getHTMLTextDir,
|
|
1120
|
+
getLocaleName,
|
|
1121
|
+
getLocalizedUrl,
|
|
1122
|
+
} from "intlayer";
|
|
1123
|
+
import { useLocale } from "preact-intlayer";
|
|
1124
|
+
import { h } from "preact"; // Pour JSX
|
|
1125
|
+
|
|
1126
|
+
const LocaleSwitcher = () => {
|
|
1127
|
+
const location = useLocation();
|
|
1128
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1129
|
+
onLocaleChange: (newLocale) => {
|
|
1130
|
+
const currentFullPath = location.url;
|
|
1131
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1132
|
+
route(pathWithLocale, true);
|
|
1133
|
+
},
|
|
1134
|
+
});
|
|
1135
|
+
|
|
1136
|
+
return (
|
|
1137
|
+
<div>
|
|
1138
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1139
|
+
<div id="localePopover" popover="auto">
|
|
1140
|
+
{availableLocales.map((localeItem) => (
|
|
1141
|
+
<a
|
|
1142
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1143
|
+
hreflang={localeItem}
|
|
1144
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1145
|
+
onClick={(e) => {
|
|
1146
|
+
e.preventDefault();
|
|
1147
|
+
setLocale(localeItem);
|
|
1148
|
+
}}
|
|
1149
|
+
key={localeItem}
|
|
1150
|
+
>
|
|
1151
|
+
<span>{localeItem}</span>
|
|
1152
|
+
<span>{getLocaleName(localeItem, localeItem)}</span>
|
|
1153
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1154
|
+
{getLocaleName(localeItem, locale)}
|
|
1155
|
+
</span>
|
|
1156
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1157
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1158
|
+
</span>
|
|
1159
|
+
</a>
|
|
1160
|
+
))}
|
|
1161
|
+
</div>
|
|
1162
|
+
</div>
|
|
1163
|
+
);
|
|
1164
|
+
};
|
|
1165
|
+
|
|
1166
|
+
export default LocaleSwitcher;
|
|
1167
|
+
```
|
|
1168
|
+
|
|
1169
|
+
```jsx fileName="src/components/LocaleSwitcher.cjsx" codeFormat="commonjs"
|
|
1170
|
+
const { useLocation, route } = require("preact-iso");
|
|
1171
|
+
const {
|
|
1172
|
+
Locales,
|
|
1173
|
+
getHTMLTextDir,
|
|
1174
|
+
getLocaleName,
|
|
1175
|
+
getLocalizedUrl,
|
|
1176
|
+
} = require("intlayer");
|
|
1177
|
+
const { useLocale } = require("preact-intlayer");
|
|
1178
|
+
const { h } = require("preact"); // Pour JSX
|
|
1179
|
+
|
|
1180
|
+
const LocaleSwitcher = () => {
|
|
1181
|
+
const location = useLocation();
|
|
1182
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1183
|
+
onLocaleChange: (newLocale) => {
|
|
1184
|
+
const currentFullPath = location.url;
|
|
1185
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1186
|
+
route(pathWithLocale, true);
|
|
1187
|
+
},
|
|
1188
|
+
});
|
|
1189
|
+
|
|
1190
|
+
return (
|
|
1191
|
+
<div>
|
|
1192
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1193
|
+
<div id="localePopover" popover="auto">
|
|
1194
|
+
{availableLocales.map((localeItem) => (
|
|
1195
|
+
<a
|
|
1196
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1197
|
+
hreflang={localeItem}
|
|
1198
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1199
|
+
onClick={(e) => {
|
|
1200
|
+
e.preventDefault();
|
|
1201
|
+
setLocale(localeItem);
|
|
1202
|
+
}}
|
|
1203
|
+
key={localeItem}
|
|
1204
|
+
>
|
|
1205
|
+
<span>{localeItem}</span>
|
|
1206
|
+
<span>{getLocaleName(localeItem, localeItem)}</span>
|
|
1207
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1208
|
+
{getLocaleName(localeItem, locale)}
|
|
1209
|
+
</span>
|
|
1210
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1211
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1212
|
+
</span>
|
|
1213
|
+
</a>
|
|
1214
|
+
))}
|
|
1215
|
+
</div>
|
|
1216
|
+
</div>
|
|
1217
|
+
);
|
|
1218
|
+
};
|
|
1219
|
+
|
|
1220
|
+
module.exports = LocaleSwitcher;
|
|
1221
|
+
```
|
|
1222
|
+
|
|
1223
|
+
> Références de la documentation :
|
|
1224
|
+
|
|
1225
|
+
> - [`useLocale` hook](https://github.com/aymericzip/intlayer/blob/main/docs/fr/packages/react-intlayer/useLocale.md) (L'API est similaire pour `preact-intlayer`)
|
|
1226
|
+
|
|
1227
|
+
> - [`getLocaleName` hook](https://github.com/aymericzip/intlayer/blob/main/docs/fr/packages/intlayer/getLocaleName.md)
|
|
1228
|
+
|
|
1229
|
+
> - [`getLocalizedUrl` hook](https://github.com/aymericzip/intlayer/blob/main/docs/fr/packages/intlayer/getLocalizedUrl.md)
|
|
1230
|
+
|
|
1231
|
+
> - [`getHTMLTextDir` hook](https://github.com/aymericzip/intlayer/blob/main/docs/fr/packages/intlayer/getHTMLTextDir.md)
|
|
1232
|
+
|
|
1233
|
+
> - [`hreflang` attribute](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
|
|
1234
|
+
|
|
1235
|
+
> - [`lang` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
|
|
1236
|
+
|
|
1237
|
+
> - [`dir` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
|
|
1238
|
+
|
|
1239
|
+
> - [`aria-current` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1240
|
+
|
|
1241
|
+
> - [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
1242
|
+
|
|
1243
|
+
---
|
|
1244
|
+
|
|
1245
|
+
### (Optionnel) Étape 9 : Changer les attributs de langue et de direction HTML
|
|
1246
|
+
|
|
1247
|
+
Lorsque votre application prend en charge plusieurs langues, il est crucial de mettre à jour les attributs `lang` et `dir` de la balise `<html>` pour correspondre à la langue actuelle. Cela garantit :
|
|
1248
|
+
|
|
1249
|
+
- **Accessibilité** : Les lecteurs d'écran et les technologies d'assistance s'appuient sur l'attribut `lang` correct pour prononcer et interpréter le contenu avec précision.
|
|
1250
|
+
|
|
1251
|
+
- **SEO** : Les moteurs de recherche utilisent l'attribut `lang` pour déterminer la langue de votre page, aidant à fournir le contenu localisé approprié dans les résultats de recherche.
|
|
1252
|
+
|
|
1253
|
+
En mettant à jour ces attributs dynamiquement lorsque la langue change, vous garantissez une expérience cohérente et accessible pour les utilisateurs dans toutes les langues prises en charge.
|
|
1254
|
+
|
|
1255
|
+
#### Implémentation du Hook
|
|
1256
|
+
|
|
1257
|
+
Créez un hook personnalisé pour gérer les attributs HTML. Le hook écoute les changements de langue et met à jour les attributs en conséquence :
|
|
1258
|
+
|
|
1259
|
+
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
|
|
1260
|
+
import { useEffect } from "preact/hooks";
|
|
1261
|
+
import { useLocale } from "preact-intlayer";
|
|
1262
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1263
|
+
|
|
1264
|
+
/**
|
|
1265
|
+
* Met à jour les attributs `lang` et `dir` de l'élément HTML <html> en fonction de la langue actuelle.
|
|
1266
|
+
* - `lang` : Informe les navigateurs et moteurs de recherche de la langue de la page.
|
|
1267
|
+
* - `dir` : Assure le bon ordre de lecture (par exemple, 'ltr' pour l'anglais, 'rtl' pour l'arabe).
|
|
1268
|
+
*
|
|
1269
|
+
* Cette mise à jour dynamique est essentielle pour un rendu correct du texte, l'accessibilité et le SEO.
|
|
1270
|
+
*/
|
|
1271
|
+
export const useI18nHTMLAttributes = () => {
|
|
1272
|
+
const { locale } = useLocale();
|
|
1273
|
+
|
|
1274
|
+
useEffect(() => {
|
|
1275
|
+
// Met à jour l'attribut de langue avec la langue actuelle.
|
|
1276
|
+
document.documentElement.lang = locale;
|
|
1277
|
+
|
|
1278
|
+
// Définit la direction du texte en fonction de la langue actuelle.
|
|
1279
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1280
|
+
}, [locale]);
|
|
1281
|
+
};
|
|
1282
|
+
```
|
|
1283
|
+
|
|
1284
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.jsx" codeFormat="esm"
|
|
1285
|
+
import { useEffect } from "preact/hooks";
|
|
1286
|
+
import { useLocale } from "preact-intlayer";
|
|
1287
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1288
|
+
|
|
1289
|
+
/**
|
|
1290
|
+
* Met à jour les attributs `lang` et `dir` de l'élément HTML <html> en fonction de la langue actuelle.
|
|
1291
|
+
*/
|
|
1292
|
+
export const useI18nHTMLAttributes = () => {
|
|
1293
|
+
const { locale } = useLocale();
|
|
1294
|
+
|
|
1295
|
+
useEffect(() => {
|
|
1296
|
+
document.documentElement.lang = locale;
|
|
1297
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1298
|
+
}, [locale]);
|
|
1299
|
+
};
|
|
1300
|
+
```
|
|
1301
|
+
|
|
1302
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.cjsx" codeFormat="commonjs"
|
|
1303
|
+
const { useEffect } = require("preact/hooks");
|
|
1304
|
+
const { useLocale } = require("preact-intlayer");
|
|
1305
|
+
const { getHTMLTextDir } = require("intlayer");
|
|
1306
|
+
|
|
1307
|
+
/**
|
|
1308
|
+
* Met à jour les attributs `lang` et `dir` de l'élément HTML <html> en fonction de la langue actuelle.
|
|
1309
|
+
*/
|
|
1310
|
+
const useI18nHTMLAttributes = () => {
|
|
1311
|
+
const { locale } = useLocale();
|
|
1312
|
+
|
|
1313
|
+
useEffect(() => {
|
|
1314
|
+
document.documentElement.lang = locale;
|
|
1315
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1316
|
+
}, [locale]);
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
module.exports = { useI18nHTMLAttributes };
|
|
1320
|
+
```
|
|
1321
|
+
|
|
1322
|
+
#### Utilisation du Hook dans votre application
|
|
1323
|
+
|
|
1324
|
+
Intégrez le hook dans votre composant principal pour que les attributs HTML soient mis à jour à chaque changement de langue :
|
|
1325
|
+
|
|
1326
|
+
```tsx fileName="src/app.tsx" codeFormat="typescript"
|
|
1327
|
+
import type { FunctionalComponent } from "preact";
|
|
1328
|
+
import { IntlayerProvider } from "preact-intlayer"; // useIntlayer déjà importé si AppContent en a besoin
|
|
1329
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1330
|
+
import "./app.css";
|
|
1331
|
+
// Définition de AppContent depuis l'étape 5
|
|
1332
|
+
|
|
1333
|
+
const AppWithHooks: FunctionalComponent = () => {
|
|
1334
|
+
// Applique le hook pour mettre à jour les attributs lang et dir de la balise <html> en fonction de la langue.
|
|
1335
|
+
useI18nHTMLAttributes();
|
|
1336
|
+
|
|
1337
|
+
// Supposons que AppContent est votre composant principal d'affichage de contenu depuis l'étape 5
|
|
1338
|
+
return <AppContent />;
|
|
1339
|
+
};
|
|
1340
|
+
|
|
1341
|
+
const App: FunctionalComponent = () => (
|
|
1342
|
+
<IntlayerProvider>
|
|
1343
|
+
<AppWithHooks />
|
|
1344
|
+
</IntlayerProvider>
|
|
1345
|
+
);
|
|
1346
|
+
|
|
1347
|
+
export default App;
|
|
1348
|
+
```
|
|
1349
|
+
|
|
1350
|
+
```jsx fileName="src/app.jsx" codeFormat="esm"
|
|
1351
|
+
import { IntlayerProvider } from "preact-intlayer";
|
|
1352
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1353
|
+
import "./app.css";
|
|
1354
|
+
// Définition de AppContent depuis l'étape 5
|
|
1355
|
+
|
|
1356
|
+
const AppWithHooks = () => {
|
|
1357
|
+
useI18nHTMLAttributes();
|
|
1358
|
+
return <AppContent />;
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1361
|
+
const App = () => (
|
|
1362
|
+
<IntlayerProvider>
|
|
1363
|
+
<AppWithHooks />
|
|
1364
|
+
</IntlayerProvider>
|
|
1365
|
+
);
|
|
1366
|
+
|
|
1367
|
+
export default App;
|
|
1368
|
+
```
|
|
1369
|
+
|
|
1370
|
+
```jsx fileName="src/app.cjsx" codeFormat="commonjs"
|
|
1371
|
+
const { IntlayerProvider } = require("preact-intlayer");
|
|
1372
|
+
const { useI18nHTMLAttributes } = require("./hooks/useI18nHTMLAttributes");
|
|
1373
|
+
require("./app.css");
|
|
1374
|
+
// Définition de AppContent depuis l'étape 5
|
|
1375
|
+
|
|
1376
|
+
const AppWithHooks = () => {
|
|
1377
|
+
useI18nHTMLAttributes();
|
|
1378
|
+
return <AppContent />;
|
|
1379
|
+
};
|
|
1380
|
+
|
|
1381
|
+
const App = () => (
|
|
1382
|
+
<IntlayerProvider>
|
|
1383
|
+
<AppWithHooks />
|
|
1384
|
+
</IntlayerProvider>
|
|
1385
|
+
);
|
|
1386
|
+
|
|
1387
|
+
module.exports = App;
|
|
1388
|
+
```
|
|
1389
|
+
|
|
1390
|
+
En appliquant ces modifications, votre application :
|
|
1391
|
+
|
|
1392
|
+
- Garantira que l'attribut **langue** (`lang`) reflète correctement la langue actuelle, ce qui est important pour le SEO et le comportement des navigateurs.
|
|
1393
|
+
- Ajustera la **direction du texte** (`dir`) en fonction de la langue, améliorant la lisibilité et l'utilisabilité pour les langues avec des ordres de lecture différents.
|
|
1394
|
+
- Fournira une expérience plus **accessible**, car les technologies d'assistance dépendent de ces attributs pour fonctionner de manière optimale.
|
|
1395
|
+
|
|
1396
|
+
### (Optionnel) Étape 10 : Création d'un composant de lien localisé
|
|
1397
|
+
|
|
1398
|
+
Pour garantir que la navigation dans votre application respecte la langue actuelle, vous pouvez créer un composant `Link` personnalisé. Ce composant préfixe automatiquement les URL internes avec la langue actuelle.
|
|
1399
|
+
|
|
1400
|
+
Ce comportement est utile pour plusieurs raisons :
|
|
1401
|
+
|
|
1402
|
+
- **SEO et expérience utilisateur** : Les URL localisées aident les moteurs de recherche à indexer correctement les pages spécifiques à une langue et fournissent aux utilisateurs un contenu dans leur langue préférée.
|
|
1403
|
+
- **Cohérence** : En utilisant un lien localisé dans toute votre application, vous garantissez que la navigation reste dans la langue actuelle, évitant les changements de langue inattendus.
|
|
1404
|
+
- **Maintenabilité** : Centraliser la logique de localisation dans un seul composant simplifie la gestion des URL.
|
|
1405
|
+
|
|
1406
|
+
Pour Preact avec `preact-iso`, les balises `<a>` standard sont généralement utilisées pour la navigation, et `preact-iso` gère le routage. Si vous avez besoin d'une navigation programmatique au clic (par exemple, pour effectuer des actions avant de naviguer), vous pouvez utiliser la fonction `route` de `useLocation`. Voici comment créer un composant d'ancre personnalisé qui localise les URL :
|
|
1407
|
+
|
|
1408
|
+
```tsx fileName="src/components/LocalizedLink.tsx" codeFormat="typescript"
|
|
1409
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1410
|
+
import { useLocale, useLocation, route } from "preact-intlayer"; // Supposons que useLocation et route peuvent être de preact-iso via preact-intlayer s'ils sont réexportés, ou importés directement
|
|
1411
|
+
// Si non réexportés, importez directement : import { useLocation, route } from "preact-iso";
|
|
1412
|
+
import type { JSX } from "preact"; // Pour HTMLAttributes
|
|
1413
|
+
import { forwardRef } from "preact/compat"; // Pour transmettre les refs
|
|
1414
|
+
|
|
1415
|
+
export interface LocalizedLinkProps
|
|
1416
|
+
extends JSX.HTMLAttributes<HTMLAnchorElement> {
|
|
1417
|
+
href: string;
|
|
1418
|
+
replace?: boolean; // Optionnel : pour remplacer l'état de l'historique
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
/**
|
|
1422
|
+
* Fonction utilitaire pour vérifier si une URL donnée est externe.
|
|
1423
|
+
* Si l'URL commence par http:// ou https://, elle est considérée comme externe.
|
|
1424
|
+
*/
|
|
1425
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1426
|
+
/^https?:\/\//.test(href ?? "");
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
* Un composant Link personnalisé qui adapte l'attribut href en fonction de la langue actuelle.
|
|
1430
|
+
* Pour les liens internes, il utilise `getLocalizedUrl` pour préfixer l'URL avec la langue (par exemple, /fr/about).
|
|
1431
|
+
* Cela garantit que la navigation reste dans le même contexte linguistique.
|
|
1432
|
+
* Il utilise une balise <a> standard mais peut déclencher une navigation côté client en utilisant la fonction `route` de preact-iso.
|
|
1433
|
+
*/
|
|
1434
|
+
export const LocalizedLink = forwardRef<HTMLAnchorElement, LocalizedLinkProps>(
|
|
1435
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1436
|
+
const { locale } = useLocale();
|
|
1437
|
+
const location = useLocation(); // de preact-iso
|
|
1438
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1439
|
+
|
|
1440
|
+
const hrefI18n =
|
|
1441
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1442
|
+
|
|
1443
|
+
const handleClick = (event: JSX.TargetedMouseEvent<HTMLAnchorElement>) => {
|
|
1444
|
+
if (onClick) {
|
|
1445
|
+
onClick(event);
|
|
1446
|
+
}
|
|
1447
|
+
if (
|
|
1448
|
+
!isExternalLink &&
|
|
1449
|
+
href && // Assurez-vous que href est défini
|
|
1450
|
+
event.button === 0 && // Clic gauche
|
|
1451
|
+
!event.metaKey &&
|
|
1452
|
+
|
|
1453
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1454
|
+
import { useLocale } from "preact-intlayer";
|
|
1455
|
+
import { useLocation, route } from "preact-iso"; // Importé depuis preact-iso
|
|
1456
|
+
import { forwardRef } from "preact/compat";
|
|
1457
|
+
import { h } from "preact"; // Pour JSX
|
|
1458
|
+
|
|
1459
|
+
export const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1460
|
+
|
|
1461
|
+
export const LocalizedLink = forwardRef(
|
|
1462
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1463
|
+
const { locale } = useLocale();
|
|
1464
|
+
const location = useLocation();
|
|
1465
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1466
|
+
|
|
1467
|
+
const hrefI18n =
|
|
1468
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1469
|
+
|
|
1470
|
+
const handleClick = (event) => {
|
|
1471
|
+
if (onClick) {
|
|
1472
|
+
onClick(event);
|
|
1473
|
+
}
|
|
1474
|
+
if (
|
|
1475
|
+
!isExternalLink &&
|
|
1476
|
+
href &&
|
|
1477
|
+
event.button === 0 &&
|
|
1478
|
+
!event.metaKey &&
|
|
1479
|
+
!event.ctrlKey &&
|
|
1480
|
+
!event.shiftKey &&
|
|
1481
|
+
!event.altKey &&
|
|
1482
|
+
!props.target
|
|
1483
|
+
) {
|
|
1484
|
+
event.preventDefault();
|
|
1485
|
+
if (location.url !== hrefI18n) {
|
|
1486
|
+
route(hrefI18n, replace);
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
};
|
|
1490
|
+
|
|
1491
|
+
return (
|
|
1492
|
+
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1493
|
+
{children}
|
|
1494
|
+
</a>
|
|
1495
|
+
);
|
|
1496
|
+
}
|
|
1497
|
+
);
|
|
1498
|
+
```
|
|
1499
|
+
|
|
1500
|
+
```jsx fileName="src/components/LocalizedLink.cjsx" codeFormat="commonjs"
|
|
1501
|
+
const { getLocalizedUrl } = require("intlayer");
|
|
1502
|
+
const { useLocale } = require("preact-intlayer");
|
|
1503
|
+
const { useLocation, route } = require("preact-iso"); // Importé depuis preact-iso
|
|
1504
|
+
const { forwardRef } = require("preact/compat");
|
|
1505
|
+
const { h } = require("preact"); // Pour JSX
|
|
1506
|
+
|
|
1507
|
+
const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1508
|
+
|
|
1509
|
+
const LocalizedLink = forwardRef(
|
|
1510
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1511
|
+
const { locale } = useLocale();
|
|
1512
|
+
const location = useLocation();
|
|
1513
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1514
|
+
|
|
1515
|
+
const hrefI18n =
|
|
1516
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1517
|
+
|
|
1518
|
+
const handleClick = (event) => {
|
|
1519
|
+
if (onClick) {
|
|
1520
|
+
onClick(event);
|
|
1521
|
+
}
|
|
1522
|
+
if (
|
|
1523
|
+
!isExternalLink &&
|
|
1524
|
+
href &&
|
|
1525
|
+
event.button === 0 &&
|
|
1526
|
+
!event.metaKey &&
|
|
1527
|
+
!event.ctrlKey &&
|
|
1528
|
+
!event.shiftKey &&
|
|
1529
|
+
!event.altKey &&
|
|
1530
|
+
!props.target
|
|
1531
|
+
) {
|
|
1532
|
+
event.preventDefault();
|
|
1533
|
+
if (location.url !== hrefI18n) {
|
|
1534
|
+
route(hrefI18n, replace);
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
};
|
|
1538
|
+
|
|
1539
|
+
return (
|
|
1540
|
+
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1541
|
+
{children}
|
|
1542
|
+
</a>
|
|
1543
|
+
);
|
|
1544
|
+
}
|
|
1545
|
+
);
|
|
1546
|
+
|
|
1547
|
+
module.exports = { LocalizedLink, checkIsExternalLink };
|
|
1548
|
+
```
|
|
1549
|
+
|
|
1550
|
+
#### Comment cela fonctionne
|
|
1551
|
+
|
|
1552
|
+
- **Détection des liens externes** :
|
|
1553
|
+
La fonction utilitaire `checkIsExternalLink` détermine si une URL est externe. Les liens externes ne sont pas modifiés.
|
|
1554
|
+
- **Récupération de la locale actuelle** :
|
|
1555
|
+
Le hook `useLocale` fournit la locale actuelle.
|
|
1556
|
+
- **Localisation de l'URL** :
|
|
1557
|
+
Pour les liens internes, `getLocalizedUrl` ajoute un préfixe à l'URL avec la locale actuelle.
|
|
1558
|
+
- **Navigation côté client** :
|
|
1559
|
+
La fonction `handleClick` vérifie s'il s'agit d'un lien interne et si la navigation standard doit être empêchée. Si c'est le cas, elle utilise la fonction `route` de `preact-iso` (obtenue via `useLocation` ou directement importée) pour effectuer une navigation côté client. Cela permet un comportement de type SPA sans rechargement complet de la page.
|
|
1560
|
+
- **Retour du lien** :
|
|
1561
|
+
Le composant retourne un élément `<a>` avec l'URL localisée et le gestionnaire de clic personnalisé.
|
|
1562
|
+
|
|
1563
|
+
### Configurer TypeScript
|
|
1564
|
+
|
|
1565
|
+
Intlayer utilise l'augmentation de module pour tirer parti de TypeScript et renforcer votre base de code.
|
|
1566
|
+
|
|
1567
|
+

|
|
1568
|
+
|
|
1569
|
+

|
|
1570
|
+
|
|
1571
|
+
Assurez-vous que votre configuration TypeScript inclut les types générés automatiquement.
|
|
1572
|
+
|
|
1573
|
+
```json5 fileName="tsconfig.json"
|
|
1574
|
+
{
|
|
1575
|
+
// ... Vos configurations TypeScript existantes
|
|
1576
|
+
"compilerOptions": {
|
|
1577
|
+
// ...
|
|
1578
|
+
"jsx": "react-jsx",
|
|
1579
|
+
"jsxImportSource": "preact", // Recommandé pour Preact 10+
|
|
1580
|
+
// ...
|
|
1581
|
+
},
|
|
1582
|
+
"include": [
|
|
1583
|
+
// ... Vos configurations TypeScript existantes
|
|
1584
|
+
".intlayer/**/*.ts", // Inclure les types générés automatiquement
|
|
1585
|
+
],
|
|
1586
|
+
}
|
|
1587
|
+
```
|
|
1588
|
+
|
|
1589
|
+
> Assurez-vous que votre `tsconfig.json` est configuré pour Preact, en particulier `jsx` et `jsxImportSource` ou `jsxFactory`/`jsxFragmentFactory` pour les anciennes versions de Preact si vous n'utilisez pas les paramètres par défaut de `preset-vite`.
|
|
1590
|
+
|
|
1591
|
+
### Configuration Git
|
|
1592
|
+
|
|
1593
|
+
Il est recommandé d'ignorer les fichiers générés par Intlayer. Cela vous permet d'éviter de les ajouter à votre dépôt Git.
|
|
1594
|
+
|
|
1595
|
+
Pour ce faire, vous pouvez ajouter les instructions suivantes à votre fichier `.gitignore` :
|
|
1596
|
+
|
|
1597
|
+
```plaintext
|
|
1598
|
+
# Ignorer les fichiers générés par Intlayer
|
|
1599
|
+
.intlayer
|
|
1600
|
+
```
|
|
1601
|
+
|
|
1602
|
+
### Extension VS Code
|
|
1603
|
+
|
|
1604
|
+
Pour améliorer votre expérience de développement avec Intlayer, vous pouvez installer l'extension officielle **Intlayer VS Code Extension**.
|
|
1605
|
+
|
|
1606
|
+
[Installer depuis le VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
1607
|
+
|
|
1608
|
+
Cette extension fournit :
|
|
1609
|
+
|
|
1610
|
+
- **Autocomplétion** pour les clés de traduction.
|
|
1611
|
+
- **Détection d'erreurs en temps réel** pour les traductions manquantes.
|
|
1612
|
+
- **Aperçus en ligne** du contenu traduit.
|
|
1613
|
+
- **Actions rapides** pour créer et mettre à jour facilement les traductions.
|
|
1614
|
+
|
|
1615
|
+
Pour plus de détails sur l'utilisation de l'extension, consultez la [documentation de l'extension Intlayer VS Code](https://intlayer.org/doc/vs-code-extension).
|
|
1616
|
+
|
|
1617
|
+
---
|
|
1618
|
+
|
|
1619
|
+
### Aller plus loin
|
|
1620
|
+
|
|
1621
|
+
Pour aller plus loin, vous pouvez implémenter l'[éditeur visuel](https://github.com/aymericzip/intlayer/blob/main/docs/fr/intlayer_visual_editor.md) ou externaliser votre contenu en utilisant le [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/fr/intlayer_CMS.md).
|