@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,1580 @@
|
|
|
1
|
+
# Introduzione all'Internazionalizzazione (i18n) con Intlayer, Vite e React
|
|
2
|
+
|
|
3
|
+
<iframe title="Vite + React: Build a Multilingual App from Scratch using Intlayer" class="m-auto aspect-[16/9] w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/dS9L7uJeak4?autoplay=0&origin=http://intlayer.org&controls=0&rel=1"/>
|
|
4
|
+
|
|
5
|
+
Vedi [Application Template](https://github.com/aymericzip/intlayer-vite-react-template) su GitHub.
|
|
6
|
+
|
|
7
|
+
## Cos'è Intlayer?
|
|
8
|
+
|
|
9
|
+
**Intlayer** è una libreria open-source innovativa per l'internazionalizzazione (i18n) progettata per semplificare il supporto multilingue nelle applicazioni web moderne.
|
|
10
|
+
|
|
11
|
+
Con Intlayer, puoi:
|
|
12
|
+
|
|
13
|
+
- **Gestire facilmente le traduzioni** utilizzando dizionari dichiarativi a livello di componente.
|
|
14
|
+
- **Localizzare dinamicamente metadati**, percorsi e contenuti.
|
|
15
|
+
- **Garantire il supporto TypeScript** con tipi autogenerati, migliorando l'autocompletamento e il rilevamento degli errori.
|
|
16
|
+
- **Beneficiare di funzionalità avanzate**, come il rilevamento e il cambio dinamico della lingua.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Guida passo-passo per configurare Intlayer in un'applicazione Vite e React
|
|
21
|
+
|
|
22
|
+
### Passo 1: Installa le dipendenze
|
|
23
|
+
|
|
24
|
+
Installa i pacchetti necessari utilizzando npm:
|
|
25
|
+
|
|
26
|
+
```bash packageManager="npm"
|
|
27
|
+
npm install intlayer react-intlayer vite-intlayer
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```bash packageManager="pnpm"
|
|
31
|
+
pnpm add intlayer react-intlayer vite-intlayer
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```bash packageManager="yarn"
|
|
35
|
+
yarn add intlayer react-intlayer vite-intlayer
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- **intlayer**
|
|
39
|
+
|
|
40
|
+
Il pacchetto principale che fornisce strumenti di internazionalizzazione per la gestione della configurazione, traduzione, [dichiarazione dei contenuti](https://github.com/aymericzip/intlayer/blob/main/docs/it/dictionary/get_started.md), transpilation e [comandi CLI](https://github.com/aymericzip/intlayer/blob/main/docs/it/intlayer_cli.md).
|
|
41
|
+
|
|
42
|
+
- **react-intlayer**
|
|
43
|
+
Il pacchetto che integra Intlayer con l'applicazione React. Fornisce provider di contesto e hook per l'internazionalizzazione in React.
|
|
44
|
+
|
|
45
|
+
- **vite-intlayer**
|
|
46
|
+
Include il plugin Vite per integrare Intlayer con il [bundler Vite](https://vite.dev/guide/why.html#why-bundle-for-production), oltre a middleware per rilevare la lingua preferita dell'utente, gestire i cookie e gestire i reindirizzamenti URL.
|
|
47
|
+
|
|
48
|
+
### Passo 2: Configurazione del progetto
|
|
49
|
+
|
|
50
|
+
Crea un file di configurazione per configurare le lingue della tua applicazione:
|
|
51
|
+
|
|
52
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
53
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
54
|
+
|
|
55
|
+
const config: IntlayerConfig = {
|
|
56
|
+
internationalization: {
|
|
57
|
+
locales: [
|
|
58
|
+
Locales.ENGLISH,
|
|
59
|
+
Locales.FRENCH,
|
|
60
|
+
Locales.SPANISH,
|
|
61
|
+
// Le tue altre lingue
|
|
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
|
+
internationalization: {
|
|
76
|
+
locales: [
|
|
77
|
+
Locales.ENGLISH,
|
|
78
|
+
Locales.FRENCH,
|
|
79
|
+
Locales.SPANISH,
|
|
80
|
+
// Le tue altre lingue
|
|
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
|
+
internationalization: {
|
|
95
|
+
locales: [
|
|
96
|
+
Locales.ENGLISH,
|
|
97
|
+
Locales.FRENCH,
|
|
98
|
+
Locales.SPANISH,
|
|
99
|
+
// Le tue altre lingue
|
|
100
|
+
],
|
|
101
|
+
defaultLocale: Locales.ENGLISH,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
module.exports = config;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
> Tramite questo file di configurazione, puoi configurare URL localizzati, reindirizzamenti middleware, nomi dei cookie, la posizione e l'estensione delle dichiarazioni dei contenuti, disabilitare i log di Intlayer nella console e altro. Per un elenco completo dei parametri disponibili, consulta la [documentazione di configurazione](https://github.com/aymericzip/intlayer/blob/main/docs/it/configuration.md).
|
|
109
|
+
|
|
110
|
+
### Passo 3: Integra Intlayer nella configurazione di Vite
|
|
111
|
+
|
|
112
|
+
Aggiungi il plugin intlayer alla tua configurazione.
|
|
113
|
+
|
|
114
|
+
```typescript fileName="vite.config.ts" codeFormat="typescript"
|
|
115
|
+
import { defineConfig } from "vite";
|
|
116
|
+
import react from "@vitejs/plugin-react-swc";
|
|
117
|
+
import { intlayerPlugin } from "vite-intlayer";
|
|
118
|
+
|
|
119
|
+
// https://vitejs.dev/config/
|
|
120
|
+
export default defineConfig({
|
|
121
|
+
plugins: [react(), intlayerPlugin()],
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```javascript fileName="vite.config.mjs" codeFormat="esm"
|
|
126
|
+
import { defineConfig } from "vite";
|
|
127
|
+
import react from "@vitejs/plugin-react-swc";
|
|
128
|
+
import { intlayerPlugin } from "vite-intlayer";
|
|
129
|
+
|
|
130
|
+
// https://vitejs.dev/config/
|
|
131
|
+
export default defineConfig({
|
|
132
|
+
plugins: [react(), intlayerPlugin()],
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```javascript fileName="vite.config.cjs" codeFormat="commonjs"
|
|
137
|
+
const { defineConfig } = require("vite");
|
|
138
|
+
const react = require("@vitejs/plugin-react-swc");
|
|
139
|
+
const { intlayerPlugin } = require("vite-intlayer");
|
|
140
|
+
|
|
141
|
+
// https://vitejs.dev/config/
|
|
142
|
+
module.exports = defineConfig({
|
|
143
|
+
plugins: [react(), intlayerPlugin()],
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
> Il plugin `intlayerPlugin()` di Vite viene utilizzato per integrare Intlayer con Vite. Garantisce la costruzione dei file di dichiarazione dei contenuti e li monitora in modalità sviluppo. Definisce le variabili di ambiente di Intlayer all'interno dell'applicazione Vite. Inoltre, fornisce alias per ottimizzare le prestazioni.
|
|
148
|
+
|
|
149
|
+
### Passo 4: Dichiarare i tuoi contenuti
|
|
150
|
+
|
|
151
|
+
Crea e gestisci le dichiarazioni dei tuoi contenuti per memorizzare le traduzioni:
|
|
152
|
+
|
|
153
|
+
```tsx fileName="src/app.content.tsx" contentDeclarationFormat="typescript"
|
|
154
|
+
import { t, type Dictionary } from "intlayer";
|
|
155
|
+
import type { ReactNode } from "react";
|
|
156
|
+
|
|
157
|
+
const appContent = {
|
|
158
|
+
key: "app",
|
|
159
|
+
content: {
|
|
160
|
+
viteLogo: t({
|
|
161
|
+
it: "Logo Vite",
|
|
162
|
+
en: "Vite logo",
|
|
163
|
+
fr: "Logo Vite",
|
|
164
|
+
es: "Logo Vite",
|
|
165
|
+
}),
|
|
166
|
+
reactLogo: t({
|
|
167
|
+
it: "Logo React",
|
|
168
|
+
en: "React logo",
|
|
169
|
+
fr: "Logo React",
|
|
170
|
+
es: "Logo React",
|
|
171
|
+
}),
|
|
172
|
+
|
|
173
|
+
title: "Vite + React",
|
|
174
|
+
|
|
175
|
+
count: t({
|
|
176
|
+
it: "il conteggio è ",
|
|
177
|
+
en: "count is ",
|
|
178
|
+
fr: "le compte est ",
|
|
179
|
+
es: "el recuento es ",
|
|
180
|
+
}),
|
|
181
|
+
|
|
182
|
+
edit: t<ReactNode>({
|
|
183
|
+
it: (
|
|
184
|
+
<>
|
|
185
|
+
Modifica <code>src/App.tsx</code> e salva per testare HMR
|
|
186
|
+
</>
|
|
187
|
+
),
|
|
188
|
+
en: (
|
|
189
|
+
<>
|
|
190
|
+
Edit <code>src/App.tsx</code> and save to test HMR
|
|
191
|
+
</>
|
|
192
|
+
),
|
|
193
|
+
fr: (
|
|
194
|
+
<>
|
|
195
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
196
|
+
</>
|
|
197
|
+
),
|
|
198
|
+
es: (
|
|
199
|
+
<>
|
|
200
|
+
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
201
|
+
</>
|
|
202
|
+
),
|
|
203
|
+
}),
|
|
204
|
+
|
|
205
|
+
readTheDocs: t({
|
|
206
|
+
it: "Clicca sui loghi di Vite e React per saperne di più",
|
|
207
|
+
en: "Click on the Vite and React logos to learn more",
|
|
208
|
+
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
209
|
+
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
210
|
+
}),
|
|
211
|
+
},
|
|
212
|
+
} satisfies Dictionary;
|
|
213
|
+
|
|
214
|
+
export default appContent;
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
```javascript fileName="src/app.content.mjs" contentDeclarationFormat="esm"
|
|
218
|
+
import { t } from "intlayer";
|
|
219
|
+
|
|
220
|
+
/** @type {import('intlayer').Dictionary} */
|
|
221
|
+
const appContent = {
|
|
222
|
+
key: "app",
|
|
223
|
+
content: {
|
|
224
|
+
viteLogo: t({
|
|
225
|
+
it: "Logo Vite",
|
|
226
|
+
en: "Vite logo",
|
|
227
|
+
fr: "Logo Vite",
|
|
228
|
+
es: "Logo Vite",
|
|
229
|
+
}),
|
|
230
|
+
reactLogo: t({
|
|
231
|
+
it: "Logo React",
|
|
232
|
+
en: "React logo",
|
|
233
|
+
fr: "Logo React",
|
|
234
|
+
es: "Logo React",
|
|
235
|
+
}),
|
|
236
|
+
|
|
237
|
+
title: "Vite + React",
|
|
238
|
+
|
|
239
|
+
count: t({
|
|
240
|
+
it: "il conteggio è ",
|
|
241
|
+
en: "count is ",
|
|
242
|
+
fr: "le compte est ",
|
|
243
|
+
es: "el recuento es ",
|
|
244
|
+
}),
|
|
245
|
+
|
|
246
|
+
edit:
|
|
247
|
+
t <
|
|
248
|
+
ReactNode >
|
|
249
|
+
{
|
|
250
|
+
// Ricorda di importare React se utilizzi un nodo React nei tuoi contenuti
|
|
251
|
+
it: (
|
|
252
|
+
<>
|
|
253
|
+
Modifica <code>src/App.tsx</code> e salva per testare HMR
|
|
254
|
+
</>
|
|
255
|
+
),
|
|
256
|
+
en: (
|
|
257
|
+
<>
|
|
258
|
+
Edit <code>src/App.tsx</code> and save to test HMR
|
|
259
|
+
</>
|
|
260
|
+
),
|
|
261
|
+
fr: (
|
|
262
|
+
<>
|
|
263
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
264
|
+
</>
|
|
265
|
+
),
|
|
266
|
+
es: (
|
|
267
|
+
<>
|
|
268
|
+
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
269
|
+
</>
|
|
270
|
+
),
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
readTheDocs: t({
|
|
274
|
+
it: "Clicca sui loghi di Vite e React per saperne di più",
|
|
275
|
+
en: "Click on the Vite and React logos to learn more",
|
|
276
|
+
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
277
|
+
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
278
|
+
}),
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
export default appContent;
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
```javascript fileName="src/app.content.cjs" contentDeclarationFormat="commonjs"
|
|
286
|
+
const { t } = require("intlayer");
|
|
287
|
+
|
|
288
|
+
/** @type {import('intlayer').Dictionary} */
|
|
289
|
+
const appContent = {
|
|
290
|
+
key: "app",
|
|
291
|
+
content: {
|
|
292
|
+
viteLogo: t({
|
|
293
|
+
it: "Logo Vite",
|
|
294
|
+
en: "Vite logo",
|
|
295
|
+
fr: "Logo Vite",
|
|
296
|
+
es: "Logo Vite",
|
|
297
|
+
}),
|
|
298
|
+
reactLogo: t({
|
|
299
|
+
it: "Logo React",
|
|
300
|
+
en: "React logo",
|
|
301
|
+
fr: "Logo React",
|
|
302
|
+
es: "Logo React",
|
|
303
|
+
}),
|
|
304
|
+
|
|
305
|
+
title: "Vite + React",
|
|
306
|
+
|
|
307
|
+
count: t({
|
|
308
|
+
it: "il conteggio è ",
|
|
309
|
+
en: "count is ",
|
|
310
|
+
fr: "le compte est ",
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
{
|
|
314
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
315
|
+
"key": "app",
|
|
316
|
+
"content": {
|
|
317
|
+
"viteLogo": {
|
|
318
|
+
"nodeType": "translation",
|
|
319
|
+
"translation": {
|
|
320
|
+
"en": "Vite logo",
|
|
321
|
+
"fr": "Logo Vite",
|
|
322
|
+
"es": "Logo Vite",
|
|
323
|
+
"it": "Logo Vite"
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
"reactLogo": {
|
|
327
|
+
"nodeType": "translation",
|
|
328
|
+
"translation": {
|
|
329
|
+
"en": "React logo",
|
|
330
|
+
"fr": "Logo React",
|
|
331
|
+
"es": "Logo React",
|
|
332
|
+
"it": "Logo React"
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
"title": {
|
|
336
|
+
"nodeType": "translation",
|
|
337
|
+
"translation": {
|
|
338
|
+
"en": "Vite + React",
|
|
339
|
+
"fr": "Vite + React",
|
|
340
|
+
"es": "Vite + React",
|
|
341
|
+
"it": "Vite + React"
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
"count": {
|
|
345
|
+
"nodeType": "translation",
|
|
346
|
+
"translation": {
|
|
347
|
+
"en": "count is ",
|
|
348
|
+
"fr": "le compte est ",
|
|
349
|
+
"es": "el recuento es ",
|
|
350
|
+
"it": "il conteggio è "
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
"edit": {
|
|
354
|
+
"nodeType": "translation",
|
|
355
|
+
"translation": {
|
|
356
|
+
"en": "Edit src/App.tsx and save to test HMR",
|
|
357
|
+
"fr": "Éditez src/App.tsx et enregistrez pour tester HMR",
|
|
358
|
+
"es": "Edita src/App.tsx y guarda para probar HMR",
|
|
359
|
+
"it": "Modifica src/App.tsx e salva per testare HMR"
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
"readTheDocs": {
|
|
363
|
+
"nodeType": "translation",
|
|
364
|
+
"translation": {
|
|
365
|
+
"en": "Click on the Vite and React logos to learn more",
|
|
366
|
+
"fr": "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
367
|
+
"es": "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
368
|
+
"it": "Clicca sui loghi Vite e React per saperne di più"
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
> Le dichiarazioni dei contenuti possono essere definite ovunque nella tua applicazione purché siano incluse nella directory `contentDir` (di default, `./src`). E corrispondano all'estensione del file di dichiarazione dei contenuti (di default, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
376
|
+
|
|
377
|
+
> Per maggiori dettagli, consulta la [documentazione sulla dichiarazione dei contenuti](https://github.com/aymericzip/intlayer/blob/main/docs/it/dictionary/get_started.md).
|
|
378
|
+
|
|
379
|
+
> Se il tuo file di contenuti include codice TSX, considera di importare `import React from "react";` nel tuo file di contenuti.
|
|
380
|
+
|
|
381
|
+
### Step 5: Utilizza Intlayer nel tuo codice
|
|
382
|
+
|
|
383
|
+
Accedi ai tuoi dizionari di contenuti in tutta l'applicazione:
|
|
384
|
+
|
|
385
|
+
```tsx {5,9} fileName="src/App.tsx" codeFormat="typescript"
|
|
386
|
+
import { useState, type FC } from "react";
|
|
387
|
+
import reactLogo from "./assets/react.svg";
|
|
388
|
+
import viteLogo from "/vite.svg";
|
|
389
|
+
import "./App.css";
|
|
390
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
391
|
+
|
|
392
|
+
const AppContent: FC = () => {
|
|
393
|
+
const [count, setCount] = useState(0);
|
|
394
|
+
const content = useIntlayer("app");
|
|
395
|
+
|
|
396
|
+
return (
|
|
397
|
+
<>
|
|
398
|
+
<div>
|
|
399
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
400
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
401
|
+
</a>
|
|
402
|
+
<a href="https://react.dev" target="_blank">
|
|
403
|
+
<img
|
|
404
|
+
src={reactLogo}
|
|
405
|
+
className="logo react"
|
|
406
|
+
alt={content.reactLogo.value}
|
|
407
|
+
/>
|
|
408
|
+
</a>
|
|
409
|
+
</div>
|
|
410
|
+
<h1>{content.title}</h1>
|
|
411
|
+
<div className="card">
|
|
412
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
413
|
+
{content.count}
|
|
414
|
+
{count}
|
|
415
|
+
</button>
|
|
416
|
+
<p>{content.edit}</p>
|
|
417
|
+
</div>
|
|
418
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
419
|
+
</>
|
|
420
|
+
);
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
const App: FC = () => (
|
|
424
|
+
<IntlayerProvider>
|
|
425
|
+
<AppContent />
|
|
426
|
+
</IntlayerProvider>
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
export default App;
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
```tsx {5,9} fileName="src/App.msx" codeFormat="esm"
|
|
433
|
+
import { useState } from "react";
|
|
434
|
+
import reactLogo from "./assets/react.svg";
|
|
435
|
+
import viteLogo from "/vite.svg";
|
|
436
|
+
import "./App.css";
|
|
437
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
438
|
+
|
|
439
|
+
const AppContent = () => {
|
|
440
|
+
const [count, setCount] = useState(0);
|
|
441
|
+
const content = useIntlayer("app");
|
|
442
|
+
|
|
443
|
+
return (
|
|
444
|
+
<>
|
|
445
|
+
<div>
|
|
446
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
447
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
448
|
+
</a>
|
|
449
|
+
<a href="https://react.dev" target="_blank">
|
|
450
|
+
<img
|
|
451
|
+
src={reactLogo}
|
|
452
|
+
className="logo react"
|
|
453
|
+
alt={content.reactLogo.value}
|
|
454
|
+
/>
|
|
455
|
+
</a>
|
|
456
|
+
</div>
|
|
457
|
+
<h1>{content.title}</h1>
|
|
458
|
+
<div className="card">
|
|
459
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
460
|
+
{content.count}
|
|
461
|
+
{count}
|
|
462
|
+
</button>
|
|
463
|
+
<p>{content.edit}</p>
|
|
464
|
+
</div>
|
|
465
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
466
|
+
</>
|
|
467
|
+
);
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
const App = () => (
|
|
471
|
+
<IntlayerProvider>
|
|
472
|
+
<AppContent />
|
|
473
|
+
</IntlayerProvider>
|
|
474
|
+
);
|
|
475
|
+
|
|
476
|
+
export default App;
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
```tsx {5,9} fileName="src/App.csx" codeFormat="commonjs"
|
|
480
|
+
const { useState } = require("react");
|
|
481
|
+
const reactLogo = require("./assets/react.svg");
|
|
482
|
+
const viteLogo = require("/vite.svg");
|
|
483
|
+
require("./App.css");
|
|
484
|
+
const { IntlayerProvider, useIntlayer } = require("react-intlayer");
|
|
485
|
+
|
|
486
|
+
const AppContent = () => {
|
|
487
|
+
const [count, setCount] = useState(0);
|
|
488
|
+
const content = useIntlayer("app");
|
|
489
|
+
|
|
490
|
+
return (
|
|
491
|
+
<>
|
|
492
|
+
<div>
|
|
493
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
494
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
495
|
+
</a>
|
|
496
|
+
<a href="https://react.dev" target="_blank">
|
|
497
|
+
<img
|
|
498
|
+
src={reactLogo}
|
|
499
|
+
className="logo react"
|
|
500
|
+
alt={content.reactLogo.value}
|
|
501
|
+
/>
|
|
502
|
+
</a>
|
|
503
|
+
</div>
|
|
504
|
+
<h1>{content.title}</h1>
|
|
505
|
+
<div className="card">
|
|
506
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
507
|
+
{content.count}
|
|
508
|
+
{count}
|
|
509
|
+
</button>
|
|
510
|
+
<p>{content.edit}</p>
|
|
511
|
+
</div>
|
|
512
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
513
|
+
</>
|
|
514
|
+
);
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
const App = () => (
|
|
518
|
+
<IntlayerProvider>
|
|
519
|
+
<AppContent />
|
|
520
|
+
</IntlayerProvider>
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
module.exports = App;
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
> Se vuoi utilizzare il tuo contenuto in un attributo `string`, come `alt`, `title`, `href`, `aria-label`, ecc., devi chiamare il valore della funzione, come:
|
|
527
|
+
|
|
528
|
+
> ```jsx
|
|
529
|
+
>
|
|
530
|
+
> ```
|
|
531
|
+
|
|
532
|
+
> <img src={content.image.src.value} alt={content.image.value} />
|
|
533
|
+
|
|
534
|
+
> ```
|
|
535
|
+
>
|
|
536
|
+
> ```
|
|
537
|
+
|
|
538
|
+
> Per saperne di più sul hook `useIntlayer`, consulta la [documentazione](https://github.com/aymericzip/intlayer/blob/main/docs/it/packages/react-intlayer/useIntlayer.md).
|
|
539
|
+
|
|
540
|
+
### (Opzionale) Step 6: Cambia la lingua del tuo contenuto
|
|
541
|
+
|
|
542
|
+
Per cambiare la lingua del tuo contenuto, puoi utilizzare la funzione `setLocale` fornita dal hook `useLocale`. Questa funzione ti permette di impostare la lingua dell'applicazione e aggiornare il contenuto di conseguenza.
|
|
543
|
+
|
|
544
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
545
|
+
import type { FC } from "react";
|
|
546
|
+
import { Locales } from "intlayer";
|
|
547
|
+
import { useLocale } from "react-intlayer";
|
|
548
|
+
|
|
549
|
+
const LocaleSwitcher: FC = () => {
|
|
550
|
+
const { setLocale } = useLocale();
|
|
551
|
+
|
|
552
|
+
return (
|
|
553
|
+
<button onClick={() => setLocale(Locales.English)}>
|
|
554
|
+
Cambia lingua in Inglese
|
|
555
|
+
</button>
|
|
556
|
+
);
|
|
557
|
+
};
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
```jsx fileName="src/components/LocaleSwitcher.msx" codeFormat="esm"
|
|
561
|
+
import { Locales } from "intlayer";
|
|
562
|
+
import { useLocale } from "react-intlayer";
|
|
563
|
+
|
|
564
|
+
const LocaleSwitcher = () => {
|
|
565
|
+
const { setLocale } = useLocale();
|
|
566
|
+
|
|
567
|
+
return (
|
|
568
|
+
<button onClick={() => setLocale(Locales.English)}>
|
|
569
|
+
Cambia lingua in Inglese
|
|
570
|
+
</button>
|
|
571
|
+
);
|
|
572
|
+
};
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
```jsx fileName="src/components/LocaleSwitcher.csx" codeFormat="commonjs"
|
|
576
|
+
const { Locales } = require("intlayer");
|
|
577
|
+
|
|
578
|
+
const { useLocale } = require("react-intlayer");
|
|
579
|
+
|
|
580
|
+
const LocaleSwitcher = () => {
|
|
581
|
+
const { setLocale } = useLocale();
|
|
582
|
+
|
|
583
|
+
return (
|
|
584
|
+
<button onClick={() => setLocale(Locales.English)}>
|
|
585
|
+
Cambia lingua in Inglese
|
|
586
|
+
</button>
|
|
587
|
+
);
|
|
588
|
+
};
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
> Per saperne di più sul hook `useLocale`, consulta la [documentazione](https://github.com/aymericzip/intlayer/blob/main/docs/it/packages/react-intlayer/useLocale.md).
|
|
592
|
+
|
|
593
|
+
### (Opzionale) Passo 7: Aggiungi il routing localizzato alla tua applicazione
|
|
594
|
+
|
|
595
|
+
Lo scopo di questo passo è creare percorsi unici per ogni lingua. Questo è utile per SEO e URL SEO-friendly.
|
|
596
|
+
Esempio:
|
|
597
|
+
|
|
598
|
+
```plaintext
|
|
599
|
+
- https://example.com/about
|
|
600
|
+
- https://example.com/es/about
|
|
601
|
+
- https://example.com/fr/about
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
> Per impostazione predefinita, i percorsi non sono prefissati per la lingua predefinita. Se desideri prefissare la lingua predefinita, puoi impostare l'opzione `middleware.prefixDefault` su `true` nella tua configurazione. Consulta la [documentazione di configurazione](https://github.com/aymericzip/intlayer/blob/main/docs/it/configuration.md) per maggiori informazioni.
|
|
605
|
+
|
|
606
|
+
Per aggiungere il routing localizzato alla tua applicazione, puoi creare un componente `LocaleRouter` che avvolge i percorsi della tua applicazione e gestisce il routing basato sulla lingua. Ecco un esempio utilizzando [React Router](https://reactrouter.com/home):
|
|
607
|
+
|
|
608
|
+
```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
|
|
609
|
+
// Importazione delle dipendenze e funzioni necessarie
|
|
610
|
+
import { type Locales, configuration, getPathWithoutLocale } from "intlayer"; // Funzioni e tipi utili da 'intlayer'
|
|
611
|
+
import type { FC, PropsWithChildren } from "react"; // Tipi React per componenti funzionali e props
|
|
612
|
+
import { IntlayerProvider } from "react-intlayer"; // Provider per il contesto di internazionalizzazione
|
|
613
|
+
import {
|
|
614
|
+
BrowserRouter,
|
|
615
|
+
Routes,
|
|
616
|
+
Route,
|
|
617
|
+
Navigate,
|
|
618
|
+
useLocation,
|
|
619
|
+
} from "react-router-dom"; // Componenti Router per gestire la navigazione
|
|
620
|
+
|
|
621
|
+
// Destrutturazione della configurazione da Intlayer
|
|
622
|
+
const { internationalization, middleware } = configuration;
|
|
623
|
+
const { locales, defaultLocale } = internationalization;
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Un componente che gestisce la localizzazione e avvolge i figli con il contesto di lingua appropriato.
|
|
627
|
+
* Gestisce il rilevamento e la validazione della lingua basata sull'URL.
|
|
628
|
+
*/
|
|
629
|
+
const AppLocalized: FC<PropsWithChildren<{ locale: Locales }>> = ({
|
|
630
|
+
children,
|
|
631
|
+
locale,
|
|
632
|
+
}) => {
|
|
633
|
+
const { pathname, search } = useLocation(); // Ottieni il percorso URL corrente
|
|
634
|
+
|
|
635
|
+
// Determina la lingua corrente, utilizzando quella predefinita se non fornita
|
|
636
|
+
const currentLocale = locale ?? defaultLocale;
|
|
637
|
+
|
|
638
|
+
// Rimuovi il prefisso della lingua dal percorso per costruire un percorso base
|
|
639
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
640
|
+
pathname // Percorso URL corrente
|
|
641
|
+
);
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Se middleware.prefixDefault è true, la lingua predefinita dovrebbe sempre essere prefissata.
|
|
645
|
+
*/
|
|
646
|
+
if (middleware.prefixDefault) {
|
|
647
|
+
// Valida la lingua
|
|
648
|
+
if (!locale || !locales.includes(locale)) {
|
|
649
|
+
// Reindirizza alla lingua predefinita con il percorso aggiornato
|
|
650
|
+
return (
|
|
651
|
+
<Navigate
|
|
652
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
653
|
+
replace // Sostituisci la voce corrente nella cronologia con quella nuova
|
|
654
|
+
/>
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// Avvolgi i figli con IntlayerProvider e imposta la lingua corrente
|
|
659
|
+
return (
|
|
660
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
661
|
+
);
|
|
662
|
+
} else {
|
|
663
|
+
/**
|
|
664
|
+
* Quando middleware.prefixDefault è false, la lingua predefinita non è prefissata.
|
|
665
|
+
* Assicurati che la lingua corrente sia valida e non quella predefinita.
|
|
666
|
+
*/
|
|
667
|
+
if (
|
|
668
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
669
|
+
!locales
|
|
670
|
+
.filter(
|
|
671
|
+
(locale) => locale.toString() !== defaultLocale.toString() // Escludi la lingua predefinita
|
|
672
|
+
)
|
|
673
|
+
.includes(currentLocale) // Controlla se la lingua corrente è nell'elenco delle lingue valide
|
|
674
|
+
) {
|
|
675
|
+
// Reindirizza al percorso senza prefisso di lingua
|
|
676
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// Avvolgi i figli con IntlayerProvider e imposta la lingua corrente
|
|
680
|
+
return (
|
|
681
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Un componente router che configura percorsi specifici per lingua.
|
|
688
|
+
* Utilizza React Router per gestire la navigazione e rendere i componenti localizzati.
|
|
689
|
+
*/
|
|
690
|
+
export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
|
|
691
|
+
<BrowserRouter>
|
|
692
|
+
<Routes>
|
|
693
|
+
{locales
|
|
694
|
+
.filter(
|
|
695
|
+
(locale) => middleware.prefixDefault || locale !== defaultLocale
|
|
696
|
+
)
|
|
697
|
+
.map((locale) => (
|
|
698
|
+
<Route
|
|
699
|
+
// Modello di percorso per catturare la lingua (es., /it/, /fr/) e abbinare tutti i percorsi successivi
|
|
700
|
+
path={`/${locale}/*`}
|
|
701
|
+
key={locale}
|
|
702
|
+
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // Avvolge i figli con la gestione della lingua
|
|
703
|
+
/>
|
|
704
|
+
))}
|
|
705
|
+
|
|
706
|
+
{
|
|
707
|
+
// Se il prefisso della lingua predefinita è disabilitato, rendi i figli direttamente al percorso radice
|
|
708
|
+
!middleware.prefixDefault && (
|
|
709
|
+
<Route
|
|
710
|
+
path="*"
|
|
711
|
+
element={
|
|
712
|
+
<AppLocalized locale={defaultLocale}>{children}</AppLocalized>
|
|
713
|
+
} // Avvolge i figli con la gestione della lingua
|
|
714
|
+
/>
|
|
715
|
+
)
|
|
716
|
+
}
|
|
717
|
+
</Routes>
|
|
718
|
+
</BrowserRouter>
|
|
719
|
+
);
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
```jsx fileName="src/components/LocaleRouter.mjx" codeFormat="esm"
|
|
723
|
+
// Importazione delle dipendenze e funzioni necessarie
|
|
724
|
+
import { configuration, getPathWithoutLocale } from "intlayer"; // Funzioni e tipi utili da 'intlayer'
|
|
725
|
+
import { IntlayerProvider } from "react-intlayer"; // Provider per il contesto di internazionalizzazione
|
|
726
|
+
import {
|
|
727
|
+
BrowserRouter,
|
|
728
|
+
Routes,
|
|
729
|
+
Route,
|
|
730
|
+
Navigate,
|
|
731
|
+
useLocation,
|
|
732
|
+
} from "react-router-dom"; // Componenti Router per gestire la navigazione
|
|
733
|
+
|
|
734
|
+
// Destrutturazione della configurazione da Intlayer
|
|
735
|
+
const { internationalization, middleware } = configuration;
|
|
736
|
+
const { locales, defaultLocale } = internationalization;
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Un componente che gestisce la localizzazione e avvolge i figli con il contesto di lingua appropriato.
|
|
740
|
+
* Gestisce il rilevamento e la validazione della lingua basata sull'URL.
|
|
741
|
+
*/
|
|
742
|
+
const AppLocalized = ({ children, locale }) => {
|
|
743
|
+
const { pathname, search } = useLocation(); // Ottieni il percorso URL corrente
|
|
744
|
+
|
|
745
|
+
// Determina la lingua corrente, utilizzando quella predefinita se non fornita
|
|
746
|
+
const currentLocale = locale ?? defaultLocale;
|
|
747
|
+
|
|
748
|
+
// Rimuovi il prefisso della lingua dal percorso per costruire un percorso base
|
|
749
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
750
|
+
pathname // Percorso URL corrente
|
|
751
|
+
);
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Se middleware.prefixDefault è true, la lingua predefinita dovrebbe sempre essere prefissata.
|
|
755
|
+
*/
|
|
756
|
+
if (middleware.prefixDefault) {
|
|
757
|
+
// Valida la lingua
|
|
758
|
+
if (!locale || !locales.includes(locale)) {
|
|
759
|
+
// Reindirizza alla lingua predefinita con il percorso aggiornato
|
|
760
|
+
return (
|
|
761
|
+
<Navigate
|
|
762
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
763
|
+
replace // Sostituisci la voce corrente nella cronologia con quella nuova
|
|
764
|
+
/>
|
|
765
|
+
);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
// Avvolgi i figli con IntlayerProvider e imposta la lingua corrente
|
|
769
|
+
return (
|
|
770
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
771
|
+
);
|
|
772
|
+
} else {
|
|
773
|
+
/**
|
|
774
|
+
* Quando middleware.prefixDefault è false, la lingua predefinita non è prefissata.
|
|
775
|
+
* Assicurati che la lingua corrente sia valida e non quella predefinita.
|
|
776
|
+
*/
|
|
777
|
+
if (
|
|
778
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
779
|
+
!locales
|
|
780
|
+
.filter(
|
|
781
|
+
(locale) => locale.toString() !== defaultLocale.toString() // Escludi la lingua predefinita
|
|
782
|
+
)
|
|
783
|
+
.includes(currentLocale) // Controlla se la lingua corrente è nell'elenco delle lingue valide
|
|
784
|
+
) {
|
|
785
|
+
// Reindirizza al percorso senza prefisso di lingua
|
|
786
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// Avvolgi i figli con IntlayerProvider e imposta la lingua corrente
|
|
790
|
+
return (
|
|
791
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
792
|
+
);
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Utilizza React Router per gestire la navigazione e rendere i componenti localizzati.
|
|
798
|
+
*/
|
|
799
|
+
export const LocaleRouter = ({ children }) => (
|
|
800
|
+
<BrowserRouter>
|
|
801
|
+
<Routes>
|
|
802
|
+
{locales
|
|
803
|
+
.filter(
|
|
804
|
+
(locale) => middleware.prefixDefault || locale !== defaultLocale
|
|
805
|
+
)
|
|
806
|
+
.map((locale) => (
|
|
807
|
+
<Route
|
|
808
|
+
// Modello di percorso per catturare la lingua (es., /en/, /fr/) e corrispondere a tutti i percorsi successivi
|
|
809
|
+
path={`/${locale}/*`}
|
|
810
|
+
key={locale}
|
|
811
|
+
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // Avvolge i figli con la gestione della lingua
|
|
812
|
+
/>
|
|
813
|
+
))}
|
|
814
|
+
|
|
815
|
+
{
|
|
816
|
+
// Se il prefisso della lingua predefinita è disabilitato, renderizza i figli direttamente al percorso radice
|
|
817
|
+
!middleware.prefixDefault && (
|
|
818
|
+
<Route
|
|
819
|
+
path="*"
|
|
820
|
+
element={
|
|
821
|
+
<AppLocalized locale={defaultLocale}>{children}</AppLocalized>
|
|
822
|
+
} // Avvolge i figli con la gestione della lingua
|
|
823
|
+
/>
|
|
824
|
+
)
|
|
825
|
+
}
|
|
826
|
+
</Routes>
|
|
827
|
+
</BrowserRouter>
|
|
828
|
+
);
|
|
829
|
+
```
|
|
830
|
+
|
|
831
|
+
```jsx fileName="src/components/LocaleRouter.cjx" codeFormat="commonjs"
|
|
832
|
+
// Importazione delle dipendenze e funzioni necessarie
|
|
833
|
+
const { configuration, getPathWithoutLocale } = require("intlayer"); // Funzioni e tipi utili da 'intlayer'
|
|
834
|
+
const { IntlayerProvider, useLocale } = require("react-intlayer"); // Provider per il contesto di internazionalizzazione
|
|
835
|
+
const {
|
|
836
|
+
BrowserRouter,
|
|
837
|
+
Routes,
|
|
838
|
+
Route,
|
|
839
|
+
Navigate,
|
|
840
|
+
useLocation,
|
|
841
|
+
} = require("react-router-dom"); // Componenti router per gestire la navigazione
|
|
842
|
+
|
|
843
|
+
// De-strutturazione della configurazione da Intlayer
|
|
844
|
+
const { internationalization, middleware } = configuration;
|
|
845
|
+
const { locales, defaultLocale } = internationalization;
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* Un componente che gestisce la localizzazione e avvolge i figli con il contesto della lingua appropriata.
|
|
849
|
+
* Gestisce il rilevamento e la validazione della lingua basata sull'URL.
|
|
850
|
+
*/
|
|
851
|
+
const AppLocalized = ({ children, locale }) => {
|
|
852
|
+
const { pathname, search } = useLocation(); // Ottieni il percorso URL corrente
|
|
853
|
+
|
|
854
|
+
// Determina la lingua corrente, utilizzando quella predefinita se non fornita
|
|
855
|
+
const currentLocale = locale ?? defaultLocale;
|
|
856
|
+
|
|
857
|
+
// Rimuovi il prefisso della lingua dal percorso per costruire un percorso base
|
|
858
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
859
|
+
pathname // Percorso URL corrente
|
|
860
|
+
);
|
|
861
|
+
|
|
862
|
+
/**
|
|
863
|
+
* Se middleware.prefixDefault è true, la lingua predefinita dovrebbe sempre essere prefissata.
|
|
864
|
+
*/
|
|
865
|
+
if (middleware.prefixDefault) {
|
|
866
|
+
// Valida la lingua
|
|
867
|
+
if (!locale || !locales.includes(locale)) {
|
|
868
|
+
// Reindirizza alla lingua predefinita con il percorso aggiornato
|
|
869
|
+
return (
|
|
870
|
+
<Navigate
|
|
871
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
872
|
+
replace // Sostituisci la voce corrente nella cronologia con quella nuova
|
|
873
|
+
/>
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// Avvolge i figli con IntlayerProvider e imposta la lingua corrente
|
|
878
|
+
return (
|
|
879
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
880
|
+
);
|
|
881
|
+
} else {
|
|
882
|
+
/**
|
|
883
|
+
* Quando middleware.prefixDefault è false, la lingua predefinita non è prefissata.
|
|
884
|
+
* Assicurati che la lingua corrente sia valida e non sia la lingua predefinita.
|
|
885
|
+
*/
|
|
886
|
+
if (
|
|
887
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
888
|
+
!locales
|
|
889
|
+
.filter(
|
|
890
|
+
(locale) => locale.toString() !== defaultLocale.toString() // Escludi la lingua predefinita
|
|
891
|
+
)
|
|
892
|
+
.includes(currentLocale) // Controlla se la lingua corrente è nell'elenco delle lingue valide
|
|
893
|
+
) {
|
|
894
|
+
// Reindirizza al percorso senza prefisso della lingua
|
|
895
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
// Avvolge i figli con IntlayerProvider e imposta la lingua corrente
|
|
899
|
+
return (
|
|
900
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
901
|
+
);
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Un componente router che configura percorsi specifici per la lingua.
|
|
907
|
+
* Utilizza React Router per gestire la navigazione e rendere i componenti localizzati.
|
|
908
|
+
*/
|
|
909
|
+
const LocaleRouter = ({ children }) => (
|
|
910
|
+
<BrowserRouter>
|
|
911
|
+
<Routes>
|
|
912
|
+
{locales
|
|
913
|
+
.filter(
|
|
914
|
+
(locale) => middleware.prefixDefault || locale !== defaultLocale
|
|
915
|
+
)
|
|
916
|
+
.map((locale) => (
|
|
917
|
+
<Route
|
|
918
|
+
// Modello di percorso per catturare la lingua (es., /en/, /fr/) e corrispondere a tutti i percorsi successivi
|
|
919
|
+
path={`/${locale}/*`}
|
|
920
|
+
key={locale}
|
|
921
|
+
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // Avvolge i figli con la gestione della lingua
|
|
922
|
+
/>
|
|
923
|
+
))}
|
|
924
|
+
|
|
925
|
+
{
|
|
926
|
+
// Se il prefisso della lingua predefinita è disabilitato, renderizza i figli direttamente al percorso radice
|
|
927
|
+
!middleware.prefixDefault && (
|
|
928
|
+
<Route
|
|
929
|
+
path="*"
|
|
930
|
+
element={
|
|
931
|
+
<AppLocalized locale={defaultLocale}>{children}</AppLocalized>
|
|
932
|
+
} // Avvolge i figli con la gestione della lingua
|
|
933
|
+
/>
|
|
934
|
+
)
|
|
935
|
+
}
|
|
936
|
+
</Routes>
|
|
937
|
+
</BrowserRouter>
|
|
938
|
+
);
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
Ora puoi utilizzare il componente `LocaleRouter` nella tua applicazione:
|
|
942
|
+
|
|
943
|
+
```tsx fileName="src/App.tsx" codeFormat="typescript"
|
|
944
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
945
|
+
import type { FC } from "react";
|
|
946
|
+
|
|
947
|
+
// ... Il tuo componente AppContent
|
|
948
|
+
|
|
949
|
+
const App: FC = () => (
|
|
950
|
+
<LocaleRouter>
|
|
951
|
+
<AppContent />
|
|
952
|
+
</LocaleRouter>
|
|
953
|
+
);
|
|
954
|
+
```
|
|
955
|
+
|
|
956
|
+
```jsx fileName="src/App.mjx" codeFormat="esm"
|
|
957
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
958
|
+
|
|
959
|
+
// ... Il tuo componente AppContent
|
|
960
|
+
|
|
961
|
+
const App = () => (
|
|
962
|
+
<LocaleRouter>
|
|
963
|
+
<AppContent />
|
|
964
|
+
</LocaleRouter>
|
|
965
|
+
);
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
```jsx fileName="src/App.cjx" codeFormat="commonjs"
|
|
969
|
+
const { LocaleRouter } = require("./components/LocaleRouter");
|
|
970
|
+
|
|
971
|
+
// ... Il tuo componente AppContent
|
|
972
|
+
|
|
973
|
+
const App = () => (
|
|
974
|
+
<LocaleRouter>
|
|
975
|
+
<AppContent />
|
|
976
|
+
</LocaleRouter>
|
|
977
|
+
);
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
In parallelo, puoi anche utilizzare il plugin `intLayerMiddlewarePlugin` per aggiungere il routing lato server alla tua applicazione. Questo plugin rileverà automaticamente la lingua corrente basandosi sull'URL e imposterà il cookie della lingua appropriato. Se non viene specificata alcuna lingua, il plugin determinerà la lingua più appropriata in base alle preferenze linguistiche del browser dell'utente. Se non viene rilevata alcuna lingua, reindirizzerà alla lingua predefinita.
|
|
981
|
+
|
|
982
|
+
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
983
|
+
import { defineConfig } from "vite";
|
|
984
|
+
import react from "@vitejs/plugin-react-swc";
|
|
985
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
986
|
+
|
|
987
|
+
// https://vitejs.dev/config/
|
|
988
|
+
export default defineConfig({
|
|
989
|
+
plugins: [react(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
990
|
+
});
|
|
991
|
+
```
|
|
992
|
+
|
|
993
|
+
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
994
|
+
import { defineConfig } from "vite";
|
|
995
|
+
import react from "@vitejs/plugin-react-swc";
|
|
996
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
997
|
+
|
|
998
|
+
// https://vitejs.dev/config/
|
|
999
|
+
export default defineConfig({
|
|
1000
|
+
plugins: [react(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1001
|
+
});
|
|
1002
|
+
```
|
|
1003
|
+
|
|
1004
|
+
```javascript {5,10} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
1005
|
+
const { defineConfig } = require("vite");
|
|
1006
|
+
const react = require("@vitejs/plugin-react-swc");
|
|
1007
|
+
const { intlayerPlugin, intLayerMiddlewarePlugin } = require("vite-intlayer");
|
|
1008
|
+
|
|
1009
|
+
// https://vitejs.dev/config/
|
|
1010
|
+
module.exports = defineConfig({
|
|
1011
|
+
plugins: [react(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1012
|
+
});
|
|
1013
|
+
```
|
|
1014
|
+
|
|
1015
|
+
### (Opzionale) Passaggio 8: Cambia l'URL quando cambia la lingua
|
|
1016
|
+
|
|
1017
|
+
Per cambiare l'URL quando cambia la lingua, puoi utilizzare la prop `onLocaleChange` fornita dal hook `useLocale`. In parallelo, puoi utilizzare i hook `useLocation` e `useNavigate` da `react-router-dom` per aggiornare il percorso URL.
|
|
1018
|
+
|
|
1019
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
1020
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
1021
|
+
import {
|
|
1022
|
+
Locales,
|
|
1023
|
+
getHTMLTextDir,
|
|
1024
|
+
getLocaleName,
|
|
1025
|
+
getLocalizedUrl,
|
|
1026
|
+
} from "intlayer";
|
|
1027
|
+
import { useLocale } from "react-intlayer";
|
|
1028
|
+
import { type FC } from "react";
|
|
1029
|
+
|
|
1030
|
+
const LocaleSwitcher: FC = () => {
|
|
1031
|
+
const { pathname, search } = useLocation(); // Ottieni il percorso URL corrente. Esempio: /fr/about?foo=bar
|
|
1032
|
+
const navigate = useNavigate();
|
|
1033
|
+
|
|
1034
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1035
|
+
onLocaleChange: (locale) => {
|
|
1036
|
+
// Costruire l'URL con la localizzazione aggiornata
|
|
1037
|
+
// Esempio: /es/about?foo=bar
|
|
1038
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
1039
|
+
|
|
1040
|
+
// Aggiornare il percorso dell'URL
|
|
1041
|
+
navigate(pathWithLocale);
|
|
1042
|
+
},
|
|
1043
|
+
});
|
|
1044
|
+
|
|
1045
|
+
return (
|
|
1046
|
+
<div>
|
|
1047
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1048
|
+
<div id="localePopover" popover="auto">
|
|
1049
|
+
{availableLocales.map((localeItem) => (
|
|
1050
|
+
<a
|
|
1051
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
1052
|
+
hrefLang={localeItem}
|
|
1053
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1054
|
+
onClick={(e) => {
|
|
1055
|
+
e.preventDefault();
|
|
1056
|
+
setLocale(localeItem);
|
|
1057
|
+
}}
|
|
1058
|
+
key={localeItem}
|
|
1059
|
+
>
|
|
1060
|
+
<span>
|
|
1061
|
+
{/* Locale - ad esempio FR */}
|
|
1062
|
+
{localeItem}
|
|
1063
|
+
</span>
|
|
1064
|
+
<span>
|
|
1065
|
+
{/* Lingua nella propria localizzazione - ad esempio Français */}
|
|
1066
|
+
{getLocaleName(localeItem, locale)}
|
|
1067
|
+
</span>
|
|
1068
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1069
|
+
{/* Lingua nella localizzazione corrente - ad esempio Francés con localizzazione corrente impostata su Locales.SPANISH */}
|
|
1070
|
+
{getLocaleName(localeItem)}
|
|
1071
|
+
</span>
|
|
1072
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1073
|
+
{/* Lingua in Inglese - ad esempio French */}
|
|
1074
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1075
|
+
</span>
|
|
1076
|
+
</a>
|
|
1077
|
+
))}
|
|
1078
|
+
</div>
|
|
1079
|
+
</div>
|
|
1080
|
+
);
|
|
1081
|
+
};
|
|
1082
|
+
```
|
|
1083
|
+
|
|
1084
|
+
```jsx fileName="src/components/LocaleSwitcher.msx" codeFormat="esm"
|
|
1085
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
1086
|
+
import {
|
|
1087
|
+
Locales,
|
|
1088
|
+
getHTMLTextDir,
|
|
1089
|
+
getLocaleName,
|
|
1090
|
+
getLocalizedUrl,
|
|
1091
|
+
} from "intlayer";
|
|
1092
|
+
import { useLocale } from "react-intlayer";
|
|
1093
|
+
|
|
1094
|
+
const LocaleSwitcher = () => {
|
|
1095
|
+
const { pathname, search } = useLocation(); // Ottenere il percorso URL corrente. Esempio: /fr/about?foo=bar
|
|
1096
|
+
const navigate = useNavigate();
|
|
1097
|
+
|
|
1098
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1099
|
+
onLocaleChange: (locale) => {
|
|
1100
|
+
// Costruire l'URL con la localizzazione aggiornata
|
|
1101
|
+
// Esempio: /es/about?foo=bar
|
|
1102
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
1103
|
+
|
|
1104
|
+
// Aggiornare il percorso dell'URL
|
|
1105
|
+
navigate(pathWithLocale);
|
|
1106
|
+
},
|
|
1107
|
+
});
|
|
1108
|
+
|
|
1109
|
+
return (
|
|
1110
|
+
<div>
|
|
1111
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1112
|
+
<div id="localePopover" popover="auto">
|
|
1113
|
+
{availableLocales.map((localeItem) => (
|
|
1114
|
+
<a
|
|
1115
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
1116
|
+
hrefLang={localeItem}
|
|
1117
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1118
|
+
onClick={(e) => {
|
|
1119
|
+
e.preventDefault();
|
|
1120
|
+
setLocale(localeItem);
|
|
1121
|
+
}}
|
|
1122
|
+
key={localeItem}
|
|
1123
|
+
>
|
|
1124
|
+
<span>
|
|
1125
|
+
{/* Locale - ad esempio FR */}
|
|
1126
|
+
{localeItem}
|
|
1127
|
+
</span>
|
|
1128
|
+
<span>
|
|
1129
|
+
{/* Lingua nella propria localizzazione - ad esempio Français */}
|
|
1130
|
+
{getLocaleName(localeItem, locale)}
|
|
1131
|
+
</span>
|
|
1132
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1133
|
+
{/* Lingua nella localizzazione corrente - ad esempio Francés con localizzazione corrente impostata su Locales.SPANISH */}
|
|
1134
|
+
{getLocaleName(localeItem)}
|
|
1135
|
+
</span>
|
|
1136
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1137
|
+
{/* Lingua in Inglese - ad esempio French */}
|
|
1138
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1139
|
+
</span>
|
|
1140
|
+
</a>
|
|
1141
|
+
))}
|
|
1142
|
+
</div>
|
|
1143
|
+
</div>
|
|
1144
|
+
);
|
|
1145
|
+
};
|
|
1146
|
+
```
|
|
1147
|
+
|
|
1148
|
+
```jsx fileName="src/components/LocaleSwitcher.csx" codeFormat="commonjs"
|
|
1149
|
+
const { useLocation, useNavigate } = require("react-router-dom");
|
|
1150
|
+
const {
|
|
1151
|
+
Locales,
|
|
1152
|
+
getHTMLTextDir,
|
|
1153
|
+
getLocaleName,
|
|
1154
|
+
getLocalizedUrl,
|
|
1155
|
+
} = require("intlayer");
|
|
1156
|
+
const { useLocale } = require("react-intlayer");
|
|
1157
|
+
|
|
1158
|
+
const LocaleSwitcher = () => {
|
|
1159
|
+
const { pathname, search } = useLocation(); // Ottenere il percorso URL corrente. Esempio: /fr/about?foo=bar
|
|
1160
|
+
const navigate = useNavigate();
|
|
1161
|
+
|
|
1162
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1163
|
+
onLocaleChange: (locale) => {
|
|
1164
|
+
// Costruire l'URL con la localizzazione aggiornata
|
|
1165
|
+
// Esempio: /es/about?foo=bar
|
|
1166
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
1167
|
+
|
|
1168
|
+
// Aggiornare il percorso dell'URL
|
|
1169
|
+
navigate(pathWithLocale);
|
|
1170
|
+
},
|
|
1171
|
+
});
|
|
1172
|
+
|
|
1173
|
+
return (
|
|
1174
|
+
<div>
|
|
1175
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1176
|
+
<div id="localePopover" popover="auto">
|
|
1177
|
+
{availableLocales.map((localeItem) => (
|
|
1178
|
+
<a
|
|
1179
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
1180
|
+
hrefLang={localeItem}
|
|
1181
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1182
|
+
onClick={(e) => {
|
|
1183
|
+
e.preventDefault();
|
|
1184
|
+
setLocale(localeItem);
|
|
1185
|
+
}}
|
|
1186
|
+
key={localeItem}
|
|
1187
|
+
>
|
|
1188
|
+
<span>
|
|
1189
|
+
{/* Locale - ad esempio FR */}
|
|
1190
|
+
{localeItem}
|
|
1191
|
+
</span>
|
|
1192
|
+
<span>
|
|
1193
|
+
{/* Lingua nella propria localizzazione - ad esempio Français */}
|
|
1194
|
+
{getLocaleName(localeItem, locale)}
|
|
1195
|
+
</span>
|
|
1196
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1197
|
+
{/* Lingua nella localizzazione corrente - ad esempio Francés con localizzazione corrente impostata su Locales.SPANISH */}
|
|
1198
|
+
{getLocaleName(localeItem)}
|
|
1199
|
+
</span>
|
|
1200
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1201
|
+
{/* Lingua in Inglese - ad esempio French */}
|
|
1202
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1203
|
+
</span>
|
|
1204
|
+
</a>
|
|
1205
|
+
))}
|
|
1206
|
+
</div>
|
|
1207
|
+
</div>
|
|
1208
|
+
);
|
|
1209
|
+
};
|
|
1210
|
+
```
|
|
1211
|
+
|
|
1212
|
+
> Riferimenti alla documentazione:
|
|
1213
|
+
|
|
1214
|
+
> - [`useLocale` hook](https://github.com/aymericzip/intlayer/blob/main/docs/it/packages/react-intlayer/useLocale.md)
|
|
1215
|
+
|
|
1216
|
+
> - [`getLocaleName` hook](https://github.com/aymericzip/intlayer/blob/main/docs/it/packages/intlayer/getLocaleName.md)
|
|
1217
|
+
|
|
1218
|
+
> - [`getLocalizedUrl` hook](https://github.com/aymericzip/intlayer/blob/main/docs/it/packages/intlayer/getLocalizedUrl.md)
|
|
1219
|
+
|
|
1220
|
+
> - [`getHTMLTextDir` hook](https://github.com/aymericzip/intlayer/blob/main/docs/it/packages/intlayer/getHTMLTextDir.md)
|
|
1221
|
+
|
|
1222
|
+
> - [`hrefLang` attribute](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
|
|
1223
|
+
|
|
1224
|
+
> - [`lang` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
|
|
1225
|
+
|
|
1226
|
+
> - [`dir` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
|
|
1227
|
+
|
|
1228
|
+
> - [`aria-current` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1229
|
+
|
|
1230
|
+
---
|
|
1231
|
+
|
|
1232
|
+
### (Opzionale) Step 9: Cambiare gli attributi di lingua e direzione HTML
|
|
1233
|
+
|
|
1234
|
+
Quando la tua applicazione supporta più lingue, è fondamentale aggiornare gli attributi `lang` e `dir` del tag `<html>` per corrispondere alla localizzazione corrente. Questo garantisce:
|
|
1235
|
+
|
|
1236
|
+
- **Accessibilità**: I lettori di schermo e le tecnologie assistive si basano sull'attributo `lang` corretto per pronunciare e interpretare accuratamente i contenuti.
|
|
1237
|
+
- **Rendering del testo**: L'attributo `dir` (direzione) garantisce che il testo venga reso nell'ordine corretto (ad esempio, da sinistra a destra per l'inglese, da destra a sinistra per l'arabo o l'ebraico), essenziale per la leggibilità.
|
|
1238
|
+
- **SEO**: I motori di ricerca utilizzano l'attributo `lang` per determinare la lingua della tua pagina, aiutando a fornire il contenuto localizzato corretto nei risultati di ricerca.
|
|
1239
|
+
|
|
1240
|
+
Aggiornando dinamicamente questi attributi quando cambia la localizzazione, garantisci un'esperienza coerente e accessibile per gli utenti in tutte le lingue supportate.
|
|
1241
|
+
|
|
1242
|
+
#### Implementazione dell'Hook
|
|
1243
|
+
|
|
1244
|
+
Crea un hook personalizzato per gestire gli attributi HTML. L'hook ascolta i cambiamenti di localizzazione e aggiorna gli attributi di conseguenza:
|
|
1245
|
+
|
|
1246
|
+
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
|
|
1247
|
+
import { useEffect } from "react";
|
|
1248
|
+
import { useLocale } from "react-intlayer";
|
|
1249
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1250
|
+
|
|
1251
|
+
/**
|
|
1252
|
+
|
|
1253
|
+
* - `lang`: Informa i browser e i motori di ricerca sulla lingua della pagina.
|
|
1254
|
+
* - `dir`: Garantisce il corretto ordine di lettura (ad esempio, 'ltr' per l'inglese, 'rtl' per l'arabo).
|
|
1255
|
+
*
|
|
1256
|
+
* Questo aggiornamento dinamico è essenziale per una corretta visualizzazione del testo, accessibilità e SEO.
|
|
1257
|
+
*/
|
|
1258
|
+
export const useI18nHTMLAttributes = () => {
|
|
1259
|
+
const { locale } = useLocale();
|
|
1260
|
+
|
|
1261
|
+
useEffect(() => {
|
|
1262
|
+
// Aggiorna l'attributo della lingua in base alla lingua corrente.
|
|
1263
|
+
document.documentElement.lang = locale;
|
|
1264
|
+
|
|
1265
|
+
// Imposta la direzione del testo in base alla lingua corrente.
|
|
1266
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1267
|
+
}, [locale]);
|
|
1268
|
+
};
|
|
1269
|
+
```
|
|
1270
|
+
|
|
1271
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.msx" codeFormat="esm"
|
|
1272
|
+
import { useEffect } from "react";
|
|
1273
|
+
import { useLocale } from "react-intlayer";
|
|
1274
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* Aggiorna gli attributi `lang` e `dir` dell'elemento HTML <html> in base alla lingua corrente.
|
|
1278
|
+
* - `lang`: Informa i browser e i motori di ricerca sulla lingua della pagina.
|
|
1279
|
+
* - `dir`: Garantisce il corretto ordine di lettura (ad esempio, 'ltr' per l'inglese, 'rtl' per l'arabo).
|
|
1280
|
+
*
|
|
1281
|
+
* Questo aggiornamento dinamico è essenziale per una corretta visualizzazione del testo, accessibilità e SEO.
|
|
1282
|
+
*/
|
|
1283
|
+
export const useI18nHTMLAttributes = () => {
|
|
1284
|
+
const { locale } = useLocale();
|
|
1285
|
+
|
|
1286
|
+
useEffect(() => {
|
|
1287
|
+
// Aggiorna l'attributo della lingua in base alla lingua corrente.
|
|
1288
|
+
document.documentElement.lang = locale;
|
|
1289
|
+
|
|
1290
|
+
// Imposta la direzione del testo in base alla lingua corrente.
|
|
1291
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1292
|
+
}, [locale]);
|
|
1293
|
+
};
|
|
1294
|
+
```
|
|
1295
|
+
|
|
1296
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.csx" codeFormat="commonjs"
|
|
1297
|
+
const { useEffect } = require("react");
|
|
1298
|
+
const { useLocale } = require("react-intlayer");
|
|
1299
|
+
const { getHTMLTextDir } = require("intlayer");
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* Aggiorna gli attributi `lang` e `dir` dell'elemento HTML <html> in base alla lingua corrente.
|
|
1303
|
+
* - `lang`: Informa i browser e i motori di ricerca sulla lingua della pagina.
|
|
1304
|
+
* - `dir`: Garantisce il corretto ordine di lettura (ad esempio, 'ltr' per l'inglese, 'rtl' per l'arabo).
|
|
1305
|
+
*
|
|
1306
|
+
* Questo aggiornamento dinamico è essenziale per una corretta visualizzazione del testo, accessibilità e SEO.
|
|
1307
|
+
*/
|
|
1308
|
+
const useI18nHTMLAttributes = () => {
|
|
1309
|
+
const { locale } = useLocale();
|
|
1310
|
+
|
|
1311
|
+
useEffect(() => {
|
|
1312
|
+
// Aggiorna l'attributo della lingua in base alla lingua corrente.
|
|
1313
|
+
document.documentElement.lang = locale;
|
|
1314
|
+
|
|
1315
|
+
// Imposta la direzione del testo in base alla lingua corrente.
|
|
1316
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1317
|
+
}, [locale]);
|
|
1318
|
+
};
|
|
1319
|
+
|
|
1320
|
+
module.exports = { useI18nHTMLAttributes };
|
|
1321
|
+
```
|
|
1322
|
+
|
|
1323
|
+
#### Utilizzo dell'Hook nella tua Applicazione
|
|
1324
|
+
|
|
1325
|
+
Integra l'hook nel tuo componente principale in modo che gli attributi HTML vengano aggiornati ogni volta che cambia la lingua:
|
|
1326
|
+
|
|
1327
|
+
```tsx fileName="src/App.tsx" codeFormat="typescript"
|
|
1328
|
+
import type { FC } from "react";
|
|
1329
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
1330
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1331
|
+
import "./App.css";
|
|
1332
|
+
|
|
1333
|
+
const AppContent: FC = () => {
|
|
1334
|
+
// Applica l'hook per aggiornare gli attributi lang e dir del tag <html> in base alla lingua.
|
|
1335
|
+
useI18nHTMLAttributes();
|
|
1336
|
+
|
|
1337
|
+
// ... Resto del tuo componente
|
|
1338
|
+
};
|
|
1339
|
+
|
|
1340
|
+
const App: FC = () => (
|
|
1341
|
+
<IntlayerProvider>
|
|
1342
|
+
<AppContent />
|
|
1343
|
+
</IntlayerProvider>
|
|
1344
|
+
);
|
|
1345
|
+
|
|
1346
|
+
export default App;
|
|
1347
|
+
```
|
|
1348
|
+
|
|
1349
|
+
```jsx fileName="src/App.msx" codeFormat="esm"
|
|
1350
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
1351
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1352
|
+
import "./App.css";
|
|
1353
|
+
|
|
1354
|
+
const AppContent = () => {
|
|
1355
|
+
// Applica l'hook per aggiornare gli attributi lang e dir del tag <html> in base alla lingua.
|
|
1356
|
+
useI18nHTMLAttributes();
|
|
1357
|
+
|
|
1358
|
+
// ... Resto del tuo componente
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1361
|
+
const App = () => (
|
|
1362
|
+
<IntlayerProvider>
|
|
1363
|
+
<AppContent />
|
|
1364
|
+
</IntlayerProvider>
|
|
1365
|
+
);
|
|
1366
|
+
|
|
1367
|
+
export default App;
|
|
1368
|
+
```
|
|
1369
|
+
|
|
1370
|
+
```jsx fileName="src/App.csx" codeFormat="commonjs"
|
|
1371
|
+
const { FC } = require("react");
|
|
1372
|
+
const { IntlayerProvider, useIntlayer } = require("react-intlayer");
|
|
1373
|
+
const { useI18nHTMLAttributes } = require("./hooks/useI18nHTMLAttributes");
|
|
1374
|
+
require("./App.css");
|
|
1375
|
+
|
|
1376
|
+
const AppContent = () => {
|
|
1377
|
+
// Applica l'hook per aggiornare gli attributi lang e dir del tag <html> in base alla lingua.
|
|
1378
|
+
useI18nHTMLAttributes();
|
|
1379
|
+
|
|
1380
|
+
// ... Resto del tuo componente
|
|
1381
|
+
};
|
|
1382
|
+
|
|
1383
|
+
const App = () => (
|
|
1384
|
+
<IntlayerProvider>
|
|
1385
|
+
<AppContent />
|
|
1386
|
+
</IntlayerProvider>
|
|
1387
|
+
);
|
|
1388
|
+
|
|
1389
|
+
module.exports = App;
|
|
1390
|
+
```
|
|
1391
|
+
|
|
1392
|
+
Applicando queste modifiche, la tua applicazione:
|
|
1393
|
+
|
|
1394
|
+
- Garantirà che l'attributo **lingua** (`lang`) rifletta correttamente la lingua corrente, importante per SEO e comportamento del browser.
|
|
1395
|
+
- Adatterà la **direzione del testo** (`dir`) in base alla lingua, migliorando la leggibilità e l'usabilità per lingue con ordini di lettura diversi.
|
|
1396
|
+
- Fornirà un'esperienza più **accessibile**, poiché le tecnologie assistive dipendono da questi attributi per funzionare in modo ottimale.
|
|
1397
|
+
|
|
1398
|
+
### (Opzionale) Passo 10: Creazione di un Componente Link Localizzato
|
|
1399
|
+
|
|
1400
|
+
Per garantire che la navigazione della tua applicazione rispetti la lingua corrente, puoi creare un componente `Link` personalizzato. Questo componente aggiunge automaticamente il prefisso alle URL interne con la lingua corrente. Ad esempio, quando un utente francofono clicca su un link alla pagina "About", viene reindirizzato a `/it/about` invece di `/about`.
|
|
1401
|
+
|
|
1402
|
+
Questo comportamento è utile per diversi motivi:
|
|
1403
|
+
|
|
1404
|
+
- **SEO e Esperienza Utente**: Le URL localizzate aiutano i motori di ricerca a indicizzare correttamente le pagine specifiche per lingua e forniscono agli utenti contenuti nella loro lingua preferita.
|
|
1405
|
+
- **Coerenza**: Utilizzando un link localizzato in tutta l'applicazione, garantisci che la navigazione rimanga nella lingua corrente, evitando cambiamenti di lingua inaspettati.
|
|
1406
|
+
- **Manutenibilità**: Centralizzando la logica di localizzazione in un unico componente, semplifichi la gestione delle URL, rendendo il tuo codice più facile da mantenere ed estendere man mano che l'applicazione cresce.
|
|
1407
|
+
|
|
1408
|
+
Di seguito l'implementazione di un componente `Link` localizzato in TypeScript:
|
|
1409
|
+
|
|
1410
|
+
```tsx fileName="src/components/Link.tsx" codeFormat="typescript"
|
|
1411
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1412
|
+
import {
|
|
1413
|
+
forwardRef,
|
|
1414
|
+
type DetailedHTMLProps,
|
|
1415
|
+
type AnchorHTMLAttributes,
|
|
1416
|
+
} from "react";
|
|
1417
|
+
import { useLocale } from "react-intlayer";
|
|
1418
|
+
|
|
1419
|
+
export interface LinkProps
|
|
1420
|
+
extends DetailedHTMLProps<
|
|
1421
|
+
AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
1422
|
+
HTMLAnchorElement
|
|
1423
|
+
> {}
|
|
1424
|
+
|
|
1425
|
+
/**
|
|
1426
|
+
* Funzione di utilità per verificare se un URL è esterno.
|
|
1427
|
+
* Se l'URL inizia con http:// o https://, viene considerato esterno.
|
|
1428
|
+
*/
|
|
1429
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1430
|
+
/^https?:\/\//.test(href ?? "");
|
|
1431
|
+
|
|
1432
|
+
/**
|
|
1433
|
+
* Un componente Link personalizzato che adatta l'attributo href in base alla lingua corrente.
|
|
1434
|
+
* Per i link interni, utilizza `getLocalizedUrl` per aggiungere il prefisso della lingua all'URL (ad esempio, /it/about).
|
|
1435
|
+
* Questo garantisce che la navigazione rimanga nel contesto della lingua corrente.
|
|
1436
|
+
*/
|
|
1437
|
+
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
1438
|
+
({ href, children, ...props }, ref) => {
|
|
1439
|
+
const { locale } = useLocale();
|
|
1440
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1441
|
+
|
|
1442
|
+
// Se il link è interno e viene fornito un href valido, ottieni l'URL localizzato.
|
|
1443
|
+
const hrefI18n =
|
|
1444
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1445
|
+
|
|
1446
|
+
return (
|
|
1447
|
+
<a href={hrefI18n} ref={ref} {...props}>
|
|
1448
|
+
{children}
|
|
1449
|
+
</a>
|
|
1450
|
+
);
|
|
1451
|
+
}
|
|
1452
|
+
);
|
|
1453
|
+
|
|
1454
|
+
Link.displayName = "Link";
|
|
1455
|
+
```
|
|
1456
|
+
|
|
1457
|
+
```jsx fileName="src/components/Link.mjx" codeFormat="esm"
|
|
1458
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1459
|
+
import { useLocale } from "react-intlayer";
|
|
1460
|
+
import { forwardRef } from "react";
|
|
1461
|
+
|
|
1462
|
+
/**
|
|
1463
|
+
* Funzione di utilità per verificare se un URL è esterno.
|
|
1464
|
+
* Se l'URL inizia con http:// o https://, viene considerato esterno.
|
|
1465
|
+
*/
|
|
1466
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1467
|
+
/^https?:\/\//.test(href ?? "");
|
|
1468
|
+
|
|
1469
|
+
/**
|
|
1470
|
+
* Un componente Link personalizzato che adatta l'attributo href in base alla lingua corrente.
|
|
1471
|
+
* Per i link interni, utilizza `getLocalizedUrl` per aggiungere il prefisso della lingua all'URL (ad esempio, /it/about).
|
|
1472
|
+
* Questo garantisce che la navigazione rimanga nel contesto della lingua corrente.
|
|
1473
|
+
*/
|
|
1474
|
+
export const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1475
|
+
|
|
1476
|
+
const { locale } = useLocale();
|
|
1477
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1478
|
+
|
|
1479
|
+
// Se il link è interno e viene fornito un href valido, ottieni l'URL localizzato.
|
|
1480
|
+
const hrefI18n =
|
|
1481
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1482
|
+
|
|
1483
|
+
return (
|
|
1484
|
+
<a href={hrefI18n} ref={ref} {...props}>
|
|
1485
|
+
{children}
|
|
1486
|
+
</a>
|
|
1487
|
+
);
|
|
1488
|
+
});
|
|
1489
|
+
|
|
1490
|
+
Link.displayName = "Link";
|
|
1491
|
+
```
|
|
1492
|
+
|
|
1493
|
+
```jsx fileName="src/components/Link.csx" codeFormat="commonjs"
|
|
1494
|
+
const { getLocalizedUrl } = require("intlayer");
|
|
1495
|
+
const { useLocale } = require("react-intlayer");
|
|
1496
|
+
const { forwardRef } = require("react");
|
|
1497
|
+
|
|
1498
|
+
/**
|
|
1499
|
+
* Funzione di utilità per verificare se un determinato URL è esterno.
|
|
1500
|
+
* Se l'URL inizia con http:// o https://, è considerato esterno.
|
|
1501
|
+
*/
|
|
1502
|
+
const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1503
|
+
|
|
1504
|
+
/**
|
|
1505
|
+
* Un componente Link personalizzato che adatta l'attributo href in base alla lingua corrente.
|
|
1506
|
+
* Per i link interni, utilizza `getLocalizedUrl` per aggiungere il prefisso dell'URL con la lingua (es. /it/about).
|
|
1507
|
+
* Questo garantisce che la navigazione rimanga nel contesto della stessa lingua.
|
|
1508
|
+
*/
|
|
1509
|
+
const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1510
|
+
const { locale } = useLocale();
|
|
1511
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1512
|
+
|
|
1513
|
+
// Se il link è interno e viene fornito un href valido, ottieni l'URL localizzato.
|
|
1514
|
+
const localizedHref = isExternalLink ? href : getLocalizedUrl(href, locale);
|
|
1515
|
+
|
|
1516
|
+
return (
|
|
1517
|
+
<a
|
|
1518
|
+
href={localizedHref}
|
|
1519
|
+
ref={ref}
|
|
1520
|
+
{...props}
|
|
1521
|
+
aria-current={isExternalLink ? "external" : undefined}
|
|
1522
|
+
>
|
|
1523
|
+
{children}
|
|
1524
|
+
</a>
|
|
1525
|
+
);
|
|
1526
|
+
});
|
|
1527
|
+
|
|
1528
|
+
Link.displayName = "Link";
|
|
1529
|
+
```
|
|
1530
|
+
|
|
1531
|
+
#### Come Funziona
|
|
1532
|
+
|
|
1533
|
+
- **Rilevamento dei Link Esterni**:
|
|
1534
|
+
La funzione helper `checkIsExternalLink` determina se un URL è esterno. I link esterni rimangono invariati poiché non necessitano di localizzazione.
|
|
1535
|
+
|
|
1536
|
+
- **Recupero della Lingua Corrente**:
|
|
1537
|
+
L'hook `useLocale` fornisce la lingua corrente (es. `it` per Italiano).
|
|
1538
|
+
|
|
1539
|
+
- **Localizzazione dell'URL**:
|
|
1540
|
+
Per i link interni (cioè non esterni), viene utilizzato `getLocalizedUrl` per aggiungere automaticamente il prefisso dell'URL con la lingua corrente. Questo significa che se l'utente è in Italiano, passando `/about` come `href`, verrà trasformato in `/it/about`.
|
|
1541
|
+
|
|
1542
|
+
- **Restituzione del Link**:
|
|
1543
|
+
Il componente restituisce un elemento `<a>` con l'URL localizzato, garantendo che la navigazione sia coerente con la lingua.
|
|
1544
|
+
|
|
1545
|
+
Integrando questo componente `Link` nella tua applicazione, puoi mantenere un'esperienza utente coerente e consapevole della lingua, migliorando anche SEO e usabilità.
|
|
1546
|
+
|
|
1547
|
+
### Configurare TypeScript
|
|
1548
|
+
|
|
1549
|
+
Intlayer utilizza l'augmentazione dei moduli per sfruttare i vantaggi di TypeScript e rendere il tuo codice più robusto.
|
|
1550
|
+
|
|
1551
|
+

|
|
1552
|
+
|
|
1553
|
+

|
|
1554
|
+
|
|
1555
|
+
Assicurati che la configurazione di TypeScript includa i tipi generati automaticamente.
|
|
1556
|
+
|
|
1557
|
+
```json5 fileName="tsconfig.json"
|
|
1558
|
+
{
|
|
1559
|
+
// ... Le tue configurazioni TypeScript esistenti
|
|
1560
|
+
"include": [
|
|
1561
|
+
// ... Le tue configurazioni TypeScript esistenti
|
|
1562
|
+
".intlayer/**/*.ts", // Includi i tipi generati automaticamente
|
|
1563
|
+
],
|
|
1564
|
+
}
|
|
1565
|
+
```
|
|
1566
|
+
|
|
1567
|
+
### Configurazione di Git
|
|
1568
|
+
|
|
1569
|
+
Si consiglia di ignorare i file generati da Intlayer. Questo ti permette di evitare di commetterli nel tuo repository Git.
|
|
1570
|
+
|
|
1571
|
+
Per fare ciò, puoi aggiungere le seguenti istruzioni al tuo file `.gitignore`:
|
|
1572
|
+
|
|
1573
|
+
```plaintext
|
|
1574
|
+
# Ignora i file generati da Intlayer
|
|
1575
|
+
.intlayer
|
|
1576
|
+
```
|
|
1577
|
+
|
|
1578
|
+
### Approfondimenti
|
|
1579
|
+
|
|
1580
|
+
Per approfondire, puoi implementare l'[editor visuale](https://github.com/aymericzip/intlayer/blob/main/docs/it/intlayer_visual_editor.md) o esternalizzare i tuoi contenuti utilizzando il [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/it/intlayer_CMS.md).
|