@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,1637 @@
|
|
|
1
|
+
> Este paquete está en desarrollo. Consulte el [issue](https://github.com/aymericzip/intlayer/issues/118) para más información. Muestre su interés en Intlayer para Preact dando like al issue.
|
|
2
|
+
|
|
3
|
+
Consulte [Plantilla de Aplicación](https://github.com/aymericzip/intlayer-vite-preact-template) en GitHub.
|
|
4
|
+
|
|
5
|
+
## ¿Qué es Intlayer?
|
|
6
|
+
|
|
7
|
+
**Intlayer** es una biblioteca de internacionalización (i18n) innovadora y de código abierto diseñada para simplificar el soporte multilingüe en aplicaciones web modernas.
|
|
8
|
+
|
|
9
|
+
Con Intlayer, puedes:
|
|
10
|
+
|
|
11
|
+
- **Gestionar traducciones fácilmente** utilizando diccionarios declarativos a nivel de componente.
|
|
12
|
+
- **Localizar dinámicamente metadatos**, rutas y contenido.
|
|
13
|
+
- **Asegurar soporte para TypeScript** con tipos autogenerados, mejorando la autocompletación y la detección de errores.
|
|
14
|
+
- **Beneficiarte de características avanzadas**, como la detección dinámica de locales y el cambio entre ellos.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Guía paso a paso para configurar Intlayer en una aplicación Vite y Preact
|
|
19
|
+
|
|
20
|
+
### Paso 1: Instalar dependencias
|
|
21
|
+
|
|
22
|
+
Instala los paquetes necesarios utilizando npm:
|
|
23
|
+
|
|
24
|
+
```bash packageManager="npm"
|
|
25
|
+
npm install intlayer preact-intlayer vite-intlayer
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```bash packageManager="pnpm"
|
|
29
|
+
pnpm add intlayer preact-intlayer vite-intlayer
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```bash packageManager="yarn"
|
|
33
|
+
yarn add intlayer preact-intlayer vite-intlayer
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
- **intlayer**
|
|
37
|
+
|
|
38
|
+
El paquete principal que proporciona herramientas de internacionalización para la gestión de configuración, traducción, [declaración de contenido](https://github.com/aymericzip/intlayer/blob/main/docs/es/dictionary/get_started.md), transpilación y [comandos CLI](https://github.com/aymericzip/intlayer/blob/main/docs/es/intlayer_cli.md).
|
|
39
|
+
|
|
40
|
+
- **preact-intlayer**
|
|
41
|
+
El paquete que integra Intlayer con aplicaciones Preact. Proporciona proveedores de contexto y hooks para la internacionalización en Preact.
|
|
42
|
+
|
|
43
|
+
- **vite-intlayer**
|
|
44
|
+
Incluye el plugin de Vite para integrar Intlayer con el [empaquetador Vite](https://vite.dev/guide/why.html#why-bundle-for-production), así como middleware para detectar el idioma preferido del usuario, gestionar cookies y manejar redirecciones de URL.
|
|
45
|
+
|
|
46
|
+
### Paso 2: Configuración de tu proyecto
|
|
47
|
+
|
|
48
|
+
Crea un archivo de configuración para configurar los idiomas de tu aplicación:
|
|
49
|
+
|
|
50
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
51
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
52
|
+
|
|
53
|
+
const config: IntlayerConfig = {
|
|
54
|
+
internationalization: {
|
|
55
|
+
locales: [
|
|
56
|
+
Locales.ENGLISH,
|
|
57
|
+
Locales.FRENCH,
|
|
58
|
+
Locales.SPANISH,
|
|
59
|
+
// Tus otros locales
|
|
60
|
+
],
|
|
61
|
+
defaultLocale: Locales.ENGLISH,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default config;
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
69
|
+
import { Locales } from "intlayer";
|
|
70
|
+
|
|
71
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
72
|
+
const config = {
|
|
73
|
+
internationalization: {
|
|
74
|
+
locales: [
|
|
75
|
+
Locales.ENGLISH,
|
|
76
|
+
Locales.FRENCH,
|
|
77
|
+
Locales.SPANISH,
|
|
78
|
+
// Tus otros locales
|
|
79
|
+
],
|
|
80
|
+
defaultLocale: Locales.ENGLISH,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export default config;
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
88
|
+
const { Locales } = require("intlayer");
|
|
89
|
+
|
|
90
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
91
|
+
const config = {
|
|
92
|
+
internationalization: {
|
|
93
|
+
locales: [
|
|
94
|
+
Locales.ENGLISH,
|
|
95
|
+
Locales.FRENCH,
|
|
96
|
+
Locales.SPANISH,
|
|
97
|
+
// Tus otros locales
|
|
98
|
+
],
|
|
99
|
+
defaultLocale: Locales.ENGLISH,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
module.exports = config;
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
> A través de este archivo de configuración, puedes configurar URLs localizadas, redirección de middleware, nombres de cookies, la ubicación y extensión de tus declaraciones de contenido, desactivar los logs de Intlayer en la consola y más. Para una lista completa de parámetros disponibles, consulta la [documentación de configuración](https://github.com/aymericzip/intlayer/blob/main/docs/es/configuration.md).
|
|
107
|
+
|
|
108
|
+
### Paso 3: Integrar Intlayer en tu configuración de Vite
|
|
109
|
+
|
|
110
|
+
Agrega el plugin de Intlayer en tu configuración.
|
|
111
|
+
|
|
112
|
+
```typescript fileName="vite.config.ts" codeFormat="typescript"
|
|
113
|
+
import { defineConfig } from "vite";
|
|
114
|
+
import preact from "@preact/preset-vite";
|
|
115
|
+
import { intlayerPlugin } from "vite-intlayer";
|
|
116
|
+
|
|
117
|
+
// https://vitejs.dev/config/
|
|
118
|
+
export default defineConfig({
|
|
119
|
+
plugins: [preact(), intlayerPlugin()],
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
```javascript fileName="vite.config.mjs" codeFormat="esm"
|
|
124
|
+
import { defineConfig } from "vite";
|
|
125
|
+
import preact from "@preact/preset-vite";
|
|
126
|
+
import { intlayerPlugin } from "vite-intlayer";
|
|
127
|
+
|
|
128
|
+
// https://vitejs.dev/config/
|
|
129
|
+
export default defineConfig({
|
|
130
|
+
plugins: [preact(), intlayerPlugin()],
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
```javascript fileName="vite.config.cjs" codeFormat="commonjs"
|
|
135
|
+
const { defineConfig } = require("vite");
|
|
136
|
+
const preact = require("@preact/preset-vite");
|
|
137
|
+
const { intlayerPlugin } = require("vite-intlayer");
|
|
138
|
+
|
|
139
|
+
// https://vitejs.dev/config/
|
|
140
|
+
module.exports = defineConfig({
|
|
141
|
+
plugins: [preact(), intlayerPlugin()],
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
> El plugin `intlayerPlugin()` de Vite se utiliza para integrar Intlayer con Vite. Asegura la construcción de archivos de declaración de contenido y los monitorea en modo de desarrollo. Define variables de entorno de Intlayer dentro de la aplicación Vite. Además, proporciona alias para optimizar el rendimiento.
|
|
146
|
+
|
|
147
|
+
### Paso 4: Declarar tu contenido
|
|
148
|
+
|
|
149
|
+
Crea y gestiona tus declaraciones de contenido para almacenar traducciones:
|
|
150
|
+
|
|
151
|
+
```tsx fileName="src/app.content.tsx" contentDeclarationFormat="typescript"
|
|
152
|
+
import { t, type Dictionary } from "intlayer";
|
|
153
|
+
import type { ComponentChildren } from "preact";
|
|
154
|
+
|
|
155
|
+
const appContent = {
|
|
156
|
+
key: "app",
|
|
157
|
+
content: {
|
|
158
|
+
viteLogo: t({
|
|
159
|
+
es: "Logo Vite",
|
|
160
|
+
en: "Vite logo",
|
|
161
|
+
fr: "Logo Vite",
|
|
162
|
+
}),
|
|
163
|
+
preactLogo: t({
|
|
164
|
+
es: "Logo Preact",
|
|
165
|
+
en: "Preact logo",
|
|
166
|
+
fr: "Logo Preact",
|
|
167
|
+
}),
|
|
168
|
+
|
|
169
|
+
title: "Vite + Preact",
|
|
170
|
+
|
|
171
|
+
count: t({
|
|
172
|
+
es: "el recuento es ",
|
|
173
|
+
en: "count is ",
|
|
174
|
+
fr: "le compte est ",
|
|
175
|
+
}),
|
|
176
|
+
|
|
177
|
+
edit: t<ComponentChildren>({
|
|
178
|
+
en: "Edit src/app.tsx and save to test HMR",
|
|
179
|
+
fr: "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
180
|
+
es: "Edita src/app.tsx y guarda para probar HMR",
|
|
181
|
+
}),
|
|
182
|
+
|
|
183
|
+
readTheDocs: t({
|
|
184
|
+
es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
185
|
+
en: "Click on the Vite and Preact logos to learn more",
|
|
186
|
+
fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
187
|
+
}),
|
|
188
|
+
},
|
|
189
|
+
} satisfies Dictionary;
|
|
190
|
+
|
|
191
|
+
export default appContent;
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
```javascript fileName="src/app.content.mjs" contentDeclarationFormat="esm"
|
|
195
|
+
import { t } from "intlayer";
|
|
196
|
+
// import { h } from 'preact'; // Necesario si usas JSX directamente en .mjs
|
|
197
|
+
|
|
198
|
+
/** @type {import('intlayer').Dictionary} */
|
|
199
|
+
const appContent = {
|
|
200
|
+
key: "app",
|
|
201
|
+
content: {
|
|
202
|
+
viteLogo: t({
|
|
203
|
+
es: "Logo Vite",
|
|
204
|
+
en: "Vite logo",
|
|
205
|
+
fr: "Logo Vite",
|
|
206
|
+
}),
|
|
207
|
+
preactLogo: t({
|
|
208
|
+
es: "Logo Preact",
|
|
209
|
+
en: "Preact logo",
|
|
210
|
+
fr: "Logo Preact",
|
|
211
|
+
}),
|
|
212
|
+
|
|
213
|
+
title: "Vite + Preact",
|
|
214
|
+
|
|
215
|
+
count: t({
|
|
216
|
+
es: "el recuento es ",
|
|
217
|
+
en: "count is ",
|
|
218
|
+
fr: "le compte est ",
|
|
219
|
+
}),
|
|
220
|
+
|
|
221
|
+
edit: t({
|
|
222
|
+
en: "Edit src/app.tsx and save to test HMR",
|
|
223
|
+
fr: "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
224
|
+
es: "Edita src/app.tsx y guarda para probar HMR",
|
|
225
|
+
}),
|
|
226
|
+
|
|
227
|
+
readTheDocs: t({
|
|
228
|
+
es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
229
|
+
en: "Click on the Vite and Preact logos to learn more",
|
|
230
|
+
fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
231
|
+
}),
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
export default appContent;
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
```javascript fileName="src/app.content.cjs" contentDeclarationFormat="commonjs"
|
|
239
|
+
const { t } = require("intlayer");
|
|
240
|
+
|
|
241
|
+
/** @type {import('intlayer').Dictionary} */
|
|
242
|
+
const appContent = {
|
|
243
|
+
key: "app",
|
|
244
|
+
content: {
|
|
245
|
+
viteLogo: t({
|
|
246
|
+
es: "Logo Vite",
|
|
247
|
+
en: "Vite logo",
|
|
248
|
+
fr: "Logo Vite",
|
|
249
|
+
}),
|
|
250
|
+
preactLogo: t({
|
|
251
|
+
es: "Logo Preact",
|
|
252
|
+
en: "Preact logo",
|
|
253
|
+
fr: "Logo Preact",
|
|
254
|
+
}),
|
|
255
|
+
|
|
256
|
+
title: "Vite + Preact",
|
|
257
|
+
|
|
258
|
+
count: t({
|
|
259
|
+
es: "el recuento es ",
|
|
260
|
+
en: "count is ",
|
|
261
|
+
fr: "le compte est ",
|
|
262
|
+
}),
|
|
263
|
+
|
|
264
|
+
edit: t({
|
|
265
|
+
en: "Edit src/app.tsx and save to test HMR",
|
|
266
|
+
fr: "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
267
|
+
es: "Edita src/app.tsx y guarda para probar HMR",
|
|
268
|
+
}),
|
|
269
|
+
|
|
270
|
+
readTheDocs: t({
|
|
271
|
+
es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
272
|
+
en: "Click on the Vite and Preact logos to learn more",
|
|
273
|
+
fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
274
|
+
}),
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
module.exports = appContent;
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
```json fileName="src/app.content.json" contentDeclarationFormat="json"
|
|
282
|
+
{
|
|
283
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
284
|
+
"key": "app",
|
|
285
|
+
"content": {
|
|
286
|
+
"viteLogo": {
|
|
287
|
+
"nodeType": "translation",
|
|
288
|
+
"translation": {
|
|
289
|
+
"es": "Logo Vite",
|
|
290
|
+
"en": "Vite logo",
|
|
291
|
+
"fr": "Logo Vite"
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
"preactLogo": {
|
|
295
|
+
"nodeType": "translation",
|
|
296
|
+
"translation": {
|
|
297
|
+
"es": "Logo Preact",
|
|
298
|
+
"en": "Preact logo",
|
|
299
|
+
"fr": "Logo Preact"
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
"title": {
|
|
303
|
+
"nodeType": "translation",
|
|
304
|
+
"translation": {
|
|
305
|
+
"es": "Vite + Preact",
|
|
306
|
+
"en": "Vite + Preact",
|
|
307
|
+
"fr": "Vite + Preact"
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
"count": {
|
|
311
|
+
"nodeType": "translation",
|
|
312
|
+
"translation": {
|
|
313
|
+
"es": "el recuento es ",
|
|
314
|
+
"en": "count is ",
|
|
315
|
+
"fr": "le compte est "
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
"edit": {
|
|
319
|
+
"nodeType": "translation",
|
|
320
|
+
"translation": {
|
|
321
|
+
"es": "Edita src/app.tsx y guarda para probar HMR",
|
|
322
|
+
"en": "Edit src/app.tsx and save to test HMR",
|
|
323
|
+
"fr": "Éditez src/app.tsx et enregistrez pour tester HMR"
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
"readTheDocs": {
|
|
327
|
+
"nodeType": "translation",
|
|
328
|
+
"translation": {
|
|
329
|
+
"es": "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
330
|
+
"en": "Click on the Vite and Preact logos to learn more",
|
|
331
|
+
"fr": "Cliquez sur les logos Vite et Preact pour en savoir plus"
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
> Tus declaraciones de contenido pueden definirse en cualquier lugar de tu aplicación siempre que estén incluidas en el directorio `contentDir` (por defecto, `./src`). Y coincidan con la extensión del archivo de declaración de contenido (por defecto, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
339
|
+
|
|
340
|
+
> Para más detalles, consulta la [documentación de declaración de contenido](https://github.com/aymericzip/intlayer/blob/main/docs/es/dictionary/get_started.md).
|
|
341
|
+
|
|
342
|
+
> Si tu archivo de contenido incluye código TSX, es posible que necesites importar `import { h } from "preact";` o asegurarte de que tu pragma JSX esté configurado correctamente para Preact.
|
|
343
|
+
|
|
344
|
+
### Paso 5: Utiliza Intlayer en tu código
|
|
345
|
+
|
|
346
|
+
Accede a tus diccionarios de contenido en toda tu aplicación:
|
|
347
|
+
|
|
348
|
+
```tsx {6,10} fileName="src/app.tsx" codeFormat="typescript"
|
|
349
|
+
import { useState } from "preact/hooks";
|
|
350
|
+
import type { FunctionalComponent } from "preact";
|
|
351
|
+
import preactLogo from "./assets/preact.svg"; // Suponiendo que tienes un preact.svg
|
|
352
|
+
import viteLogo from "/vite.svg";
|
|
353
|
+
import "./app.css"; // Suponiendo que tu archivo CSS se llama app.css
|
|
354
|
+
import { IntlayerProvider, useIntlayer } from "preact-intlayer";
|
|
355
|
+
|
|
356
|
+
const AppContent: FunctionalComponent = () => {
|
|
357
|
+
const [count, setCount] = useState(0);
|
|
358
|
+
const content = useIntlayer("app");
|
|
359
|
+
|
|
360
|
+
return (
|
|
361
|
+
<>
|
|
362
|
+
<div>
|
|
363
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
364
|
+
<img src={viteLogo} class="logo" alt={content.viteLogo.value} />
|
|
365
|
+
</a>
|
|
366
|
+
<a href="https://preactjs.com" target="_blank">
|
|
367
|
+
<img
|
|
368
|
+
src={preactLogo}
|
|
369
|
+
class="logo preact"
|
|
370
|
+
alt={content.preactLogo.value}
|
|
371
|
+
/>
|
|
372
|
+
</a>
|
|
373
|
+
</div>
|
|
374
|
+
<h1>{content.title}</h1>
|
|
375
|
+
<div class="card">
|
|
376
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
377
|
+
{content.count}
|
|
378
|
+
{count}
|
|
379
|
+
</button>
|
|
380
|
+
<p>{content.edit}</p>
|
|
381
|
+
</div>
|
|
382
|
+
<p class="read-the-docs">{content.readTheDocs}</p>
|
|
383
|
+
</>
|
|
384
|
+
);
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
const App: FunctionalComponent = () => (
|
|
388
|
+
<IntlayerProvider>
|
|
389
|
+
<AppContent />
|
|
390
|
+
</IntlayerProvider>
|
|
391
|
+
);
|
|
392
|
+
|
|
393
|
+
export default App;
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
```jsx {5,9} fileName="src/app.jsx" codeFormat="esm"
|
|
397
|
+
import { useState } from "preact/hooks";
|
|
398
|
+
import preactLogo from "./assets/preact.svg";
|
|
399
|
+
import viteLogo from "/vite.svg";
|
|
400
|
+
import "./app.css";
|
|
401
|
+
import { IntlayerProvider, useIntlayer } from "preact-intlayer";
|
|
402
|
+
|
|
403
|
+
const AppContent = () => {
|
|
404
|
+
const [count, setCount] = useState(0);
|
|
405
|
+
const content = useIntlayer("app");
|
|
406
|
+
|
|
407
|
+
return (
|
|
408
|
+
<>
|
|
409
|
+
<div>
|
|
410
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
411
|
+
<img src={viteLogo} class="logo" alt={content.viteLogo.value} />
|
|
412
|
+
</a>
|
|
413
|
+
<a href="https://preactjs.com" target="_blank">
|
|
414
|
+
<img
|
|
415
|
+
src={preactLogo}
|
|
416
|
+
class="logo preact"
|
|
417
|
+
alt={content.preactLogo.value}
|
|
418
|
+
/>
|
|
419
|
+
</a>
|
|
420
|
+
</div>
|
|
421
|
+
<h1>{content.title}</h1>
|
|
422
|
+
<div class="card">
|
|
423
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
424
|
+
{content.count}
|
|
425
|
+
{count}
|
|
426
|
+
</button>
|
|
427
|
+
<p>{content.edit}</p>
|
|
428
|
+
</div>
|
|
429
|
+
<p class="read-the-docs">{content.readTheDocs}</p>
|
|
430
|
+
</>
|
|
431
|
+
);
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
const App = () => (
|
|
435
|
+
<IntlayerProvider>
|
|
436
|
+
<AppContent />
|
|
437
|
+
</IntlayerProvider>
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
export default App;
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
```jsx {5,9} fileName="src/app.cjsx" codeFormat="commonjs"
|
|
444
|
+
const { useState } = require("preact/hooks");
|
|
445
|
+
const preactLogo = require("./assets/preact.svg");
|
|
446
|
+
const viteLogo = require("/vite.svg");
|
|
447
|
+
require("./app.css");
|
|
448
|
+
const { IntlayerProvider, useIntlayer } = require("preact-intlayer");
|
|
449
|
+
|
|
450
|
+
const AppContent = () => {
|
|
451
|
+
const [count, setCount] = useState(0);
|
|
452
|
+
const content = useIntlayer("app");
|
|
453
|
+
|
|
454
|
+
return (
|
|
455
|
+
<>
|
|
456
|
+
<div>
|
|
457
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
458
|
+
<img src={viteLogo} class="logo" alt={content.viteLogo.value} />
|
|
459
|
+
</a>
|
|
460
|
+
<a href="https://preactjs.com" target="_blank">
|
|
461
|
+
<img
|
|
462
|
+
src={preactLogo}
|
|
463
|
+
class="logo preact"
|
|
464
|
+
alt={content.preactLogo.value}
|
|
465
|
+
/>
|
|
466
|
+
</a>
|
|
467
|
+
</div>
|
|
468
|
+
<h1>{content.title}</h1>
|
|
469
|
+
<div class="card">
|
|
470
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
471
|
+
{content.count}
|
|
472
|
+
{count}
|
|
473
|
+
</button>
|
|
474
|
+
<p>{content.edit}</p>
|
|
475
|
+
</div>
|
|
476
|
+
<p class="read-the-docs">{content.readTheDocs}</p>
|
|
477
|
+
</>
|
|
478
|
+
);
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
const App = () => (
|
|
482
|
+
<IntlayerProvider>
|
|
483
|
+
<AppContent />
|
|
484
|
+
</IntlayerProvider>
|
|
485
|
+
);
|
|
486
|
+
|
|
487
|
+
module.exports = App;
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
> Si deseas usar tu contenido en un atributo `string`, como `alt`, `title`, `href`, `aria-label`, etc., debes llamar al valor de la función, como:
|
|
491
|
+
|
|
492
|
+
> ```jsx
|
|
493
|
+
>
|
|
494
|
+
> ```
|
|
495
|
+
|
|
496
|
+
> <img src={content.image.src.value} alt={content.image.value} />
|
|
497
|
+
|
|
498
|
+
> ```
|
|
499
|
+
>
|
|
500
|
+
> ```
|
|
501
|
+
|
|
502
|
+
> Nota: En Preact, `className` se escribe típicamente como `class`.
|
|
503
|
+
|
|
504
|
+
> Para aprender más sobre el hook `useIntlayer`, consulta la [documentación](https://github.com/aymericzip/intlayer/blob/main/docs/es/packages/react-intlayer/useIntlayer.md) (La API es similar para `preact-intlayer`).
|
|
505
|
+
|
|
506
|
+
### (Opcional) Paso 6: Cambia el idioma de tu contenido
|
|
507
|
+
|
|
508
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
509
|
+
import type { FunctionalComponent } from "preact";
|
|
510
|
+
import { Locales } from "intlayer";
|
|
511
|
+
import { useLocale } from "preact-intlayer";
|
|
512
|
+
|
|
513
|
+
const LocaleSwitcher: FunctionalComponent = () => {
|
|
514
|
+
const { setLocale } = useLocale();
|
|
515
|
+
|
|
516
|
+
return (
|
|
517
|
+
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
518
|
+
Cambiar idioma a inglés
|
|
519
|
+
</button>
|
|
520
|
+
);
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
export default LocaleSwitcher;
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
```jsx fileName="src/components/LocaleSwitcher.jsx" codeFormat="esm"
|
|
527
|
+
import { Locales } from "intlayer";
|
|
528
|
+
import { useLocale } from "preact-intlayer";
|
|
529
|
+
|
|
530
|
+
const LocaleSwitcher = () => {
|
|
531
|
+
const { setLocale } = useLocale();
|
|
532
|
+
|
|
533
|
+
return (
|
|
534
|
+
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
535
|
+
Cambiar idioma a inglés
|
|
536
|
+
</button>
|
|
537
|
+
);
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
export default LocaleSwitcher;
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
```jsx fileName="src/components/LocaleSwitcher.cjsx" codeFormat="commonjs"
|
|
544
|
+
const { Locales } = require("intlayer");
|
|
545
|
+
const { useLocale } = require("preact-intlayer");
|
|
546
|
+
|
|
547
|
+
const LocaleSwitcher = () => {
|
|
548
|
+
const { setLocale } = useLocale();
|
|
549
|
+
|
|
550
|
+
return (
|
|
551
|
+
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
552
|
+
Cambiar idioma a inglés
|
|
553
|
+
</button>
|
|
554
|
+
);
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
module.exports = LocaleSwitcher;
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
> Para aprender más sobre el hook `useLocale`, consulta la [documentación](https://github.com/aymericzip/intlayer/blob/main/docs/es/packages/react-intlayer/useLocale.md) (La API es similar para `preact-intlayer`).
|
|
561
|
+
|
|
562
|
+
### (Opcional) Paso 7: Agregar enrutamiento localizado a tu aplicación
|
|
563
|
+
|
|
564
|
+
El propósito de este paso es crear rutas únicas para cada idioma. Esto es útil para SEO y URLs amigables para SEO.
|
|
565
|
+
Ejemplo:
|
|
566
|
+
|
|
567
|
+
```plaintext
|
|
568
|
+
- https://example.com/about
|
|
569
|
+
- https://example.com/es/about
|
|
570
|
+
- https://example.com/fr/about
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
> Por defecto, las rutas no están prefijadas para la configuración regional predeterminada. Si deseas prefijar la configuración regional predeterminada, puedes establecer la opción `middleware.prefixDefault` en `true` en tu configuración. Consulta la [documentación de configuración](https://github.com/aymericzip/intlayer/blob/main/docs/es/configuration.md) para más información.
|
|
574
|
+
|
|
575
|
+
Para agregar enrutamiento localizado a tu aplicación, puedes crear un componente `LocaleRouter` que envuelva las rutas de tu aplicación y maneje el enrutamiento basado en la configuración regional. Aquí hay un ejemplo usando [preact-iso](https://github.com/preactjs/preact-iso):
|
|
576
|
+
|
|
577
|
+
Primero, instala `preact-iso`:
|
|
578
|
+
|
|
579
|
+
```bash packageManager="npm"
|
|
580
|
+
npm install preact-iso
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
```bash packageManager="pnpm"
|
|
584
|
+
pnpm add preact-iso
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
```bash packageManager="yarn"
|
|
588
|
+
yarn add preact-iso
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
|
|
592
|
+
import { type Locales, configuration, getPathWithoutLocale } from "intlayer";
|
|
593
|
+
import { ComponentChildren, FunctionalComponent } from "preact";
|
|
594
|
+
import { IntlayerProvider } from "preact-intlayer";
|
|
595
|
+
import { LocationProvider, useLocation } from "preact-iso";
|
|
596
|
+
import { useEffect } from "preact/hooks";
|
|
597
|
+
|
|
598
|
+
const { internationalization, middleware } = configuration;
|
|
599
|
+
const { locales, defaultLocale } = internationalization;
|
|
600
|
+
|
|
601
|
+
const Navigate: FunctionalComponent<{ to: string; replace?: boolean }> = ({
|
|
602
|
+
to,
|
|
603
|
+
replace,
|
|
604
|
+
}) => {
|
|
605
|
+
const { route } = useLocation();
|
|
606
|
+
useEffect(() => {
|
|
607
|
+
route(to, replace);
|
|
608
|
+
}, [to, replace, route]);
|
|
609
|
+
return null;
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Un componente que maneja la localización y envuelve a los hijos con el contexto de configuración regional apropiado.
|
|
614
|
+
* Gestiona la detección y validación de la configuración regional basada en la URL.
|
|
615
|
+
*/
|
|
616
|
+
const AppLocalized: FunctionalComponent<{
|
|
617
|
+
children: ComponentChildren;
|
|
618
|
+
locale?: Locales;
|
|
619
|
+
}> = ({ children, locale }) => {
|
|
620
|
+
const { path: pathname, url } = useLocation();
|
|
621
|
+
|
|
622
|
+
if (!url) {
|
|
623
|
+
return null;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
const search = url.substring(pathname.length);
|
|
627
|
+
|
|
628
|
+
// Determina la configuración regional actual, usando la predeterminada si no se proporciona
|
|
629
|
+
const currentLocale = locale ?? defaultLocale;
|
|
630
|
+
|
|
631
|
+
// Elimina el prefijo de configuración regional del camino para construir una ruta base
|
|
632
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
633
|
+
pathname // Ruta actual de la URL
|
|
634
|
+
);
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Si middleware.prefixDefault es verdadero, la configuración regional predeterminada siempre debe estar prefijada.
|
|
638
|
+
*/
|
|
639
|
+
if (middleware.prefixDefault) {
|
|
640
|
+
// Valida la configuración regional
|
|
641
|
+
if (!locale || !locales.includes(locale)) {
|
|
642
|
+
// Redirige a la configuración regional predeterminada con la ruta actualizada
|
|
643
|
+
return (
|
|
644
|
+
<Navigate
|
|
645
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
646
|
+
replace // Reemplaza la entrada actual del historial con la nueva
|
|
647
|
+
/>
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// Envuelve a los hijos con el IntlayerProvider y establece la configuración regional actual
|
|
652
|
+
return (
|
|
653
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
654
|
+
);
|
|
655
|
+
} else {
|
|
656
|
+
/**
|
|
657
|
+
* Cuando middleware.prefixDefault es falso, la configuración regional predeterminada no está prefijada.
|
|
658
|
+
* Asegúrate de que la configuración regional actual sea válida y no sea la predeterminada.
|
|
659
|
+
*/
|
|
660
|
+
if (
|
|
661
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
662
|
+
!locales
|
|
663
|
+
.filter(
|
|
664
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Excluye la configuración regional predeterminada
|
|
665
|
+
)
|
|
666
|
+
.includes(currentLocale) // Verifica si la configuración regional actual está en la lista de configuraciones válidas
|
|
667
|
+
) {
|
|
668
|
+
// Redirige a la ruta sin prefijo de configuración regional
|
|
669
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
// Envuelve a los hijos con el IntlayerProvider y establece la configuración regional actual
|
|
673
|
+
return (
|
|
674
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
675
|
+
);
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
const RouterContent: FunctionalComponent<{
|
|
680
|
+
children: ComponentChildren;
|
|
681
|
+
}> = ({ children }) => {
|
|
682
|
+
const { path } = useLocation();
|
|
683
|
+
|
|
684
|
+
if (!path) {
|
|
685
|
+
return null;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
const pathLocale = path.split("/")[1] as Locales;
|
|
689
|
+
|
|
690
|
+
const isLocaleRoute = locales
|
|
691
|
+
.filter((locale) => middleware.prefixDefault || locale !== defaultLocale)
|
|
692
|
+
.some((locale) => locale.toString() === pathLocale);
|
|
693
|
+
|
|
694
|
+
if (isLocaleRoute) {
|
|
695
|
+
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
return (
|
|
699
|
+
<AppLocalized
|
|
700
|
+
locale={!middleware.prefixDefault ? defaultLocale : undefined}
|
|
701
|
+
>
|
|
702
|
+
{children}
|
|
703
|
+
</AppLocalized>
|
|
704
|
+
);
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Un componente de enrutador que configura rutas específicas de configuración regional.
|
|
709
|
+
* Utiliza preact-iso para gestionar la navegación y renderizar componentes localizados.
|
|
710
|
+
*/
|
|
711
|
+
export const LocaleRouter: FunctionalComponent<{
|
|
712
|
+
children: ComponentChildren;
|
|
713
|
+
}> = ({ children }) => (
|
|
714
|
+
<LocationProvider>
|
|
715
|
+
<RouterContent>{children}</RouterContent>
|
|
716
|
+
</LocationProvider>
|
|
717
|
+
);
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
```jsx fileName="src/components/LocaleRouter.jsx" codeFormat="esm"
|
|
721
|
+
// Importando las dependencias y funciones necesarias
|
|
722
|
+
import { configuration, getPathWithoutLocale } from "intlayer";
|
|
723
|
+
import { IntlayerProvider } from "preact-intlayer";
|
|
724
|
+
import { LocationProvider, useLocation } from "preact-iso";
|
|
725
|
+
import { useEffect } from "preact/hooks";
|
|
726
|
+
import { h } from "preact"; // Requerido para JSX
|
|
727
|
+
|
|
728
|
+
// Desestructurando configuración desde Intlayer
|
|
729
|
+
const { internationalization, middleware } = configuration;
|
|
730
|
+
const { locales, defaultLocale } = internationalization;
|
|
731
|
+
|
|
732
|
+
const Navigate = ({ to, replace }) => {
|
|
733
|
+
const { route } = useLocation();
|
|
734
|
+
useEffect(() => {
|
|
735
|
+
route(to, replace);
|
|
736
|
+
}, [to, replace, route]);
|
|
737
|
+
return null;
|
|
738
|
+
};
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Un componente que maneja la localización y envuelve a los hijos con el contexto de configuración regional apropiado.
|
|
742
|
+
* Gestiona la detección y validación de la configuración regional basada en la URL.
|
|
743
|
+
*/
|
|
744
|
+
const AppLocalized = ({ children, locale }) => {
|
|
745
|
+
const { path: pathname, url } = useLocation();
|
|
746
|
+
|
|
747
|
+
if (!url) {
|
|
748
|
+
return null;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
const search = url.substring(pathname.length);
|
|
752
|
+
|
|
753
|
+
// Determina la configuración regional actual, usando la predeterminada si no se proporciona
|
|
754
|
+
const currentLocale = locale ?? defaultLocale;
|
|
755
|
+
|
|
756
|
+
// Elimina el prefijo de configuración regional del camino para construir una ruta base
|
|
757
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
758
|
+
pathname // Ruta actual de la URL
|
|
759
|
+
);
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Si middleware.prefixDefault es verdadero, el locale predeterminado siempre debe estar prefijado.
|
|
765
|
+
*/
|
|
766
|
+
if (middleware.prefixDefault) {
|
|
767
|
+
// Validar el locale
|
|
768
|
+
if (!locale || !locales.includes(locale)) {
|
|
769
|
+
// Redirigir al locale predeterminado con la ruta actualizada
|
|
770
|
+
return (
|
|
771
|
+
<Navigate
|
|
772
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
773
|
+
replace // Reemplazar la entrada actual del historial con la nueva
|
|
774
|
+
/>
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
// Envolver los hijos con el IntlayerProvider y establecer el locale actual
|
|
779
|
+
return (
|
|
780
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
781
|
+
);
|
|
782
|
+
} else {
|
|
783
|
+
/**
|
|
784
|
+
* Cuando middleware.prefixDefault es falso, el locale predeterminado no está prefijado.
|
|
785
|
+
* Asegurarse de que el locale actual sea válido y no el predeterminado.
|
|
786
|
+
*/
|
|
787
|
+
if (
|
|
788
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
789
|
+
!locales
|
|
790
|
+
.filter(
|
|
791
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Excluir el locale predeterminado
|
|
792
|
+
)
|
|
793
|
+
.includes(currentLocale) // Verificar si el locale actual está en la lista de locales válidos
|
|
794
|
+
) {
|
|
795
|
+
// Redirigir a la ruta sin prefijo de locale
|
|
796
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// Envolver los hijos con el IntlayerProvider y establecer el locale actual
|
|
800
|
+
return (
|
|
801
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
};
|
|
805
|
+
|
|
806
|
+
const RouterContent = ({ children }) => {
|
|
807
|
+
const { path } = useLocation();
|
|
808
|
+
|
|
809
|
+
if (!path) {
|
|
810
|
+
return null;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
const pathLocale = path.split("/")[1];
|
|
814
|
+
|
|
815
|
+
const isLocaleRoute = locales
|
|
816
|
+
.filter((locale) => middleware.prefixDefault || locale !== defaultLocale)
|
|
817
|
+
.some((locale) => locale.toString() === pathLocale);
|
|
818
|
+
|
|
819
|
+
if (isLocaleRoute) {
|
|
820
|
+
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
return (
|
|
824
|
+
<AppLocalized
|
|
825
|
+
locale={!middleware.prefixDefault ? defaultLocale : undefined}
|
|
826
|
+
>
|
|
827
|
+
{children}
|
|
828
|
+
</AppLocalized>
|
|
829
|
+
);
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* Un componente de router que configura rutas específicas de locales.
|
|
834
|
+
* Utiliza preact-iso para gestionar la navegación y renderizar componentes localizados.
|
|
835
|
+
*/
|
|
836
|
+
export const LocaleRouter = ({ children }) => (
|
|
837
|
+
<LocationProvider>
|
|
838
|
+
<RouterContent>{children}</RouterContent>
|
|
839
|
+
</LocationProvider>
|
|
840
|
+
);
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
```jsx fileName="src/components/LocaleRouter.cjsx" codeFormat="commonjs"
|
|
844
|
+
// Importando las dependencias y funciones necesarias
|
|
845
|
+
const { configuration, getPathWithoutLocale } = require("intlayer");
|
|
846
|
+
const { IntlayerProvider } = require("preact-intlayer");
|
|
847
|
+
const { LocationProvider, useLocation } = require("preact-iso");
|
|
848
|
+
const { useEffect } = require("preact/hooks");
|
|
849
|
+
const { h } = require("preact"); // Requerido para JSX
|
|
850
|
+
|
|
851
|
+
// Desestructuración de configuración desde Intlayer
|
|
852
|
+
const { internationalization, middleware } = configuration;
|
|
853
|
+
const { locales, defaultLocale } = internationalization;
|
|
854
|
+
|
|
855
|
+
const Navigate = ({ to, replace }) => {
|
|
856
|
+
const { route } = useLocation();
|
|
857
|
+
useEffect(() => {
|
|
858
|
+
route(to, replace);
|
|
859
|
+
}, [to, replace, route]);
|
|
860
|
+
return null;
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Un componente que maneja la localización y envuelve los hijos con el contexto de locale apropiado.
|
|
865
|
+
* Gestiona la detección y validación del locale basado en la URL.
|
|
866
|
+
*/
|
|
867
|
+
const AppLocalized = ({ children, locale }) => {
|
|
868
|
+
const { path: pathname, url } = useLocation();
|
|
869
|
+
|
|
870
|
+
if (!url) {
|
|
871
|
+
return null;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
const search = url.substring(pathname.length);
|
|
875
|
+
|
|
876
|
+
// Determinar el locale actual, utilizando el predeterminado si no se proporciona
|
|
877
|
+
const currentLocale = locale ?? defaultLocale;
|
|
878
|
+
|
|
879
|
+
// Eliminar el prefijo del locale de la ruta para construir una ruta base
|
|
880
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
881
|
+
pathname // Ruta actual de la URL
|
|
882
|
+
);
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* Si middleware.prefixDefault es verdadero, el locale predeterminado siempre debe estar prefijado.
|
|
886
|
+
*/
|
|
887
|
+
if (middleware.prefixDefault) {
|
|
888
|
+
// Validar el locale
|
|
889
|
+
if (!locale || !locales.includes(locale)) {
|
|
890
|
+
// Redirigir al locale predeterminado con la ruta actualizada
|
|
891
|
+
return (
|
|
892
|
+
<Navigate
|
|
893
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
894
|
+
replace // Reemplazar la entrada actual del historial con la nueva
|
|
895
|
+
/>
|
|
896
|
+
);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
// Envolver los hijos con el IntlayerProvider y establecer el locale actual
|
|
900
|
+
return (
|
|
901
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
902
|
+
);
|
|
903
|
+
} else {
|
|
904
|
+
/**
|
|
905
|
+
* Cuando middleware.prefixDefault es falso, el locale predeterminado no está prefijado.
|
|
906
|
+
* Asegurarse de que el locale actual sea válido y no el predeterminado.
|
|
907
|
+
*/
|
|
908
|
+
if (
|
|
909
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
910
|
+
!locales
|
|
911
|
+
.filter(
|
|
912
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Excluir el locale predeterminado
|
|
913
|
+
)
|
|
914
|
+
.includes(currentLocale) // Verificar si el locale actual está en la lista de locales válidos
|
|
915
|
+
) {
|
|
916
|
+
// Redirigir a la ruta sin prefijo de locale
|
|
917
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// Envolver los hijos con el IntlayerProvider y establecer el locale actual
|
|
921
|
+
return (
|
|
922
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
923
|
+
);
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
const RouterContent = ({ children }) => {
|
|
928
|
+
const { path } = useLocation();
|
|
929
|
+
|
|
930
|
+
if (!path) {
|
|
931
|
+
return null;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
const pathLocale = path.split("/")[1];
|
|
935
|
+
|
|
936
|
+
const isLocaleRoute = locales
|
|
937
|
+
.filter((locale) => middleware.prefixDefault || locale !== defaultLocale)
|
|
938
|
+
.some((locale) => locale.toString() === pathLocale);
|
|
939
|
+
|
|
940
|
+
if (isLocaleRoute) {
|
|
941
|
+
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
return (
|
|
945
|
+
<AppLocalized
|
|
946
|
+
locale={!middleware.prefixDefault ? defaultLocale : undefined}
|
|
947
|
+
>
|
|
948
|
+
{children}
|
|
949
|
+
</AppLocalized>
|
|
950
|
+
);
|
|
951
|
+
};
|
|
952
|
+
|
|
953
|
+
/**
|
|
954
|
+
* Un componente de router que configura rutas específicas de locales.
|
|
955
|
+
* Utiliza preact-iso para gestionar la navegación y renderizar componentes localizados.
|
|
956
|
+
*/
|
|
957
|
+
const LocaleRouter = ({ children }) => (
|
|
958
|
+
<LocationProvider>
|
|
959
|
+
<RouterContent>{children}</RouterContent>
|
|
960
|
+
</LocationProvider>
|
|
961
|
+
);
|
|
962
|
+
|
|
963
|
+
module.exports = { LocaleRouter };
|
|
964
|
+
```
|
|
965
|
+
|
|
966
|
+
Luego, puedes usar el componente `LocaleRouter` en tu aplicación:
|
|
967
|
+
|
|
968
|
+
```tsx fileName="src/app.tsx" codeFormat="typescript"
|
|
969
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
970
|
+
import type { FunctionalComponent } from "preact";
|
|
971
|
+
// ... Tu componente AppContent (definido en el Paso 5)
|
|
972
|
+
|
|
973
|
+
const App: FunctionalComponent = () => (
|
|
974
|
+
<LocaleRouter>
|
|
975
|
+
<AppContent />
|
|
976
|
+
</LocaleRouter>
|
|
977
|
+
);
|
|
978
|
+
|
|
979
|
+
export default App;
|
|
980
|
+
```
|
|
981
|
+
|
|
982
|
+
```jsx fileName="src/app.jsx" codeFormat="esm"
|
|
983
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
984
|
+
// ... Tu componente AppContent (definido en el Paso 5)
|
|
985
|
+
|
|
986
|
+
const App = () => (
|
|
987
|
+
<LocaleRouter>
|
|
988
|
+
<AppContent />
|
|
989
|
+
</LocaleRouter>
|
|
990
|
+
);
|
|
991
|
+
|
|
992
|
+
export default App;
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
```jsx fileName="src/app.cjsx" codeFormat="commonjs"
|
|
996
|
+
const { LocaleRouter } = require("./components/LocaleRouter");
|
|
997
|
+
// ... Tu componente AppContent (definido en el Paso 5)
|
|
998
|
+
|
|
999
|
+
const App = () => (
|
|
1000
|
+
<LocaleRouter>
|
|
1001
|
+
<AppContent />
|
|
1002
|
+
</LocaleRouter>
|
|
1003
|
+
);
|
|
1004
|
+
|
|
1005
|
+
module.exports = App;
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
Paralelamente, también puedes usar el `intLayerMiddlewarePlugin` para agregar enrutamiento del lado del servidor a tu aplicación. Este plugin detectará automáticamente el locale actual basado en la URL y establecerá la cookie de locale apropiada. Si no se especifica un locale, el plugin determinará el locale más apropiado basado en las preferencias de idioma del navegador del usuario. Si no se detecta ningún locale, redirigirá al locale predeterminado.
|
|
1009
|
+
|
|
1010
|
+
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
1011
|
+
import { defineConfig } from "vite";
|
|
1012
|
+
import preact from "@preact/preset-vite";
|
|
1013
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
1014
|
+
|
|
1015
|
+
// https://vitejs.dev/config/
|
|
1016
|
+
export default defineConfig({
|
|
1017
|
+
plugins: [preact(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1018
|
+
});
|
|
1019
|
+
```
|
|
1020
|
+
|
|
1021
|
+
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
1022
|
+
import { defineConfig } from "vite";
|
|
1023
|
+
import preact from "@preact/preset-vite";
|
|
1024
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
1025
|
+
|
|
1026
|
+
// https://vitejs.dev/config/
|
|
1027
|
+
|
|
1028
|
+
const { defineConfig } = require("vite");
|
|
1029
|
+
const preact = require("@preact/preset-vite");
|
|
1030
|
+
const { intlayerPlugin, intLayerMiddlewarePlugin } = require("vite-intlayer");
|
|
1031
|
+
|
|
1032
|
+
// https://vitejs.dev/config/
|
|
1033
|
+
module.exports = defineConfig({
|
|
1034
|
+
plugins: [preact(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1035
|
+
});
|
|
1036
|
+
```
|
|
1037
|
+
|
|
1038
|
+
### (Opcional) Paso 8: Cambiar la URL cuando cambia el idioma
|
|
1039
|
+
|
|
1040
|
+
Para cambiar la URL cuando cambia el idioma, puedes usar la propiedad `onLocaleChange` proporcionada por el hook `useLocale`. Paralelamente, puedes usar `useLocation` y `route` de `preact-iso` para actualizar la ruta de la URL.
|
|
1041
|
+
|
|
1042
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
1043
|
+
import { useLocation, route } from "preact-iso";
|
|
1044
|
+
import {
|
|
1045
|
+
Locales,
|
|
1046
|
+
getHTMLTextDir,
|
|
1047
|
+
getLocaleName,
|
|
1048
|
+
getLocalizedUrl,
|
|
1049
|
+
} from "intlayer";
|
|
1050
|
+
import { useLocale } from "preact-intlayer";
|
|
1051
|
+
import type { FunctionalComponent } from "preact";
|
|
1052
|
+
|
|
1053
|
+
const LocaleSwitcher: FunctionalComponent = () => {
|
|
1054
|
+
const location = useLocation();
|
|
1055
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1056
|
+
onLocaleChange: (newLocale) => {
|
|
1057
|
+
const currentFullPath = location.url; // preact-iso proporciona la URL completa
|
|
1058
|
+
// Construir la URL con el idioma actualizado
|
|
1059
|
+
// Ejemplo: /es/about?foo=bar
|
|
1060
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1061
|
+
|
|
1062
|
+
// Actualizar la ruta de la URL
|
|
1063
|
+
route(pathWithLocale, true); // true para reemplazar
|
|
1064
|
+
},
|
|
1065
|
+
});
|
|
1066
|
+
|
|
1067
|
+
return (
|
|
1068
|
+
<div>
|
|
1069
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1070
|
+
<div id="localePopover" popover="auto">
|
|
1071
|
+
{availableLocales.map((localeItem) => (
|
|
1072
|
+
<a
|
|
1073
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1074
|
+
hreflang={localeItem}
|
|
1075
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1076
|
+
onClick={(e) => {
|
|
1077
|
+
e.preventDefault();
|
|
1078
|
+
setLocale(localeItem);
|
|
1079
|
+
// La navegación programática después de establecer el idioma será manejada por onLocaleChange
|
|
1080
|
+
}}
|
|
1081
|
+
key={localeItem}
|
|
1082
|
+
>
|
|
1083
|
+
<span>
|
|
1084
|
+
{/* Idioma - ej. FR */}
|
|
1085
|
+
{localeItem}
|
|
1086
|
+
</span>
|
|
1087
|
+
<span>
|
|
1088
|
+
{/* Idioma en su propio idioma - ej. Français */}
|
|
1089
|
+
{getLocaleName(localeItem, localeItem)}
|
|
1090
|
+
</span>
|
|
1091
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1092
|
+
{/* Idioma en el idioma actual - ej. Francés con el idioma actual configurado en Locales.SPANISH */}
|
|
1093
|
+
{getLocaleName(localeItem, locale)}
|
|
1094
|
+
</span>
|
|
1095
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1096
|
+
{/* Idioma en inglés - ej. French */}
|
|
1097
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1098
|
+
</span>
|
|
1099
|
+
</a>
|
|
1100
|
+
))}
|
|
1101
|
+
</div>
|
|
1102
|
+
</div>
|
|
1103
|
+
);
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
export default LocaleSwitcher;
|
|
1107
|
+
```
|
|
1108
|
+
|
|
1109
|
+
```jsx fileName="src/components/LocaleSwitcher.jsx" codeFormat="esm"
|
|
1110
|
+
import { useLocation, route } from "preact-iso";
|
|
1111
|
+
import {
|
|
1112
|
+
Locales,
|
|
1113
|
+
getHTMLTextDir,
|
|
1114
|
+
getLocaleName,
|
|
1115
|
+
getLocalizedUrl,
|
|
1116
|
+
} from "intlayer";
|
|
1117
|
+
import { useLocale } from "preact-intlayer";
|
|
1118
|
+
import { h } from "preact"; // Para JSX
|
|
1119
|
+
|
|
1120
|
+
const LocaleSwitcher = () => {
|
|
1121
|
+
const location = useLocation();
|
|
1122
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1123
|
+
onLocaleChange: (newLocale) => {
|
|
1124
|
+
const currentFullPath = location.url;
|
|
1125
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1126
|
+
route(pathWithLocale, true);
|
|
1127
|
+
},
|
|
1128
|
+
});
|
|
1129
|
+
|
|
1130
|
+
return (
|
|
1131
|
+
<div>
|
|
1132
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1133
|
+
<div id="localePopover" popover="auto">
|
|
1134
|
+
{availableLocales.map((localeItem) => (
|
|
1135
|
+
<a
|
|
1136
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1137
|
+
hreflang={localeItem}
|
|
1138
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1139
|
+
onClick={(e) => {
|
|
1140
|
+
e.preventDefault();
|
|
1141
|
+
setLocale(localeItem);
|
|
1142
|
+
}}
|
|
1143
|
+
key={localeItem}
|
|
1144
|
+
>
|
|
1145
|
+
<span>{localeItem}</span>
|
|
1146
|
+
<span>{getLocaleName(localeItem, localeItem)}</span>
|
|
1147
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1148
|
+
{getLocaleName(localeItem, locale)}
|
|
1149
|
+
</span>
|
|
1150
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1151
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1152
|
+
</span>
|
|
1153
|
+
</a>
|
|
1154
|
+
))}
|
|
1155
|
+
</div>
|
|
1156
|
+
</div>
|
|
1157
|
+
);
|
|
1158
|
+
};
|
|
1159
|
+
|
|
1160
|
+
export default LocaleSwitcher;
|
|
1161
|
+
```
|
|
1162
|
+
|
|
1163
|
+
```jsx fileName="src/components/LocaleSwitcher.cjsx" codeFormat="commonjs"
|
|
1164
|
+
const { useLocation, route } = require("preact-iso");
|
|
1165
|
+
const {
|
|
1166
|
+
Locales,
|
|
1167
|
+
getHTMLTextDir,
|
|
1168
|
+
getLocaleName,
|
|
1169
|
+
getLocalizedUrl,
|
|
1170
|
+
} = require("intlayer");
|
|
1171
|
+
const { useLocale } = require("preact-intlayer");
|
|
1172
|
+
const { h } = require("preact"); // Para JSX
|
|
1173
|
+
|
|
1174
|
+
const LocaleSwitcher = () => {
|
|
1175
|
+
const location = useLocation();
|
|
1176
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1177
|
+
onLocaleChange: (newLocale) => {
|
|
1178
|
+
const currentFullPath = location.url;
|
|
1179
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1180
|
+
route(pathWithLocale, true);
|
|
1181
|
+
},
|
|
1182
|
+
});
|
|
1183
|
+
|
|
1184
|
+
return (
|
|
1185
|
+
<div>
|
|
1186
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1187
|
+
<div id="localePopover" popover="auto">
|
|
1188
|
+
{availableLocales.map((localeItem) => (
|
|
1189
|
+
<a
|
|
1190
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1191
|
+
hreflang={localeItem}
|
|
1192
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1193
|
+
onClick={(e) => {
|
|
1194
|
+
e.preventDefault();
|
|
1195
|
+
setLocale(localeItem);
|
|
1196
|
+
}}
|
|
1197
|
+
key={localeItem}
|
|
1198
|
+
>
|
|
1199
|
+
<span>{localeItem}</span>
|
|
1200
|
+
<span>{getLocaleName(localeItem, localeItem)}</span>
|
|
1201
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1202
|
+
{getLocaleName(localeItem, locale)}
|
|
1203
|
+
</span>
|
|
1204
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1205
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1206
|
+
</span>
|
|
1207
|
+
</a>
|
|
1208
|
+
))}
|
|
1209
|
+
</div>
|
|
1210
|
+
</div>
|
|
1211
|
+
);
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1214
|
+
module.exports = LocaleSwitcher;
|
|
1215
|
+
```
|
|
1216
|
+
|
|
1217
|
+
> Referencias de documentación:
|
|
1218
|
+
|
|
1219
|
+
> - [`useLocale` hook](https://github.com/aymericzip/intlayer/blob/main/docs/es/packages/react-intlayer/useLocale.md) (La API es similar para `preact-intlayer`)
|
|
1220
|
+
|
|
1221
|
+
> - [`getLocaleName` hook](https://github.com/aymericzip/intlayer/blob/main/docs/es/packages/intlayer/getLocaleName.md)
|
|
1222
|
+
|
|
1223
|
+
> - [`getLocalizedUrl` hook](https://github.com/aymericzip/intlayer/blob/main/docs/es/packages/intlayer/getLocalizedUrl.md)
|
|
1224
|
+
|
|
1225
|
+
> - [`getHTMLTextDir` hook](https://github.com/aymericzip/intlayer/blob/main/docs/es/packages/intlayer/getHTMLTextDir.md)
|
|
1226
|
+
|
|
1227
|
+
> - [`hreflang` attribute](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=es)
|
|
1228
|
+
|
|
1229
|
+
> - [`lang` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
|
|
1230
|
+
|
|
1231
|
+
> - [`dir` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
|
|
1232
|
+
|
|
1233
|
+
> - [`aria-current` attribute](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1234
|
+
|
|
1235
|
+
> - [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
1236
|
+
|
|
1237
|
+
---
|
|
1238
|
+
|
|
1239
|
+
### (Opcional) Paso 9: Cambiar los atributos de idioma y dirección en HTML
|
|
1240
|
+
|
|
1241
|
+
Cuando tu aplicación soporta múltiples idiomas, es crucial actualizar los atributos `lang` y `dir` de la etiqueta `<html>` para que coincidan con el idioma actual. Esto asegura:
|
|
1242
|
+
|
|
1243
|
+
- **Accesibilidad**: Los lectores de pantalla y tecnologías asistivas dependen del atributo `lang` correcto para pronunciar e interpretar el contenido con precisión.
|
|
1244
|
+
|
|
1245
|
+
- **SEO**: Los motores de búsqueda utilizan el atributo `lang` para determinar el idioma de tu página, ayudando a mostrar el contenido localizado correcto en los resultados de búsqueda.
|
|
1246
|
+
|
|
1247
|
+
Al actualizar estos atributos dinámicamente cuando cambia la configuración regional, garantizas una experiencia consistente y accesible para los usuarios en todos los idiomas compatibles.
|
|
1248
|
+
|
|
1249
|
+
#### Implementación del Hook
|
|
1250
|
+
|
|
1251
|
+
Crea un hook personalizado para gestionar los atributos HTML. El hook escucha los cambios de configuración regional y actualiza los atributos en consecuencia:
|
|
1252
|
+
|
|
1253
|
+
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
|
|
1254
|
+
import { useEffect } from "preact/hooks";
|
|
1255
|
+
import { useLocale } from "preact-intlayer";
|
|
1256
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1257
|
+
|
|
1258
|
+
/**
|
|
1259
|
+
* Actualiza los atributos `lang` y `dir` del elemento HTML <html> según la configuración regional actual.
|
|
1260
|
+
* - `lang`: Informa a los navegadores y motores de búsqueda sobre el idioma de la página.
|
|
1261
|
+
* - `dir`: Asegura el orden de lectura correcto (por ejemplo, 'ltr' para inglés, 'rtl' para árabe).
|
|
1262
|
+
*
|
|
1263
|
+
* Esta actualización dinámica es esencial para un renderizado de texto adecuado, accesibilidad y SEO.
|
|
1264
|
+
*/
|
|
1265
|
+
export const useI18nHTMLAttributes = () => {
|
|
1266
|
+
const { locale } = useLocale();
|
|
1267
|
+
|
|
1268
|
+
useEffect(() => {
|
|
1269
|
+
// Actualiza el atributo de idioma al idioma actual.
|
|
1270
|
+
document.documentElement.lang = locale;
|
|
1271
|
+
|
|
1272
|
+
// Establece la dirección del texto según la configuración regional actual.
|
|
1273
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1274
|
+
}, [locale]);
|
|
1275
|
+
};
|
|
1276
|
+
```
|
|
1277
|
+
|
|
1278
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.jsx" codeFormat="esm"
|
|
1279
|
+
import { useEffect } from "preact/hooks";
|
|
1280
|
+
import { useLocale } from "preact-intlayer";
|
|
1281
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* Actualiza los atributos `lang` y `dir` del elemento HTML <html> según la configuración regional actual.
|
|
1285
|
+
*/
|
|
1286
|
+
export const useI18nHTMLAttributes = () => {
|
|
1287
|
+
const { locale } = useLocale();
|
|
1288
|
+
|
|
1289
|
+
useEffect(() => {
|
|
1290
|
+
document.documentElement.lang = locale;
|
|
1291
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1292
|
+
}, [locale]);
|
|
1293
|
+
};
|
|
1294
|
+
```
|
|
1295
|
+
|
|
1296
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.cjsx" codeFormat="commonjs"
|
|
1297
|
+
const { useEffect } = require("preact/hooks");
|
|
1298
|
+
const { useLocale } = require("preact-intlayer");
|
|
1299
|
+
const { getHTMLTextDir } = require("intlayer");
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* Actualiza los atributos `lang` y `dir` del elemento HTML <html> según la configuración regional actual.
|
|
1303
|
+
*/
|
|
1304
|
+
const useI18nHTMLAttributes = () => {
|
|
1305
|
+
const { locale } = useLocale();
|
|
1306
|
+
|
|
1307
|
+
useEffect(() => {
|
|
1308
|
+
document.documentElement.lang = locale;
|
|
1309
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1310
|
+
}, [locale]);
|
|
1311
|
+
};
|
|
1312
|
+
|
|
1313
|
+
module.exports = { useI18nHTMLAttributes };
|
|
1314
|
+
```
|
|
1315
|
+
|
|
1316
|
+
#### Uso del Hook en tu Aplicación
|
|
1317
|
+
|
|
1318
|
+
Integra el hook en tu componente principal para que los atributos HTML se actualicen cada vez que cambie la configuración regional:
|
|
1319
|
+
|
|
1320
|
+
```tsx fileName="src/app.tsx" codeFormat="typescript"
|
|
1321
|
+
import type { FunctionalComponent } from "preact";
|
|
1322
|
+
import { IntlayerProvider } from "preact-intlayer"; // useIntlayer ya importado si AppContent lo necesita
|
|
1323
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1324
|
+
import "./app.css";
|
|
1325
|
+
// Definición de AppContent desde el Paso 5
|
|
1326
|
+
|
|
1327
|
+
const AppWithHooks: FunctionalComponent = () => {
|
|
1328
|
+
// Aplica el hook para actualizar los atributos lang y dir de la etiqueta <html> según la configuración regional.
|
|
1329
|
+
useI18nHTMLAttributes();
|
|
1330
|
+
|
|
1331
|
+
// Suponiendo que AppContent es tu componente principal de visualización de contenido del Paso 5
|
|
1332
|
+
return <AppContent />;
|
|
1333
|
+
};
|
|
1334
|
+
|
|
1335
|
+
const App: FunctionalComponent = () => (
|
|
1336
|
+
<IntlayerProvider>
|
|
1337
|
+
<AppWithHooks />
|
|
1338
|
+
</IntlayerProvider>
|
|
1339
|
+
);
|
|
1340
|
+
|
|
1341
|
+
export default App;
|
|
1342
|
+
```
|
|
1343
|
+
|
|
1344
|
+
```jsx fileName="src/app.jsx" codeFormat="esm"
|
|
1345
|
+
import { IntlayerProvider } from "preact-intlayer";
|
|
1346
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1347
|
+
import "./app.css";
|
|
1348
|
+
// Definición de AppContent desde el Paso 5
|
|
1349
|
+
|
|
1350
|
+
const AppWithHooks = () => {
|
|
1351
|
+
useI18nHTMLAttributes();
|
|
1352
|
+
return <AppContent />;
|
|
1353
|
+
};
|
|
1354
|
+
|
|
1355
|
+
const App = () => (
|
|
1356
|
+
<IntlayerProvider>
|
|
1357
|
+
<AppWithHooks />
|
|
1358
|
+
</IntlayerProvider>
|
|
1359
|
+
);
|
|
1360
|
+
|
|
1361
|
+
export default App;
|
|
1362
|
+
```
|
|
1363
|
+
|
|
1364
|
+
```jsx fileName="src/app.cjsx" codeFormat="commonjs"
|
|
1365
|
+
const { IntlayerProvider } = require("preact-intlayer");
|
|
1366
|
+
const { useI18nHTMLAttributes } = require("./hooks/useI18nHTMLAttributes");
|
|
1367
|
+
require("./app.css");
|
|
1368
|
+
// Definición de AppContent desde el Paso 5
|
|
1369
|
+
|
|
1370
|
+
const AppWithHooks = () => {
|
|
1371
|
+
useI18nHTMLAttributes();
|
|
1372
|
+
return <AppContent />;
|
|
1373
|
+
};
|
|
1374
|
+
|
|
1375
|
+
const App = () => (
|
|
1376
|
+
<IntlayerProvider>
|
|
1377
|
+
<AppWithHooks />
|
|
1378
|
+
</IntlayerProvider>
|
|
1379
|
+
);
|
|
1380
|
+
|
|
1381
|
+
module.exports = App;
|
|
1382
|
+
```
|
|
1383
|
+
|
|
1384
|
+
Al aplicar estos cambios, tu aplicación:
|
|
1385
|
+
|
|
1386
|
+
- Asegurará que el atributo **idioma** (`lang`) refleje correctamente la configuración regional actual, lo cual es importante para el SEO y el comportamiento del navegador.
|
|
1387
|
+
- Ajustará la **dirección del texto** (`dir`) según la configuración regional, mejorando la legibilidad y usabilidad para idiomas con diferentes órdenes de lectura.
|
|
1388
|
+
- Proporcionará una experiencia más **accesible**, ya que las tecnologías de asistencia dependen de estos atributos para funcionar de manera óptima.
|
|
1389
|
+
|
|
1390
|
+
### (Opcional) Paso 10: Creación de un Componente de Enlace Localizado
|
|
1391
|
+
|
|
1392
|
+
Para garantizar que la navegación de tu aplicación respete la configuración regional actual, puedes crear un componente personalizado `Link`. Este componente automáticamente añade un prefijo a las URLs internas con el idioma actual.
|
|
1393
|
+
|
|
1394
|
+
Este comportamiento es útil por varias razones:
|
|
1395
|
+
|
|
1396
|
+
- **SEO y Experiencia de Usuario**: Las URLs localizadas ayudan a los motores de búsqueda a indexar correctamente las páginas específicas de cada idioma y proporcionan a los usuarios contenido en su idioma preferido.
|
|
1397
|
+
- **Consistencia**: Al usar un enlace localizado en toda tu aplicación, garantizas que la navegación permanezca dentro del contexto de la configuración regional actual, evitando cambios inesperados de idioma.
|
|
1398
|
+
- **Mantenibilidad**: Centralizar la lógica de localización en un único componente simplifica la gestión de URLs.
|
|
1399
|
+
|
|
1400
|
+
Para Preact con `preact-iso`, normalmente se utilizan etiquetas `<a>` estándar para la navegación, y `preact-iso` gestiona el enrutamiento. Si necesitas navegación programática al hacer clic (por ejemplo, para realizar acciones antes de navegar), puedes usar la función `route` de `useLocation`. Aquí tienes cómo crear un componente de anclaje personalizado que localiza URLs:
|
|
1401
|
+
|
|
1402
|
+
```tsx fileName="src/components/LocalizedLink.tsx" codeFormat="typescript"
|
|
1403
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1404
|
+
import { useLocale, useLocation, route } from "preact-intlayer"; // Suponiendo que useLocation y route pueden ser de preact-iso vía preact-intlayer si se reexportan, o importar directamente
|
|
1405
|
+
// Si no se reexportan, importar directamente: import { useLocation, route } from "preact-iso";
|
|
1406
|
+
import type { JSX } from "preact"; // Para HTMLAttributes
|
|
1407
|
+
import { forwardRef } from "preact/compat"; // Para reenviar referencias
|
|
1408
|
+
|
|
1409
|
+
export interface LocalizedLinkProps
|
|
1410
|
+
extends JSX.HTMLAttributes<HTMLAnchorElement> {
|
|
1411
|
+
href: string;
|
|
1412
|
+
replace?: boolean; // Opcional: para reemplazar el estado del historial
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
/**
|
|
1416
|
+
* Función de utilidad para verificar si una URL dada es externa.
|
|
1417
|
+
* Si la URL comienza con http:// o https://, se considera externa.
|
|
1418
|
+
*/
|
|
1419
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1420
|
+
/^https?:\/\//.test(href ?? "");
|
|
1421
|
+
|
|
1422
|
+
/**
|
|
1423
|
+
* Un componente de enlace personalizado que adapta el atributo href según la configuración regional actual.
|
|
1424
|
+
* Para enlaces internos, utiliza `getLocalizedUrl` para añadir un prefijo a la URL con la configuración regional (por ejemplo, /es/about).
|
|
1425
|
+
* Esto asegura que la navegación permanezca dentro del mismo contexto de configuración regional.
|
|
1426
|
+
* Utiliza una etiqueta <a> estándar pero puede activar la navegación del lado del cliente usando `route` de preact-iso.
|
|
1427
|
+
*/
|
|
1428
|
+
export const LocalizedLink = forwardRef<HTMLAnchorElement, LocalizedLinkProps>(
|
|
1429
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1430
|
+
const { locale } = useLocale();
|
|
1431
|
+
const location = useLocation(); // de preact-iso
|
|
1432
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1433
|
+
|
|
1434
|
+
const hrefI18n =
|
|
1435
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1436
|
+
|
|
1437
|
+
const handleClick = (event: JSX.TargetedMouseEvent<HTMLAnchorElement>) => {
|
|
1438
|
+
if (onClick) {
|
|
1439
|
+
onClick(event);
|
|
1440
|
+
}
|
|
1441
|
+
if (
|
|
1442
|
+
!isExternalLink &&
|
|
1443
|
+
href && // Asegura que href esté definido
|
|
1444
|
+
event.button === 0 && // Clic izquierdo
|
|
1445
|
+
!event.metaKey &&
|
|
1446
|
+
!event.ctrlKey &&
|
|
1447
|
+
!event.shiftKey &&
|
|
1448
|
+
!event.altKey && // Verificación de modificadores estándar
|
|
1449
|
+
!props.target // No se está apuntando a una nueva pestaña/ventana
|
|
1450
|
+
) {
|
|
1451
|
+
event.preventDefault();
|
|
1452
|
+
if (location.url !== hrefI18n) {
|
|
1453
|
+
// Navegar solo si la URL es diferente
|
|
1454
|
+
route(hrefI18n, replace); // Usar la función route de preact-iso
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
|
|
1459
|
+
return (
|
|
1460
|
+
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1461
|
+
{children}
|
|
1462
|
+
</a>
|
|
1463
|
+
);
|
|
1464
|
+
}
|
|
1465
|
+
);
|
|
1466
|
+
```
|
|
1467
|
+
|
|
1468
|
+
```jsx fileName="src/components/LocalizedLink.jsx" codeFormat="esm"
|
|
1469
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1470
|
+
import { useLocale } from "preact-intlayer";
|
|
1471
|
+
import { useLocation, route } from "preact-iso"; // Importar desde preact-iso
|
|
1472
|
+
import { forwardRef } from "preact/compat";
|
|
1473
|
+
import { h } from "preact"; // Para JSX
|
|
1474
|
+
|
|
1475
|
+
export const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1476
|
+
|
|
1477
|
+
export const LocalizedLink = forwardRef(
|
|
1478
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1479
|
+
const { locale } = useLocale();
|
|
1480
|
+
const location = useLocation();
|
|
1481
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1482
|
+
|
|
1483
|
+
const hrefI18n =
|
|
1484
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1485
|
+
|
|
1486
|
+
const handleClick = (event) => {
|
|
1487
|
+
if (onClick) {
|
|
1488
|
+
onClick(event);
|
|
1489
|
+
}
|
|
1490
|
+
if (
|
|
1491
|
+
!isExternalLink &&
|
|
1492
|
+
href &&
|
|
1493
|
+
event.button === 0 &&
|
|
1494
|
+
!event.metaKey &&
|
|
1495
|
+
!event.ctrlKey &&
|
|
1496
|
+
!event.shiftKey &&
|
|
1497
|
+
!event.altKey &&
|
|
1498
|
+
!props.target
|
|
1499
|
+
) {
|
|
1500
|
+
event.preventDefault();
|
|
1501
|
+
if (location.url !== hrefI18n) {
|
|
1502
|
+
route(hrefI18n, replace);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
};
|
|
1506
|
+
|
|
1507
|
+
return (
|
|
1508
|
+
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1509
|
+
{children}
|
|
1510
|
+
</a>
|
|
1511
|
+
);
|
|
1512
|
+
}
|
|
1513
|
+
);
|
|
1514
|
+
```
|
|
1515
|
+
|
|
1516
|
+
```jsx fileName="src/components/LocalizedLink.cjsx" codeFormat="commonjs"
|
|
1517
|
+
const { getLocalizedUrl } = require("intlayer");
|
|
1518
|
+
const { useLocale } = require("preact-intlayer");
|
|
1519
|
+
const { useLocation, route } = require("preact-iso"); // Importar desde preact-iso
|
|
1520
|
+
const { forwardRef } = require("preact/compat");
|
|
1521
|
+
const { h } = require("preact"); // Para JSX
|
|
1522
|
+
|
|
1523
|
+
const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1524
|
+
|
|
1525
|
+
const LocalizedLink = forwardRef(
|
|
1526
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1527
|
+
const { locale } = useLocale();
|
|
1528
|
+
const location = useLocation();
|
|
1529
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1530
|
+
|
|
1531
|
+
const hrefI18n =
|
|
1532
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1533
|
+
|
|
1534
|
+
const handleClick = (event) => {
|
|
1535
|
+
if (onClick) {
|
|
1536
|
+
onClick(event);
|
|
1537
|
+
}
|
|
1538
|
+
if (
|
|
1539
|
+
!isExternalLink &&
|
|
1540
|
+
href &&
|
|
1541
|
+
event.button === 0 &&
|
|
1542
|
+
!event.metaKey &&
|
|
1543
|
+
!event.ctrlKey &&
|
|
1544
|
+
!event.shiftKey &&
|
|
1545
|
+
!event.altKey &&
|
|
1546
|
+
!props.target
|
|
1547
|
+
) {
|
|
1548
|
+
event.preventDefault();
|
|
1549
|
+
if (location.url !== hrefI18n) {
|
|
1550
|
+
route(hrefI18n, replace);
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
};
|
|
1554
|
+
|
|
1555
|
+
return (
|
|
1556
|
+
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1557
|
+
{children}
|
|
1558
|
+
</a>
|
|
1559
|
+
);
|
|
1560
|
+
}
|
|
1561
|
+
);
|
|
1562
|
+
|
|
1563
|
+
module.exports = { LocalizedLink, checkIsExternalLink };
|
|
1564
|
+
```
|
|
1565
|
+
|
|
1566
|
+
#### Cómo Funciona
|
|
1567
|
+
|
|
1568
|
+
- **Detección de Enlaces Externos**:
|
|
1569
|
+
La función auxiliar `checkIsExternalLink` determina si una URL es externa. Los enlaces externos no se modifican.
|
|
1570
|
+
- **Recuperación del Idioma Actual**:
|
|
1571
|
+
El hook `useLocale` proporciona el idioma actual.
|
|
1572
|
+
- **Localización de la URL**:
|
|
1573
|
+
Para enlaces internos, `getLocalizedUrl` añade el prefijo del idioma actual a la URL.
|
|
1574
|
+
- **Navegación en el Cliente**:
|
|
1575
|
+
La función `handleClick` verifica si es un enlace interno y si se debe prevenir la navegación estándar. Si es así, utiliza la función `route` de `preact-iso` (obtenida mediante `useLocation` o importada directamente) para realizar la navegación en el cliente. Esto proporciona un comportamiento tipo SPA sin recargar toda la página.
|
|
1576
|
+
- **Devolución del Enlace**:
|
|
1577
|
+
El componente devuelve un elemento `<a>` con la URL localizada y el controlador de clic personalizado.
|
|
1578
|
+
|
|
1579
|
+
### Configurar TypeScript
|
|
1580
|
+
|
|
1581
|
+
Intlayer utiliza la ampliación de módulos para aprovechar TypeScript y fortalecer tu base de código.
|
|
1582
|
+
|
|
1583
|
+

|
|
1584
|
+
|
|
1585
|
+

|
|
1586
|
+
|
|
1587
|
+
Asegúrate de que tu configuración de TypeScript incluya los tipos autogenerados.
|
|
1588
|
+
|
|
1589
|
+
```json5 fileName="tsconfig.json"
|
|
1590
|
+
{
|
|
1591
|
+
// ... Tu configuración existente de TypeScript
|
|
1592
|
+
"compilerOptions": {
|
|
1593
|
+
// ...
|
|
1594
|
+
"jsx": "react-jsx",
|
|
1595
|
+
"jsxImportSource": "preact", // Recomendado para Preact 10+
|
|
1596
|
+
// ...
|
|
1597
|
+
},
|
|
1598
|
+
"include": [
|
|
1599
|
+
// ... Tu configuración existente de TypeScript
|
|
1600
|
+
".intlayer/**/*.ts", // Incluir los tipos autogenerados
|
|
1601
|
+
],
|
|
1602
|
+
}
|
|
1603
|
+
```
|
|
1604
|
+
|
|
1605
|
+
> Asegúrate de que tu `tsconfig.json` esté configurado para Preact, especialmente `jsx` y `jsxImportSource` o `jsxFactory`/`jsxFragmentFactory` para versiones anteriores de Preact si no estás utilizando los valores predeterminados de `preset-vite`.
|
|
1606
|
+
|
|
1607
|
+
### Configuración de Git
|
|
1608
|
+
|
|
1609
|
+
Se recomienda ignorar los archivos generados por Intlayer. Esto te permite evitar que se comprometan en tu repositorio Git.
|
|
1610
|
+
|
|
1611
|
+
Para hacerlo, puedes agregar las siguientes instrucciones a tu archivo `.gitignore`:
|
|
1612
|
+
|
|
1613
|
+
```plaintext
|
|
1614
|
+
# Ignorar los archivos generados por Intlayer
|
|
1615
|
+
.intlayer
|
|
1616
|
+
```
|
|
1617
|
+
|
|
1618
|
+
### Extensión de VS Code
|
|
1619
|
+
|
|
1620
|
+
Para mejorar tu experiencia de desarrollo con Intlayer, puedes instalar la **Extensión Oficial de Intlayer para VS Code**.
|
|
1621
|
+
|
|
1622
|
+
[Instalar desde el Marketplace de VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
1623
|
+
|
|
1624
|
+
Esta extensión proporciona:
|
|
1625
|
+
|
|
1626
|
+
- **Autocompletado** para claves de traducción.
|
|
1627
|
+
- **Detección de errores en tiempo real** para traducciones faltantes.
|
|
1628
|
+
- **Previsualizaciones en línea** del contenido traducido.
|
|
1629
|
+
- **Acciones rápidas** para crear y actualizar traducciones fácilmente.
|
|
1630
|
+
|
|
1631
|
+
Para más detalles sobre cómo usar la extensión, consulta la [documentación de la Extensión de Intlayer para VS Code](https://intlayer.org/doc/vs-code-extension).
|
|
1632
|
+
|
|
1633
|
+
---
|
|
1634
|
+
|
|
1635
|
+
### Ir Más Allá
|
|
1636
|
+
|
|
1637
|
+
Para ir más allá, puedes implementar el [editor visual](https://github.com/aymericzip/intlayer/blob/main/docs/es/intlayer_visual_editor.md) o externalizar tu contenido utilizando el [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/es/intlayer_CMS.md).
|