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

|
|
1628
|
+
|
|
1629
|
+

|
|
1630
|
+
|
|
1631
|
+
Assicurati che la configurazione di TypeScript includa i tipi generati automaticamente.
|
|
1632
|
+
|
|
1633
|
+
```json5 fileName="tsconfig.json"
|
|
1634
|
+
{
|
|
1635
|
+
// ... Le tue configurazioni TypeScript esistenti
|
|
1636
|
+
"compilerOptions": {
|
|
1637
|
+
// ...
|
|
1638
|
+
"jsx": "react-jsx",
|
|
1639
|
+
"jsxImportSource": "preact", // Consigliato per Preact 10+
|
|
1640
|
+
// ...
|
|
1641
|
+
},
|
|
1642
|
+
"include": [
|
|
1643
|
+
// ... Le tue configurazioni TypeScript esistenti
|
|
1644
|
+
".intlayer/**/*.ts", // Includi i tipi generati automaticamente
|
|
1645
|
+
],
|
|
1646
|
+
}
|
|
1647
|
+
```
|
|
1648
|
+
|
|
1649
|
+
> Assicurati che il tuo `tsconfig.json` sia configurato per Preact, in particolare `jsx` e `jsxImportSource` o `jsxFactory`/`jsxFragmentFactory` per le versioni precedenti di Preact se non utilizzi i valori predefiniti di `preset-vite`.
|
|
1650
|
+
|
|
1651
|
+
### Configurazione Git
|
|
1652
|
+
|
|
1653
|
+
Si consiglia di ignorare i file generati da Intlayer. Questo ti permette di evitare di commetterli nel tuo repository Git.
|
|
1654
|
+
|
|
1655
|
+
Per fare ciò, puoi aggiungere le seguenti istruzioni al tuo file `.gitignore`:
|
|
1656
|
+
|
|
1657
|
+
```plaintext
|
|
1658
|
+
# Ignora i file generati da Intlayer
|
|
1659
|
+
.intlayer
|
|
1660
|
+
```
|
|
1661
|
+
|
|
1662
|
+
### Estensione VS Code
|
|
1663
|
+
|
|
1664
|
+
Per migliorare la tua esperienza di sviluppo con Intlayer, puoi installare l'estensione ufficiale **Intlayer VS Code Extension**.
|
|
1665
|
+
|
|
1666
|
+
[Installa dal Marketplace di VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
1667
|
+
|
|
1668
|
+
Questa estensione fornisce:
|
|
1669
|
+
|
|
1670
|
+
- **Autocompletamento** per le chiavi di traduzione.
|
|
1671
|
+
- **Rilevamento degli errori in tempo reale** per le traduzioni mancanti.
|
|
1672
|
+
- **Anteprime inline** del contenuto tradotto.
|
|
1673
|
+
- **Azioni rapide** per creare e aggiornare facilmente le traduzioni.
|
|
1674
|
+
|
|
1675
|
+
Per maggiori dettagli su come utilizzare l'estensione, consulta la [documentazione dell'estensione Intlayer per VS Code](https://intlayer.org/doc/vs-code-extension).
|
|
1676
|
+
|
|
1677
|
+
---
|
|
1678
|
+
|
|
1679
|
+
### Approfondimenti
|
|
1680
|
+
|
|
1681
|
+
Per approfondire, puoi implementare l'[editor visuale](https://github.com/aymericzip/intlayer/blob/main/docs/it/intlayer_visual_editor.md) o esternalizzare il tuo contenuto utilizzando il [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/it/intlayer_CMS.md).
|