@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,1663 @@
|
|
|
1
|
+
# Introdução à Internacionalização (i18n) com Intlayer, Vite e Preact
|
|
2
|
+
|
|
3
|
+
> Este pacote está em desenvolvimento. Veja o [issue](https://github.com/aymericzip/intlayer/issues/118) para mais informações. Mostre seu interesse no Intlayer para Preact curtindo o issue.
|
|
4
|
+
|
|
5
|
+
Veja o [Template de Aplicação](https://github.com/aymericzip/intlayer-vite-preact-template) no GitHub.
|
|
6
|
+
|
|
7
|
+
## O que é o Intlayer?
|
|
8
|
+
|
|
9
|
+
**Intlayer** é uma biblioteca de internacionalização (i18n) inovadora e de código aberto, projetada para simplificar o suporte multilíngue em aplicações web modernas.
|
|
10
|
+
|
|
11
|
+
Com o Intlayer, você pode:
|
|
12
|
+
|
|
13
|
+
- **Gerenciar traduções facilmente** usando dicionários declarativos no nível do componente.
|
|
14
|
+
- **Localizar dinamicamente metadados**, rotas e conteúdo.
|
|
15
|
+
- **Garantir suporte ao TypeScript** com tipos autogerados, melhorando a autocompletação e a detecção de erros.
|
|
16
|
+
- **Aproveitar recursos avançados**, como detecção dinâmica de localidade e troca de idiomas.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Guia Passo a Passo para Configurar o Intlayer em uma Aplicação Vite e Preact
|
|
21
|
+
|
|
22
|
+
### Passo 1: Instale as Dependências
|
|
23
|
+
|
|
24
|
+
Instale os pacotes necessários usando 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
|
+
O pacote principal que fornece ferramentas de internacionalização para gerenciamento de configuração, tradução, [declaração de conteúdo](https://github.com/aymericzip/intlayer/blob/main/docs/pt/dictionary/get_started.md), transpilações e [comandos CLI](https://github.com/aymericzip/intlayer/blob/main/docs/pt/intlayer_cli.md).
|
|
41
|
+
|
|
42
|
+
- **preact-intlayer**
|
|
43
|
+
O pacote que integra o Intlayer com a aplicação Preact. Ele fornece provedores de contexto e hooks para internacionalização no Preact.
|
|
44
|
+
|
|
45
|
+
- **vite-intlayer**
|
|
46
|
+
Inclui o plugin Vite para integrar o Intlayer com o [empacotador Vite](https://vite.dev/guide/why.html#why-bundle-for-production), bem como middleware para detectar a localidade preferida do usuário, gerenciar cookies e lidar com redirecionamento de URLs.
|
|
47
|
+
|
|
48
|
+
### Passo 2: Configuração do seu projeto
|
|
49
|
+
|
|
50
|
+
Crie um arquivo de configuração para configurar os idiomas da sua aplicação:
|
|
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
|
+
// Seus outros idiomas
|
|
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
|
+
// Seus outros idiomas
|
|
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
|
+
// Seus outros idiomas
|
|
100
|
+
],
|
|
101
|
+
defaultLocale: Locales.ENGLISH,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
module.exports = config;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
> Através deste arquivo de configuração, você pode configurar URLs localizados, redirecionamento de middleware, nomes de cookies, a localização e extensão de suas declarações de conteúdo, desativar logs do Intlayer no console e muito mais. Para uma lista completa de parâmetros disponíveis, consulte a [documentação de configuração](https://github.com/aymericzip/intlayer/blob/main/docs/pt/configuration.md).
|
|
109
|
+
|
|
110
|
+
### Passo 3: Integre o Intlayer na Configuração do Vite
|
|
111
|
+
|
|
112
|
+
Adicione o plugin intlayer na sua configuração.
|
|
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
|
+
> O plugin `intlayerPlugin()` do Vite é usado para integrar o Intlayer com o Vite. Ele garante a construção de arquivos de declaração de conteúdo e os monitora no modo de desenvolvimento. Ele define variáveis de ambiente do Intlayer dentro da aplicação Vite. Além disso, fornece aliases para otimizar o desempenho.
|
|
148
|
+
|
|
149
|
+
### Passo 4: Declare Seu Conteúdo
|
|
150
|
+
|
|
151
|
+
Crie e gerencie suas declarações de conteúdo para armazenar traduções:
|
|
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
|
+
pt: "Logotipo do Vite",
|
|
161
|
+
en: "Vite logo",
|
|
162
|
+
fr: "Logo Vite",
|
|
163
|
+
es: "Logo Vite",
|
|
164
|
+
}),
|
|
165
|
+
preactLogo: t({
|
|
166
|
+
pt: "Logotipo do Preact",
|
|
167
|
+
en: "Preact logo",
|
|
168
|
+
fr: "Logo Preact",
|
|
169
|
+
es: "Logo Preact",
|
|
170
|
+
}),
|
|
171
|
+
|
|
172
|
+
title: "Vite + Preact",
|
|
173
|
+
|
|
174
|
+
count: t({
|
|
175
|
+
pt: "o contador é ",
|
|
176
|
+
en: "count is ",
|
|
177
|
+
fr: "le compte est ",
|
|
178
|
+
es: "el recuento es ",
|
|
179
|
+
}),
|
|
180
|
+
|
|
181
|
+
edit: t({
|
|
182
|
+
pt: "Edite src/app.tsx e salve para testar 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
|
+
pt: "Clique nos logotipos do Vite e Preact para saber mais",
|
|
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'; // Necessário se você usar JSX diretamente em .mjs
|
|
203
|
+
|
|
204
|
+
/** @type {import('intlayer').Dictionary} */
|
|
205
|
+
const appContent = {
|
|
206
|
+
key: "app",
|
|
207
|
+
content: {
|
|
208
|
+
viteLogo: t({
|
|
209
|
+
pt: "Logotipo do Vite",
|
|
210
|
+
en: "Vite logo",
|
|
211
|
+
fr: "Logo Vite",
|
|
212
|
+
es: "Logo Vite",
|
|
213
|
+
}),
|
|
214
|
+
preactLogo: t({
|
|
215
|
+
pt: "Logotipo do Preact",
|
|
216
|
+
en: "Preact logo",
|
|
217
|
+
fr: "Logo Preact",
|
|
218
|
+
es: "Logo Preact",
|
|
219
|
+
}),
|
|
220
|
+
|
|
221
|
+
title: "Vite + Preact",
|
|
222
|
+
|
|
223
|
+
count: t({
|
|
224
|
+
pt: "o contador é ",
|
|
225
|
+
en: "count is ",
|
|
226
|
+
fr: "le compte est ",
|
|
227
|
+
es: "el recuento es ",
|
|
228
|
+
}),
|
|
229
|
+
|
|
230
|
+
edit: t({
|
|
231
|
+
pt: "Edite src/app.jsx e salve para testar o 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
|
+
pt: "Clique nos logotipos do Vite e Preact para saber mais",
|
|
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'); // Necessário se você usar JSX diretamente em .cjs
|
|
252
|
+
|
|
253
|
+
/** @type {import('intlayer').Dictionary} */
|
|
254
|
+
const appContent = {
|
|
255
|
+
key: "app",
|
|
256
|
+
content: {
|
|
257
|
+
viteLogo: t({
|
|
258
|
+
pt: "Logotipo do Vite",
|
|
259
|
+
en: "Vite logo",
|
|
260
|
+
fr: "Logo Vite",
|
|
261
|
+
es: "Logo Vite",
|
|
262
|
+
}),
|
|
263
|
+
preactLogo: t({
|
|
264
|
+
pt: "Logotipo do Preact",
|
|
265
|
+
en: "Preact logo",
|
|
266
|
+
fr: "Logo Preact",
|
|
267
|
+
es: "Logo Preact",
|
|
268
|
+
}),
|
|
269
|
+
|
|
270
|
+
title: "Vite + Preact",
|
|
271
|
+
|
|
272
|
+
count: t({
|
|
273
|
+
pt: "a contagem é ",
|
|
274
|
+
en: "count is ",
|
|
275
|
+
fr: "le compte est ",
|
|
276
|
+
es: "el recuento es ",
|
|
277
|
+
}),
|
|
278
|
+
|
|
279
|
+
edit: t({
|
|
280
|
+
pt: "Edite src/app.tsx e salve para testar 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
|
+
pt: "Clique nos logos do Vite e Preact para saber mais",
|
|
288
|
+
en: "Click on the Vite and Preact logos to learn more",
|
|
289
|
+
fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
290
|
+
es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
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
|
+
"pt": "Logo do Vite",
|
|
307
|
+
"en": "Vite logo",
|
|
308
|
+
"fr": "Logo Vite",
|
|
309
|
+
"es": "Logo Vite"
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
"preactLogo": {
|
|
313
|
+
"nodeType": "translation",
|
|
314
|
+
"translation": {
|
|
315
|
+
"pt": "Logo do Preact",
|
|
316
|
+
"en": "Preact logo",
|
|
317
|
+
"fr": "Logo Preact",
|
|
318
|
+
"es": "Logo Preact"
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
"title": {
|
|
322
|
+
"nodeType": "translation",
|
|
323
|
+
"translation": {
|
|
324
|
+
"pt": "Vite + Preact",
|
|
325
|
+
"en": "Vite + Preact",
|
|
326
|
+
"fr": "Vite + Preact",
|
|
327
|
+
"es": "Vite + Preact"
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
"count": {
|
|
331
|
+
"nodeType": "translation",
|
|
332
|
+
"translation": {
|
|
333
|
+
"pt": "a contagem é ",
|
|
334
|
+
"en": "count is ",
|
|
335
|
+
"fr": "le compte est ",
|
|
336
|
+
"es": "el recuento es "
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
"edit": {
|
|
340
|
+
"nodeType": "translation",
|
|
341
|
+
"translation": {
|
|
342
|
+
"pt": "Edite src/app.tsx e salve para testar HMR",
|
|
343
|
+
"en": "Edit src/app.tsx and save to test HMR",
|
|
344
|
+
"fr": "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
345
|
+
"es": "Edita src/app.tsx y guarda para probar HMR"
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
"readTheDocs": {
|
|
349
|
+
"nodeType": "translation",
|
|
350
|
+
"translation": {
|
|
351
|
+
"pt": "Clique nos logos do Vite e Preact para saber mais",
|
|
352
|
+
"en": "Click on the Vite and Preact logos to learn more",
|
|
353
|
+
"fr": "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
354
|
+
"es": "Haga clic en los logotipos de Vite y Preact para obtener más información"
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
> Suas declarações de conteúdo podem ser definidas em qualquer lugar do seu aplicativo, desde que sejam incluídas no diretório `contentDir` (por padrão, `./src`). E correspondam à extensão do arquivo de declaração de conteúdo (por padrão, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
362
|
+
|
|
363
|
+
> Para mais detalhes, consulte a [documentação de declaração de conteúdo](https://github.com/aymericzip/intlayer/blob/main/docs/pt/dictionary/get_started.md).
|
|
364
|
+
|
|
365
|
+
> Se o seu arquivo de conteúdo incluir código TSX, talvez seja necessário importar `import { h } from "preact";` ou garantir que sua pragma JSX esteja configurada corretamente para o Preact.
|
|
366
|
+
|
|
367
|
+
### Passo 5: Utilize o Intlayer no Seu Código
|
|
368
|
+
|
|
369
|
+
Acesse seus dicionários de conteúdo em todo o seu aplicativo:
|
|
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"; // Supondo que você tenha um preact.svg
|
|
375
|
+
import viteLogo from "/vite.svg";
|
|
376
|
+
import "./app.css"; // Supondo que seu arquivo CSS seja nomeado 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 você quiser usar seu conteúdo em um atributo `string`, como `alt`, `title`, `href`, `aria-label`, etc., você deve chamar o valor da função, como:
|
|
514
|
+
|
|
515
|
+
> ```jsx
|
|
516
|
+
>
|
|
517
|
+
> ```
|
|
518
|
+
|
|
519
|
+
> <img src={content.image.src.value} alt={content.image.value} />
|
|
520
|
+
|
|
521
|
+
> ```
|
|
522
|
+
>
|
|
523
|
+
> ```
|
|
524
|
+
|
|
525
|
+
> Nota: No Preact, `className` é tipicamente escrito como `class`.
|
|
526
|
+
|
|
527
|
+
> Para saber mais sobre o hook `useIntlayer`, consulte a [documentação](https://github.com/aymericzip/intlayer/blob/main/docs/pt/packages/react-intlayer/useIntlayer.md) (A API é semelhante para `preact-intlayer`).
|
|
528
|
+
|
|
529
|
+
### (Opcional) Passo 6: Alterar o idioma do seu conteúdo
|
|
530
|
+
|
|
531
|
+
Para alterar o idioma do seu conteúdo, você pode usar a função `setLocale` fornecida pelo hook `useLocale`. Essa função permite definir o locale do aplicativo e atualizar o conteúdo de acordo.
|
|
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.PORTUGUESE)}>
|
|
543
|
+
Alterar idioma para Português
|
|
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
|
+
Alterar idioma para Inglês
|
|
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
|
+
Alterar idioma para Inglês
|
|
571
|
+
</button>
|
|
572
|
+
);
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
module.exports = LocaleSwitcher;
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
> Para saber mais sobre o hook `useLocale`, consulte a [documentação](https://github.com/aymericzip/intlayer/blob/main/docs/pt/packages/react-intlayer/useLocale.md) (A API é semelhante para `preact-intlayer`).
|
|
579
|
+
|
|
580
|
+
### (Opcional) Etapa 7: Adicione roteamento localizado à sua aplicação
|
|
581
|
+
|
|
582
|
+
O objetivo desta etapa é criar rotas únicas para cada idioma. Isso é útil para SEO e URLs amigáveis para SEO.
|
|
583
|
+
Exemplo:
|
|
584
|
+
|
|
585
|
+
```plaintext
|
|
586
|
+
- https://example.com/about
|
|
587
|
+
- https://example.com/es/about
|
|
588
|
+
- https://example.com/fr/about
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
> Por padrão, as rotas não são prefixadas para o idioma padrão. Se você deseja prefixar o idioma padrão, pode definir a opção `middleware.prefixDefault` como `true` na sua configuração. Consulte a [documentação de configuração](https://github.com/aymericzip/intlayer/blob/main/docs/pt/configuration.md) para mais informações.
|
|
592
|
+
|
|
593
|
+
Para adicionar roteamento localizado à sua aplicação, você pode criar um componente `LocaleRouter` que envolve as rotas da sua aplicação e gerencia o roteamento baseado no idioma. Aqui está um exemplo usando [preact-iso](https://github.com/preactjs/preact-iso):
|
|
594
|
+
|
|
595
|
+
Primeiro, instale o `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
|
+
* Um componente que gerencia a localização e envolve os filhos com o contexto de idioma apropriado.
|
|
632
|
+
* Ele gerencia a detecção e validação de idioma baseada na 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 o idioma atual, retornando ao padrão se não for fornecido
|
|
647
|
+
const currentLocale = locale ?? defaultLocale;
|
|
648
|
+
|
|
649
|
+
// Remove o prefixo do idioma do caminho para construir um caminho base
|
|
650
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
651
|
+
pathname // Caminho atual da URL
|
|
652
|
+
);
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Se middleware.prefixDefault for verdadeiro, o idioma padrão deve sempre ser prefixado.
|
|
656
|
+
*/
|
|
657
|
+
if (middleware.prefixDefault) {
|
|
658
|
+
// Valida o idioma
|
|
659
|
+
if (!locale || !locales.includes(locale)) {
|
|
660
|
+
// Redireciona para o idioma padrão com o caminho atualizado
|
|
661
|
+
return (
|
|
662
|
+
<Navigate
|
|
663
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
664
|
+
replace // Substitui a entrada atual do histórico pela nova
|
|
665
|
+
/>
|
|
666
|
+
);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// Envolve os filhos com o IntlayerProvider e define o idioma atual
|
|
670
|
+
return (
|
|
671
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
672
|
+
);
|
|
673
|
+
} else {
|
|
674
|
+
/**
|
|
675
|
+
* Quando middleware.prefixDefault é falso, o idioma padrão não é prefixado.
|
|
676
|
+
* Garante que o idioma atual seja válido e não o idioma padrão.
|
|
677
|
+
*/
|
|
678
|
+
if (
|
|
679
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
680
|
+
!locales
|
|
681
|
+
.filter(
|
|
682
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Exclui o idioma padrão
|
|
683
|
+
)
|
|
684
|
+
.includes(currentLocale) // Verifica se o idioma atual está na lista de idiomas válidos
|
|
685
|
+
) {
|
|
686
|
+
// Redireciona para o caminho sem o prefixo do idioma
|
|
687
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
// Envolve os filhos com o IntlayerProvider e define o idioma atual
|
|
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
|
+
* Um componente de roteador que configura rotas específicas para idiomas.
|
|
727
|
+
* Ele usa preact-iso para gerenciar a navegação e renderizar componentes localizados.
|
|
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
|
+
// Importando dependências e funções necessárias
|
|
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"; // Necessário para JSX
|
|
745
|
+
|
|
746
|
+
// Desestruturando configuração do 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
|
+
* Um componente que gerencia a localização e envolve os filhos com o contexto de idioma apropriado.
|
|
760
|
+
* Ele gerencia a detecção e validação de idioma baseada na 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 o idioma atual, retornando ao padrão se não for fornecido
|
|
772
|
+
const currentLocale = locale ?? defaultLocale;
|
|
773
|
+
|
|
774
|
+
// Remove o prefixo do idioma do caminho para construir um caminho base
|
|
775
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
776
|
+
pathname // Caminho atual da URL
|
|
777
|
+
);
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Se middleware.prefixDefault for verdadeiro, o idioma padrão deve sempre ser prefixado.
|
|
781
|
+
*/
|
|
782
|
+
if (middleware.prefixDefault) {
|
|
783
|
+
// Valida o idioma
|
|
784
|
+
if (!locale || !locales.includes(locale)) {
|
|
785
|
+
// Redireciona para o idioma padrão com o caminho atualizado
|
|
786
|
+
return (
|
|
787
|
+
<Navigate
|
|
788
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
789
|
+
replace // Substitui a entrada atual do histórico pela nova
|
|
790
|
+
/>
|
|
791
|
+
);
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
// Envolve os filhos com o IntlayerProvider e define o idioma atual
|
|
795
|
+
return (
|
|
796
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
797
|
+
);
|
|
798
|
+
} else {
|
|
799
|
+
/**
|
|
800
|
+
---
|
|
801
|
+
|
|
802
|
+
* Quando middleware.prefixDefault é falso, o locale padrão não é prefixado.
|
|
803
|
+
* Certifique-se de que o locale atual é válido e não é o locale padrão.
|
|
804
|
+
*/
|
|
805
|
+
if (
|
|
806
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
807
|
+
!locales
|
|
808
|
+
.filter(
|
|
809
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Excluir o locale padrão
|
|
810
|
+
)
|
|
811
|
+
.includes(currentLocale) // Verificar se o locale atual está na lista de locales válidos
|
|
812
|
+
) {
|
|
813
|
+
// Redirecionar para o caminho sem prefixo de locale
|
|
814
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
// Envolver os filhos com o IntlayerProvider e definir o locale atual
|
|
818
|
+
return (
|
|
819
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
820
|
+
);
|
|
821
|
+
}
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
const RouterContent = ({ children }) => {
|
|
825
|
+
const { path } = useLocation();
|
|
826
|
+
|
|
827
|
+
if (!path) {
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
const pathLocale = path.split("/")[1];
|
|
832
|
+
|
|
833
|
+
const isLocaleRoute = locales
|
|
834
|
+
.filter((locale) => middleware.prefixDefault || locale !== defaultLocale)
|
|
835
|
+
.some((locale) => locale.toString() === pathLocale);
|
|
836
|
+
|
|
837
|
+
if (isLocaleRoute) {
|
|
838
|
+
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
return (
|
|
842
|
+
<AppLocalized
|
|
843
|
+
locale={!middleware.prefixDefault ? defaultLocale : undefined}
|
|
844
|
+
>
|
|
845
|
+
{children}
|
|
846
|
+
</AppLocalized>
|
|
847
|
+
);
|
|
848
|
+
};
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* Um componente de roteador que configura rotas específicas para locales.
|
|
852
|
+
* Ele usa preact-iso para gerenciar a navegação e renderizar componentes localizados.
|
|
853
|
+
*/
|
|
854
|
+
export const LocaleRouter = ({ children }) => (
|
|
855
|
+
<LocationProvider>
|
|
856
|
+
<RouterContent>{children}</RouterContent>
|
|
857
|
+
</LocationProvider>
|
|
858
|
+
);
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
```jsx fileName="src/components/LocaleRouter.cjsx" codeFormat="commonjs"
|
|
862
|
+
// Importando dependências e funções necessárias
|
|
863
|
+
const { configuration, getPathWithoutLocale } = require("intlayer");
|
|
864
|
+
const { IntlayerProvider } = require("preact-intlayer");
|
|
865
|
+
const { LocationProvider, useLocation } = require("preact-iso");
|
|
866
|
+
const { useEffect } = require("preact/hooks");
|
|
867
|
+
const { h } = require("preact"); // Necessário para JSX
|
|
868
|
+
|
|
869
|
+
// Desestruturando configuração do Intlayer
|
|
870
|
+
const { internationalization, middleware } = configuration;
|
|
871
|
+
const { locales, defaultLocale } = internationalization;
|
|
872
|
+
|
|
873
|
+
const Navigate = ({ to, replace }) => {
|
|
874
|
+
const { route } = useLocation();
|
|
875
|
+
useEffect(() => {
|
|
876
|
+
route(to, replace);
|
|
877
|
+
}, [to, replace, route]);
|
|
878
|
+
return null;
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* Um componente que gerencia a localização e envolve os filhos com o contexto de locale apropriado.
|
|
883
|
+
* Ele gerencia a detecção e validação de locale baseada em URL.
|
|
884
|
+
*/
|
|
885
|
+
const AppLocalized = ({ children, locale }) => {
|
|
886
|
+
const { path: pathname, url } = useLocation();
|
|
887
|
+
|
|
888
|
+
if (!url) {
|
|
889
|
+
return null;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
const search = url.substring(pathname.length);
|
|
893
|
+
|
|
894
|
+
// Determinar o locale atual, retornando ao padrão se não fornecido
|
|
895
|
+
const currentLocale = locale ?? defaultLocale;
|
|
896
|
+
|
|
897
|
+
// Remover o prefixo de locale do caminho para construir um caminho base
|
|
898
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
899
|
+
pathname // Caminho atual da URL
|
|
900
|
+
);
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Se middleware.prefixDefault for verdadeiro, o locale padrão deve sempre ser prefixado.
|
|
904
|
+
*/
|
|
905
|
+
if (middleware.prefixDefault) {
|
|
906
|
+
// Validar o locale
|
|
907
|
+
if (!locale || !locales.includes(locale)) {
|
|
908
|
+
// Redirecionar para o locale padrão com o caminho atualizado
|
|
909
|
+
return (
|
|
910
|
+
<Navigate
|
|
911
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
912
|
+
replace // Substituir a entrada atual do histórico pela nova
|
|
913
|
+
/>
|
|
914
|
+
);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
// Envolver os filhos com o IntlayerProvider e definir o locale atual
|
|
918
|
+
return (
|
|
919
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
920
|
+
);
|
|
921
|
+
} else {
|
|
922
|
+
/**
|
|
923
|
+
* Quando middleware.prefixDefault é falso, o locale padrão não é prefixado.
|
|
924
|
+
* Certifique-se de que o locale atual é válido e não é o locale padrão.
|
|
925
|
+
*/
|
|
926
|
+
if (
|
|
927
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
928
|
+
!locales
|
|
929
|
+
.filter(
|
|
930
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Excluir o locale padrão
|
|
931
|
+
)
|
|
932
|
+
.includes(currentLocale) // Verificar se o locale atual está na lista de locales válidos
|
|
933
|
+
) {
|
|
934
|
+
// Redirecionar para o caminho sem prefixo de locale
|
|
935
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
// Envolver os filhos com o IntlayerProvider e definir o locale atual
|
|
939
|
+
return (
|
|
940
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
941
|
+
);
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
|
|
945
|
+
const RouterContent = ({ children }) => {
|
|
946
|
+
const { path } = useLocation();
|
|
947
|
+
|
|
948
|
+
if (!path) {
|
|
949
|
+
return null;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
const pathLocale = path.split("/")[1];
|
|
953
|
+
|
|
954
|
+
const isLocaleRoute = locales
|
|
955
|
+
.filter((locale) => middleware.prefixDefault || locale !== defaultLocale)
|
|
956
|
+
.some((locale) => locale.toString() === pathLocale);
|
|
957
|
+
|
|
958
|
+
if (isLocaleRoute) {
|
|
959
|
+
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
return (
|
|
963
|
+
<AppLocalized
|
|
964
|
+
locale={!middleware.prefixDefault ? defaultLocale : undefined}
|
|
965
|
+
>
|
|
966
|
+
{children}
|
|
967
|
+
</AppLocalized>
|
|
968
|
+
);
|
|
969
|
+
};
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Um componente de roteador que configura rotas específicas para locales.
|
|
973
|
+
* Ele usa preact-iso para gerenciar a navegação e renderizar componentes localizados.
|
|
974
|
+
*/
|
|
975
|
+
const LocaleRouter = ({ children }) => (
|
|
976
|
+
<LocationProvider>
|
|
977
|
+
<RouterContent>{children}</RouterContent>
|
|
978
|
+
</LocationProvider>
|
|
979
|
+
);
|
|
980
|
+
|
|
981
|
+
module.exports = { LocaleRouter };
|
|
982
|
+
```
|
|
983
|
+
|
|
984
|
+
Então, você pode usar o componente `LocaleRouter` em sua aplicação:
|
|
985
|
+
|
|
986
|
+
```tsx fileName="src/app.tsx" codeFormat="typescript"
|
|
987
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
988
|
+
import type { FunctionalComponent } from "preact";
|
|
989
|
+
// ... Seu componente AppContent (definido no Passo 5)
|
|
990
|
+
|
|
991
|
+
const App: FunctionalComponent = () => (
|
|
992
|
+
<LocaleRouter>
|
|
993
|
+
<AppContent />
|
|
994
|
+
</LocaleRouter>
|
|
995
|
+
);
|
|
996
|
+
|
|
997
|
+
export default App;
|
|
998
|
+
```
|
|
999
|
+
|
|
1000
|
+
```jsx fileName="src/app.jsx" codeFormat="esm"
|
|
1001
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
1002
|
+
// ... Seu componente AppContent (definido no Passo 5)
|
|
1003
|
+
|
|
1004
|
+
const App = () => (
|
|
1005
|
+
<LocaleRouter>
|
|
1006
|
+
<AppContent />
|
|
1007
|
+
</LocaleRouter>
|
|
1008
|
+
);
|
|
1009
|
+
|
|
1010
|
+
export default App;
|
|
1011
|
+
```
|
|
1012
|
+
|
|
1013
|
+
```jsx fileName="src/app.cjsx" codeFormat="commonjs"
|
|
1014
|
+
const { LocaleRouter } = require("./components/LocaleRouter");
|
|
1015
|
+
// ... Seu componente AppContent (definido no Passo 5)
|
|
1016
|
+
|
|
1017
|
+
const App = () => (
|
|
1018
|
+
<LocaleRouter>
|
|
1019
|
+
<AppContent />
|
|
1020
|
+
</LocaleRouter>
|
|
1021
|
+
);
|
|
1022
|
+
|
|
1023
|
+
module.exports = App;
|
|
1024
|
+
```
|
|
1025
|
+
|
|
1026
|
+
Paralelamente, você também pode usar o `intLayerMiddlewarePlugin` para adicionar roteamento no lado do servidor à sua aplicação. Este plugin detectará automaticamente o locale atual com base na URL e definirá o cookie de locale apropriado. Se nenhum locale for especificado, o plugin determinará o locale mais apropriado com base nas preferências de idioma do navegador do usuário. Se nenhum locale for detectado, ele redirecionará para o locale padrão.
|
|
1027
|
+
|
|
1028
|
+
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
1029
|
+
import { defineConfig } from "vite";
|
|
1030
|
+
import preact from "@preact/preset-vite";
|
|
1031
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
1032
|
+
|
|
1033
|
+
// https://vitejs.dev/config/
|
|
1034
|
+
export default defineConfig({
|
|
1035
|
+
plugins: [preact(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1036
|
+
});
|
|
1037
|
+
```
|
|
1038
|
+
|
|
1039
|
+
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
1040
|
+
import { defineConfig } from "vite";
|
|
1041
|
+
import preact from "@preact/preset-vite";
|
|
1042
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
1043
|
+
|
|
1044
|
+
// https://vitejs.dev/config/
|
|
1045
|
+
export default defineConfig({
|
|
1046
|
+
plugins: [preact(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1047
|
+
});
|
|
1048
|
+
```
|
|
1049
|
+
|
|
1050
|
+
```javascript {3,7} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
1051
|
+
const { defineConfig } = require("vite");
|
|
1052
|
+
const preact = require("@preact/preset-vite");
|
|
1053
|
+
const { intlayerPlugin, intLayerMiddlewarePlugin } = require("vite-intlayer");
|
|
1054
|
+
|
|
1055
|
+
// https://vitejs.dev/config/
|
|
1056
|
+
module.exports = defineConfig({
|
|
1057
|
+
plugins: [preact(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1058
|
+
});
|
|
1059
|
+
```
|
|
1060
|
+
|
|
1061
|
+
### (Opcional) Passo 8: Alterar a URL quando o locale muda
|
|
1062
|
+
|
|
1063
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
1064
|
+
import { useLocation, route } from "preact-iso";
|
|
1065
|
+
import {
|
|
1066
|
+
Locales,
|
|
1067
|
+
getHTMLTextDir,
|
|
1068
|
+
getLocaleName,
|
|
1069
|
+
getLocalizedUrl,
|
|
1070
|
+
} from "intlayer";
|
|
1071
|
+
import { useLocale } from "preact-intlayer";
|
|
1072
|
+
import type { FunctionalComponent } from "preact";
|
|
1073
|
+
|
|
1074
|
+
const LocaleSwitcher: FunctionalComponent = () => {
|
|
1075
|
+
const location = useLocation();
|
|
1076
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1077
|
+
onLocaleChange: (newLocale) => {
|
|
1078
|
+
const currentFullPath = location.url; // preact-iso fornece a URL completa
|
|
1079
|
+
// Constrói a URL com o idioma atualizado
|
|
1080
|
+
// Exemplo: /es/about?foo=bar
|
|
1081
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1082
|
+
|
|
1083
|
+
// Atualiza o caminho da URL
|
|
1084
|
+
route(pathWithLocale, true); // true para substituir
|
|
1085
|
+
},
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
return (
|
|
1089
|
+
<div>
|
|
1090
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1091
|
+
<div id="localePopover" popover="auto">
|
|
1092
|
+
{availableLocales.map((localeItem) => (
|
|
1093
|
+
<a
|
|
1094
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1095
|
+
hreflang={localeItem}
|
|
1096
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1097
|
+
onClick={(e) => {
|
|
1098
|
+
e.preventDefault();
|
|
1099
|
+
setLocale(localeItem);
|
|
1100
|
+
// A navegação programática após definir o idioma será tratada por onLocaleChange
|
|
1101
|
+
}}
|
|
1102
|
+
key={localeItem}
|
|
1103
|
+
>
|
|
1104
|
+
<span>
|
|
1105
|
+
{/* Idioma - ex.: FR */}
|
|
1106
|
+
{localeItem}
|
|
1107
|
+
</span>
|
|
1108
|
+
<span>
|
|
1109
|
+
{/* Idioma no próprio idioma - ex.: Français */}
|
|
1110
|
+
{getLocaleName(localeItem, localeItem)}
|
|
1111
|
+
</span>
|
|
1112
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1113
|
+
{/* Idioma no idioma atual - ex.: Francés com o idioma atual definido como Locales.SPANISH */}
|
|
1114
|
+
{getLocaleName(localeItem, locale)}
|
|
1115
|
+
</span>
|
|
1116
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1117
|
+
{/* Idioma em inglês - ex.: French */}
|
|
1118
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1119
|
+
</span>
|
|
1120
|
+
</a>
|
|
1121
|
+
))}
|
|
1122
|
+
</div>
|
|
1123
|
+
</div>
|
|
1124
|
+
);
|
|
1125
|
+
};
|
|
1126
|
+
|
|
1127
|
+
export default LocaleSwitcher;
|
|
1128
|
+
```
|
|
1129
|
+
|
|
1130
|
+
```jsx fileName="src/components/LocaleSwitcher.jsx" codeFormat="esm"
|
|
1131
|
+
import { useLocation, route } from "preact-iso";
|
|
1132
|
+
import {
|
|
1133
|
+
Locales,
|
|
1134
|
+
getHTMLTextDir,
|
|
1135
|
+
getLocaleName,
|
|
1136
|
+
getLocalizedUrl,
|
|
1137
|
+
} from "intlayer";
|
|
1138
|
+
import { useLocale } from "preact-intlayer";
|
|
1139
|
+
import { h } from "preact"; // Para JSX
|
|
1140
|
+
|
|
1141
|
+
const LocaleSwitcher = () => {
|
|
1142
|
+
const location = useLocation();
|
|
1143
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1144
|
+
onLocaleChange: (newLocale) => {
|
|
1145
|
+
const currentFullPath = location.url;
|
|
1146
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1147
|
+
route(pathWithLocale, true);
|
|
1148
|
+
},
|
|
1149
|
+
});
|
|
1150
|
+
|
|
1151
|
+
return (
|
|
1152
|
+
<div>
|
|
1153
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1154
|
+
<div id="localePopover" popover="auto">
|
|
1155
|
+
{availableLocales.map((localeItem) => (
|
|
1156
|
+
<a
|
|
1157
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1158
|
+
hreflang={localeItem}
|
|
1159
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1160
|
+
onClick={(e) => {
|
|
1161
|
+
e.preventDefault();
|
|
1162
|
+
setLocale(localeItem);
|
|
1163
|
+
}}
|
|
1164
|
+
key={localeItem}
|
|
1165
|
+
>
|
|
1166
|
+
<span>{localeItem}</span>
|
|
1167
|
+
<span>{getLocaleName(localeItem, localeItem)}</span>
|
|
1168
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1169
|
+
{getLocaleName(localeItem, locale)}
|
|
1170
|
+
</span>
|
|
1171
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1172
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1173
|
+
</span>
|
|
1174
|
+
</a>
|
|
1175
|
+
))}
|
|
1176
|
+
</div>
|
|
1177
|
+
</div>
|
|
1178
|
+
);
|
|
1179
|
+
};
|
|
1180
|
+
|
|
1181
|
+
export default LocaleSwitcher;
|
|
1182
|
+
```
|
|
1183
|
+
|
|
1184
|
+
```jsx fileName="src/components/LocaleSwitcher.cjsx" codeFormat="commonjs"
|
|
1185
|
+
const { useLocation, route } = require("preact-iso");
|
|
1186
|
+
const {
|
|
1187
|
+
Locales,
|
|
1188
|
+
getHTMLTextDir,
|
|
1189
|
+
getLocaleName,
|
|
1190
|
+
getLocalizedUrl,
|
|
1191
|
+
} = require("intlayer");
|
|
1192
|
+
const { useLocale } = require("preact-intlayer");
|
|
1193
|
+
const { h } = require("preact"); // Para JSX
|
|
1194
|
+
|
|
1195
|
+
const LocaleSwitcher = () => {
|
|
1196
|
+
const location = useLocation();
|
|
1197
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1198
|
+
onLocaleChange: (newLocale) => {
|
|
1199
|
+
const currentFullPath = location.url;
|
|
1200
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1201
|
+
route(pathWithLocale, true);
|
|
1202
|
+
},
|
|
1203
|
+
});
|
|
1204
|
+
|
|
1205
|
+
return (
|
|
1206
|
+
<div>
|
|
1207
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1208
|
+
<div id="localePopover" popover="auto">
|
|
1209
|
+
{availableLocales.map((localeItem) => (
|
|
1210
|
+
<a
|
|
1211
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1212
|
+
hreflang={localeItem}
|
|
1213
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1214
|
+
onClick={(e) => {
|
|
1215
|
+
e.preventDefault();
|
|
1216
|
+
setLocale(localeItem);
|
|
1217
|
+
}}
|
|
1218
|
+
key={localeItem}
|
|
1219
|
+
>
|
|
1220
|
+
<span>{localeItem}</span>
|
|
1221
|
+
<span>{getLocaleName(localeItem, localeItem)}</span>
|
|
1222
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1223
|
+
{getLocaleName(localeItem, locale)}
|
|
1224
|
+
</span>
|
|
1225
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1226
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1227
|
+
</span>
|
|
1228
|
+
</a>
|
|
1229
|
+
))}
|
|
1230
|
+
</div>
|
|
1231
|
+
</div>
|
|
1232
|
+
);
|
|
1233
|
+
};
|
|
1234
|
+
|
|
1235
|
+
module.exports = LocaleSwitcher;
|
|
1236
|
+
```
|
|
1237
|
+
|
|
1238
|
+
> Referências da documentação:
|
|
1239
|
+
|
|
1240
|
+
> - [`useLocale` hook](https://github.com/aymericzip/intlayer/blob/main/docs/pt/packages/react-intlayer/useLocale.md) (A API é semelhante para `preact-intlayer`)
|
|
1241
|
+
|
|
1242
|
+
> - [`getLocaleName` hook](https://github.com/aymericzip/intlayer/blob/main/docs/pt/packages/intlayer/getLocaleName.md)
|
|
1243
|
+
|
|
1244
|
+
> - [`getLocalizedUrl` hook](https://github.com/aymericzip/intlayer/blob/main/docs/pt/packages/intlayer/getLocalizedUrl.md)
|
|
1245
|
+
|
|
1246
|
+
> - [`getHTMLTextDir` hook](https://github.com/aymericzip/intlayer/blob/main/docs/pt/packages/intlayer/getHTMLTextDir.md)
|
|
1247
|
+
|
|
1248
|
+
> - [`hreflang` attribute](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=pt)
|
|
1249
|
+
|
|
1250
|
+
> - [`lang` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
|
|
1251
|
+
|
|
1252
|
+
> - [`dir` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
|
|
1253
|
+
|
|
1254
|
+
> - [`aria-current` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1255
|
+
|
|
1256
|
+
> - [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
1257
|
+
|
|
1258
|
+
Abaixo está o **Passo 9** atualizado com explicações adicionais e exemplos de código refinados:
|
|
1259
|
+
|
|
1260
|
+
---
|
|
1261
|
+
|
|
1262
|
+
### (Opcional) Passo 9: Alterar os Atributos de Idioma e Direção do HTML
|
|
1263
|
+
|
|
1264
|
+
Quando sua aplicação suporta múltiplos idiomas, é crucial atualizar os atributos `lang` e `dir` da tag `<html>` para corresponder ao idioma atual. Fazer isso garante:
|
|
1265
|
+
|
|
1266
|
+
- **Acessibilidade**: Leitores de tela e tecnologias assistivas dependem do atributo `lang` correto para pronunciar e interpretar o conteúdo com precisão.
|
|
1267
|
+
- **Renderização de Texto**: O atributo `dir` (direção) garante que o texto seja renderizado na ordem correta (por exemplo, da esquerda para a direita para inglês, da direita para a esquerda para árabe ou hebraico), essencial para a legibilidade.
|
|
1268
|
+
- **SEO**: Os motores de busca usam o atributo `lang` para determinar o idioma da sua página, ajudando a exibir o conteúdo localizado correto nos resultados de busca.
|
|
1269
|
+
|
|
1270
|
+
Ao atualizar esses atributos dinamicamente quando o idioma muda, você garante uma experiência consistente e acessível para os usuários em todos os idiomas suportados.
|
|
1271
|
+
|
|
1272
|
+
#### Implementando o Hook
|
|
1273
|
+
|
|
1274
|
+
Crie um hook personalizado para gerenciar os atributos HTML. O hook escuta as mudanças de idioma e atualiza os atributos de forma correspondente:
|
|
1275
|
+
|
|
1276
|
+
import { useEffect } from "preact/hooks";
|
|
1277
|
+
import { useLocale } from "preact-intlayer";
|
|
1278
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1279
|
+
|
|
1280
|
+
/\*\*
|
|
1281
|
+
|
|
1282
|
+
- Atualiza os atributos `lang` e `dir` do elemento HTML <html> com base no idioma atual.
|
|
1283
|
+
- - `lang`: Informa navegadores e motores de busca sobre o idioma da página.
|
|
1284
|
+
- - `dir`: Garante a ordem de leitura correta (por exemplo, 'ltr' para inglês, 'rtl' para árabe).
|
|
1285
|
+
-
|
|
1286
|
+
- Essa atualização dinâmica é essencial para renderização de texto adequada, acessibilidade e SEO.
|
|
1287
|
+
\*/
|
|
1288
|
+
export const useI18nHTMLAttributes = () => {
|
|
1289
|
+
const { locale } = useLocale();
|
|
1290
|
+
|
|
1291
|
+
useEffect(() => {
|
|
1292
|
+
// Atualiza o atributo de idioma para o idioma atual.
|
|
1293
|
+
document.documentElement.lang = locale;
|
|
1294
|
+
|
|
1295
|
+
// Define a direção do texto com base no idioma atual.
|
|
1296
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1297
|
+
|
|
1298
|
+
}, [locale]);
|
|
1299
|
+
};
|
|
1300
|
+
|
|
1301
|
+
````
|
|
1302
|
+
|
|
1303
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.jsx" codeFormat="esm"
|
|
1304
|
+
import { useEffect } from "preact/hooks";
|
|
1305
|
+
import { useLocale } from "preact-intlayer";
|
|
1306
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1307
|
+
|
|
1308
|
+
/**
|
|
1309
|
+
* Atualiza os atributos `lang` e `dir` do elemento HTML <html> com base no idioma atual.
|
|
1310
|
+
*/
|
|
1311
|
+
export const useI18nHTMLAttributes = () => {
|
|
1312
|
+
const { locale } = useLocale();
|
|
1313
|
+
|
|
1314
|
+
useEffect(() => {
|
|
1315
|
+
document.documentElement.lang = locale;
|
|
1316
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1317
|
+
}, [locale]);
|
|
1318
|
+
};
|
|
1319
|
+
````
|
|
1320
|
+
|
|
1321
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.cjsx" codeFormat="commonjs"
|
|
1322
|
+
const { useEffect } = require("preact/hooks");
|
|
1323
|
+
const { useLocale } = require("preact-intlayer");
|
|
1324
|
+
const { getHTMLTextDir } = require("intlayer");
|
|
1325
|
+
|
|
1326
|
+
/**
|
|
1327
|
+
* Atualiza os atributos `lang` e `dir` do elemento HTML <html> com base no idioma atual.
|
|
1328
|
+
*/
|
|
1329
|
+
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
|
+
module.exports = { useI18nHTMLAttributes };
|
|
1339
|
+
```
|
|
1340
|
+
|
|
1341
|
+
#### Usando o Hook na Sua Aplicação
|
|
1342
|
+
|
|
1343
|
+
Integre o hook no seu componente principal para que os atributos HTML sejam atualizados sempre que o idioma mudar:
|
|
1344
|
+
|
|
1345
|
+
```tsx fileName="src/app.tsx" codeFormat="typescript"
|
|
1346
|
+
import type { FunctionalComponent } from "preact";
|
|
1347
|
+
import { IntlayerProvider } from "preact-intlayer"; // useIntlayer já importado se AppContent precisar
|
|
1348
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1349
|
+
import "./app.css";
|
|
1350
|
+
// Definição de AppContent do Passo 5
|
|
1351
|
+
|
|
1352
|
+
const AppWithHooks: FunctionalComponent = () => {
|
|
1353
|
+
// Aplica o hook para atualizar os atributos lang e dir da tag <html> com base no idioma.
|
|
1354
|
+
useI18nHTMLAttributes();
|
|
1355
|
+
|
|
1356
|
+
// Supondo que AppContent seja o componente principal de exibição de conteúdo do Passo 5
|
|
1357
|
+
return <AppContent />;
|
|
1358
|
+
};
|
|
1359
|
+
|
|
1360
|
+
const App: FunctionalComponent = () => (
|
|
1361
|
+
<IntlayerProvider>
|
|
1362
|
+
<AppWithHooks />
|
|
1363
|
+
</IntlayerProvider>
|
|
1364
|
+
);
|
|
1365
|
+
|
|
1366
|
+
export default App;
|
|
1367
|
+
```
|
|
1368
|
+
|
|
1369
|
+
```jsx fileName="src/app.jsx" codeFormat="esm"
|
|
1370
|
+
import { IntlayerProvider } from "preact-intlayer";
|
|
1371
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1372
|
+
import "./app.css";
|
|
1373
|
+
// Definição de AppContent do Passo 5
|
|
1374
|
+
|
|
1375
|
+
const AppWithHooks = () => {
|
|
1376
|
+
useI18nHTMLAttributes();
|
|
1377
|
+
return <AppContent />;
|
|
1378
|
+
};
|
|
1379
|
+
|
|
1380
|
+
const App = () => (
|
|
1381
|
+
<IntlayerProvider>
|
|
1382
|
+
<AppWithHooks />
|
|
1383
|
+
</IntlayerProvider>
|
|
1384
|
+
);
|
|
1385
|
+
|
|
1386
|
+
export default App;
|
|
1387
|
+
```
|
|
1388
|
+
|
|
1389
|
+
```jsx fileName="src/app.cjsx" codeFormat="commonjs"
|
|
1390
|
+
const { IntlayerProvider } = require("preact-intlayer");
|
|
1391
|
+
const { useI18nHTMLAttributes } = require("./hooks/useI18nHTMLAttributes");
|
|
1392
|
+
require("./app.css");
|
|
1393
|
+
// Definição de AppContent do Passo 5
|
|
1394
|
+
|
|
1395
|
+
const AppWithHooks = () => {
|
|
1396
|
+
useI18nHTMLAttributes();
|
|
1397
|
+
return <AppContent />;
|
|
1398
|
+
};
|
|
1399
|
+
|
|
1400
|
+
const App = () => (
|
|
1401
|
+
<IntlayerProvider>
|
|
1402
|
+
<AppWithHooks />
|
|
1403
|
+
</IntlayerProvider>
|
|
1404
|
+
);
|
|
1405
|
+
|
|
1406
|
+
module.exports = App;
|
|
1407
|
+
```
|
|
1408
|
+
|
|
1409
|
+
Ao aplicar essas alterações, sua aplicação irá:
|
|
1410
|
+
|
|
1411
|
+
- Garantir que o atributo **idioma** (`lang`) reflita corretamente o idioma atual, o que é importante para SEO e comportamento do navegador.
|
|
1412
|
+
- Ajustar a **direção do texto** (`dir`) de acordo com o idioma, melhorando a legibilidade e usabilidade para idiomas com ordens de leitura diferentes.
|
|
1413
|
+
- Proporcionar uma experiência mais **acessível**, já que tecnologias assistivas dependem desses atributos para funcionar de forma ideal.
|
|
1414
|
+
|
|
1415
|
+
### (Opcional) Passo 10: Criando um Componente de Link Localizado
|
|
1416
|
+
|
|
1417
|
+
Para garantir que a navegação da sua aplicação respeite o idioma atual, você pode criar um componente de `Link` personalizado. Este componente automaticamente adiciona o prefixo do idioma atual às URLs internas.
|
|
1418
|
+
|
|
1419
|
+
Esse comportamento é útil por vários motivos:
|
|
1420
|
+
|
|
1421
|
+
- **SEO e Experiência do Usuário**: URLs localizadas ajudam os motores de busca a indexar corretamente as páginas específicas de cada idioma e fornecem aos usuários conteúdo no idioma preferido.
|
|
1422
|
+
- **Consistência**: Usando um link localizado em toda a aplicação, você garante que a navegação permaneça no idioma atual, evitando mudanças inesperadas de idioma.
|
|
1423
|
+
- **Manutenibilidade**: Centralizar a lógica de localização em um único componente simplifica o gerenciamento de URLs.
|
|
1424
|
+
|
|
1425
|
+
Para Preact com `preact-iso`, tags padrão `<a>` são normalmente usadas para navegação, e o `preact-iso` gerencia o roteamento. Se você precisar de navegação programática ao clicar (por exemplo, para realizar ações antes de navegar), pode usar a função `route` de `useLocation`. Veja como criar um componente de âncora personalizado que localiza URLs:
|
|
1426
|
+
|
|
1427
|
+
```tsx fileName="src/components/LocalizedLink.tsx" codeFormat="typescript"
|
|
1428
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1429
|
+
import { useLocale, useLocation, route } from "preact-intlayer"; // Supondo que useLocation e route possam ser do preact-iso via preact-intlayer se reexportados, ou importados diretamente
|
|
1430
|
+
// Se não forem reexportados, importe diretamente: import { useLocation, route } from "preact-iso";
|
|
1431
|
+
import type { JSX } from "preact"; // Para HTMLAttributes
|
|
1432
|
+
import { forwardRef } from "preact/compat"; // Para encaminhar refs
|
|
1433
|
+
|
|
1434
|
+
export interface LocalizedLinkProps
|
|
1435
|
+
extends JSX.HTMLAttributes<HTMLAnchorElement> {
|
|
1436
|
+
href: string;
|
|
1437
|
+
replace?: boolean; // Opcional: para substituir o estado do histórico
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
/**
|
|
1441
|
+
* Função utilitária para verificar se uma URL é externa.
|
|
1442
|
+
* Se a URL começar com http:// ou https://, é considerada externa.
|
|
1443
|
+
*/
|
|
1444
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1445
|
+
/^https?:\/\//.test(href ?? "");
|
|
1446
|
+
|
|
1447
|
+
/**
|
|
1448
|
+
* Um componente de Link personalizado que adapta o atributo href com base no idioma atual.
|
|
1449
|
+
* Para links internos, ele usa `getLocalizedUrl` para adicionar o prefixo do idioma à URL (por exemplo, /pt/sobre).
|
|
1450
|
+
* Isso garante que a navegação permaneça dentro do contexto do idioma atual.
|
|
1451
|
+
* Ele usa uma tag padrão <a>, mas pode acionar navegação no cliente usando o `route` do preact-iso.
|
|
1452
|
+
*/
|
|
1453
|
+
export const LocalizedLink = forwardRef<HTMLAnchorElement, LocalizedLinkProps>(
|
|
1454
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1455
|
+
const { locale } = useLocale();
|
|
1456
|
+
const location = useLocation(); // do preact-iso
|
|
1457
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1458
|
+
|
|
1459
|
+
const hrefI18n =
|
|
1460
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1461
|
+
|
|
1462
|
+
const handleClick = (event: JSX.TargetedMouseEvent<HTMLAnchorElement>) => {
|
|
1463
|
+
if (onClick) {
|
|
1464
|
+
onClick(event);
|
|
1465
|
+
}
|
|
1466
|
+
if (
|
|
1467
|
+
!isExternalLink &&
|
|
1468
|
+
href && // Garante que href está definido
|
|
1469
|
+
event.button === 0 && // Clique esquerdo
|
|
1470
|
+
!event.metaKey &&
|
|
1471
|
+
!event.ctrlKey &&
|
|
1472
|
+
!event.shiftKey &&
|
|
1473
|
+
!event.altKey && // Verificação de modificadores padrão
|
|
1474
|
+
!props.target // Não direcionando para uma nova aba/janela
|
|
1475
|
+
) {
|
|
1476
|
+
event.preventDefault();
|
|
1477
|
+
if (location.url !== hrefI18n) {
|
|
1478
|
+
// Navega apenas se a URL for diferente
|
|
1479
|
+
route(hrefI18n, replace); // Usa o route do preact-iso
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
|
|
1484
|
+
return (
|
|
1485
|
+
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1486
|
+
{children}
|
|
1487
|
+
</a>
|
|
1488
|
+
);
|
|
1489
|
+
}
|
|
1490
|
+
);
|
|
1491
|
+
```
|
|
1492
|
+
|
|
1493
|
+
```jsx fileName="src/components/LocalizedLink.jsx" codeFormat="esm"
|
|
1494
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1495
|
+
import { useLocale } from "preact-intlayer";
|
|
1496
|
+
|
|
1497
|
+
import { useLocation, route } from "preact-iso"; // Importar de preact-iso
|
|
1498
|
+
import { forwardRef } from "preact/compat";
|
|
1499
|
+
import { h } from "preact"; // Para JSX
|
|
1500
|
+
|
|
1501
|
+
export const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1502
|
+
|
|
1503
|
+
export const LocalizedLink = forwardRef(
|
|
1504
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1505
|
+
const { locale } = useLocale();
|
|
1506
|
+
const location = useLocation();
|
|
1507
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1508
|
+
|
|
1509
|
+
const hrefI18n =
|
|
1510
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1511
|
+
|
|
1512
|
+
const handleClick = (event) => {
|
|
1513
|
+
if (onClick) {
|
|
1514
|
+
onClick(event);
|
|
1515
|
+
}
|
|
1516
|
+
if (
|
|
1517
|
+
!isExternalLink &&
|
|
1518
|
+
href &&
|
|
1519
|
+
event.button === 0 &&
|
|
1520
|
+
!event.metaKey &&
|
|
1521
|
+
!event.ctrlKey &&
|
|
1522
|
+
!event.shiftKey &&
|
|
1523
|
+
!event.altKey &&
|
|
1524
|
+
!props.target
|
|
1525
|
+
) {
|
|
1526
|
+
event.preventDefault();
|
|
1527
|
+
if (location.url !== hrefI18n) {
|
|
1528
|
+
route(hrefI18n, replace);
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
return (
|
|
1534
|
+
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1535
|
+
{children}
|
|
1536
|
+
</a>
|
|
1537
|
+
);
|
|
1538
|
+
}
|
|
1539
|
+
);
|
|
1540
|
+
```
|
|
1541
|
+
|
|
1542
|
+
```jsx fileName="src/components/LocalizedLink.cjsx" codeFormat="commonjs"
|
|
1543
|
+
const { getLocalizedUrl } = require("intlayer");
|
|
1544
|
+
const { useLocale } = require("preact-intlayer");
|
|
1545
|
+
const { useLocation, route } = require("preact-iso"); // Importar de preact-iso
|
|
1546
|
+
const { forwardRef } = require("preact/compat");
|
|
1547
|
+
const { h } = require("preact"); // Para JSX
|
|
1548
|
+
|
|
1549
|
+
const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1550
|
+
|
|
1551
|
+
const LocalizedLink = forwardRef(
|
|
1552
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1553
|
+
const { locale } = useLocale();
|
|
1554
|
+
const location = useLocation();
|
|
1555
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1556
|
+
|
|
1557
|
+
const hrefI18n =
|
|
1558
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1559
|
+
|
|
1560
|
+
const handleClick = (event) => {
|
|
1561
|
+
if (onClick) {
|
|
1562
|
+
onClick(event);
|
|
1563
|
+
}
|
|
1564
|
+
if (
|
|
1565
|
+
!isExternalLink &&
|
|
1566
|
+
href &&
|
|
1567
|
+
event.button === 0 &&
|
|
1568
|
+
!event.metaKey &&
|
|
1569
|
+
!event.ctrlKey &&
|
|
1570
|
+
!event.shiftKey &&
|
|
1571
|
+
!event.altKey &&
|
|
1572
|
+
!props.target
|
|
1573
|
+
) {
|
|
1574
|
+
event.preventDefault();
|
|
1575
|
+
if (location.url !== hrefI18n) {
|
|
1576
|
+
route(hrefI18n, replace);
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
|
|
1581
|
+
return (
|
|
1582
|
+
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1583
|
+
{children}
|
|
1584
|
+
</a>
|
|
1585
|
+
);
|
|
1586
|
+
}
|
|
1587
|
+
);
|
|
1588
|
+
|
|
1589
|
+
module.exports = { LocalizedLink, checkIsExternalLink };
|
|
1590
|
+
```
|
|
1591
|
+
|
|
1592
|
+
#### Como Funciona
|
|
1593
|
+
|
|
1594
|
+
- **Detectando Links Externos**:
|
|
1595
|
+
A função auxiliar `checkIsExternalLink` determina se uma URL é externa. Links externos permanecem inalterados.
|
|
1596
|
+
- **Recuperando o Idioma Atual**:
|
|
1597
|
+
O hook `useLocale` fornece o idioma atual.
|
|
1598
|
+
- **Localizando a URL**:
|
|
1599
|
+
Para links internos, `getLocalizedUrl` adiciona o prefixo do idioma atual à URL.
|
|
1600
|
+
- **Navegação no Lado do Cliente**:
|
|
1601
|
+
A função `handleClick` verifica se é um link interno e se a navegação padrão deve ser evitada. Se sim, utiliza a função `route` do `preact-iso` (obtida via `useLocation` ou importada diretamente) para realizar a navegação no lado do cliente. Isso proporciona um comportamento semelhante a uma SPA sem recarregar a página inteira.
|
|
1602
|
+
- **Retornando o Link**:
|
|
1603
|
+
O componente retorna um elemento `<a>` com a URL localizada e o manipulador de clique personalizado.
|
|
1604
|
+
|
|
1605
|
+
### Configurar TypeScript
|
|
1606
|
+
|
|
1607
|
+
O Intlayer utiliza a ampliação de módulos para aproveitar os benefícios do TypeScript e tornar sua base de código mais robusta.
|
|
1608
|
+
|
|
1609
|
+

|
|
1610
|
+
|
|
1611
|
+

|
|
1612
|
+
|
|
1613
|
+
Certifique-se de que sua configuração do TypeScript inclua os tipos gerados automaticamente.
|
|
1614
|
+
|
|
1615
|
+
```json5 fileName="tsconfig.json"
|
|
1616
|
+
{
|
|
1617
|
+
// ... Suas configurações existentes do TypeScript
|
|
1618
|
+
"compilerOptions": {
|
|
1619
|
+
// ...
|
|
1620
|
+
"jsx": "react-jsx",
|
|
1621
|
+
"jsxImportSource": "preact", // Recomendado para Preact 10+
|
|
1622
|
+
// ...
|
|
1623
|
+
},
|
|
1624
|
+
"include": [
|
|
1625
|
+
// ... Suas configurações existentes do TypeScript
|
|
1626
|
+
".intlayer/**/*.ts", // Inclua os tipos gerados automaticamente
|
|
1627
|
+
],
|
|
1628
|
+
}
|
|
1629
|
+
```
|
|
1630
|
+
|
|
1631
|
+
> Certifique-se de que seu `tsconfig.json` esteja configurado para Preact, especialmente `jsx` e `jsxImportSource` ou `jsxFactory`/`jsxFragmentFactory` para versões mais antigas do Preact, caso não esteja usando os padrões do `preset-vite`.
|
|
1632
|
+
|
|
1633
|
+
### Configuração do Git
|
|
1634
|
+
|
|
1635
|
+
Recomenda-se ignorar os arquivos gerados pelo Intlayer. Isso permite evitar que sejam adicionados ao seu repositório Git.
|
|
1636
|
+
|
|
1637
|
+
Para isso, você pode adicionar as seguintes instruções ao seu arquivo `.gitignore`:
|
|
1638
|
+
|
|
1639
|
+
```plaintext
|
|
1640
|
+
# Ignore os arquivos gerados pelo Intlayer
|
|
1641
|
+
.intlayer
|
|
1642
|
+
```
|
|
1643
|
+
|
|
1644
|
+
### Extensão do VS Code
|
|
1645
|
+
|
|
1646
|
+
Para melhorar sua experiência de desenvolvimento com o Intlayer, você pode instalar a **Extensão Oficial do Intlayer para VS Code**.
|
|
1647
|
+
|
|
1648
|
+
[Instale no VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
1649
|
+
|
|
1650
|
+
Esta extensão fornece:
|
|
1651
|
+
|
|
1652
|
+
- **Autocompletar** para chaves de tradução.
|
|
1653
|
+
- **Detecção de erros em tempo real** para traduções ausentes.
|
|
1654
|
+
- **Pré-visualizações inline** de conteúdo traduzido.
|
|
1655
|
+
- **Ações rápidas** para criar e atualizar traduções facilmente.
|
|
1656
|
+
|
|
1657
|
+
Para mais detalhes sobre como usar a extensão, consulte a [documentação da Extensão do Intlayer para VS Code](https://intlayer.org/doc/vs-code-extension).
|
|
1658
|
+
|
|
1659
|
+
---
|
|
1660
|
+
|
|
1661
|
+
### Vá Além
|
|
1662
|
+
|
|
1663
|
+
## Para ir além, você pode implementar o [editor visual](https://github.com/aymericzip/intlayer/blob/main/docs/pt/intlayer_visual_editor.md) ou externalizar seu conteúdo usando o [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/pt/intlayer_CMS.md).
|