@intlayer/docs 5.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/ar/CI_CD.md +149 -0
- package/ar/autoFill.md +157 -0
- package/ar/concept/content/file.md +1 -0
- package/ar/configuration.md +492 -0
- package/ar/dictionary/condition.md +213 -0
- package/ar/dictionary/content_extention_customization.md +81 -0
- package/ar/dictionary/enumeration.md +221 -0
- package/ar/dictionary/file.md +209 -0
- package/ar/dictionary/function_fetching.md +190 -0
- package/ar/dictionary/get_started.md +490 -0
- package/ar/dictionary/insertion.md +161 -0
- package/ar/dictionary/markdown.md +343 -0
- package/ar/dictionary/nesting.md +249 -0
- package/ar/dictionary/translation.md +307 -0
- package/ar/header.md +7 -0
- package/ar/how_works_intlayer.md +219 -0
- package/ar/index.md +125 -0
- package/ar/interest_of_intlayer.md +132 -0
- package/ar/intlayer_CMS.md +328 -0
- package/ar/intlayer_cli.md +258 -0
- package/ar/intlayer_visual_editor.md +210 -0
- package/ar/intlayer_with_angular.md +3 -0
- package/ar/intlayer_with_create_react_app.md +1196 -0
- package/ar/intlayer_with_express.md +270 -0
- package/ar/intlayer_with_lynx+react.md +482 -0
- package/ar/intlayer_with_nextjs_14.md +1260 -0
- package/ar/intlayer_with_nextjs_15.md +1311 -0
- package/ar/intlayer_with_nextjs_page_router.md +1099 -0
- package/ar/intlayer_with_react_native+expo.md +539 -0
- package/ar/intlayer_with_vite+preact.md +1679 -0
- package/ar/intlayer_with_vite+react.md +1582 -0
- package/ar/intlayer_with_vite+solid.md +3 -0
- package/ar/intlayer_with_vite+svelte.md +3 -0
- package/ar/intlayer_with_vite+vue.md +989 -0
- package/ar/introduction.md +190 -0
- package/ar/mcp_server.md +150 -0
- package/ar/packages/@intlayer/api/index.md +31 -0
- package/ar/packages/@intlayer/chokidar/index.md +31 -0
- package/ar/packages/@intlayer/cli/index.md +1 -0
- package/ar/packages/@intlayer/config/index.md +116 -0
- package/ar/packages/@intlayer/core/index.md +25 -0
- package/ar/packages/@intlayer/design-system/index.md +21 -0
- package/ar/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/ar/packages/@intlayer/editor/index.md +21 -0
- package/ar/packages/@intlayer/editor-react/index.md +21 -0
- package/ar/packages/@intlayer/webpack/index.md +35 -0
- package/ar/packages/angular-intlayer/index.md +3 -0
- package/ar/packages/express-intlayer/index.md +232 -0
- package/ar/packages/express-intlayer/t.md +448 -0
- package/ar/packages/intlayer/getConfiguration.md +120 -0
- package/ar/packages/intlayer/getEnumeration.md +138 -0
- package/ar/packages/intlayer/getHTMLTextDir.md +97 -0
- package/ar/packages/intlayer/getLocaleLang.md +61 -0
- package/ar/packages/intlayer/getLocaleName.md +93 -0
- package/ar/packages/intlayer/getLocalizedUrl.md +221 -0
- package/ar/packages/intlayer/getMultilingualUrls.md +198 -0
- package/ar/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/ar/packages/intlayer/getTranslation.md +175 -0
- package/ar/packages/intlayer/getTranslationContent.md +175 -0
- package/ar/packages/intlayer/index.md +254 -0
- package/ar/packages/intlayer-cli/index.md +41 -0
- package/ar/packages/intlayer-editor/index.md +113 -0
- package/ar/packages/lynx-intlayer/index.md +58 -0
- package/ar/packages/next-intlayer/index.md +267 -0
- package/ar/packages/next-intlayer/t.md +341 -0
- package/ar/packages/next-intlayer/useDictionary.md +248 -0
- package/ar/packages/next-intlayer/useIntlayer.md +237 -0
- package/ar/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/ar/packages/next-intlayer/useLocale.md +105 -0
- package/ar/packages/preact-intlayer/index.md +3 -0
- package/ar/packages/react-intlayer/index.md +261 -0
- package/ar/packages/react-intlayer/t.md +283 -0
- package/ar/packages/react-intlayer/useDictionary.md +268 -0
- package/ar/packages/react-intlayer/useIntlayer.md +225 -0
- package/ar/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/ar/packages/react-intlayer/useLocale.md +184 -0
- package/ar/packages/react-native-intlayer/index.md +57 -0
- package/ar/packages/react-scripts-intlayer/index.md +57 -0
- package/ar/packages/solid-intlayer/index.md +3 -0
- package/ar/packages/svelte-intlayer/index.md +3 -0
- package/ar/packages/vite-intlayer/index.md +53 -0
- package/ar/packages/vue-intlayer/index.md +3 -0
- package/ar/per_locale_file.md +298 -0
- package/ar/privacy_notice.md +61 -0
- package/ar/roadmap.md +208 -0
- package/ar/terms_of_service.md +33 -0
- package/ar/vs_code_extension.md +139 -0
- package/de/CI_CD.md +149 -0
- package/de/angular-intlayer/index.md +3 -0
- package/de/autoFill.md +157 -0
- package/de/configuration.md +501 -0
- package/de/dictionary/condition.md +213 -0
- package/de/dictionary/content_extention_customization.md +81 -0
- package/de/dictionary/enumeration.md +221 -0
- package/de/dictionary/file.md +207 -0
- package/de/dictionary/function_fetching.md +190 -0
- package/de/dictionary/get_started.md +466 -0
- package/de/dictionary/insertion.md +167 -0
- package/de/dictionary/markdown.md +345 -0
- package/de/dictionary/nesting.md +252 -0
- package/de/dictionary/translation.md +287 -0
- package/de/header.md +5 -0
- package/de/how_works_intlayer.md +216 -0
- package/de/index.md +125 -0
- package/de/insertion.md +0 -0
- package/de/interest_of_intlayer.md +132 -0
- package/de/intlayer_CMS.md +334 -0
- package/de/intlayer_cli.md +274 -0
- package/de/intlayer_visual_editor.md +210 -0
- package/de/intlayer_with_angular.md +3 -0
- package/de/intlayer_with_create_react_app.md +1200 -0
- package/de/intlayer_with_express.md +268 -0
- package/de/intlayer_with_lynx+react.md +482 -0
- package/de/intlayer_with_nextjs_14.md +1258 -0
- package/de/intlayer_with_nextjs_15.md +1306 -0
- package/de/intlayer_with_nextjs_page_router.md +1087 -0
- package/de/intlayer_with_react_native+expo.md +539 -0
- package/de/intlayer_with_vite+preact.md +1701 -0
- package/de/intlayer_with_vite+react.md +1584 -0
- package/de/intlayer_with_vite+solid.md +3 -0
- package/de/intlayer_with_vite+svelte.md +3 -0
- package/de/intlayer_with_vite+vue.md +989 -0
- package/de/introduction.md +186 -0
- package/de/mcp_server.md +150 -0
- package/de/packages/@intlayer/api/index.md +31 -0
- package/de/packages/@intlayer/chokidar/index.md +31 -0
- package/de/packages/@intlayer/cli/index.md +21 -0
- package/de/packages/@intlayer/config/index.md +116 -0
- package/de/packages/@intlayer/core/index.md +25 -0
- package/de/packages/@intlayer/design-system/index.md +21 -0
- package/de/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/de/packages/@intlayer/editor/index.md +21 -0
- package/de/packages/@intlayer/editor-react/index.md +21 -0
- package/de/packages/@intlayer/webpack/index.md +35 -0
- package/de/packages/angular-intlayer/index.md +31 -0
- package/de/packages/express-intlayer/index.md +229 -0
- package/de/packages/express-intlayer/t.md +432 -0
- package/de/packages/intlayer/getConfiguration.md +120 -0
- package/de/packages/intlayer/getEnumeration.md +140 -0
- package/de/packages/intlayer/getHTMLTextDir.md +97 -0
- package/de/packages/intlayer/getLocaleLang.md +57 -0
- package/de/packages/intlayer/getLocaleName.md +93 -0
- package/de/packages/intlayer/getLocalizedUrl.md +221 -0
- package/de/packages/intlayer/getMultilingualUrls.md +198 -0
- package/de/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/de/packages/intlayer/getTranslation.md +166 -0
- package/de/packages/intlayer/getTranslationContent.md +166 -0
- package/de/packages/intlayer/index.md +478 -0
- package/de/packages/intlayer-cli/index.md +41 -0
- package/de/packages/intlayer-editor/index.md +113 -0
- package/de/packages/lynx-intlayer/index.md +58 -0
- package/de/packages/next-intlayer/index.md +263 -0
- package/de/packages/next-intlayer/t.md +325 -0
- package/de/packages/next-intlayer/useDictionary.md +242 -0
- package/de/packages/next-intlayer/useIntlayer.md +237 -0
- package/de/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/de/packages/next-intlayer/useLocale.md +105 -0
- package/de/packages/preact-intlayer/index.md +3 -0
- package/de/packages/react-intlayer/index.md +260 -0
- package/de/packages/react-intlayer/t.md +277 -0
- package/de/packages/react-intlayer/useDictionary.md +260 -0
- package/de/packages/react-intlayer/useIntlayer.md +225 -0
- package/de/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/de/packages/react-intlayer/useLocale.md +184 -0
- package/de/packages/react-native-intlayer/index.md +57 -0
- package/de/packages/react-scripts-intlayer/index.md +57 -0
- package/de/packages/solid-intlayer/index.md +3 -0
- package/de/packages/svelte-intlayer/index.md +3 -0
- package/de/packages/vite-intlayer/index.md +53 -0
- package/de/packages/vue-intlayer/index.md +3 -0
- package/de/per_locale_file.md +298 -0
- package/de/privacy_notice.md +61 -0
- package/de/roadmap.md +206 -0
- package/de/terms_of_service.md +33 -0
- package/de/vs_code_extension.md +139 -0
- package/en/CI_CD.md +149 -0
- package/en/autoFill.md +157 -0
- package/en/configuration.md +506 -0
- package/en/dictionary/condition.md +213 -0
- package/en/dictionary/content_extention_customization.md +81 -0
- package/en/dictionary/enumeration.md +221 -0
- package/en/dictionary/file.md +198 -0
- package/en/dictionary/function_fetching.md +190 -0
- package/en/dictionary/get_started.md +504 -0
- package/en/dictionary/insertion.md +167 -0
- package/en/dictionary/markdown.md +355 -0
- package/en/dictionary/nesting.md +249 -0
- package/en/dictionary/translation.md +285 -0
- package/en/frequent_questions/build_dictionaries.md +37 -0
- package/en/frequent_questions/domain_routing.md +92 -0
- package/en/frequent_questions/esbuild_error.md +9 -0
- package/en/frequent_questions/get_locale_cookie.md +121 -0
- package/en/frequent_questions/intlayer_command_undefined.md +135 -0
- package/en/frequent_questions/locale_incorect_in_url.md +52 -0
- package/en/frequent_questions/static_rendering.md +24 -0
- package/en/frequent_questions/unknown_command.md +76 -0
- package/en/header.md +5 -0
- package/en/how_works_intlayer.md +219 -0
- package/en/index.md +139 -0
- package/en/interest_of_intlayer.md +133 -0
- package/en/intlayer_CMS.md +334 -0
- package/en/intlayer_cli.md +309 -0
- package/en/intlayer_visual_editor.md +244 -0
- package/en/intlayer_with_angular.md +139 -0
- package/en/intlayer_with_create_react_app.md +1209 -0
- package/en/intlayer_with_express.md +391 -0
- package/en/intlayer_with_lynx+react.md +483 -0
- package/en/intlayer_with_nextjs_14.md +1298 -0
- package/en/intlayer_with_nextjs_15.md +1347 -0
- package/en/intlayer_with_nextjs_page_router.md +1126 -0
- package/en/intlayer_with_react_native+expo.md +630 -0
- package/en/intlayer_with_vite+preact.md +1659 -0
- package/en/intlayer_with_vite+react.md +1605 -0
- package/en/intlayer_with_vite+solid.md +254 -0
- package/en/intlayer_with_vite+svelte.md +254 -0
- package/en/intlayer_with_vite+vue.md +1000 -0
- package/en/introduction.md +185 -0
- package/en/mcp_server.md +150 -0
- package/en/packages/@intlayer/api/index.md +31 -0
- package/en/packages/@intlayer/chokidar/index.md +31 -0
- package/en/packages/@intlayer/cli/index.md +21 -0
- package/en/packages/@intlayer/config/index.md +116 -0
- package/en/packages/@intlayer/core/index.md +25 -0
- package/en/packages/@intlayer/design-system/index.md +21 -0
- package/en/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/en/packages/@intlayer/editor/index.md +21 -0
- package/en/packages/@intlayer/editor-react/index.md +21 -0
- package/en/packages/@intlayer/webpack/index.md +35 -0
- package/en/packages/angular-intlayer/index.md +31 -0
- package/en/packages/express-intlayer/index.md +229 -0
- package/en/packages/express-intlayer/t.md +432 -0
- package/en/packages/intlayer/getConfiguration.md +120 -0
- package/en/packages/intlayer/getEnumeration.md +138 -0
- package/en/packages/intlayer/getHTMLTextDir.md +97 -0
- package/en/packages/intlayer/getLocaleLang.md +57 -0
- package/en/packages/intlayer/getLocaleName.md +93 -0
- package/en/packages/intlayer/getLocalizedUrl.md +221 -0
- package/en/packages/intlayer/getMultilingualUrls.md +198 -0
- package/en/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/en/packages/intlayer/getTranslation.md +166 -0
- package/en/packages/intlayer/getTranslationContent.md +166 -0
- package/en/packages/intlayer/index.md +476 -0
- package/en/packages/intlayer-cli/index.md +41 -0
- package/en/packages/intlayer-editor/index.md +113 -0
- package/en/packages/lynx-intlayer/index.md +60 -0
- package/en/packages/next-intlayer/index.md +263 -0
- package/en/packages/next-intlayer/t.md +326 -0
- package/en/packages/next-intlayer/useDictionary.md +242 -0
- package/en/packages/next-intlayer/useIntlayer.md +237 -0
- package/en/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/en/packages/next-intlayer/useLocale.md +105 -0
- package/en/packages/preact-intlayer/index.md +31 -0
- package/en/packages/react-intlayer/index.md +257 -0
- package/en/packages/react-intlayer/t.md +277 -0
- package/en/packages/react-intlayer/useDictionary.md +260 -0
- package/en/packages/react-intlayer/useIntlayer.md +225 -0
- package/en/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/en/packages/react-intlayer/useLocale.md +184 -0
- package/en/packages/react-native-intlayer/index.md +59 -0
- package/en/packages/react-scripts-intlayer/index.md +57 -0
- package/en/packages/solid-intlayer/index.md +31 -0
- package/en/packages/svelte-intlayer/index.md +31 -0
- package/en/packages/vite-intlayer/index.md +53 -0
- package/en/packages/vue-intlayer/index.md +31 -0
- package/en/per_locale_file.md +297 -0
- package/en/privacy_notice.md +61 -0
- package/en/roadmap.md +270 -0
- package/en/t.md +163 -0
- package/en/terms_of_service.md +33 -0
- package/en/vs_code_extension.md +129 -0
- package/en-GB/CI_CD.md +149 -0
- package/en-GB/autoFill.md +0 -0
- package/en-GB/configuration.md +490 -0
- package/en-GB/dictionary/condition.md +213 -0
- package/en-GB/dictionary/content_extention_customization.md +83 -0
- package/en-GB/dictionary/enumeration.md +221 -0
- package/en-GB/dictionary/file.md +201 -0
- package/en-GB/dictionary/function_fetching.md +190 -0
- package/en-GB/dictionary/get_started.md +466 -0
- package/en-GB/dictionary/insertion.md +167 -0
- package/en-GB/dictionary/markdown.md +343 -0
- package/en-GB/dictionary/nesting.md +249 -0
- package/en-GB/dictionary/translation.md +285 -0
- package/en-GB/header.md +1 -0
- package/en-GB/how_works_intlayer.md +217 -0
- package/en-GB/index.md +142 -0
- package/en-GB/interest_of_intlayer.md +123 -0
- package/en-GB/intlayer_CMS.md +334 -0
- package/en-GB/intlayer_cli.md +239 -0
- package/en-GB/intlayer_visual_editor.md +210 -0
- package/en-GB/intlayer_with_angular.md +3 -0
- package/en-GB/intlayer_with_create_react_app.md +1192 -0
- package/en-GB/intlayer_with_express.md +267 -0
- package/en-GB/intlayer_with_lynx+react.md +484 -0
- package/en-GB/intlayer_with_nextjs_14.md +1267 -0
- package/en-GB/intlayer_with_nextjs_15.md +1308 -0
- package/en-GB/intlayer_with_nextjs_page_router.md +1087 -0
- package/en-GB/intlayer_with_react_native+expo.md +539 -0
- package/en-GB/intlayer_with_vite+preact.md +1648 -0
- package/en-GB/intlayer_with_vite+react.md +1430 -0
- package/en-GB/intlayer_with_vite+solid.md +3 -0
- package/en-GB/intlayer_with_vite+svelte.md +3 -0
- package/en-GB/intlayer_with_vite+vue.md +993 -0
- package/en-GB/introduction.md +201 -0
- package/en-GB/mcp_server.md +150 -0
- package/en-GB/packages/@intlayer/api/index.md +31 -0
- package/en-GB/packages/@intlayer/chokidar/index.md +31 -0
- package/en-GB/packages/@intlayer/cli/index.md +21 -0
- package/en-GB/packages/@intlayer/config/index.md +116 -0
- package/en-GB/packages/@intlayer/core/index.md +25 -0
- package/en-GB/packages/@intlayer/design-system/index.md +21 -0
- package/en-GB/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/en-GB/packages/@intlayer/editor/index.md +21 -0
- package/en-GB/packages/@intlayer/editor-react/index.md +21 -0
- package/en-GB/packages/@intlayer/webpack/index.md +35 -0
- package/en-GB/packages/angular-intlayer/index.md +3 -0
- package/en-GB/packages/express-intlayer/index.md +229 -0
- package/en-GB/packages/express-intlayer/t.md +432 -0
- package/en-GB/packages/intlayer/getConfiguration.md +120 -0
- package/en-GB/packages/intlayer/getEnumeration.md +140 -0
- package/en-GB/packages/intlayer/getHTMLTextDir.md +97 -0
- package/en-GB/packages/intlayer/getLocaleLang.md +57 -0
- package/en-GB/packages/intlayer/getLocaleName.md +93 -0
- package/en-GB/packages/intlayer/getLocalizedUrl.md +221 -0
- package/en-GB/packages/intlayer/getMultilingualUrls.md +198 -0
- package/en-GB/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/en-GB/packages/intlayer/getTranslation.md +166 -0
- package/en-GB/packages/intlayer/getTranslationContent.md +166 -0
- package/en-GB/packages/intlayer/index.md +476 -0
- package/en-GB/packages/intlayer-cli/index.md +41 -0
- package/en-GB/packages/intlayer-editor/index.md +113 -0
- package/en-GB/packages/lynx-intlayer/index.md +58 -0
- package/en-GB/packages/next-intlayer/index.md +263 -0
- package/en-GB/packages/next-intlayer/t.md +326 -0
- package/en-GB/packages/next-intlayer/useDictionary.md +242 -0
- package/en-GB/packages/next-intlayer/useIntlayer.md +237 -0
- package/en-GB/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/en-GB/packages/next-intlayer/useLocale.md +105 -0
- package/en-GB/packages/preact-intlayer/index.md +3 -0
- package/en-GB/packages/react-intlayer/index.md +257 -0
- package/en-GB/packages/react-intlayer/t.md +277 -0
- package/en-GB/packages/react-intlayer/useDictionary.md +260 -0
- package/en-GB/packages/react-intlayer/useIntlayer.md +225 -0
- package/en-GB/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/en-GB/packages/react-intlayer/useLocale.md +184 -0
- package/en-GB/packages/react-native-intlayer/index.md +57 -0
- package/en-GB/packages/react-scripts-intlayer/index.md +57 -0
- package/en-GB/packages/solid-intlayer/index.md +3 -0
- package/en-GB/packages/svelte-intlayer/index.md +3 -0
- package/en-GB/packages/vite-intlayer/index.md +53 -0
- package/en-GB/packages/vue-intlayer/index.md +3 -0
- package/en-GB/per_locale_file.md +298 -0
- package/en-GB/privacy_notice.md +57 -0
- package/en-GB/roadmap.md +206 -0
- package/en-GB/terms_of_service.md +33 -0
- package/en-GB/vs_code_extension.md +139 -0
- package/es/CI_CD.md +149 -0
- package/es/autoFill.md +157 -0
- package/es/configuration.md +503 -0
- package/es/dictionary/condition.md +213 -0
- package/es/dictionary/content_extention_customization.md +81 -0
- package/es/dictionary/enumeration.md +221 -0
- package/es/dictionary/file.md +206 -0
- package/es/dictionary/function_fetching.md +190 -0
- package/es/dictionary/get_started.md +466 -0
- package/es/dictionary/insertion.md +161 -0
- package/es/dictionary/markdown.md +338 -0
- package/es/dictionary/nesting.md +249 -0
- package/es/dictionary/translation.md +287 -0
- package/es/header.md +5 -0
- package/es/how_works_intlayer.md +217 -0
- package/es/index.md +122 -0
- package/es/interest_of_intlayer.md +132 -0
- package/es/intlayer_CMS.md +334 -0
- package/es/intlayer_cli.md +274 -0
- package/es/intlayer_visual_editor.md +210 -0
- package/es/intlayer_with_angular.md +3 -0
- package/es/intlayer_with_create_react_app.md +1192 -0
- package/es/intlayer_with_express.md +276 -0
- package/es/intlayer_with_lynx+react.md +475 -0
- package/es/intlayer_with_nextjs_14.md +1258 -0
- package/es/intlayer_with_nextjs_15.md +1308 -0
- package/es/intlayer_with_nextjs_page_router.md +1088 -0
- package/es/intlayer_with_react_native+expo.md +180 -0
- package/es/intlayer_with_vite+preact.md +1637 -0
- package/es/intlayer_with_vite+react.md +1592 -0
- package/es/intlayer_with_vite+solid.md +3 -0
- package/es/intlayer_with_vite+svelte.md +3 -0
- package/es/intlayer_with_vite+vue.md +947 -0
- package/es/introduction.md +184 -0
- package/es/mcp_server.md +150 -0
- package/es/packages/@intlayer/api/index.md +31 -0
- package/es/packages/@intlayer/chokidar/index.md +31 -0
- package/es/packages/@intlayer/cli/index.md +21 -0
- package/es/packages/@intlayer/config/index.md +116 -0
- package/es/packages/@intlayer/core/index.md +25 -0
- package/es/packages/@intlayer/design-system/index.md +21 -0
- package/es/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/es/packages/@intlayer/editor/index.md +21 -0
- package/es/packages/@intlayer/editor-react/index.md +21 -0
- package/es/packages/@intlayer/webpack/index.md +35 -0
- package/es/packages/angular-intlayer/index.md +3 -0
- package/es/packages/express-intlayer/index.md +229 -0
- package/es/packages/express-intlayer/t.md +432 -0
- package/es/packages/intlayer/getConfiguration.md +120 -0
- package/es/packages/intlayer/getEnumeration.md +138 -0
- package/es/packages/intlayer/getHTMLTextDir.md +97 -0
- package/es/packages/intlayer/getLocaleLang.md +57 -0
- package/es/packages/intlayer/getLocaleName.md +93 -0
- package/es/packages/intlayer/getLocalizedUrl.md +221 -0
- package/es/packages/intlayer/getMultilingualUrls.md +198 -0
- package/es/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/es/packages/intlayer/getTranslation.md +166 -0
- package/es/packages/intlayer/getTranslationContent.md +166 -0
- package/es/packages/intlayer/index.md +478 -0
- package/es/packages/intlayer-cli/index.md +41 -0
- package/es/packages/intlayer-editor/index.md +115 -0
- package/es/packages/lynx-intlayer/index.md +58 -0
- package/es/packages/next-intlayer/index.md +263 -0
- package/es/packages/next-intlayer/t.md +325 -0
- package/es/packages/next-intlayer/useDictionary.md +242 -0
- package/es/packages/next-intlayer/useIntlayer.md +237 -0
- package/es/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/es/packages/next-intlayer/useLocale.md +105 -0
- package/es/packages/preact-intlayer/index.md +3 -0
- package/es/packages/react-intlayer/index.md +263 -0
- package/es/packages/react-intlayer/t.md +277 -0
- package/es/packages/react-intlayer/useDictionary.md +270 -0
- package/es/packages/react-intlayer/useIntlayer.md +225 -0
- package/es/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/es/packages/react-intlayer/useLocale.md +184 -0
- package/es/packages/react-native-intlayer/index.md +57 -0
- package/es/packages/react-scripts-intlayer/index.md +57 -0
- package/es/packages/solid-intlayer/index.md +3 -0
- package/es/packages/svelte-intlayer/index.md +5 -0
- package/es/packages/vite-intlayer/index.md +53 -0
- package/es/packages/vue-intlayer/index.md +3 -0
- package/es/per_locale_file.md +293 -0
- package/es/privacy_notice.md +61 -0
- package/es/roadmap.md +157 -0
- package/es/terms_of_service.md +33 -0
- package/es/vs_code_extension.md +139 -0
- package/fr/CI_CD.md +149 -0
- package/fr/autoFill.md +157 -0
- package/fr/configuration.md +481 -0
- package/fr/dictionary/condition.md +213 -0
- package/fr/dictionary/content_extention_customization.md +81 -0
- package/fr/dictionary/enumeration.md +221 -0
- package/fr/dictionary/file.md +206 -0
- package/fr/dictionary/function_fetching.md +190 -0
- package/fr/dictionary/get_started.md +466 -0
- package/fr/dictionary/insertion.md +161 -0
- package/fr/dictionary/markdown.md +335 -0
- package/fr/dictionary/nesting.md +249 -0
- package/fr/dictionary/translation.md +287 -0
- package/fr/header.md +5 -0
- package/fr/how_works_intlayer.md +217 -0
- package/fr/index.md +122 -0
- package/fr/interest_of_intlayer.md +132 -0
- package/fr/intlayer_CMS.md +334 -0
- package/fr/intlayer_cli.md +274 -0
- package/fr/intlayer_visual_editor.md +210 -0
- package/fr/intlayer_with_angular.md +3 -0
- package/fr/intlayer_with_create_react_app.md +1192 -0
- package/fr/intlayer_with_express.md +270 -0
- package/fr/intlayer_with_lynx+react.md +466 -0
- package/fr/intlayer_with_nextjs_14.md +1258 -0
- package/fr/intlayer_with_nextjs_15.md +1308 -0
- package/fr/intlayer_with_nextjs_page_router.md +1085 -0
- package/fr/intlayer_with_react_native+expo.md +535 -0
- package/fr/intlayer_with_vite+preact.md +1621 -0
- package/fr/intlayer_with_vite+react.md +1589 -0
- package/fr/intlayer_with_vite+solid.md +3 -0
- package/fr/intlayer_with_vite+svelte.md +3 -0
- package/fr/intlayer_with_vite+vue.md +947 -0
- package/fr/introduction.md +190 -0
- package/fr/mcp_server.md +152 -0
- package/fr/packages/@intlayer/api/index.md +31 -0
- package/fr/packages/@intlayer/chokidar/index.md +31 -0
- package/fr/packages/@intlayer/cli/index.md +21 -0
- package/fr/packages/@intlayer/config/index.md +116 -0
- package/fr/packages/@intlayer/core/index.md +25 -0
- package/fr/packages/@intlayer/design-system/index.md +21 -0
- package/fr/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/fr/packages/@intlayer/editor/index.md +21 -0
- package/fr/packages/@intlayer/editor-react/index.md +21 -0
- package/fr/packages/@intlayer/webpack/index.md +35 -0
- package/fr/packages/angular-intlayer/index.md +3 -0
- package/fr/packages/express-intlayer/index.md +238 -0
- package/fr/packages/express-intlayer/t.md +432 -0
- package/fr/packages/intlayer/getConfiguration.md +120 -0
- package/fr/packages/intlayer/getEnumeration.md +138 -0
- package/fr/packages/intlayer/getHTMLTextDir.md +97 -0
- package/fr/packages/intlayer/getLocaleLang.md +57 -0
- package/fr/packages/intlayer/getLocaleName.md +93 -0
- package/fr/packages/intlayer/getLocalizedUrl.md +221 -0
- package/fr/packages/intlayer/getMultilingualUrls.md +198 -0
- package/fr/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/fr/packages/intlayer/getTranslation.md +166 -0
- package/fr/packages/intlayer/getTranslationContent.md +166 -0
- package/fr/packages/intlayer/index.md +476 -0
- package/fr/packages/intlayer-cli/index.md +41 -0
- package/fr/packages/intlayer-editor/index.md +115 -0
- package/fr/packages/lynx-intlayer/index.md +58 -0
- package/fr/packages/next-intlayer/index.md +266 -0
- package/fr/packages/next-intlayer/t.md +325 -0
- package/fr/packages/next-intlayer/useDictionary.md +242 -0
- package/fr/packages/next-intlayer/useIntlayer.md +237 -0
- package/fr/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/fr/packages/next-intlayer/useLocale.md +105 -0
- package/fr/packages/preact-intlayer/index.md +3 -0
- package/fr/packages/react-intlayer/index.md +257 -0
- package/fr/packages/react-intlayer/t.md +277 -0
- package/fr/packages/react-intlayer/useDictionary.md +269 -0
- package/fr/packages/react-intlayer/useIntlayer.md +234 -0
- package/fr/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/fr/packages/react-intlayer/useLocale.md +184 -0
- package/fr/packages/react-native-intlayer/index.md +57 -0
- package/fr/packages/react-scripts-intlayer/index.md +57 -0
- package/fr/packages/solid-intlayer/index.md +3 -0
- package/fr/packages/svelte-intlayer/index.md +3 -0
- package/fr/packages/vite-intlayer/index.md +53 -0
- package/fr/packages/vue-intlayer/index.md +3 -0
- package/fr/per_locale_file.md +297 -0
- package/fr/privacy_notice.md +57 -0
- package/fr/roadmap.md +206 -0
- package/fr/terms_of_service.md +33 -0
- package/fr/vs_code_extension.md +139 -0
- package/hi/CI_CD.md +149 -0
- package/hi/autoFill.md +157 -0
- package/hi/configuration.md +509 -0
- package/hi/dictionary/condition.md +213 -0
- package/hi/dictionary/content_extention_customization.md +81 -0
- package/hi/dictionary/enumeration.md +221 -0
- package/hi/dictionary/file.md +209 -0
- package/hi/dictionary/function_fetching.md +188 -0
- package/hi/dictionary/get_started.md +490 -0
- package/hi/dictionary/insertion.md +167 -0
- package/hi/dictionary/markdown.md +344 -0
- package/hi/dictionary/nesting.md +249 -0
- package/hi/dictionary/translation.md +307 -0
- package/hi/header.md +7 -0
- package/hi/how_works_intlayer.md +217 -0
- package/hi/index.md +125 -0
- package/hi/interest_of_intlayer.md +132 -0
- package/hi/intlayer_CMS.md +334 -0
- package/hi/intlayer_cli.md +274 -0
- package/hi/intlayer_visual_editor.md +210 -0
- package/hi/intlayer_with_angular.md +3 -0
- package/hi/intlayer_with_create_react_app.md +1395 -0
- package/hi/intlayer_with_express.md +273 -0
- package/hi/intlayer_with_lynx+react.md +456 -0
- package/hi/intlayer_with_nextjs_14.md +1283 -0
- package/hi/intlayer_with_nextjs_15.md +1319 -0
- package/hi/intlayer_with_nextjs_page_router.md +1097 -0
- package/hi/intlayer_with_react_native+expo.md +554 -0
- package/hi/intlayer_with_vite+preact.md +1538 -0
- package/hi/intlayer_with_vite+react.md +1540 -0
- package/hi/intlayer_with_vite+solid.md +3 -0
- package/hi/intlayer_with_vite+svelte.md +3 -0
- package/hi/intlayer_with_vite+vue.md +840 -0
- package/hi/introduction.md +190 -0
- package/hi/mcp_server.md +150 -0
- package/hi/packages/@intlayer/api/index.md +31 -0
- package/hi/packages/@intlayer/chokidar/index.md +31 -0
- package/hi/packages/@intlayer/cli/index.md +21 -0
- package/hi/packages/@intlayer/config/index.md +116 -0
- package/hi/packages/@intlayer/core/index.md +25 -0
- package/hi/packages/@intlayer/design-system/index.md +21 -0
- package/hi/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/hi/packages/@intlayer/editor/index.md +21 -0
- package/hi/packages/@intlayer/editor-react/index.md +21 -0
- package/hi/packages/@intlayer/webpack/index.md +35 -0
- package/hi/packages/angular-intlayer/index.md +3 -0
- package/hi/packages/express-intlayer/index.md +232 -0
- package/hi/packages/express-intlayer/t.md +445 -0
- package/hi/packages/intlayer/getConfiguration.md +120 -0
- package/hi/packages/intlayer/getEnumeration.md +138 -0
- package/hi/packages/intlayer/getHTMLTextDir.md +97 -0
- package/hi/packages/intlayer/getLocaleLang.md +57 -0
- package/hi/packages/intlayer/getLocaleName.md +93 -0
- package/hi/packages/intlayer/getLocalizedUrl.md +221 -0
- package/hi/packages/intlayer/getMultilingualUrls.md +198 -0
- package/hi/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/hi/packages/intlayer/getTranslation.md +175 -0
- package/hi/packages/intlayer/getTranslationContent.md +175 -0
- package/hi/packages/intlayer/index.md +314 -0
- package/hi/packages/intlayer-cli/index.md +41 -0
- package/hi/packages/intlayer-editor/index.md +113 -0
- package/hi/packages/lynx-intlayer/index.md +58 -0
- package/hi/packages/next-intlayer/index.md +270 -0
- package/hi/packages/next-intlayer/t.md +337 -0
- package/hi/packages/next-intlayer/useDictionary.md +248 -0
- package/hi/packages/next-intlayer/useIntlayer.md +237 -0
- package/hi/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/hi/packages/next-intlayer/useLocale.md +105 -0
- package/hi/packages/preact-intlayer/index.md +3 -0
- package/hi/packages/react-intlayer/index.md +261 -0
- package/hi/packages/react-intlayer/t.md +283 -0
- package/hi/packages/react-intlayer/useDictionary.md +268 -0
- package/hi/packages/react-intlayer/useIntlayer.md +225 -0
- package/hi/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/hi/packages/react-intlayer/useLocale.md +184 -0
- package/hi/packages/react-native-intlayer/index.md +57 -0
- package/hi/packages/react-scripts-intlayer/index.md +57 -0
- package/hi/packages/solid-intlayer/index.md +3 -0
- package/hi/packages/svelte-intlayer/index.md +3 -0
- package/hi/packages/vite-intlayer/index.md +53 -0
- package/hi/packages/vue-intlayer/index.md +3 -0
- package/hi/per_locale_file.md +298 -0
- package/hi/privacy_notice.md +61 -0
- package/hi/roadmap.md +206 -0
- package/hi/terms_of_service.md +33 -0
- package/hi/vs_code_extension.md +139 -0
- package/index.cjs +1265 -0
- package/index.d.ts +100 -0
- package/it/CI_CD.md +149 -0
- package/it/autoFill.md +157 -0
- package/it/configuration.md +503 -0
- package/it/dictionary/condition.md +213 -0
- package/it/dictionary/content_extention_customization.md +81 -0
- package/it/dictionary/enumeration.md +221 -0
- package/it/dictionary/file.md +207 -0
- package/it/dictionary/function_fetching.md +190 -0
- package/it/dictionary/get_started.md +466 -0
- package/it/dictionary/insertion.md +161 -0
- package/it/dictionary/markdown.md +343 -0
- package/it/dictionary/nesting.md +249 -0
- package/it/dictionary/translation.md +287 -0
- package/it/header.md +7 -0
- package/it/how_works_intlayer.md +217 -0
- package/it/index.md +125 -0
- package/it/interest_of_intlayer.md +132 -0
- package/it/intlayer_CMS.md +334 -0
- package/it/intlayer_cli.md +274 -0
- package/it/intlayer_visual_editor.md +210 -0
- package/it/intlayer_with_angular.md +3 -0
- package/it/intlayer_with_create_react_app.md +413 -0
- package/it/intlayer_with_express.md +267 -0
- package/it/intlayer_with_lynx+react.md +482 -0
- package/it/intlayer_with_nextjs_14.md +1269 -0
- package/it/intlayer_with_nextjs_15.md +1319 -0
- package/it/intlayer_with_nextjs_page_router.md +1095 -0
- package/it/intlayer_with_react_native+expo.md +261 -0
- package/it/intlayer_with_vite+preact.md +1681 -0
- package/it/intlayer_with_vite+react.md +1580 -0
- package/it/intlayer_with_vite+solid.md +3 -0
- package/it/intlayer_with_vite+svelte.md +3 -0
- package/it/intlayer_with_vite+vue.md +989 -0
- package/it/introduction.md +192 -0
- package/it/mcp_server.md +152 -0
- package/it/packages/@intlayer/api/index.md +31 -0
- package/it/packages/@intlayer/chokidar/index.md +31 -0
- package/it/packages/@intlayer/cli/index.md +21 -0
- package/it/packages/@intlayer/config/index.md +116 -0
- package/it/packages/@intlayer/core/index.md +25 -0
- package/it/packages/@intlayer/design-system/index.md +21 -0
- package/it/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/it/packages/@intlayer/editor/index.md +21 -0
- package/it/packages/@intlayer/editor-react/index.md +21 -0
- package/it/packages/@intlayer/webpack/index.md +35 -0
- package/it/packages/angular-intlayer/index.md +3 -0
- package/it/packages/express-intlayer/index.md +229 -0
- package/it/packages/express-intlayer/t.md +432 -0
- package/it/packages/intlayer/getConfiguration.md +120 -0
- package/it/packages/intlayer/getEnumeration.md +138 -0
- package/it/packages/intlayer/getHTMLTextDir.md +97 -0
- package/it/packages/intlayer/getLocaleLang.md +57 -0
- package/it/packages/intlayer/getLocaleName.md +93 -0
- package/it/packages/intlayer/getLocalizedUrl.md +221 -0
- package/it/packages/intlayer/getMultilingualUrls.md +200 -0
- package/it/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/it/packages/intlayer/getTranslation.md +166 -0
- package/it/packages/intlayer/getTranslationContent.md +166 -0
- package/it/packages/intlayer/index.md +479 -0
- package/it/packages/intlayer-cli/index.md +41 -0
- package/it/packages/intlayer-editor/index.md +113 -0
- package/it/packages/lynx-intlayer/index.md +58 -0
- package/it/packages/next-intlayer/index.md +267 -0
- package/it/packages/next-intlayer/t.md +326 -0
- package/it/packages/next-intlayer/useDictionary.md +242 -0
- package/it/packages/next-intlayer/useIntlayer.md +237 -0
- package/it/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/it/packages/next-intlayer/useLocale.md +105 -0
- package/it/packages/preact-intlayer/index.md +3 -0
- package/it/packages/react-intlayer/index.md +260 -0
- package/it/packages/react-intlayer/t.md +277 -0
- package/it/packages/react-intlayer/useDictionary.md +260 -0
- package/it/packages/react-intlayer/useIntlayer.md +225 -0
- package/it/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/it/packages/react-intlayer/useLocale.md +184 -0
- package/it/packages/react-native-intlayer/index.md +57 -0
- package/it/packages/react-scripts-intlayer/index.md +57 -0
- package/it/packages/solid-intlayer/index.md +5 -0
- package/it/packages/svelte-intlayer/index.md +3 -0
- package/it/packages/vite-intlayer/index.md +53 -0
- package/it/packages/vue-intlayer/index.md +5 -0
- package/it/per_locale_file.md +298 -0
- package/it/privacy_notice.md +61 -0
- package/it/roadmap.md +206 -0
- package/it/terms_of_service.md +33 -0
- package/it/vs_code_extension.md +139 -0
- package/ja/CI_CD.md +149 -0
- package/ja/autoFill.md +157 -0
- package/ja/configuration.md +507 -0
- package/ja/dictionary/condition.md +213 -0
- package/ja/dictionary/content_extention_customization.md +81 -0
- package/ja/dictionary/enumeration.md +221 -0
- package/ja/dictionary/file.md +209 -0
- package/ja/dictionary/function_fetching.md +190 -0
- package/ja/dictionary/get_started.md +466 -0
- package/ja/dictionary/insertion.md +161 -0
- package/ja/dictionary/markdown.md +343 -0
- package/ja/dictionary/nesting.md +249 -0
- package/ja/dictionary/translation.md +287 -0
- package/ja/header.md +7 -0
- package/ja/how_works_intlayer.md +217 -0
- package/ja/index.md +125 -0
- package/ja/interest_of_intlayer.md +132 -0
- package/ja/intlayer_CMS.md +334 -0
- package/ja/intlayer_cli.md +274 -0
- package/ja/intlayer_visual_editor.md +213 -0
- package/ja/intlayer_with_angular.md +3 -0
- package/ja/intlayer_with_create_react_app.md +1186 -0
- package/ja/intlayer_with_express.md +267 -0
- package/ja/intlayer_with_lynx+react.md +482 -0
- package/ja/intlayer_with_nextjs_14.md +1256 -0
- package/ja/intlayer_with_nextjs_15.md +1308 -0
- package/ja/intlayer_with_nextjs_page_router.md +1085 -0
- package/ja/intlayer_with_react_native+expo.md +537 -0
- package/ja/intlayer_with_vite+preact.md +1601 -0
- package/ja/intlayer_with_vite+react.md +1555 -0
- package/ja/intlayer_with_vite+solid.md +3 -0
- package/ja/intlayer_with_vite+svelte.md +3 -0
- package/ja/intlayer_with_vite+vue.md +990 -0
- package/ja/introduction.md +186 -0
- package/ja/mcp_server.md +150 -0
- package/ja/packages/@intlayer/api/index.md +31 -0
- package/ja/packages/@intlayer/chokidar/index.md +31 -0
- package/ja/packages/@intlayer/cli/index.md +21 -0
- package/ja/packages/@intlayer/config/index.md +116 -0
- package/ja/packages/@intlayer/core/index.md +25 -0
- package/ja/packages/@intlayer/design-system/index.md +21 -0
- package/ja/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/ja/packages/@intlayer/editor/index.md +21 -0
- package/ja/packages/@intlayer/editor-react/index.md +21 -0
- package/ja/packages/@intlayer/webpack/index.md +35 -0
- package/ja/packages/angular-intlayer/index.md +3 -0
- package/ja/packages/express-intlayer/index.md +229 -0
- package/ja/packages/express-intlayer/t.md +432 -0
- package/ja/packages/intlayer/getConfiguration.md +120 -0
- package/ja/packages/intlayer/getEnumeration.md +140 -0
- package/ja/packages/intlayer/getHTMLTextDir.md +97 -0
- package/ja/packages/intlayer/getLocaleLang.md +59 -0
- package/ja/packages/intlayer/getLocaleName.md +93 -0
- package/ja/packages/intlayer/getLocalizedUrl.md +221 -0
- package/ja/packages/intlayer/getMultilingualUrls.md +198 -0
- package/ja/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/ja/packages/intlayer/getTranslation.md +166 -0
- package/ja/packages/intlayer/getTranslationContent.md +166 -0
- package/ja/packages/intlayer/index.md +479 -0
- package/ja/packages/intlayer-cli/index.md +41 -0
- package/ja/packages/intlayer-editor/index.md +115 -0
- package/ja/packages/lynx-intlayer/index.md +58 -0
- package/ja/packages/next-intlayer/index.md +263 -0
- package/ja/packages/next-intlayer/t.md +326 -0
- package/ja/packages/next-intlayer/useDictionary.md +242 -0
- package/ja/packages/next-intlayer/useIntlayer.md +237 -0
- package/ja/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/ja/packages/next-intlayer/useLocale.md +105 -0
- package/ja/packages/preact-intlayer/index.md +3 -0
- package/ja/packages/react-intlayer/index.md +257 -0
- package/ja/packages/react-intlayer/t.md +277 -0
- package/ja/packages/react-intlayer/useDictionary.md +260 -0
- package/ja/packages/react-intlayer/useIntlayer.md +225 -0
- package/ja/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/ja/packages/react-intlayer/useLocale.md +184 -0
- package/ja/packages/react-native-intlayer/index.md +57 -0
- package/ja/packages/react-scripts-intlayer/index.md +57 -0
- package/ja/packages/solid-intlayer/index.md +3 -0
- package/ja/packages/svelte-intlayer/index.md +3 -0
- package/ja/packages/vite-intlayer/index.md +53 -0
- package/ja/packages/vue-intlayer/index.md +3 -0
- package/ja/per_locale_file.md +298 -0
- package/ja/privacy_notice.md +57 -0
- package/ja/roadmap.md +206 -0
- package/ja/terms_of_service.md +33 -0
- package/ja/vs_code_extension.md +139 -0
- package/ko/CI_CD.md +149 -0
- package/ko/autoFill.md +157 -0
- package/ko/configuration.md +507 -0
- package/ko/dictionary/condition.md +213 -0
- package/ko/dictionary/content_extention_customization.md +81 -0
- package/ko/dictionary/enumeration.md +221 -0
- package/ko/dictionary/file.md +207 -0
- package/ko/dictionary/function_fetching.md +190 -0
- package/ko/dictionary/get_started.md +466 -0
- package/ko/dictionary/insertion.md +167 -0
- package/ko/dictionary/markdown.md +343 -0
- package/ko/dictionary/nesting.md +249 -0
- package/ko/dictionary/translation.md +287 -0
- package/ko/header.md +7 -0
- package/ko/how_works_intlayer.md +216 -0
- package/ko/index.md +125 -0
- package/ko/interest_of_intlayer.md +132 -0
- package/ko/intlayer_CMS.md +334 -0
- package/ko/intlayer_cli.md +274 -0
- package/ko/intlayer_visual_editor.md +210 -0
- package/ko/intlayer_with_angular.md +3 -0
- package/ko/intlayer_with_create_react_app.md +1186 -0
- package/ko/intlayer_with_express.md +267 -0
- package/ko/intlayer_with_lynx+react.md +482 -0
- package/ko/intlayer_with_nextjs_14.md +1267 -0
- package/ko/intlayer_with_nextjs_15.md +1319 -0
- package/ko/intlayer_with_nextjs_page_router.md +1097 -0
- package/ko/intlayer_with_react_native+expo.md +537 -0
- package/ko/intlayer_with_vite+preact.md +1682 -0
- package/ko/intlayer_with_vite+react.md +1582 -0
- package/ko/intlayer_with_vite+solid.md +3 -0
- package/ko/intlayer_with_vite+svelte.md +3 -0
- package/ko/intlayer_with_vite+vue.md +988 -0
- package/ko/introduction.md +186 -0
- package/ko/mcp_server.md +150 -0
- package/ko/packages/@intlayer/api/index.md +31 -0
- package/ko/packages/@intlayer/chokidar/index.md +31 -0
- package/ko/packages/@intlayer/cli/index.md +21 -0
- package/ko/packages/@intlayer/config/index.md +116 -0
- package/ko/packages/@intlayer/core/index.md +25 -0
- package/ko/packages/@intlayer/design-system/index.md +21 -0
- package/ko/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/ko/packages/@intlayer/editor/index.md +21 -0
- package/ko/packages/@intlayer/editor-react/index.md +21 -0
- package/ko/packages/@intlayer/webpack/index.md +35 -0
- package/ko/packages/angular-intlayer/index.md +5 -0
- package/ko/packages/express-intlayer/index.md +229 -0
- package/ko/packages/express-intlayer/t.md +432 -0
- package/ko/packages/intlayer/getConfiguration.md +120 -0
- package/ko/packages/intlayer/getEnumeration.md +138 -0
- package/ko/packages/intlayer/getHTMLTextDir.md +97 -0
- package/ko/packages/intlayer/getLocaleLang.md +57 -0
- package/ko/packages/intlayer/getLocaleName.md +93 -0
- package/ko/packages/intlayer/getLocalizedUrl.md +221 -0
- package/ko/packages/intlayer/getMultilingualUrls.md +198 -0
- package/ko/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/ko/packages/intlayer/getTranslation.md +166 -0
- package/ko/packages/intlayer/getTranslationContent.md +166 -0
- package/ko/packages/intlayer/index.md +480 -0
- package/ko/packages/intlayer-cli/index.md +41 -0
- package/ko/packages/intlayer-editor/index.md +113 -0
- package/ko/packages/lynx-intlayer/index.md +58 -0
- package/ko/packages/next-intlayer/index.md +267 -0
- package/ko/packages/next-intlayer/t.md +337 -0
- package/ko/packages/next-intlayer/useDictionary.md +242 -0
- package/ko/packages/next-intlayer/useIntlayer.md +237 -0
- package/ko/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/ko/packages/next-intlayer/useLocale.md +105 -0
- package/ko/packages/preact-intlayer/index.md +3 -0
- package/ko/packages/react-intlayer/index.md +260 -0
- package/ko/packages/react-intlayer/t.md +277 -0
- package/ko/packages/react-intlayer/useDictionary.md +268 -0
- package/ko/packages/react-intlayer/useIntlayer.md +225 -0
- package/ko/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/ko/packages/react-intlayer/useLocale.md +184 -0
- package/ko/packages/react-native-intlayer/index.md +57 -0
- package/ko/packages/react-scripts-intlayer/index.md +57 -0
- package/ko/packages/solid-intlayer/index.md +3 -0
- package/ko/packages/svelte-intlayer/index.md +3 -0
- package/ko/packages/vite-intlayer/index.md +53 -0
- package/ko/packages/vue-intlayer/index.md +3 -0
- package/ko/per_locale_file.md +300 -0
- package/ko/privacy_notice.md +61 -0
- package/ko/roadmap.md +206 -0
- package/ko/terms_of_service.md +33 -0
- package/ko/vs_code_extension.md +139 -0
- package/package.json +96 -0
- package/pt/CI_CD.md +149 -0
- package/pt/autoFill.md +157 -0
- package/pt/configuration.md +503 -0
- package/pt/dictionary/condition.md +213 -0
- package/pt/dictionary/content_extention_customization.md +81 -0
- package/pt/dictionary/enumeration.md +221 -0
- package/pt/dictionary/file.md +210 -0
- package/pt/dictionary/function_fetching.md +190 -0
- package/pt/dictionary/get_started.md +490 -0
- package/pt/dictionary/insertion.md +161 -0
- package/pt/dictionary/markdown.md +339 -0
- package/pt/dictionary/nesting.md +249 -0
- package/pt/dictionary/translation.md +322 -0
- package/pt/header.md +7 -0
- package/pt/how_works_intlayer.md +216 -0
- package/pt/index.md +125 -0
- package/pt/interest_of_intlayer.md +132 -0
- package/pt/intlayer_CMS.md +334 -0
- package/pt/intlayer_cli.md +274 -0
- package/pt/intlayer_visual_editor.md +210 -0
- package/pt/intlayer_with_angular.md +3 -0
- package/pt/intlayer_with_create_react_app.md +1204 -0
- package/pt/intlayer_with_express.md +270 -0
- package/pt/intlayer_with_lynx+react.md +467 -0
- package/pt/intlayer_with_nextjs_14.md +1269 -0
- package/pt/intlayer_with_nextjs_15.md +1319 -0
- package/pt/intlayer_with_nextjs_page_router.md +1109 -0
- package/pt/intlayer_with_react_native+expo.md +259 -0
- package/pt/intlayer_with_vite+preact.md +1663 -0
- package/pt/intlayer_with_vite+react.md +1621 -0
- package/pt/intlayer_with_vite+solid.md +3 -0
- package/pt/intlayer_with_vite+svelte.md +3 -0
- package/pt/intlayer_with_vite+vue.md +989 -0
- package/pt/introduction.md +193 -0
- package/pt/mcp_server.md +150 -0
- package/pt/packages/@intlayer/api/index.md +31 -0
- package/pt/packages/@intlayer/chokidar/index.md +31 -0
- package/pt/packages/@intlayer/cli/index.md +21 -0
- package/pt/packages/@intlayer/config/index.md +116 -0
- package/pt/packages/@intlayer/core/index.md +25 -0
- package/pt/packages/@intlayer/design-system/index.md +21 -0
- package/pt/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/pt/packages/@intlayer/editor/index.md +21 -0
- package/pt/packages/@intlayer/editor-react/index.md +21 -0
- package/pt/packages/@intlayer/webpack/index.md +35 -0
- package/pt/packages/angular-intlayer/index.md +3 -0
- package/pt/packages/express-intlayer/index.md +232 -0
- package/pt/packages/express-intlayer/t.md +267 -0
- package/pt/packages/intlayer/getConfiguration.md +120 -0
- package/pt/packages/intlayer/getEnumeration.md +138 -0
- package/pt/packages/intlayer/getHTMLTextDir.md +97 -0
- package/pt/packages/intlayer/getLocaleLang.md +57 -0
- package/pt/packages/intlayer/getLocaleName.md +93 -0
- package/pt/packages/intlayer/getLocalizedUrl.md +221 -0
- package/pt/packages/intlayer/getMultilingualUrls.md +198 -0
- package/pt/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/pt/packages/intlayer/getTranslation.md +175 -0
- package/pt/packages/intlayer/getTranslationContent.md +177 -0
- package/pt/packages/intlayer/index.md +484 -0
- package/pt/packages/intlayer-cli/index.md +41 -0
- package/pt/packages/intlayer-editor/index.md +113 -0
- package/pt/packages/lynx-intlayer/index.md +58 -0
- package/pt/packages/next-intlayer/index.md +270 -0
- package/pt/packages/next-intlayer/t.md +341 -0
- package/pt/packages/next-intlayer/useDictionary.md +248 -0
- package/pt/packages/next-intlayer/useIntlayer.md +237 -0
- package/pt/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/pt/packages/next-intlayer/useLocale.md +105 -0
- package/pt/packages/preact-intlayer/index.md +3 -0
- package/pt/packages/react-intlayer/index.md +261 -0
- package/pt/packages/react-intlayer/t.md +289 -0
- package/pt/packages/react-intlayer/useDictionary.md +268 -0
- package/pt/packages/react-intlayer/useIntlayer.md +225 -0
- package/pt/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/pt/packages/react-intlayer/useLocale.md +184 -0
- package/pt/packages/react-native-intlayer/index.md +57 -0
- package/pt/packages/react-scripts-intlayer/index.md +57 -0
- package/pt/packages/solid-intlayer/index.md +3 -0
- package/pt/packages/svelte-intlayer/index.md +3 -0
- package/pt/packages/vite-intlayer/index.md +53 -0
- package/pt/packages/vue-intlayer/index.md +3 -0
- package/pt/per_locale_file.md +298 -0
- package/pt/privacy_notice.md +61 -0
- package/pt/roadmap.md +206 -0
- package/pt/terms_of_service.md +33 -0
- package/pt/vs_code_extension.md +139 -0
- package/ru/CI_CD.md +149 -0
- package/ru/autoFill.md +157 -0
- package/ru/configuration.md +507 -0
- package/ru/dictionary/condition.md +213 -0
- package/ru/dictionary/content_extention_customization.md +81 -0
- package/ru/dictionary/enumeration.md +221 -0
- package/ru/dictionary/file.md +209 -0
- package/ru/dictionary/function_fetching.md +188 -0
- package/ru/dictionary/get_started.md +311 -0
- package/ru/dictionary/insertion.md +161 -0
- package/ru/dictionary/markdown.md +339 -0
- package/ru/dictionary/nesting.md +249 -0
- package/ru/dictionary/translation.md +322 -0
- package/ru/environment/angular.md +3 -0
- package/ru/header.md +7 -0
- package/ru/how_works_intlayer.md +217 -0
- package/ru/index.md +125 -0
- package/ru/interest_of_intlayer.md +132 -0
- package/ru/intlayer_CMS.md +334 -0
- package/ru/intlayer_cli.md +274 -0
- package/ru/intlayer_visual_editor.md +210 -0
- package/ru/intlayer_with_angular.md +3 -0
- package/ru/intlayer_with_create_react_app.md +1196 -0
- package/ru/intlayer_with_express.md +273 -0
- package/ru/intlayer_with_lynx+react.md +482 -0
- package/ru/intlayer_with_nextjs_14.md +1274 -0
- package/ru/intlayer_with_nextjs_15.md +1318 -0
- package/ru/intlayer_with_nextjs_page_router.md +1100 -0
- package/ru/intlayer_with_react_native+expo.md +537 -0
- package/ru/intlayer_with_vite+preact.md +1663 -0
- package/ru/intlayer_with_vite+react.md +1546 -0
- package/ru/intlayer_with_vite+solid.md +3 -0
- package/ru/intlayer_with_vite+svelte.md +3 -0
- package/ru/intlayer_with_vite+vue.md +987 -0
- package/ru/introduction.md +190 -0
- package/ru/mcp_server.md +152 -0
- package/ru/packages/@intlayer/api/index.md +31 -0
- package/ru/packages/@intlayer/chokidar/index.md +31 -0
- package/ru/packages/@intlayer/cli/index.md +23 -0
- package/ru/packages/@intlayer/config/index.md +116 -0
- package/ru/packages/@intlayer/core/index.md +25 -0
- package/ru/packages/@intlayer/design-system/index.md +21 -0
- package/ru/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/ru/packages/@intlayer/editor/index.md +21 -0
- package/ru/packages/@intlayer/editor-react/index.md +21 -0
- package/ru/packages/@intlayer/webpack/index.md +35 -0
- package/ru/packages/angular-intlayer/index.md +3 -0
- package/ru/packages/express-intlayer/index.md +235 -0
- package/ru/packages/express-intlayer/t.md +445 -0
- package/ru/packages/intlayer/getConfiguration.md +120 -0
- package/ru/packages/intlayer/getEnumeration.md +140 -0
- package/ru/packages/intlayer/getHTMLTextDir.md +97 -0
- package/ru/packages/intlayer/getLocaleLang.md +59 -0
- package/ru/packages/intlayer/getLocaleName.md +93 -0
- package/ru/packages/intlayer/getLocalizedUrl.md +221 -0
- package/ru/packages/intlayer/getMultilingualUrls.md +198 -0
- package/ru/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/ru/packages/intlayer/getTranslation.md +177 -0
- package/ru/packages/intlayer/getTranslationContent.md +175 -0
- package/ru/packages/intlayer/index.md +275 -0
- package/ru/packages/intlayer-cli/index.md +41 -0
- package/ru/packages/intlayer-editor/index.md +115 -0
- package/ru/packages/lynx-intlayer/index.md +58 -0
- package/ru/packages/next-intlayer/index.md +267 -0
- package/ru/packages/next-intlayer/t.md +340 -0
- package/ru/packages/next-intlayer/useDictionary.md +248 -0
- package/ru/packages/next-intlayer/useIntlayer.md +237 -0
- package/ru/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/ru/packages/next-intlayer/useLocale.md +105 -0
- package/ru/packages/preact-intlayer/index.md +3 -0
- package/ru/packages/react-intlayer/index.md +261 -0
- package/ru/packages/react-intlayer/t.md +289 -0
- package/ru/packages/react-intlayer/useDictionary.md +268 -0
- package/ru/packages/react-intlayer/useIntlayer.md +225 -0
- package/ru/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/ru/packages/react-intlayer/useLocale.md +184 -0
- package/ru/packages/react-native-intlayer/index.md +57 -0
- package/ru/packages/react-scripts-intlayer/index.md +57 -0
- package/ru/packages/solid-intlayer/index.md +3 -0
- package/ru/packages/svelte-intlayer/index.md +3 -0
- package/ru/packages/vite-intlayer/index.md +53 -0
- package/ru/packages/vue-intlayer/index.md +3 -0
- package/ru/per_locale_file.md +298 -0
- package/ru/privacy_notice.md +61 -0
- package/ru/roadmap.md +206 -0
- package/ru/terms_of_service.md +33 -0
- package/ru/vs_code_extension.md +139 -0
- package/zh/CI_CD.md +149 -0
- package/zh/autoFill.md +157 -0
- package/zh/configuration.md +484 -0
- package/zh/dictionary/condition.md +213 -0
- package/zh/dictionary/content_extention_customization.md +81 -0
- package/zh/dictionary/enumeration.md +221 -0
- package/zh/dictionary/file.md +209 -0
- package/zh/dictionary/function_fetching.md +188 -0
- package/zh/dictionary/get_started.md +490 -0
- package/zh/dictionary/insertion.md +161 -0
- package/zh/dictionary/markdown.md +342 -0
- package/zh/dictionary/nesting.md +249 -0
- package/zh/dictionary/translation.md +287 -0
- package/zh/header.md +7 -0
- package/zh/how_works_intlayer.md +217 -0
- package/zh/index.md +125 -0
- package/zh/interest_of_intlayer.md +132 -0
- package/zh/intlayer_CMS.md +334 -0
- package/zh/intlayer_cli.md +274 -0
- package/zh/intlayer_visual_editor.md +210 -0
- package/zh/intlayer_with_angular.md +3 -0
- package/zh/intlayer_with_create_react_app.md +1196 -0
- package/zh/intlayer_with_express.md +267 -0
- package/zh/intlayer_with_lynx+react.md +484 -0
- package/zh/intlayer_with_nextjs_14.md +1286 -0
- package/zh/intlayer_with_nextjs_15.md +1322 -0
- package/zh/intlayer_with_nextjs_page_router.md +1097 -0
- package/zh/intlayer_with_react_native+expo.md +539 -0
- package/zh/intlayer_with_vite+preact.md +1681 -0
- package/zh/intlayer_with_vite+react.md +1577 -0
- package/zh/intlayer_with_vite+solid.md +3 -0
- package/zh/intlayer_with_vite+svelte.md +3 -0
- package/zh/intlayer_with_vite+vue.md +988 -0
- package/zh/introduction.md +186 -0
- package/zh/mcp_server.md +152 -0
- package/zh/packages/@intlayer/api/index.md +31 -0
- package/zh/packages/@intlayer/chokidar/index.md +31 -0
- package/zh/packages/@intlayer/cli/index.md +21 -0
- package/zh/packages/@intlayer/config/index.md +116 -0
- package/zh/packages/@intlayer/core/index.md +25 -0
- package/zh/packages/@intlayer/design-system/index.md +21 -0
- package/zh/packages/@intlayer/dictionary-entry/index.md +21 -0
- package/zh/packages/@intlayer/editor/index.md +21 -0
- package/zh/packages/@intlayer/editor-react/index.md +21 -0
- package/zh/packages/@intlayer/webpack/index.md +35 -0
- package/zh/packages/angular-intlayer/index.md +3 -0
- package/zh/packages/express-intlayer/index.md +229 -0
- package/zh/packages/express-intlayer/t.md +432 -0
- package/zh/packages/intlayer/getConfiguration.md +120 -0
- package/zh/packages/intlayer/getEnumeration.md +140 -0
- package/zh/packages/intlayer/getHTMLTextDir.md +97 -0
- package/zh/packages/intlayer/getLocaleLang.md +57 -0
- package/zh/packages/intlayer/getLocaleName.md +93 -0
- package/zh/packages/intlayer/getLocalizedUrl.md +221 -0
- package/zh/packages/intlayer/getMultilingualUrls.md +198 -0
- package/zh/packages/intlayer/getPathWithoutLocale.md +50 -0
- package/zh/packages/intlayer/getTranslation.md +166 -0
- package/zh/packages/intlayer/getTranslationContent.md +166 -0
- package/zh/packages/intlayer/index.md +360 -0
- package/zh/packages/intlayer-cli/index.md +41 -0
- package/zh/packages/intlayer-editor/index.md +113 -0
- package/zh/packages/lynx-intlayer/index.md +60 -0
- package/zh/packages/next-intlayer/index.md +267 -0
- package/zh/packages/next-intlayer/t.md +338 -0
- package/zh/packages/next-intlayer/useDictionary.md +242 -0
- package/zh/packages/next-intlayer/useIntlayer.md +237 -0
- package/zh/packages/next-intlayer/useIntlayerAsync.md +211 -0
- package/zh/packages/next-intlayer/useLocale.md +105 -0
- package/zh/packages/preact-intlayer/index.md +3 -0
- package/zh/packages/react-intlayer/index.md +257 -0
- package/zh/packages/react-intlayer/t.md +271 -0
- package/zh/packages/react-intlayer/useDictionary.md +260 -0
- package/zh/packages/react-intlayer/useIntlayer.md +225 -0
- package/zh/packages/react-intlayer/useIntlayerAsync.md +226 -0
- package/zh/packages/react-intlayer/useLocale.md +184 -0
- package/zh/packages/react-native-intlayer/index.md +57 -0
- package/zh/packages/react-scripts-intlayer/index.md +57 -0
- package/zh/packages/solid-intlayer/index.md +3 -0
- package/zh/packages/svelte-intlayer/index.md +3 -0
- package/zh/packages/vite-intlayer/index.md +53 -0
- package/zh/packages/vue-intlayer/index.md +3 -0
- package/zh/per_locale_file.md +298 -0
- package/zh/privacy_notice.md +61 -0
- package/zh/roadmap.md +206 -0
- package/zh/terms_of_service.md +33 -0
- package/zh/vs_code_extension.md +139 -0
|
@@ -0,0 +1,1621 @@
|
|
|
1
|
+
# Começando com Internacionalização (i18n) com Intlayer, Vite e React
|
|
2
|
+
|
|
3
|
+
<iframe title="Vite + React: Build a Multilingual App from Scratch using Intlayer" class="m-auto aspect-[16/9] w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/dS9L7uJeak4?autoplay=0&origin=http://intlayer.org&controls=0&rel=1"/>
|
|
4
|
+
|
|
5
|
+
Veja [Application Template](https://github.com/aymericzip/intlayer-vite-react-template) no GitHub.
|
|
6
|
+
|
|
7
|
+
## O que é 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 e troca dinâmica de localidade.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Guia Passo a Passo para Configurar o Intlayer em uma Aplicação Vite e React
|
|
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 react-intlayer vite-intlayer
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```bash packageManager="pnpm"
|
|
31
|
+
pnpm add intlayer react-intlayer vite-intlayer
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```bash packageManager="yarn"
|
|
35
|
+
yarn add intlayer react-intlayer vite-intlayer
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- **intlayer**
|
|
39
|
+
|
|
40
|
+
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ção e [comandos CLI](https://github.com/aymericzip/intlayer/blob/main/docs/pt/intlayer_cli.md).
|
|
41
|
+
|
|
42
|
+
- **react-intlayer**
|
|
43
|
+
O pacote que integra o Intlayer com a aplicação React. Ele fornece provedores de contexto e hooks para internacionalização no React.
|
|
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 das 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 react from "@vitejs/plugin-react-swc";
|
|
117
|
+
import { intlayerPlugin } from "vite-intlayer";
|
|
118
|
+
|
|
119
|
+
// https://vitejs.dev/config/
|
|
120
|
+
export default defineConfig({
|
|
121
|
+
plugins: [react(), intlayerPlugin()],
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```javascript fileName="vite.config.mjs" codeFormat="esm"
|
|
126
|
+
import { defineConfig } from "vite";
|
|
127
|
+
import react from "@vitejs/plugin-react-swc";
|
|
128
|
+
import { intlayerPlugin } from "vite-intlayer";
|
|
129
|
+
|
|
130
|
+
// https://vitejs.dev/config/
|
|
131
|
+
export default defineConfig({
|
|
132
|
+
plugins: [react(), intlayerPlugin()],
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```javascript fileName="vite.config.cjs" codeFormat="commonjs"
|
|
137
|
+
const { defineConfig } = require("vite");
|
|
138
|
+
const react = require("@vitejs/plugin-react-swc");
|
|
139
|
+
const { intlayerPlugin } = require("vite-intlayer");
|
|
140
|
+
|
|
141
|
+
// https://vitejs.dev/config/
|
|
142
|
+
module.exports = defineConfig({
|
|
143
|
+
plugins: [react(), intlayerPlugin()],
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
> 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. 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
|
+
import type { ReactNode } from "react";
|
|
156
|
+
|
|
157
|
+
const appContent = {
|
|
158
|
+
key: "app",
|
|
159
|
+
content: {
|
|
160
|
+
viteLogo: t({
|
|
161
|
+
pt: "Logo do Vite",
|
|
162
|
+
en: "Vite logo",
|
|
163
|
+
fr: "Logo Vite",
|
|
164
|
+
es: "Logo Vite",
|
|
165
|
+
}),
|
|
166
|
+
reactLogo: t({
|
|
167
|
+
pt: "Logo do React",
|
|
168
|
+
en: "React logo",
|
|
169
|
+
fr: "Logo React",
|
|
170
|
+
es: "Logo React",
|
|
171
|
+
}),
|
|
172
|
+
|
|
173
|
+
title: "Vite + React",
|
|
174
|
+
|
|
175
|
+
count: t({
|
|
176
|
+
pt: "a contagem é ",
|
|
177
|
+
en: "count is ",
|
|
178
|
+
fr: "le compte est ",
|
|
179
|
+
es: "el recuento es ",
|
|
180
|
+
}),
|
|
181
|
+
|
|
182
|
+
edit: t<ReactNode>({
|
|
183
|
+
pt: (
|
|
184
|
+
<>
|
|
185
|
+
Edite <code>src/App.tsx</code> e salve para testar o HMR
|
|
186
|
+
</>
|
|
187
|
+
),
|
|
188
|
+
en: (
|
|
189
|
+
<>
|
|
190
|
+
Edit <code>src/App.tsx</code> and save to test HMR
|
|
191
|
+
</>
|
|
192
|
+
),
|
|
193
|
+
fr: (
|
|
194
|
+
<>
|
|
195
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
196
|
+
</>
|
|
197
|
+
),
|
|
198
|
+
es: (
|
|
199
|
+
<>
|
|
200
|
+
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
201
|
+
</>
|
|
202
|
+
),
|
|
203
|
+
}),
|
|
204
|
+
|
|
205
|
+
readTheDocs: t({
|
|
206
|
+
pt: "Clique nos logos do Vite e React para saber mais",
|
|
207
|
+
en: "Click on the Vite and React logos to learn more",
|
|
208
|
+
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
209
|
+
es: "Haga clic en los logotipos de Vite y React para obter mais informações",
|
|
210
|
+
}),
|
|
211
|
+
},
|
|
212
|
+
} satisfies Dictionary;
|
|
213
|
+
|
|
214
|
+
export default appContent;
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
```javascript fileName="src/app.content.mjs" contentDeclarationFormat="esm"
|
|
218
|
+
import { t } from "intlayer";
|
|
219
|
+
|
|
220
|
+
/** @type {import('intlayer').Dictionary} */
|
|
221
|
+
const appContent = {
|
|
222
|
+
key: "app",
|
|
223
|
+
content: {
|
|
224
|
+
viteLogo: t({
|
|
225
|
+
pt: "Logo do Vite",
|
|
226
|
+
en: "Vite logo",
|
|
227
|
+
fr: "Logo Vite",
|
|
228
|
+
es: "Logo Vite",
|
|
229
|
+
}),
|
|
230
|
+
reactLogo: t({
|
|
231
|
+
pt: "Logo do React",
|
|
232
|
+
en: "React logo",
|
|
233
|
+
fr: "Logo React",
|
|
234
|
+
es: "Logo React",
|
|
235
|
+
}),
|
|
236
|
+
|
|
237
|
+
title: "Vite + React",
|
|
238
|
+
|
|
239
|
+
count: t({
|
|
240
|
+
pt: "a contagem é ",
|
|
241
|
+
en: "count is ",
|
|
242
|
+
fr: "le compte est ",
|
|
243
|
+
es: "el recuento es ",
|
|
244
|
+
}),
|
|
245
|
+
|
|
246
|
+
edit:
|
|
247
|
+
t <
|
|
248
|
+
ReactNode >
|
|
249
|
+
{
|
|
250
|
+
// Não se esqueça de importar React se você usar um nó React no seu conteúdo
|
|
251
|
+
pt: (
|
|
252
|
+
<>
|
|
253
|
+
Edite <code>src/App.tsx</code> e salve para testar o HMR
|
|
254
|
+
</>
|
|
255
|
+
),
|
|
256
|
+
en: (
|
|
257
|
+
<>
|
|
258
|
+
Edit <code>src/App.tsx</code> and save to test HMR
|
|
259
|
+
</>
|
|
260
|
+
),
|
|
261
|
+
fr: (
|
|
262
|
+
<>
|
|
263
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
264
|
+
</>
|
|
265
|
+
),
|
|
266
|
+
es: (
|
|
267
|
+
<>
|
|
268
|
+
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
269
|
+
</>
|
|
270
|
+
),
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
readTheDocs: t({
|
|
274
|
+
pt: "Clique nos logos do Vite e React para saber mais",
|
|
275
|
+
en: "Click on the Vite and React logos to learn more",
|
|
276
|
+
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
277
|
+
es: "Haga clic en los logotipos de Vite y React para obter mais informações",
|
|
278
|
+
}),
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
export default appContent;
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
```javascript fileName="src/app.content.cjs" contentDeclarationFormat="commonjs"
|
|
286
|
+
const { t } = require("intlayer");
|
|
287
|
+
|
|
288
|
+
/** @type {import('intlayer').Dictionary} */
|
|
289
|
+
const appContent = {
|
|
290
|
+
key: "app",
|
|
291
|
+
content: {
|
|
292
|
+
viteLogo: t({
|
|
293
|
+
pt: "Logo do Vite",
|
|
294
|
+
en: "Vite logo",
|
|
295
|
+
fr: "Logo Vite",
|
|
296
|
+
es: "Logo Vite",
|
|
297
|
+
}),
|
|
298
|
+
reactLogo: t({
|
|
299
|
+
pt: "Logo do React",
|
|
300
|
+
en: "React logo",
|
|
301
|
+
fr: "Logo React",
|
|
302
|
+
es: "Logo React",
|
|
303
|
+
}),
|
|
304
|
+
|
|
305
|
+
title: "Vite + React",
|
|
306
|
+
|
|
307
|
+
count: t({
|
|
308
|
+
pt: "a contagem é ",
|
|
309
|
+
en: "count is ",
|
|
310
|
+
fr: "le compte est ",
|
|
311
|
+
es: "el recuento es ",
|
|
312
|
+
}),
|
|
313
|
+
edit:
|
|
314
|
+
t <
|
|
315
|
+
ReactNode >
|
|
316
|
+
{
|
|
317
|
+
// Não esqueça de importar React se você usar um nó React em seu conteúdo
|
|
318
|
+
pt: (
|
|
319
|
+
<>
|
|
320
|
+
Edite <code>src/App.tsx</code> e salve para testar o HMR
|
|
321
|
+
</>
|
|
322
|
+
),
|
|
323
|
+
en: (
|
|
324
|
+
<>
|
|
325
|
+
Edit <code>src/App.tsx</code> and save to test HMR
|
|
326
|
+
</>
|
|
327
|
+
),
|
|
328
|
+
fr: (
|
|
329
|
+
<>
|
|
330
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
331
|
+
</>
|
|
332
|
+
),
|
|
333
|
+
es: (
|
|
334
|
+
<>
|
|
335
|
+
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
336
|
+
</>
|
|
337
|
+
),
|
|
338
|
+
},
|
|
339
|
+
readTheDocs: t({
|
|
340
|
+
pt: "Clique nos logotipos do Vite e React para saber mais",
|
|
341
|
+
en: "Click on the Vite and React logos to learn more",
|
|
342
|
+
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
343
|
+
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
344
|
+
}),
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
export default appContent;
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
```json fileName="src/app.content.mjs" contentDeclarationFormat="json"
|
|
352
|
+
{
|
|
353
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
354
|
+
"key": "app",
|
|
355
|
+
"content": {
|
|
356
|
+
"viteLogo": {
|
|
357
|
+
"nodeType": "translation",
|
|
358
|
+
"translation": {
|
|
359
|
+
"en": "Vite logo",
|
|
360
|
+
"fr": "Logo Vite",
|
|
361
|
+
"es": "Logo Vite",
|
|
362
|
+
"pt": "Logo Vite"
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
"reactLogo": {
|
|
366
|
+
"nodeType": "translation",
|
|
367
|
+
"translation": {
|
|
368
|
+
"en": "React logo",
|
|
369
|
+
"fr": "Logo React",
|
|
370
|
+
"es": "Logo React",
|
|
371
|
+
"pt": "Logo React"
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
"title": {
|
|
375
|
+
"nodeType": "translation",
|
|
376
|
+
"translation": {
|
|
377
|
+
"en": "Vite + React",
|
|
378
|
+
"fr": "Vite + React",
|
|
379
|
+
"es": "Vite + React",
|
|
380
|
+
"pt": "Vite + React"
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
"count": {
|
|
384
|
+
"nodeType": "translation",
|
|
385
|
+
"translation": {
|
|
386
|
+
"en": "count is ",
|
|
387
|
+
"fr": "le compte est ",
|
|
388
|
+
"es": "el recuento es ",
|
|
389
|
+
"pt": "a contagem é "
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
"edit": {
|
|
393
|
+
"nodeType": "translation",
|
|
394
|
+
"translation": {
|
|
395
|
+
"en": "Edit src/App.tsx and save to test HMR",
|
|
396
|
+
"fr": "Éditez src/App.tsx et enregistrez pour tester HMR",
|
|
397
|
+
"es": "Edita src/App.tsx y guarda para probar HMR",
|
|
398
|
+
"pt": "Edite src/App.tsx e salve para testar o HMR"
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
"readTheDocs": {
|
|
402
|
+
"nodeType": "translation",
|
|
403
|
+
"translation": {
|
|
404
|
+
"en": "Click on the Vite and React logos to learn more",
|
|
405
|
+
"fr": "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
406
|
+
"es": "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
407
|
+
"pt": "Clique nos logotipos do Vite e React para saber mais"
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
> Suas declarações de conteúdo podem ser definidas em qualquer lugar de sua aplicação, desde que estejam 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}`).
|
|
415
|
+
|
|
416
|
+
> 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).
|
|
417
|
+
|
|
418
|
+
> Se o seu arquivo de conteúdo incluir código TSX, você deve considerar importar `import React from "react";` em seu arquivo de conteúdo.
|
|
419
|
+
|
|
420
|
+
### Etapa 5: Utilize o Intlayer no Seu Código
|
|
421
|
+
|
|
422
|
+
Acesse seus dicionários de conteúdo em toda a sua aplicação:
|
|
423
|
+
|
|
424
|
+
```tsx {5,9} fileName="src/App.tsx" codeFormat="typescript"
|
|
425
|
+
import { useState, type FC } from "react";
|
|
426
|
+
import reactLogo from "./assets/react.svg";
|
|
427
|
+
import viteLogo from "/vite.svg";
|
|
428
|
+
import "./App.css";
|
|
429
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
430
|
+
|
|
431
|
+
const AppContent: FC = () => {
|
|
432
|
+
const [count, setCount] = useState(0);
|
|
433
|
+
const content = useIntlayer("app");
|
|
434
|
+
|
|
435
|
+
return (
|
|
436
|
+
<>
|
|
437
|
+
<div>
|
|
438
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
439
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
440
|
+
</a>
|
|
441
|
+
<a href="https://react.dev" target="_blank">
|
|
442
|
+
<img
|
|
443
|
+
src={reactLogo}
|
|
444
|
+
className="logo react"
|
|
445
|
+
alt={content.reactLogo.value}
|
|
446
|
+
/>
|
|
447
|
+
</a>
|
|
448
|
+
</div>
|
|
449
|
+
<h1>{content.title}</h1>
|
|
450
|
+
<div className="card">
|
|
451
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
452
|
+
{content.count}
|
|
453
|
+
{count}
|
|
454
|
+
</button>
|
|
455
|
+
<p>{content.edit}</p>
|
|
456
|
+
</div>
|
|
457
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
458
|
+
</>
|
|
459
|
+
);
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
const App: FC = () => (
|
|
463
|
+
<IntlayerProvider>
|
|
464
|
+
<AppContent />
|
|
465
|
+
</IntlayerProvider>
|
|
466
|
+
);
|
|
467
|
+
|
|
468
|
+
export default App;
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
```tsx {5,9} fileName="src/App.msx" codeFormat="esm"
|
|
472
|
+
import { useState } from "react";
|
|
473
|
+
import reactLogo from "./assets/react.svg";
|
|
474
|
+
import viteLogo from "/vite.svg";
|
|
475
|
+
import "./App.css";
|
|
476
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
477
|
+
|
|
478
|
+
const AppContent = () => {
|
|
479
|
+
const [count, setCount] = useState(0);
|
|
480
|
+
const content = useIntlayer("app");
|
|
481
|
+
|
|
482
|
+
return (
|
|
483
|
+
<>
|
|
484
|
+
<div>
|
|
485
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
486
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
487
|
+
</a>
|
|
488
|
+
<a href="https://react.dev" target="_blank">
|
|
489
|
+
<img
|
|
490
|
+
src={reactLogo}
|
|
491
|
+
className="logo react"
|
|
492
|
+
alt={content.reactLogo.value}
|
|
493
|
+
/>
|
|
494
|
+
</a>
|
|
495
|
+
</div>
|
|
496
|
+
<h1>{content.title}</h1>
|
|
497
|
+
<div className="card">
|
|
498
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
499
|
+
{content.count}
|
|
500
|
+
{count}
|
|
501
|
+
</button>
|
|
502
|
+
<p>{content.edit}</p>
|
|
503
|
+
</div>
|
|
504
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
505
|
+
</>
|
|
506
|
+
);
|
|
507
|
+
};
|
|
508
|
+
|
|
509
|
+
const App = () => (
|
|
510
|
+
<IntlayerProvider>
|
|
511
|
+
<AppContent />
|
|
512
|
+
</IntlayerProvider>
|
|
513
|
+
);
|
|
514
|
+
|
|
515
|
+
export default App;
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
```tsx {5,9} fileName="src/App.csx" codeFormat="commonjs"
|
|
519
|
+
const { useState } = require("react");
|
|
520
|
+
const reactLogo = require("./assets/react.svg");
|
|
521
|
+
const viteLogo = require("/vite.svg");
|
|
522
|
+
require("./App.css");
|
|
523
|
+
const { IntlayerProvider, useIntlayer } = require("react-intlayer");
|
|
524
|
+
|
|
525
|
+
const AppContent = () => {
|
|
526
|
+
const [count, setCount] = useState(0);
|
|
527
|
+
const content = useIntlayer("app");
|
|
528
|
+
|
|
529
|
+
return (
|
|
530
|
+
<>
|
|
531
|
+
<div>
|
|
532
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
533
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
534
|
+
</a>
|
|
535
|
+
<a href="https://react.dev" target="_blank">
|
|
536
|
+
<img
|
|
537
|
+
src={reactLogo}
|
|
538
|
+
className="logo react"
|
|
539
|
+
alt={content.reactLogo.value}
|
|
540
|
+
/>
|
|
541
|
+
</a>
|
|
542
|
+
</div>
|
|
543
|
+
<h1>{content.title}</h1>
|
|
544
|
+
<div className="card">
|
|
545
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
546
|
+
{content.count}
|
|
547
|
+
{count}
|
|
548
|
+
</button>
|
|
549
|
+
<p>{content.edit}</p>
|
|
550
|
+
</div>
|
|
551
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
552
|
+
</>
|
|
553
|
+
);
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
const App = () => (
|
|
557
|
+
<IntlayerProvider>
|
|
558
|
+
<AppContent />
|
|
559
|
+
</IntlayerProvider>
|
|
560
|
+
);
|
|
561
|
+
|
|
562
|
+
module.exports = App;
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
> 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:
|
|
566
|
+
|
|
567
|
+
> ```jsx
|
|
568
|
+
>
|
|
569
|
+
> ```
|
|
570
|
+
|
|
571
|
+
> <img src={content.image.src.value} alt={content.image.value} />
|
|
572
|
+
|
|
573
|
+
> ```
|
|
574
|
+
>
|
|
575
|
+
> ```
|
|
576
|
+
|
|
577
|
+
> 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).
|
|
578
|
+
|
|
579
|
+
### (Opcional) Etapa 6: Alterar o idioma do seu conteúdo
|
|
580
|
+
|
|
581
|
+
Para alterar o idioma do seu conteúdo, você pode usar a função `setLocale` fornecida pelo hook `useLocale`. Esta função permite definir o idioma da aplicação e atualizar o conteúdo de acordo.
|
|
582
|
+
|
|
583
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
584
|
+
import type { FC } from "react";
|
|
585
|
+
import { Locales } from "intlayer";
|
|
586
|
+
import { useLocale } from "react-intlayer";
|
|
587
|
+
|
|
588
|
+
const LocaleSwitcher: FC = () => {
|
|
589
|
+
const { setLocale } = useLocale();
|
|
590
|
+
|
|
591
|
+
return (
|
|
592
|
+
<button onClick={() => setLocale(Locales.Portuguese)}>
|
|
593
|
+
Alterar idioma para Português
|
|
594
|
+
</button>
|
|
595
|
+
);
|
|
596
|
+
};
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
```jsx fileName="src/components/LocaleSwitcher.msx" codeFormat="esm"
|
|
600
|
+
import { Locales } from "intlayer";
|
|
601
|
+
import { useLocale } from "react-intlayer";
|
|
602
|
+
|
|
603
|
+
const LocaleSwitcher = () => {
|
|
604
|
+
const { setLocale } = useLocale();
|
|
605
|
+
|
|
606
|
+
return (
|
|
607
|
+
<button onClick={() => setLocale(Locales.Portuguese)}>
|
|
608
|
+
Alterar idioma para Português
|
|
609
|
+
</button>
|
|
610
|
+
);
|
|
611
|
+
};
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
```jsx fileName="src/components/LocaleSwitcher.csx" codeFormat="commonjs"
|
|
615
|
+
const { Locales } = require("intlayer");
|
|
616
|
+
|
|
617
|
+
const { useLocale } = require("react-intlayer");
|
|
618
|
+
|
|
619
|
+
const LocaleSwitcher = () => {
|
|
620
|
+
const { setLocale } = useLocale();
|
|
621
|
+
|
|
622
|
+
return (
|
|
623
|
+
<button onClick={() => setLocale(Locales.English)}>
|
|
624
|
+
Alterar idioma para Inglês
|
|
625
|
+
</button>
|
|
626
|
+
);
|
|
627
|
+
};
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
> 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).
|
|
631
|
+
|
|
632
|
+
### (Opcional) Etapa 7: Adicione roteamento localizado à sua aplicação
|
|
633
|
+
|
|
634
|
+
O objetivo desta etapa é criar rotas únicas para cada idioma. Isso é útil para SEO e URLs amigáveis para SEO.
|
|
635
|
+
Exemplo:
|
|
636
|
+
|
|
637
|
+
```plaintext
|
|
638
|
+
- https://example.com/about
|
|
639
|
+
- https://example.com/es/about
|
|
640
|
+
- https://example.com/fr/about
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
> Por padrão, as rotas não são prefixadas para o idioma padrão. Se você quiser 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.
|
|
644
|
+
|
|
645
|
+
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 [React Router](https://reactrouter.com/home):
|
|
646
|
+
|
|
647
|
+
```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
|
|
648
|
+
// Importando dependências e funções necessárias
|
|
649
|
+
// Funções utilitárias e tipos do 'intlayer'
|
|
650
|
+
import { type Locales, configuration, getPathWithoutLocale } from "intlayer";
|
|
651
|
+
import type { FC, PropsWithChildren } from "react"; // Tipos do React para componentes funcionais e props
|
|
652
|
+
import { IntlayerProvider } from "react-intlayer"; // Provedor para o contexto de internacionalização
|
|
653
|
+
import {
|
|
654
|
+
BrowserRouter,
|
|
655
|
+
Routes,
|
|
656
|
+
Route,
|
|
657
|
+
Navigate,
|
|
658
|
+
useLocation,
|
|
659
|
+
} from "react-router-dom"; // Componentes do Router para gerenciar navegação
|
|
660
|
+
|
|
661
|
+
// Desestruturando a configuração do Intlayer
|
|
662
|
+
const { internationalization, middleware } = configuration;
|
|
663
|
+
const { locales, defaultLocale } = internationalization;
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Um componente que gerencia a localização e envolve os filhos com o contexto de idioma apropriado.
|
|
667
|
+
* Ele gerencia a detecção e validação de idioma baseada na URL.
|
|
668
|
+
*/
|
|
669
|
+
const AppLocalized: FC<PropsWithChildren<{ locale: Locales }>> = ({
|
|
670
|
+
children,
|
|
671
|
+
locale,
|
|
672
|
+
}) => {
|
|
673
|
+
const { pathname, search } = useLocation(); // Obtém o caminho atual da URL
|
|
674
|
+
|
|
675
|
+
// Determina o idioma atual, retornando ao padrão se não for fornecido
|
|
676
|
+
const currentLocale = locale ?? defaultLocale;
|
|
677
|
+
|
|
678
|
+
// Remove o prefixo do idioma do caminho para construir um caminho base
|
|
679
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
680
|
+
pathname // Caminho atual da URL
|
|
681
|
+
);
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Se middleware.prefixDefault for verdadeiro, o idioma padrão deve sempre ser prefixado.
|
|
685
|
+
*/
|
|
686
|
+
if (middleware.prefixDefault) {
|
|
687
|
+
// Valida o idioma
|
|
688
|
+
if (!locale || !locales.includes(locale)) {
|
|
689
|
+
// Redireciona para o idioma padrão com o caminho atualizado
|
|
690
|
+
return (
|
|
691
|
+
<Navigate
|
|
692
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
693
|
+
replace // Substitui a entrada atual do histórico pela nova
|
|
694
|
+
/>
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// Envolve os filhos com o IntlayerProvider e define o idioma atual
|
|
699
|
+
return (
|
|
700
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
701
|
+
);
|
|
702
|
+
} else {
|
|
703
|
+
/**
|
|
704
|
+
* Quando middleware.prefixDefault é falso, o idioma padrão não é prefixado.
|
|
705
|
+
* Garante que o idioma atual seja válido e não o idioma padrão.
|
|
706
|
+
*/
|
|
707
|
+
if (
|
|
708
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
709
|
+
!locales
|
|
710
|
+
.filter(
|
|
711
|
+
(locale) => locale.toString() !== defaultLocale.toString() // Exclui o idioma padrão
|
|
712
|
+
)
|
|
713
|
+
.includes(currentLocale) // Verifica se o idioma atual está na lista de idiomas válidos
|
|
714
|
+
) {
|
|
715
|
+
// Redireciona para o caminho sem o prefixo do idioma
|
|
716
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// Envolve os filhos com o IntlayerProvider e define o idioma atual
|
|
720
|
+
return (
|
|
721
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Um componente de roteador que configura rotas específicas de idioma.
|
|
728
|
+
* Ele usa o React Router para gerenciar a navegação e renderizar componentes localizados.
|
|
729
|
+
*/
|
|
730
|
+
export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
|
|
731
|
+
<BrowserRouter>
|
|
732
|
+
<Routes>
|
|
733
|
+
{locales
|
|
734
|
+
.filter(
|
|
735
|
+
(locale) => middleware.prefixDefault || locale !== defaultLocale
|
|
736
|
+
)
|
|
737
|
+
.map((locale) => (
|
|
738
|
+
<Route
|
|
739
|
+
// Padrão de rota para capturar o idioma (ex.: /en/, /fr/) e corresponder a todos os caminhos subsequentes
|
|
740
|
+
path={`/${locale}/*`}
|
|
741
|
+
key={locale}
|
|
742
|
+
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // Envolve os filhos com o gerenciamento de idioma
|
|
743
|
+
/>
|
|
744
|
+
))}
|
|
745
|
+
|
|
746
|
+
{
|
|
747
|
+
// Se o prefixo do idioma padrão estiver desativado, renderiza os filhos diretamente no caminho raiz
|
|
748
|
+
!middleware.prefixDefault && (
|
|
749
|
+
<Route
|
|
750
|
+
path="*"
|
|
751
|
+
element={
|
|
752
|
+
<AppLocalized locale={defaultLocale}>{children}</AppLocalized>
|
|
753
|
+
} // Envolve os filhos com o gerenciamento de idioma
|
|
754
|
+
/>
|
|
755
|
+
)
|
|
756
|
+
}
|
|
757
|
+
</Routes>
|
|
758
|
+
</BrowserRouter>
|
|
759
|
+
);
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
```jsx fileName="src/components/LocaleRouter.mjx" codeFormat="esm"
|
|
763
|
+
// Importando dependências e funções necessárias
|
|
764
|
+
// Funções utilitárias e tipos do 'intlayer'
|
|
765
|
+
import { configuration, getPathWithoutLocale } from "intlayer";
|
|
766
|
+
import { IntlayerProvider } from "react-intlayer"; // Provedor para o contexto de internacionalização
|
|
767
|
+
import {
|
|
768
|
+
BrowserRouter,
|
|
769
|
+
Routes,
|
|
770
|
+
Route,
|
|
771
|
+
Navigate,
|
|
772
|
+
useLocation,
|
|
773
|
+
} from "react-router-dom"; // Componentes do Router para gerenciar navegação
|
|
774
|
+
|
|
775
|
+
// Desestruturando a configuração do Intlayer
|
|
776
|
+
const { internationalization, middleware } = configuration;
|
|
777
|
+
const { locales, defaultLocale } = internationalization;
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Um componente que gerencia a localização e envolve os filhos com o contexto de idioma apropriado.
|
|
781
|
+
* Ele gerencia a detecção e validação de idioma baseada na URL.
|
|
782
|
+
*/
|
|
783
|
+
const AppLocalized = ({ children, locale }) => {
|
|
784
|
+
const { pathname, search } = useLocation(); // Obtém o caminho atual da URL
|
|
785
|
+
|
|
786
|
+
// Determina o idioma atual, retornando ao padrão se não for fornecido
|
|
787
|
+
const currentLocale = locale ?? defaultLocale;
|
|
788
|
+
|
|
789
|
+
// Remove o prefixo do idioma do caminho para construir um caminho base
|
|
790
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
791
|
+
pathname // Caminho atual da URL
|
|
792
|
+
);
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* Se middleware.prefixDefault for verdadeiro, o idioma padrão deve sempre ser prefixado.
|
|
796
|
+
*/
|
|
797
|
+
if (middleware.prefixDefault) {
|
|
798
|
+
// Valida o idioma
|
|
799
|
+
if (!locale || !locales.includes(locale)) {
|
|
800
|
+
// Redireciona para o idioma padrão com o caminho atualizado
|
|
801
|
+
return (
|
|
802
|
+
<Navigate
|
|
803
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
804
|
+
replace // Substitui a entrada atual do histórico pela nova
|
|
805
|
+
/>
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
// Envolve os filhos com o IntlayerProvider e define o idioma atual
|
|
810
|
+
return (
|
|
811
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
812
|
+
);
|
|
813
|
+
} else {
|
|
814
|
+
/**
|
|
815
|
+
* Quando middleware.prefixDefault é falso, o idioma padrão não é prefixado.
|
|
816
|
+
* Garante que o idioma atual seja válido e não o idioma padrão.
|
|
817
|
+
*/
|
|
818
|
+
if (
|
|
819
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
820
|
+
!locales
|
|
821
|
+
.filter(
|
|
822
|
+
(locale) => locale.toString() !== defaultLocale.toString() // Exclui o idioma padrão
|
|
823
|
+
)
|
|
824
|
+
.includes(currentLocale) // Verifica se o idioma atual está na lista de idiomas válidos
|
|
825
|
+
) {
|
|
826
|
+
// Redireciona para o caminho sem o prefixo do idioma
|
|
827
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
// Envolve os filhos com o IntlayerProvider e define o idioma atual
|
|
831
|
+
return (
|
|
832
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* Ele usa React Router para gerenciar a navegação e renderizar componentes localizados.
|
|
839
|
+
*/
|
|
840
|
+
export const LocaleRouter = ({ children }) => (
|
|
841
|
+
<BrowserRouter>
|
|
842
|
+
<Routes>
|
|
843
|
+
{locales
|
|
844
|
+
.filter(
|
|
845
|
+
(locale) => middleware.prefixDefault || locale !== defaultLocale
|
|
846
|
+
)
|
|
847
|
+
.map((locale) => (
|
|
848
|
+
<Route
|
|
849
|
+
// Padrão de rota para capturar o idioma (ex.: /en/, /fr/) e corresponder a todos os caminhos subsequentes
|
|
850
|
+
path={`/${locale}/*`}
|
|
851
|
+
key={locale}
|
|
852
|
+
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // Envolve os filhos com o gerenciamento de idioma
|
|
853
|
+
/>
|
|
854
|
+
))}
|
|
855
|
+
|
|
856
|
+
{
|
|
857
|
+
// Se o prefixo do idioma padrão estiver desativado, renderize os filhos diretamente no caminho raiz
|
|
858
|
+
!middleware.prefixDefault && (
|
|
859
|
+
<Route
|
|
860
|
+
path="*"
|
|
861
|
+
element={
|
|
862
|
+
<AppLocalized locale={defaultLocale}>{children}</AppLocalized>
|
|
863
|
+
} // Envolve os filhos com o gerenciamento de idioma
|
|
864
|
+
/>
|
|
865
|
+
)
|
|
866
|
+
}
|
|
867
|
+
</Routes>
|
|
868
|
+
</BrowserRouter>
|
|
869
|
+
);
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
```jsx fileName="src/components/LocaleRouter.cjx" codeFormat="commonjs"
|
|
873
|
+
// Importando dependências e funções necessárias
|
|
874
|
+
const { configuration, getPathWithoutLocale } = require("intlayer"); // Funções utilitárias e tipos de 'intlayer'
|
|
875
|
+
const { IntlayerProvider, useLocale } = require("react-intlayer"); // Provedor para o contexto de internacionalização
|
|
876
|
+
const {
|
|
877
|
+
BrowserRouter,
|
|
878
|
+
Routes,
|
|
879
|
+
Route,
|
|
880
|
+
Navigate,
|
|
881
|
+
useLocation,
|
|
882
|
+
} = require("react-router-dom"); // Componentes de roteador para gerenciar navegação
|
|
883
|
+
|
|
884
|
+
// Desestruturando configuração do Intlayer
|
|
885
|
+
const { internationalization, middleware } = configuration;
|
|
886
|
+
const { locales, defaultLocale } = internationalization;
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* Um componente que lida com a localização e envolve os filhos com o contexto de idioma apropriado.
|
|
890
|
+
* Ele gerencia a detecção e validação de idioma baseada em URL.
|
|
891
|
+
*/
|
|
892
|
+
const AppLocalized = ({ children, locale }) => {
|
|
893
|
+
const { pathname, search } = useLocation(); // Obtém o caminho atual da URL
|
|
894
|
+
|
|
895
|
+
// Determina o idioma atual, retornando ao padrão se não for fornecido
|
|
896
|
+
const currentLocale = locale ?? defaultLocale;
|
|
897
|
+
|
|
898
|
+
// Remove o prefixo do idioma do caminho para construir um caminho base
|
|
899
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
900
|
+
pathname // Caminho atual da URL
|
|
901
|
+
);
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Se middleware.prefixDefault for verdadeiro, o idioma padrão deve sempre ser prefixado.
|
|
905
|
+
*/
|
|
906
|
+
if (middleware.prefixDefault) {
|
|
907
|
+
// Valida o idioma
|
|
908
|
+
if (!locale || !locales.includes(locale)) {
|
|
909
|
+
// Redireciona para o idioma padrão com o caminho atualizado
|
|
910
|
+
return (
|
|
911
|
+
<Navigate
|
|
912
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
913
|
+
replace // Substitui a entrada atual do histórico pela nova
|
|
914
|
+
/>
|
|
915
|
+
);
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
// Envolve os filhos com o IntlayerProvider e define o idioma atual
|
|
919
|
+
return (
|
|
920
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
921
|
+
);
|
|
922
|
+
} else {
|
|
923
|
+
/**
|
|
924
|
+
* Quando middleware.prefixDefault é falso, o idioma padrão não é prefixado.
|
|
925
|
+
* Certifique-se de que o idioma atual é válido e não o idioma padrão.
|
|
926
|
+
*/
|
|
927
|
+
if (
|
|
928
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
929
|
+
!locales
|
|
930
|
+
.filter(
|
|
931
|
+
(locale) => locale.toString() !== defaultLocale.toString() // Exclui o idioma padrão
|
|
932
|
+
)
|
|
933
|
+
.includes(currentLocale) // Verifica se o idioma atual está na lista de idiomas válidos
|
|
934
|
+
) {
|
|
935
|
+
// Redireciona para o caminho sem o prefixo de idioma
|
|
936
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
// Envolve os filhos com o IntlayerProvider e define o idioma atual
|
|
940
|
+
return (
|
|
941
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
942
|
+
);
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* Um componente de roteador que configura rotas específicas para o idioma.
|
|
948
|
+
* Ele usa React Router para gerenciar a navegação e renderizar componentes localizados.
|
|
949
|
+
*/
|
|
950
|
+
const LocaleRouter = ({ children }) => (
|
|
951
|
+
<BrowserRouter>
|
|
952
|
+
<Routes>
|
|
953
|
+
{locales
|
|
954
|
+
.filter(
|
|
955
|
+
(locale) => middleware.prefixDefault || locale !== defaultLocale
|
|
956
|
+
)
|
|
957
|
+
.map((locale) => (
|
|
958
|
+
<Route
|
|
959
|
+
// Padrão de rota para capturar o idioma (ex.: /en/, /fr/) e corresponder a todos os caminhos subsequentes
|
|
960
|
+
path={`/${locale}/*`}
|
|
961
|
+
key={locale}
|
|
962
|
+
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // Envolve os filhos com o gerenciamento de idioma
|
|
963
|
+
/>
|
|
964
|
+
))}
|
|
965
|
+
|
|
966
|
+
{
|
|
967
|
+
// Se o prefixo do idioma padrão estiver desativado, renderize os filhos diretamente no caminho raiz
|
|
968
|
+
!middleware.prefixDefault && (
|
|
969
|
+
<Route
|
|
970
|
+
path="*"
|
|
971
|
+
element={
|
|
972
|
+
<AppLocalized locale={defaultLocale}>{children}</AppLocalized>
|
|
973
|
+
} // Envolve os filhos com o gerenciamento de idioma
|
|
974
|
+
/>
|
|
975
|
+
)
|
|
976
|
+
}
|
|
977
|
+
</Routes>
|
|
978
|
+
</BrowserRouter>
|
|
979
|
+
);
|
|
980
|
+
```
|
|
981
|
+
|
|
982
|
+
Então, você pode usar o componente `LocaleRouter` em sua aplicação:
|
|
983
|
+
|
|
984
|
+
```tsx fileName="src/App.tsx" codeFormat="typescript"
|
|
985
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
986
|
+
import type { FC } from "react";
|
|
987
|
+
|
|
988
|
+
// ... Seu componente AppContent
|
|
989
|
+
|
|
990
|
+
const App: FC = () => (
|
|
991
|
+
<LocaleRouter>
|
|
992
|
+
<AppContent />
|
|
993
|
+
</LocaleRouter>
|
|
994
|
+
);
|
|
995
|
+
```
|
|
996
|
+
|
|
997
|
+
```jsx fileName="src/App.mjx" codeFormat="esm"
|
|
998
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
999
|
+
|
|
1000
|
+
// ... Seu componente AppContent
|
|
1001
|
+
|
|
1002
|
+
const App = () => (
|
|
1003
|
+
<LocaleRouter>
|
|
1004
|
+
<AppContent />
|
|
1005
|
+
</LocaleRouter>
|
|
1006
|
+
);
|
|
1007
|
+
```
|
|
1008
|
+
|
|
1009
|
+
```jsx fileName="src/App.cjx" codeFormat="commonjs"
|
|
1010
|
+
const { LocaleRouter } = require("./components/LocaleRouter");
|
|
1011
|
+
|
|
1012
|
+
// ... Seu componente AppContent
|
|
1013
|
+
|
|
1014
|
+
const App = () => (
|
|
1015
|
+
<LocaleRouter>
|
|
1016
|
+
<AppContent />
|
|
1017
|
+
</LocaleRouter>
|
|
1018
|
+
);
|
|
1019
|
+
```
|
|
1020
|
+
|
|
1021
|
+
Paralelamente, você também pode usar o `intLayerMiddlewarePlugin` para adicionar roteamento no lado do servidor à sua aplicação. Este plugin detectará automaticamente o idioma atual com base na URL e definirá o cookie de idioma apropriado. Se nenhum idioma for especificado, o plugin determinará o idioma mais apropriado com base nas preferências de idioma do navegador do usuário. Se nenhum idioma for detectado, ele redirecionará para o idioma padrão.
|
|
1022
|
+
|
|
1023
|
+
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
1024
|
+
import { defineConfig } from "vite";
|
|
1025
|
+
import react from "@vitejs/plugin-react-swc";
|
|
1026
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
1027
|
+
|
|
1028
|
+
// https://vitejs.dev/config/
|
|
1029
|
+
export default defineConfig({
|
|
1030
|
+
plugins: [react(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1031
|
+
});
|
|
1032
|
+
```
|
|
1033
|
+
|
|
1034
|
+
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
1035
|
+
import { defineConfig } from "vite";
|
|
1036
|
+
import react from "@vitejs/plugin-react-swc";
|
|
1037
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
1038
|
+
|
|
1039
|
+
// https://vitejs.dev/config/
|
|
1040
|
+
export default defineConfig({
|
|
1041
|
+
plugins: [react(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1042
|
+
});
|
|
1043
|
+
```
|
|
1044
|
+
|
|
1045
|
+
```javascript {5,10} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
1046
|
+
const { defineConfig } = require("vite");
|
|
1047
|
+
const react = require("@vitejs/plugin-react-swc");
|
|
1048
|
+
const { intlayerPlugin, intLayerMiddlewarePlugin } = require("vite-intlayer");
|
|
1049
|
+
|
|
1050
|
+
// https://vitejs.dev/config/
|
|
1051
|
+
module.exports = defineConfig({
|
|
1052
|
+
plugins: [react(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1053
|
+
});
|
|
1054
|
+
```
|
|
1055
|
+
|
|
1056
|
+
### (Opcional) Etapa 8: Alterar a URL quando o idioma muda
|
|
1057
|
+
|
|
1058
|
+
Para alterar a URL quando o idioma muda, você pode usar a prop `onLocaleChange` fornecida pelo hook `useLocale`. Paralelamente, você pode usar os hooks `useLocation` e `useNavigate` do `react-router-dom` para atualizar o caminho da URL.
|
|
1059
|
+
|
|
1060
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
1061
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
1062
|
+
import {
|
|
1063
|
+
Locales,
|
|
1064
|
+
getHTMLTextDir,
|
|
1065
|
+
getLocaleName,
|
|
1066
|
+
getLocalizedUrl,
|
|
1067
|
+
} from "intlayer";
|
|
1068
|
+
import { useLocale } from "react-intlayer";
|
|
1069
|
+
import { type FC } from "react";
|
|
1070
|
+
|
|
1071
|
+
const LocaleSwitcher: FC = () => {
|
|
1072
|
+
const { pathname, search } = useLocation(); // Obtém o caminho atual da URL. Exemplo: /fr/about?foo=bar
|
|
1073
|
+
const navigate = useNavigate();
|
|
1074
|
+
|
|
1075
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1076
|
+
onLocaleChange: (locale) => {
|
|
1077
|
+
// Construa a URL com o locale atualizado
|
|
1078
|
+
// Exemplo: /pt/about?foo=bar
|
|
1079
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
1080
|
+
|
|
1081
|
+
// Atualize o caminho da URL
|
|
1082
|
+
navigate(pathWithLocale);
|
|
1083
|
+
},
|
|
1084
|
+
});
|
|
1085
|
+
|
|
1086
|
+
return (
|
|
1087
|
+
<div>
|
|
1088
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1089
|
+
<div id="localePopover" popover="auto">
|
|
1090
|
+
{availableLocales.map((localeItem) => (
|
|
1091
|
+
<a
|
|
1092
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
1093
|
+
hrefLang={localeItem}
|
|
1094
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1095
|
+
onClick={(e) => {
|
|
1096
|
+
e.preventDefault();
|
|
1097
|
+
setLocale(localeItem);
|
|
1098
|
+
}}
|
|
1099
|
+
key={localeItem}
|
|
1100
|
+
>
|
|
1101
|
+
<span>
|
|
1102
|
+
{/* Locale - ex.: PT */}
|
|
1103
|
+
{localeItem}
|
|
1104
|
+
</span>
|
|
1105
|
+
<span>
|
|
1106
|
+
{/* Idioma no próprio Locale - ex.: Português */}
|
|
1107
|
+
{getLocaleName(localeItem, locale)}
|
|
1108
|
+
</span>
|
|
1109
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1110
|
+
{/* Idioma no Locale atual - ex.: Portugués com o locale atual definido como Locales.SPANISH */}
|
|
1111
|
+
{getLocaleName(localeItem)}
|
|
1112
|
+
</span>
|
|
1113
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1114
|
+
{/* Idioma em Inglês - ex.: Portuguese */}
|
|
1115
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1116
|
+
</span>
|
|
1117
|
+
</a>
|
|
1118
|
+
))}
|
|
1119
|
+
</div>
|
|
1120
|
+
</div>
|
|
1121
|
+
);
|
|
1122
|
+
};
|
|
1123
|
+
```
|
|
1124
|
+
|
|
1125
|
+
```jsx fileName="src/components/LocaleSwitcher.msx" codeFormat="esm"
|
|
1126
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
1127
|
+
import {
|
|
1128
|
+
Locales,
|
|
1129
|
+
getHTMLTextDir,
|
|
1130
|
+
getLocaleName,
|
|
1131
|
+
getLocalizedUrl,
|
|
1132
|
+
} from "intlayer";
|
|
1133
|
+
import { useLocale } from "react-intlayer";
|
|
1134
|
+
|
|
1135
|
+
const LocaleSwitcher = () => {
|
|
1136
|
+
const { pathname, search } = useLocation(); // Obtenha o caminho atual da URL. Exemplo: /pt/about?foo=bar
|
|
1137
|
+
const navigate = useNavigate();
|
|
1138
|
+
|
|
1139
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1140
|
+
onLocaleChange: (locale) => {
|
|
1141
|
+
// Construa a URL com o locale atualizado
|
|
1142
|
+
// Exemplo: /pt/about?foo=bar
|
|
1143
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
1144
|
+
|
|
1145
|
+
// Atualize o caminho da URL
|
|
1146
|
+
navigate(pathWithLocale);
|
|
1147
|
+
},
|
|
1148
|
+
});
|
|
1149
|
+
|
|
1150
|
+
return (
|
|
1151
|
+
<div>
|
|
1152
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1153
|
+
<div id="localePopover" popover="auto">
|
|
1154
|
+
{availableLocales.map((localeItem) => (
|
|
1155
|
+
<a
|
|
1156
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
1157
|
+
hrefLang={localeItem}
|
|
1158
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1159
|
+
onClick={(e) => {
|
|
1160
|
+
e.preventDefault();
|
|
1161
|
+
setLocale(localeItem);
|
|
1162
|
+
}}
|
|
1163
|
+
key={localeItem}
|
|
1164
|
+
>
|
|
1165
|
+
<span>
|
|
1166
|
+
{/* Locale - ex.: PT */}
|
|
1167
|
+
{localeItem}
|
|
1168
|
+
</span>
|
|
1169
|
+
<span>
|
|
1170
|
+
{/* Idioma no próprio Locale - ex.: Português */}
|
|
1171
|
+
{getLocaleName(localeItem, locale)}
|
|
1172
|
+
</span>
|
|
1173
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1174
|
+
{/* Idioma no Locale atual - ex.: Portugués com o locale atual definido como Locales.SPANISH */}
|
|
1175
|
+
{getLocaleName(localeItem)}
|
|
1176
|
+
</span>
|
|
1177
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1178
|
+
{/* Idioma em Inglês - ex.: Portuguese */}
|
|
1179
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1180
|
+
</span>
|
|
1181
|
+
</a>
|
|
1182
|
+
))}
|
|
1183
|
+
</div>
|
|
1184
|
+
</div>
|
|
1185
|
+
);
|
|
1186
|
+
};
|
|
1187
|
+
```
|
|
1188
|
+
|
|
1189
|
+
```jsx fileName="src/components/LocaleSwitcher.csx" codeFormat="commonjs"
|
|
1190
|
+
const { useLocation, useNavigate } = require("react-router-dom");
|
|
1191
|
+
const {
|
|
1192
|
+
Locales,
|
|
1193
|
+
getHTMLTextDir,
|
|
1194
|
+
getLocaleName,
|
|
1195
|
+
getLocalizedUrl,
|
|
1196
|
+
} = require("intlayer");
|
|
1197
|
+
const { useLocale } = require("react-intlayer");
|
|
1198
|
+
|
|
1199
|
+
const LocaleSwitcher = () => {
|
|
1200
|
+
const { pathname, search } = useLocation(); // Obtenha o caminho atual da URL. Exemplo: /pt/about?foo=bar
|
|
1201
|
+
const navigate = useNavigate();
|
|
1202
|
+
|
|
1203
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1204
|
+
onLocaleChange: (locale) => {
|
|
1205
|
+
// Construa a URL com o locale atualizado
|
|
1206
|
+
// Exemplo: /pt/about?foo=bar
|
|
1207
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
1208
|
+
|
|
1209
|
+
// Atualize o caminho da URL
|
|
1210
|
+
navigate(pathWithLocale);
|
|
1211
|
+
},
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
return (
|
|
1215
|
+
<div>
|
|
1216
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1217
|
+
<div id="localePopover" popover="auto">
|
|
1218
|
+
{availableLocales.map((localeItem) => (
|
|
1219
|
+
<a
|
|
1220
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
1221
|
+
hrefLang={localeItem}
|
|
1222
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1223
|
+
onClick={(e) => {
|
|
1224
|
+
e.preventDefault();
|
|
1225
|
+
setLocale(localeItem);
|
|
1226
|
+
}}
|
|
1227
|
+
key={localeItem}
|
|
1228
|
+
>
|
|
1229
|
+
<span>
|
|
1230
|
+
{/* Locale - ex.: PT */}
|
|
1231
|
+
{localeItem}
|
|
1232
|
+
</span>
|
|
1233
|
+
<span>
|
|
1234
|
+
{/* Idioma no próprio Locale - ex.: Português */}
|
|
1235
|
+
{getLocaleName(localeItem, locale)}
|
|
1236
|
+
</span>
|
|
1237
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1238
|
+
{/* Idioma no Locale atual - ex.: Portugués com o locale atual definido como Locales.SPANISH */}
|
|
1239
|
+
{getLocaleName(localeItem)}
|
|
1240
|
+
</span>
|
|
1241
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1242
|
+
{/* Idioma em Inglês - ex.: Portuguese */}
|
|
1243
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1244
|
+
</span>
|
|
1245
|
+
</a>
|
|
1246
|
+
))}
|
|
1247
|
+
</div>
|
|
1248
|
+
</div>
|
|
1249
|
+
);
|
|
1250
|
+
};
|
|
1251
|
+
```
|
|
1252
|
+
|
|
1253
|
+
> Referências da documentação:
|
|
1254
|
+
|
|
1255
|
+
> - [`useLocale` hook](https://github.com/aymericzip/intlayer/blob/main/docs/pt/packages/react-intlayer/useLocale.md)
|
|
1256
|
+
|
|
1257
|
+
> - [`getLocaleName` hook](https://github.com/aymericzip/intlayer/blob/main/docs/pt/packages/intlayer/getLocaleName.md)
|
|
1258
|
+
|
|
1259
|
+
> - [`getLocalizedUrl` hook](https://github.com/aymericzip/intlayer/blob/main/docs/pt/packages/intlayer/getLocalizedUrl.md)
|
|
1260
|
+
|
|
1261
|
+
> - [`getHTMLTextDir` hook](https://github.com/aymericzip/intlayer/blob/main/docs/pt/packages/intlayer/getHTMLTextDir.md)
|
|
1262
|
+
|
|
1263
|
+
> - [`hrefLang` attribute](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
|
|
1264
|
+
|
|
1265
|
+
> - [`lang` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
|
|
1266
|
+
|
|
1267
|
+
> - [`dir` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
|
|
1268
|
+
|
|
1269
|
+
> - [`aria-current` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1270
|
+
|
|
1271
|
+
---
|
|
1272
|
+
|
|
1273
|
+
### (Opcional) Passo 9: Alterar os Atributos de Idioma e Direção do HTML
|
|
1274
|
+
|
|
1275
|
+
Quando sua aplicação suporta múltiplos idiomas, é crucial atualizar os atributos `lang` e `dir` da tag `<html>` para corresponder ao locale atual. Fazer isso garante:
|
|
1276
|
+
|
|
1277
|
+
- **Acessibilidade**: Leitores de tela e tecnologias assistivas dependem do atributo `lang` correto para pronunciar e interpretar o conteúdo com precisão.
|
|
1278
|
+
- **Renderização de Texto**: O atributo `dir` (direção) garante que o texto seja renderizado na ordem correta (ex.: da esquerda para a direita para o inglês, da direita para a esquerda para o árabe ou hebraico), essencial para a legibilidade.
|
|
1279
|
+
- **SEO**: Motores de busca utilizam o atributo `lang` para determinar o idioma da sua página, ajudando a fornecer o conteúdo localizado correto nos resultados de busca.
|
|
1280
|
+
|
|
1281
|
+
Ao atualizar esses atributos dinamicamente quando o locale muda, você garante uma experiência consistente e acessível para os usuários em todos os idiomas suportados.
|
|
1282
|
+
|
|
1283
|
+
#### Implementando o Hook
|
|
1284
|
+
|
|
1285
|
+
Crie um hook personalizado para gerenciar os atributos HTML. O hook escuta as mudanças de locale e atualiza os atributos de acordo:
|
|
1286
|
+
|
|
1287
|
+
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
|
|
1288
|
+
import { useEffect } from "react";
|
|
1289
|
+
import { useLocale } from "react-intlayer";
|
|
1290
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1291
|
+
|
|
1292
|
+
/**
|
|
1293
|
+
|
|
1294
|
+
* - `lang`: Informa navegadores e motores de busca sobre o idioma da página.
|
|
1295
|
+
* - `dir`: Garante a ordem de leitura correta (por exemplo, 'ltr' para inglês, 'rtl' para árabe).
|
|
1296
|
+
*
|
|
1297
|
+
* Essa atualização dinâmica é essencial para renderização de texto adequada, acessibilidade e SEO.
|
|
1298
|
+
*/
|
|
1299
|
+
export const useI18nHTMLAttributes = () => {
|
|
1300
|
+
const { locale } = useLocale();
|
|
1301
|
+
|
|
1302
|
+
useEffect(() => {
|
|
1303
|
+
// Atualiza o atributo de idioma para o idioma atual.
|
|
1304
|
+
document.documentElement.lang = locale;
|
|
1305
|
+
|
|
1306
|
+
// Define a direção do texto com base no idioma atual.
|
|
1307
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1308
|
+
}, [locale]);
|
|
1309
|
+
};
|
|
1310
|
+
```
|
|
1311
|
+
|
|
1312
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.msx" codeFormat="esm"
|
|
1313
|
+
import { useEffect } from "react";
|
|
1314
|
+
import { useLocale } from "react-intlayer";
|
|
1315
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* Atualiza os atributos `lang` e `dir` do elemento HTML <html> com base no idioma atual.
|
|
1319
|
+
* - `lang`: Informa navegadores e motores de busca sobre o idioma da página.
|
|
1320
|
+
* - `dir`: Garante a ordem de leitura correta (por exemplo, 'ltr' para inglês, 'rtl' para árabe).
|
|
1321
|
+
*
|
|
1322
|
+
* Essa atualização dinâmica é essencial para renderização de texto adequada, acessibilidade e SEO.
|
|
1323
|
+
*/
|
|
1324
|
+
export const useI18nHTMLAttributes = () => {
|
|
1325
|
+
const { locale } = useLocale();
|
|
1326
|
+
|
|
1327
|
+
useEffect(() => {
|
|
1328
|
+
// Atualiza o atributo de idioma para o idioma atual.
|
|
1329
|
+
document.documentElement.lang = locale;
|
|
1330
|
+
|
|
1331
|
+
// Define a direção do texto com base no idioma atual.
|
|
1332
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1333
|
+
}, [locale]);
|
|
1334
|
+
};
|
|
1335
|
+
```
|
|
1336
|
+
|
|
1337
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.csx" codeFormat="commonjs"
|
|
1338
|
+
const { useEffect } = require("react");
|
|
1339
|
+
const { useLocale } = require("react-intlayer");
|
|
1340
|
+
const { getHTMLTextDir } = require("intlayer");
|
|
1341
|
+
|
|
1342
|
+
/**
|
|
1343
|
+
* Atualiza os atributos `lang` e `dir` do elemento HTML <html> com base no idioma atual.
|
|
1344
|
+
* - `lang`: Informa navegadores e motores de busca sobre o idioma da página.
|
|
1345
|
+
* - `dir`: Garante a ordem de leitura correta (por exemplo, 'ltr' para inglês, 'rtl' para árabe).
|
|
1346
|
+
*
|
|
1347
|
+
* Essa atualização dinâmica é essencial para renderização de texto adequada, acessibilidade e SEO.
|
|
1348
|
+
*/
|
|
1349
|
+
const useI18nHTMLAttributes = () => {
|
|
1350
|
+
const { locale } = useLocale();
|
|
1351
|
+
|
|
1352
|
+
useEffect(() => {
|
|
1353
|
+
// Atualiza o atributo de idioma para o idioma atual.
|
|
1354
|
+
document.documentElement.lang = locale;
|
|
1355
|
+
|
|
1356
|
+
// Define a direção do texto com base no idioma atual.
|
|
1357
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1358
|
+
}, [locale]);
|
|
1359
|
+
};
|
|
1360
|
+
|
|
1361
|
+
module.exports = { useI18nHTMLAttributes };
|
|
1362
|
+
```
|
|
1363
|
+
|
|
1364
|
+
#### Usando o Hook em Sua Aplicação
|
|
1365
|
+
|
|
1366
|
+
Integre o hook no seu componente principal para que os atributos HTML sejam atualizados sempre que o idioma mudar:
|
|
1367
|
+
|
|
1368
|
+
```tsx fileName="src/App.tsx" codeFormat="typescript"
|
|
1369
|
+
import type { FC } from "react";
|
|
1370
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
1371
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1372
|
+
import "./App.css";
|
|
1373
|
+
|
|
1374
|
+
const AppContent: FC = () => {
|
|
1375
|
+
// Aplica o hook para atualizar os atributos lang e dir da tag <html> com base no idioma.
|
|
1376
|
+
useI18nHTMLAttributes();
|
|
1377
|
+
|
|
1378
|
+
// ... Resto do seu componente
|
|
1379
|
+
};
|
|
1380
|
+
|
|
1381
|
+
const App: FC = () => (
|
|
1382
|
+
<IntlayerProvider>
|
|
1383
|
+
<AppContent />
|
|
1384
|
+
</IntlayerProvider>
|
|
1385
|
+
);
|
|
1386
|
+
|
|
1387
|
+
export default App;
|
|
1388
|
+
```
|
|
1389
|
+
|
|
1390
|
+
```jsx fileName="src/App.msx" codeFormat="esm"
|
|
1391
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
1392
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1393
|
+
import "./App.css";
|
|
1394
|
+
|
|
1395
|
+
const AppContent = () => {
|
|
1396
|
+
// Aplica o hook para atualizar os atributos lang e dir da tag <html> com base no idioma.
|
|
1397
|
+
useI18nHTMLAttributes();
|
|
1398
|
+
|
|
1399
|
+
// ... Resto do seu componente
|
|
1400
|
+
};
|
|
1401
|
+
|
|
1402
|
+
const App = () => (
|
|
1403
|
+
<IntlayerProvider>
|
|
1404
|
+
<AppContent />
|
|
1405
|
+
</IntlayerProvider>
|
|
1406
|
+
);
|
|
1407
|
+
|
|
1408
|
+
export default App;
|
|
1409
|
+
```
|
|
1410
|
+
|
|
1411
|
+
```jsx fileName="src/App.csx" codeFormat="commonjs"
|
|
1412
|
+
const { FC } = require("react");
|
|
1413
|
+
const { IntlayerProvider, useIntlayer } = require("react-intlayer");
|
|
1414
|
+
const { useI18nHTMLAttributes } = require("./hooks/useI18nHTMLAttributes");
|
|
1415
|
+
require("./App.css");
|
|
1416
|
+
|
|
1417
|
+
const AppContent = () => {
|
|
1418
|
+
// Aplica o hook para atualizar os atributos lang e dir da tag <html> com base no idioma.
|
|
1419
|
+
useI18nHTMLAttributes();
|
|
1420
|
+
|
|
1421
|
+
// ... Resto do seu componente
|
|
1422
|
+
};
|
|
1423
|
+
|
|
1424
|
+
const App = () => (
|
|
1425
|
+
<IntlayerProvider>
|
|
1426
|
+
<AppContent />
|
|
1427
|
+
</IntlayerProvider>
|
|
1428
|
+
);
|
|
1429
|
+
|
|
1430
|
+
module.exports = App;
|
|
1431
|
+
```
|
|
1432
|
+
|
|
1433
|
+
Ao aplicar essas alterações, sua aplicação irá:
|
|
1434
|
+
|
|
1435
|
+
- Garantir que o atributo **idioma** (`lang`) reflita corretamente o idioma atual, o que é importante para SEO e comportamento do navegador.
|
|
1436
|
+
- Ajustar a **direção do texto** (`dir`) de acordo com o idioma, melhorando a legibilidade e usabilidade para idiomas com diferentes ordens de leitura.
|
|
1437
|
+
- Proporcionar uma experiência mais **acessível**, já que tecnologias assistivas dependem desses atributos para funcionar de forma otimizada.
|
|
1438
|
+
|
|
1439
|
+
### (Opcional) Etapa 10: Criando um Componente de Link Localizado
|
|
1440
|
+
|
|
1441
|
+
Para garantir que a navegação da sua aplicação respeite o idioma atual, você pode criar um componente `Link` personalizado. Este componente automaticamente adiciona o prefixo do idioma atual às URLs internas. Por exemplo, quando um usuário que fala francês clica em um link para a página "Sobre", ele é redirecionado para `/pt/about` em vez de `/about`.
|
|
1442
|
+
|
|
1443
|
+
Esse comportamento é útil por várias razões:
|
|
1444
|
+
|
|
1445
|
+
- **SEO e Experiência do Usuário**: URLs localizadas ajudam os motores de busca a indexar páginas específicas de idioma corretamente e fornecem aos usuários conteúdo no idioma preferido.
|
|
1446
|
+
- **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.
|
|
1447
|
+
- **Manutenibilidade**: Centralizar a lógica de localização em um único componente simplifica o gerenciamento de URLs, tornando seu código mais fácil de manter e expandir à medida que sua aplicação cresce.
|
|
1448
|
+
|
|
1449
|
+
Abaixo está a implementação de um componente `Link` localizado em TypeScript:
|
|
1450
|
+
|
|
1451
|
+
```tsx fileName="src/components/Link.tsx" codeFormat="typescript"
|
|
1452
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1453
|
+
import {
|
|
1454
|
+
forwardRef,
|
|
1455
|
+
type DetailedHTMLProps,
|
|
1456
|
+
type AnchorHTMLAttributes,
|
|
1457
|
+
} from "react";
|
|
1458
|
+
import { useLocale } from "react-intlayer";
|
|
1459
|
+
|
|
1460
|
+
export interface LinkProps
|
|
1461
|
+
extends DetailedHTMLProps<
|
|
1462
|
+
AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
1463
|
+
HTMLAnchorElement
|
|
1464
|
+
> {}
|
|
1465
|
+
|
|
1466
|
+
/**
|
|
1467
|
+
* Função utilitária para verificar se uma URL fornecida é externa.
|
|
1468
|
+
* Se a URL começar com http:// ou https://, ela é considerada externa.
|
|
1469
|
+
*/
|
|
1470
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1471
|
+
/^https?:\/\//.test(href ?? "");
|
|
1472
|
+
|
|
1473
|
+
/**
|
|
1474
|
+
* Um componente Link personalizado que adapta o atributo href com base no idioma atual.
|
|
1475
|
+
* Para links internos, ele usa `getLocalizedUrl` para prefixar a URL com o idioma (por exemplo, /pt/about).
|
|
1476
|
+
* Isso garante que a navegação permaneça no mesmo contexto de idioma.
|
|
1477
|
+
*/
|
|
1478
|
+
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
1479
|
+
({ href, children, ...props }, ref) => {
|
|
1480
|
+
const { locale } = useLocale();
|
|
1481
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1482
|
+
|
|
1483
|
+
// Se o link for interno e um href válido for fornecido, obtenha a URL localizada.
|
|
1484
|
+
const hrefI18n =
|
|
1485
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1486
|
+
|
|
1487
|
+
return (
|
|
1488
|
+
<a href={hrefI18n} ref={ref} {...props}>
|
|
1489
|
+
{children}
|
|
1490
|
+
</a>
|
|
1491
|
+
);
|
|
1492
|
+
}
|
|
1493
|
+
);
|
|
1494
|
+
|
|
1495
|
+
Link.displayName = "Link";
|
|
1496
|
+
```
|
|
1497
|
+
|
|
1498
|
+
```jsx fileName="src/components/Link.mjx" codeFormat="esm"
|
|
1499
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1500
|
+
import { useLocale } from "react-intlayer";
|
|
1501
|
+
import { forwardRef } from "react";
|
|
1502
|
+
|
|
1503
|
+
/**
|
|
1504
|
+
* Função utilitária para verificar se uma URL fornecida é externa.
|
|
1505
|
+
* Se a URL começar com http:// ou https://, ela é considerada externa.
|
|
1506
|
+
*/
|
|
1507
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1508
|
+
/^https?:\/\//.test(href ?? "");
|
|
1509
|
+
|
|
1510
|
+
/**
|
|
1511
|
+
* Um componente Link personalizado que adapta o atributo href com base no idioma atual.
|
|
1512
|
+
* Para links internos, ele usa `getLocalizedUrl` para prefixar a URL com o idioma (por exemplo, /pt/about).
|
|
1513
|
+
* Isso garante que a navegação permaneça no mesmo contexto de idioma.
|
|
1514
|
+
*/
|
|
1515
|
+
export const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1516
|
+
|
|
1517
|
+
const { locale } = useLocale();
|
|
1518
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1519
|
+
|
|
1520
|
+
// Se o link for interno e um href válido for fornecido, obtenha a URL localizada.
|
|
1521
|
+
const hrefI18n =
|
|
1522
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1523
|
+
|
|
1524
|
+
return (
|
|
1525
|
+
<a href={hrefI18n} ref={ref} {...props}>
|
|
1526
|
+
{children}
|
|
1527
|
+
</a>
|
|
1528
|
+
);
|
|
1529
|
+
});
|
|
1530
|
+
|
|
1531
|
+
Link.displayName = "Link";
|
|
1532
|
+
```
|
|
1533
|
+
|
|
1534
|
+
```jsx fileName="src/components/Link.csx" codeFormat="commonjs"
|
|
1535
|
+
const { getLocalizedUrl } = require("intlayer");
|
|
1536
|
+
const { useLocale } = require("react-intlayer");
|
|
1537
|
+
const { forwardRef } = require("react");
|
|
1538
|
+
|
|
1539
|
+
/**
|
|
1540
|
+
* Função utilitária para verificar se uma URL fornecida é externa.
|
|
1541
|
+
* Se a URL começar com http:// ou https://, ela é considerada externa.
|
|
1542
|
+
*/
|
|
1543
|
+
const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1544
|
+
|
|
1545
|
+
/**
|
|
1546
|
+
* Um componente Link personalizado que adapta o atributo href com base no idioma atual.
|
|
1547
|
+
* Para links internos, ele usa `getLocalizedUrl` para prefixar a URL com o idioma (por exemplo, /pt/sobre).
|
|
1548
|
+
* Isso garante que a navegação permaneça dentro do mesmo contexto de idioma.
|
|
1549
|
+
*/
|
|
1550
|
+
const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1551
|
+
const { locale } = useLocale();
|
|
1552
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1553
|
+
|
|
1554
|
+
// Se o link for interno e um href válido for fornecido, obtenha a URL localizada.
|
|
1555
|
+
const localizedHref = isExternalLink ? href : getLocalizedUrl(href, locale);
|
|
1556
|
+
|
|
1557
|
+
return (
|
|
1558
|
+
<a
|
|
1559
|
+
href={localizedHref}
|
|
1560
|
+
ref={ref}
|
|
1561
|
+
{...props}
|
|
1562
|
+
aria-current={isExternalLink ? "external" : undefined}
|
|
1563
|
+
>
|
|
1564
|
+
{children}
|
|
1565
|
+
</a>
|
|
1566
|
+
);
|
|
1567
|
+
});
|
|
1568
|
+
|
|
1569
|
+
Link.displayName = "Link";
|
|
1570
|
+
```
|
|
1571
|
+
|
|
1572
|
+
#### Como Funciona
|
|
1573
|
+
|
|
1574
|
+
- **Detectando Links Externos**:
|
|
1575
|
+
A função auxiliar `checkIsExternalLink` determina se uma URL é externa. Links externos permanecem inalterados porque não precisam de localização.
|
|
1576
|
+
|
|
1577
|
+
- **Recuperando o Idioma Atual**:
|
|
1578
|
+
O hook `useLocale` fornece o idioma atual (por exemplo, `pt` para Português).
|
|
1579
|
+
|
|
1580
|
+
- **Localizando a URL**:
|
|
1581
|
+
Para links internos (ou seja, não externos), `getLocalizedUrl` é usado para prefixar automaticamente a URL com o idioma atual. Isso significa que, se o usuário estiver em Português, passar `/sobre` como o `href` transformará para `/pt/sobre`.
|
|
1582
|
+
|
|
1583
|
+
- **Retornando o Link**:
|
|
1584
|
+
O componente retorna um elemento `<a>` com a URL localizada, garantindo que a navegação seja consistente com o idioma.
|
|
1585
|
+
|
|
1586
|
+
Ao integrar este componente `Link` em toda a sua aplicação, você mantém uma experiência de usuário coerente e sensível ao idioma, além de se beneficiar de melhorias em SEO e usabilidade.
|
|
1587
|
+
|
|
1588
|
+
### Configurar TypeScript
|
|
1589
|
+
|
|
1590
|
+
O Intlayer usa a ampliação de módulos para aproveitar os benefícios do TypeScript e tornar sua base de código mais robusta.
|
|
1591
|
+
|
|
1592
|
+

|
|
1593
|
+
|
|
1594
|
+

|
|
1595
|
+
|
|
1596
|
+
Certifique-se de que sua configuração do TypeScript inclua os tipos gerados automaticamente.
|
|
1597
|
+
|
|
1598
|
+
```json5 fileName="tsconfig.json"
|
|
1599
|
+
{
|
|
1600
|
+
// ... Suas configurações existentes do TypeScript
|
|
1601
|
+
"include": [
|
|
1602
|
+
// ... Suas configurações existentes do TypeScript
|
|
1603
|
+
".intlayer/**/*.ts", // Inclua os tipos gerados automaticamente
|
|
1604
|
+
],
|
|
1605
|
+
}
|
|
1606
|
+
```
|
|
1607
|
+
|
|
1608
|
+
### Configuração do Git
|
|
1609
|
+
|
|
1610
|
+
Recomenda-se ignorar os arquivos gerados pelo Intlayer. Isso permite evitar que eles sejam adicionados ao seu repositório Git.
|
|
1611
|
+
|
|
1612
|
+
Para fazer isso, você pode adicionar as seguintes instruções ao seu arquivo `.gitignore`:
|
|
1613
|
+
|
|
1614
|
+
```plaintext
|
|
1615
|
+
# Ignore os arquivos gerados pelo Intlayer
|
|
1616
|
+
.intlayer
|
|
1617
|
+
```
|
|
1618
|
+
|
|
1619
|
+
### Explore Mais
|
|
1620
|
+
|
|
1621
|
+
Para explorar mais, 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).
|