@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,1555 @@
|
|
|
1
|
+
# IntlayerとViteおよびReactを使用した国際化(i18n)の開始
|
|
2
|
+
|
|
3
|
+
<iframe title="Vite + React: Build a Multilingual App from Scratch using Intlayer" class="m-auto aspect-[16/9] w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/dS9L7uJeak4?autoplay=0&origin=http://intlayer.org&controls=0&rel=1"/>
|
|
4
|
+
|
|
5
|
+
[アプリケーションテンプレート](https://github.com/aymericzip/intlayer-vite-react-template) をGitHubで見る。
|
|
6
|
+
|
|
7
|
+
## Intlayerとは?
|
|
8
|
+
|
|
9
|
+
**Intlayer**は、モダンなウェブアプリケーションでの多言語対応を簡素化するために設計された革新的なオープンソースの国際化(i18n)ライブラリです。
|
|
10
|
+
|
|
11
|
+
Intlayerを使用すると、以下のことが可能です:
|
|
12
|
+
|
|
13
|
+
- **コンポーネントレベルで宣言的な辞書を使用して翻訳を簡単に管理**。
|
|
14
|
+
- **メタデータ、ルート、およびコンテンツを動的にローカライズ**。
|
|
15
|
+
- **TypeScriptサポートを確保**し、自動生成された型で補完機能とエラー検出を向上。
|
|
16
|
+
- **高度な機能を活用**、例えば動的なロケール検出と切り替え。
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## ViteとReactアプリケーションでIntlayerをセットアップするためのステップバイステップガイド
|
|
21
|
+
|
|
22
|
+
### ステップ1: 依存関係のインストール
|
|
23
|
+
|
|
24
|
+
npmを使用して必要なパッケージをインストールします:
|
|
25
|
+
|
|
26
|
+
```bash packageManager="npm"
|
|
27
|
+
npm install intlayer react-intlayer vite-intlayer
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```bash packageManager="pnpm"
|
|
31
|
+
pnpm add intlayer react-intlayer vite-intlayer
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```bash packageManager="yarn"
|
|
35
|
+
yarn add intlayer react-intlayer vite-intlayer
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- **intlayer**
|
|
39
|
+
|
|
40
|
+
設定管理、翻訳、[コンテンツ宣言](https://github.com/aymericzip/intlayer/blob/main/docs/ja/dictionary/get_started.md)、トランスパイル、および[CLIコマンド](https://github.com/aymericzip/intlayer/blob/main/docs/ja/intlayer_cli.md)を提供するコアパッケージ。
|
|
41
|
+
|
|
42
|
+
- **react-intlayer**
|
|
43
|
+
IntlayerをReactアプリケーションと統合するためのパッケージ。Reactの国際化のためのコンテキストプロバイダーとフックを提供します。
|
|
44
|
+
|
|
45
|
+
- **vite-intlayer**
|
|
46
|
+
[Viteバンドラー](https://vite.dev/guide/why.html#why-bundle-for-production)とIntlayerを統合するためのViteプラグインを含み、ユーザーの優先ロケールを検出し、クッキーを管理し、URLリダイレクションを処理するミドルウェアを提供します。
|
|
47
|
+
|
|
48
|
+
### ステップ2: プロジェクトの設定
|
|
49
|
+
|
|
50
|
+
アプリケーションの言語を設定するための設定ファイルを作成します:
|
|
51
|
+
|
|
52
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
53
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
54
|
+
|
|
55
|
+
const config: IntlayerConfig = {
|
|
56
|
+
internationalization: {
|
|
57
|
+
locales: [
|
|
58
|
+
Locales.ENGLISH,
|
|
59
|
+
Locales.FRENCH,
|
|
60
|
+
Locales.SPANISH,
|
|
61
|
+
// 他のロケール
|
|
62
|
+
],
|
|
63
|
+
defaultLocale: Locales.ENGLISH,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default config;
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
71
|
+
import { Locales } from "intlayer";
|
|
72
|
+
|
|
73
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
74
|
+
const config = {
|
|
75
|
+
internationalization: {
|
|
76
|
+
locales: [
|
|
77
|
+
Locales.ENGLISH,
|
|
78
|
+
Locales.FRENCH,
|
|
79
|
+
Locales.SPANISH,
|
|
80
|
+
// 他のロケール
|
|
81
|
+
],
|
|
82
|
+
defaultLocale: Locales.ENGLISH,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default config;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
90
|
+
const { Locales } = require("intlayer");
|
|
91
|
+
|
|
92
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
93
|
+
const config = {
|
|
94
|
+
internationalization: {
|
|
95
|
+
locales: [
|
|
96
|
+
Locales.ENGLISH,
|
|
97
|
+
Locales.FRENCH,
|
|
98
|
+
Locales.SPANISH,
|
|
99
|
+
// 他のロケール
|
|
100
|
+
],
|
|
101
|
+
defaultLocale: Locales.ENGLISH,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
module.exports = config;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
> この設定ファイルを通じて、ローカライズされたURL、ミドルウェアリダイレクション、クッキー名、コンテンツ宣言の場所と拡張子、コンソールでのIntlayerログの無効化などを設定できます。利用可能なパラメータの完全なリストについては、[設定ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/ja/configuration.md)を参照してください。
|
|
109
|
+
|
|
110
|
+
### ステップ3: Vite設定へのIntlayerの統合
|
|
111
|
+
|
|
112
|
+
設定にintlayerプラグインを追加します。
|
|
113
|
+
|
|
114
|
+
```typescript fileName="vite.config.ts" codeFormat="typescript"
|
|
115
|
+
import { defineConfig } from "vite";
|
|
116
|
+
import react from "@vitejs/plugin-react-swc";
|
|
117
|
+
import { intlayerPlugin } from "vite-intlayer";
|
|
118
|
+
|
|
119
|
+
// https://vitejs.dev/config/
|
|
120
|
+
export default defineConfig({
|
|
121
|
+
plugins: [react(), intlayerPlugin()],
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```javascript fileName="vite.config.mjs" codeFormat="esm"
|
|
126
|
+
import { defineConfig } from "vite";
|
|
127
|
+
import react from "@vitejs/plugin-react-swc";
|
|
128
|
+
import { intlayerPlugin } from "vite-intlayer";
|
|
129
|
+
|
|
130
|
+
// https://vitejs.dev/config/
|
|
131
|
+
export default defineConfig({
|
|
132
|
+
plugins: [react(), intlayerPlugin()],
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```javascript fileName="vite.config.cjs" codeFormat="commonjs"
|
|
137
|
+
const { defineConfig } = require("vite");
|
|
138
|
+
const react = require("@vitejs/plugin-react-swc");
|
|
139
|
+
const { intlayerPlugin } = require("vite-intlayer");
|
|
140
|
+
|
|
141
|
+
// https://vitejs.dev/config/
|
|
142
|
+
module.exports = defineConfig({
|
|
143
|
+
plugins: [react(), intlayerPlugin()],
|
|
144
|
+
});
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
> `intlayerPlugin()` Viteプラグインは、IntlayerをViteと統合するために使用されます。コンテンツ宣言ファイルのビルドを確実にし、開発モードでそれらを監視します。また、Viteアプリケーション内でIntlayer環境変数を定義し、パフォーマンスを最適化するためのエイリアスを提供します。
|
|
148
|
+
|
|
149
|
+
### ステップ4: コンテンツの宣言
|
|
150
|
+
|
|
151
|
+
翻訳を保存するためのコンテンツ宣言を作成および管理します:
|
|
152
|
+
|
|
153
|
+
```tsx fileName="src/app.content.tsx" contentDeclarationFormat="typescript"
|
|
154
|
+
import { t, type Dictionary } from "intlayer";
|
|
155
|
+
import type { ReactNode } from "react";
|
|
156
|
+
|
|
157
|
+
const appContent = {
|
|
158
|
+
key: "app",
|
|
159
|
+
content: {
|
|
160
|
+
viteLogo: t({
|
|
161
|
+
ja: "Viteロゴ",
|
|
162
|
+
en: "Vite logo",
|
|
163
|
+
fr: "Logo Vite",
|
|
164
|
+
es: "Logo Vite",
|
|
165
|
+
}),
|
|
166
|
+
reactLogo: t({
|
|
167
|
+
ja: "Reactロゴ",
|
|
168
|
+
en: "React logo",
|
|
169
|
+
fr: "Logo React",
|
|
170
|
+
es: "Logo React",
|
|
171
|
+
}),
|
|
172
|
+
|
|
173
|
+
title: "Vite + React",
|
|
174
|
+
|
|
175
|
+
count: t({
|
|
176
|
+
ja: "カウントは ",
|
|
177
|
+
en: "count is ",
|
|
178
|
+
fr: "le compte est ",
|
|
179
|
+
es: "el recuento es ",
|
|
180
|
+
}),
|
|
181
|
+
|
|
182
|
+
edit: t<ReactNode>({
|
|
183
|
+
ja: (
|
|
184
|
+
<>
|
|
185
|
+
<code>src/App.tsx</code>を編集して保存し、HMRをテストしてください
|
|
186
|
+
</>
|
|
187
|
+
),
|
|
188
|
+
en: (
|
|
189
|
+
<>
|
|
190
|
+
Edit <code>src/App.tsx</code> and save to test HMR
|
|
191
|
+
</>
|
|
192
|
+
),
|
|
193
|
+
fr: (
|
|
194
|
+
<>
|
|
195
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
196
|
+
</>
|
|
197
|
+
),
|
|
198
|
+
es: (
|
|
199
|
+
<>
|
|
200
|
+
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
201
|
+
</>
|
|
202
|
+
),
|
|
203
|
+
}),
|
|
204
|
+
|
|
205
|
+
readTheDocs: t({
|
|
206
|
+
ja: "ViteとReactのロゴをクリックして詳細を確認してください",
|
|
207
|
+
en: "Click on the Vite and React logos to learn more",
|
|
208
|
+
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
209
|
+
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
210
|
+
}),
|
|
211
|
+
},
|
|
212
|
+
} satisfies Dictionary;
|
|
213
|
+
|
|
214
|
+
export default appContent;
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
```javascript fileName="src/app.content.mjs" contentDeclarationFormat="esm"
|
|
218
|
+
import { t } from "intlayer";
|
|
219
|
+
|
|
220
|
+
/** @type {import('intlayer').Dictionary} */
|
|
221
|
+
const appContent = {
|
|
222
|
+
key: "app",
|
|
223
|
+
content: {
|
|
224
|
+
viteLogo: t({
|
|
225
|
+
ja: "Viteロゴ",
|
|
226
|
+
en: "Vite logo",
|
|
227
|
+
fr: "Logo Vite",
|
|
228
|
+
es: "Logo Vite",
|
|
229
|
+
}),
|
|
230
|
+
reactLogo: t({
|
|
231
|
+
ja: "Reactロゴ",
|
|
232
|
+
en: "React logo",
|
|
233
|
+
fr: "Logo React",
|
|
234
|
+
es: "Logo React",
|
|
235
|
+
}),
|
|
236
|
+
|
|
237
|
+
title: "Vite + React",
|
|
238
|
+
|
|
239
|
+
count: t({
|
|
240
|
+
ja: "カウントは ",
|
|
241
|
+
en: "count is ",
|
|
242
|
+
fr: "le compte est ",
|
|
243
|
+
es: "el recuento es ",
|
|
244
|
+
}),
|
|
245
|
+
|
|
246
|
+
edit:
|
|
247
|
+
t <
|
|
248
|
+
ReactNode >
|
|
249
|
+
{
|
|
250
|
+
// Reactノードをコンテンツで使用する場合はReactをインポートすることを忘れないでください
|
|
251
|
+
ja: (
|
|
252
|
+
<>
|
|
253
|
+
<code>src/App.tsx</code>を編集して保存し、HMRをテストしてください
|
|
254
|
+
</>
|
|
255
|
+
),
|
|
256
|
+
en: (
|
|
257
|
+
<>
|
|
258
|
+
Edit <code>src/App.tsx</code> and save to test HMR
|
|
259
|
+
</>
|
|
260
|
+
),
|
|
261
|
+
fr: (
|
|
262
|
+
<>
|
|
263
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
264
|
+
</>
|
|
265
|
+
),
|
|
266
|
+
es: (
|
|
267
|
+
<>
|
|
268
|
+
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
269
|
+
</>
|
|
270
|
+
),
|
|
271
|
+
},
|
|
272
|
+
|
|
273
|
+
readTheDocs: t({
|
|
274
|
+
ja: "ViteとReactのロゴをクリックして詳細を確認してください",
|
|
275
|
+
en: "Click on the Vite and React logos to learn more",
|
|
276
|
+
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
277
|
+
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
278
|
+
}),
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
export default appContent;
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
```javascript fileName="src/app.content.cjs" contentDeclarationFormat="commonjs"
|
|
286
|
+
const { t } = require("intlayer");
|
|
287
|
+
|
|
288
|
+
/** @type {import('intlayer').Dictionary} */
|
|
289
|
+
const appContent = {
|
|
290
|
+
key: "app",
|
|
291
|
+
content: {
|
|
292
|
+
viteLogo: t({
|
|
293
|
+
ja: "Viteロゴ",
|
|
294
|
+
en: "Vite logo",
|
|
295
|
+
fr: "Logo Vite",
|
|
296
|
+
es: "Logo Vite",
|
|
297
|
+
}),
|
|
298
|
+
reactLogo: t({
|
|
299
|
+
ja: "Reactロゴ",
|
|
300
|
+
en: "React logo",
|
|
301
|
+
fr: "Logo React",
|
|
302
|
+
es: "Logo React",
|
|
303
|
+
}),
|
|
304
|
+
|
|
305
|
+
title: "Vite + React",
|
|
306
|
+
|
|
307
|
+
count: t({
|
|
308
|
+
ja: "カウントは ",
|
|
309
|
+
en: "count is ",
|
|
310
|
+
fr: "le compte est ",
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
{
|
|
314
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
315
|
+
"key": "app",
|
|
316
|
+
"content": {
|
|
317
|
+
"viteLogo": {
|
|
318
|
+
"nodeType": "translation",
|
|
319
|
+
"translation": {
|
|
320
|
+
"en": "Vite logo",
|
|
321
|
+
"fr": "Logo Vite",
|
|
322
|
+
"es": "Logo Vite",
|
|
323
|
+
"ja": "Vite ロゴ"
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
"reactLogo": {
|
|
327
|
+
"nodeType": "translation",
|
|
328
|
+
"translation": {
|
|
329
|
+
"en": "React logo",
|
|
330
|
+
"fr": "Logo React",
|
|
331
|
+
"es": "Logo React",
|
|
332
|
+
"ja": "React ロゴ"
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
"title": {
|
|
336
|
+
"nodeType": "translation",
|
|
337
|
+
"translation": {
|
|
338
|
+
"en": "Vite + React",
|
|
339
|
+
"fr": "Vite + React",
|
|
340
|
+
"es": "Vite + React",
|
|
341
|
+
"ja": "Vite + React"
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
"count": {
|
|
345
|
+
"nodeType": "translation",
|
|
346
|
+
"translation": {
|
|
347
|
+
"en": "count is ",
|
|
348
|
+
"fr": "le compte est ",
|
|
349
|
+
"es": "el recuento es ",
|
|
350
|
+
"ja": "カウントは "
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
"edit": {
|
|
354
|
+
"nodeType": "translation",
|
|
355
|
+
"translation": {
|
|
356
|
+
"en": "Edit src/App.tsx and save to test HMR",
|
|
357
|
+
"fr": "Éditez src/App.tsx et enregistrez pour tester HMR",
|
|
358
|
+
"es": "Edita src/App.tsx y guarda para probar HMR",
|
|
359
|
+
"ja": "src/App.tsx を編集して保存し、HMR をテストしてください"
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
"readTheDocs": {
|
|
363
|
+
"nodeType": "translation",
|
|
364
|
+
"translation": {
|
|
365
|
+
"en": "Click on the Vite and React logos to learn more",
|
|
366
|
+
"fr": "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
367
|
+
"es": "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
368
|
+
"ja": "Vite と React のロゴをクリックして詳細を確認してください"
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
> コンテンツ宣言は、`contentDir` ディレクトリ(デフォルトでは `./src`)に含まれている限り、アプリケーション内のどこにでも定義できます。また、コンテンツ宣言ファイルの拡張子(デフォルトでは `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`)に一致する必要があります。
|
|
376
|
+
|
|
377
|
+
> 詳細については、[コンテンツ宣言のドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/ja/dictionary/get_started.md)を参照してください。
|
|
378
|
+
|
|
379
|
+
> コンテンツファイルに TSX コードが含まれている場合は、`import React from "react";` をコンテンツファイルにインポートすることを検討してください。
|
|
380
|
+
|
|
381
|
+
### ステップ 5: コード内で Intlayer を利用する
|
|
382
|
+
|
|
383
|
+
アプリケーション全体でコンテンツ辞書にアクセスします:
|
|
384
|
+
|
|
385
|
+
```tsx {5,9} fileName="src/App.tsx" codeFormat="typescript"
|
|
386
|
+
import { useState, type FC } from "react";
|
|
387
|
+
import reactLogo from "./assets/react.svg";
|
|
388
|
+
import viteLogo from "/vite.svg";
|
|
389
|
+
import "./App.css";
|
|
390
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
391
|
+
|
|
392
|
+
const AppContent: FC = () => {
|
|
393
|
+
const [count, setCount] = useState(0);
|
|
394
|
+
const content = useIntlayer("app");
|
|
395
|
+
|
|
396
|
+
return (
|
|
397
|
+
<>
|
|
398
|
+
<div>
|
|
399
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
400
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
401
|
+
</a>
|
|
402
|
+
<a href="https://react.dev" target="_blank">
|
|
403
|
+
<img
|
|
404
|
+
src={reactLogo}
|
|
405
|
+
className="logo react"
|
|
406
|
+
alt={content.reactLogo.value}
|
|
407
|
+
/>
|
|
408
|
+
</a>
|
|
409
|
+
</div>
|
|
410
|
+
<h1>{content.title}</h1>
|
|
411
|
+
<div className="card">
|
|
412
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
413
|
+
{content.count}
|
|
414
|
+
{count}
|
|
415
|
+
</button>
|
|
416
|
+
<p>{content.edit}</p>
|
|
417
|
+
</div>
|
|
418
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
419
|
+
</>
|
|
420
|
+
);
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
const App: FC = () => (
|
|
424
|
+
<IntlayerProvider>
|
|
425
|
+
<AppContent />
|
|
426
|
+
</IntlayerProvider>
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
export default App;
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
```tsx {5,9} fileName="src/App.msx" codeFormat="esm"
|
|
433
|
+
import { useState } from "react";
|
|
434
|
+
import reactLogo from "./assets/react.svg";
|
|
435
|
+
import viteLogo from "/vite.svg";
|
|
436
|
+
import "./App.css";
|
|
437
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
438
|
+
|
|
439
|
+
const AppContent = () => {
|
|
440
|
+
const [count, setCount] = useState(0);
|
|
441
|
+
const content = useIntlayer("app");
|
|
442
|
+
|
|
443
|
+
return (
|
|
444
|
+
<>
|
|
445
|
+
<div>
|
|
446
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
447
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
448
|
+
</a>
|
|
449
|
+
<a href="https://react.dev" target="_blank">
|
|
450
|
+
<img
|
|
451
|
+
src={reactLogo}
|
|
452
|
+
className="logo react"
|
|
453
|
+
alt={content.reactLogo.value}
|
|
454
|
+
/>
|
|
455
|
+
</a>
|
|
456
|
+
</div>
|
|
457
|
+
<h1>{content.title}</h1>
|
|
458
|
+
<div className="card">
|
|
459
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
460
|
+
{content.count}
|
|
461
|
+
{count}
|
|
462
|
+
</button>
|
|
463
|
+
<p>{content.edit}</p>
|
|
464
|
+
</div>
|
|
465
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
466
|
+
</>
|
|
467
|
+
);
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
const App = () => (
|
|
471
|
+
<IntlayerProvider>
|
|
472
|
+
<AppContent />
|
|
473
|
+
</IntlayerProvider>
|
|
474
|
+
);
|
|
475
|
+
|
|
476
|
+
export default App;
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
```tsx {5,9} fileName="src/App.csx" codeFormat="commonjs"
|
|
480
|
+
const { useState } = require("react");
|
|
481
|
+
const reactLogo = require("./assets/react.svg");
|
|
482
|
+
const viteLogo = require("/vite.svg");
|
|
483
|
+
require("./App.css");
|
|
484
|
+
const { IntlayerProvider, useIntlayer } = require("react-intlayer");
|
|
485
|
+
|
|
486
|
+
const AppContent = () => {
|
|
487
|
+
const [count, setCount] = useState(0);
|
|
488
|
+
const content = useIntlayer("app");
|
|
489
|
+
|
|
490
|
+
return (
|
|
491
|
+
<>
|
|
492
|
+
<div>
|
|
493
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
494
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
495
|
+
</a>
|
|
496
|
+
<a href="https://react.dev" target="_blank">
|
|
497
|
+
<img
|
|
498
|
+
src={reactLogo}
|
|
499
|
+
className="logo react"
|
|
500
|
+
alt={content.reactLogo.value}
|
|
501
|
+
/>
|
|
502
|
+
</a>
|
|
503
|
+
</div>
|
|
504
|
+
<h1>{content.title}</h1>
|
|
505
|
+
<div className="card">
|
|
506
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
507
|
+
{content.count}
|
|
508
|
+
{count}
|
|
509
|
+
</button>
|
|
510
|
+
<p>{content.edit}</p>
|
|
511
|
+
</div>
|
|
512
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
513
|
+
</>
|
|
514
|
+
);
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
const App = () => (
|
|
518
|
+
<IntlayerProvider>
|
|
519
|
+
<AppContent />
|
|
520
|
+
</IntlayerProvider>
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
module.exports = App;
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
> `alt`、`title`、`href`、`aria-label` などの `string` 属性でコンテンツを使用する場合、関数の値を呼び出す必要があります。例えば:
|
|
527
|
+
|
|
528
|
+
> ```jsx
|
|
529
|
+
>
|
|
530
|
+
> ```
|
|
531
|
+
|
|
532
|
+
> <img src={content.image.src.value} alt={content.image.value} />
|
|
533
|
+
|
|
534
|
+
> ```
|
|
535
|
+
>
|
|
536
|
+
> ```
|
|
537
|
+
|
|
538
|
+
> `useIntlayer` フックの詳細については、[ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/ja/packages/react-intlayer/useIntlayer.md)を参照してください。
|
|
539
|
+
|
|
540
|
+
### (オプション)ステップ 6: コンテンツの言語を変更する
|
|
541
|
+
|
|
542
|
+
コンテンツの言語を変更するには、`useLocale` フックが提供する `setLocale` 関数を使用します。この関数を使用すると、アプリケーションのロケールを設定し、それに応じてコンテンツを更新できます。
|
|
543
|
+
|
|
544
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
545
|
+
import type { FC } from "react";
|
|
546
|
+
import { Locales } from "intlayer";
|
|
547
|
+
import { useLocale } from "react-intlayer";
|
|
548
|
+
|
|
549
|
+
const LocaleSwitcher: FC = () => {
|
|
550
|
+
const { setLocale } = useLocale();
|
|
551
|
+
|
|
552
|
+
return (
|
|
553
|
+
<button onClick={() => setLocale(Locales.English)}>言語を英語に変更</button>
|
|
554
|
+
);
|
|
555
|
+
};
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
```jsx fileName="src/components/LocaleSwitcher.msx" codeFormat="esm"
|
|
559
|
+
import { Locales } from "intlayer";
|
|
560
|
+
import { useLocale } from "react-intlayer";
|
|
561
|
+
|
|
562
|
+
const LocaleSwitcher = () => {
|
|
563
|
+
const { setLocale } = useLocale();
|
|
564
|
+
|
|
565
|
+
return (
|
|
566
|
+
<button onClick={() => setLocale(Locales.English)}>言語を英語に変更</button>
|
|
567
|
+
);
|
|
568
|
+
};
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
```jsx fileName="src/components/LocaleSwitcher.csx" codeFormat="commonjs"
|
|
572
|
+
const { Locales } = require("intlayer");
|
|
573
|
+
|
|
574
|
+
const { useLocale } = require("react-intlayer");
|
|
575
|
+
|
|
576
|
+
const LocaleSwitcher = () => {
|
|
577
|
+
const { setLocale } = useLocale();
|
|
578
|
+
|
|
579
|
+
return (
|
|
580
|
+
<button onClick={() => setLocale(Locales.English)}>言語を英語に変更</button>
|
|
581
|
+
);
|
|
582
|
+
};
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
> `useLocale`フックについて詳しくは、[ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/ja/packages/react-intlayer/useLocale.md)を参照してください。
|
|
586
|
+
|
|
587
|
+
### (オプション) ステップ7: アプリケーションにローカライズされたルーティングを追加する
|
|
588
|
+
|
|
589
|
+
このステップの目的は、各言語に固有のルートを作成することです。これはSEOおよびSEOフレンドリーなURLに役立ちます。
|
|
590
|
+
例:
|
|
591
|
+
|
|
592
|
+
```plaintext
|
|
593
|
+
- https://example.com/about
|
|
594
|
+
- https://example.com/es/about
|
|
595
|
+
- https://example.com/fr/about
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
> デフォルトでは、デフォルトのロケールにはルートがプレフィックスされません。デフォルトのロケールにプレフィックスを付けたい場合は、設定で`middleware.prefixDefault`オプションを`true`に設定できます。詳細は[設定ドキュメント](https://github.com/aymericzip/intlayer/blob/main/docs/ja/configuration.md)を参照してください。
|
|
599
|
+
|
|
600
|
+
アプリケーションにローカライズされたルーティングを追加するには、アプリケーションのルートをラップし、ロケールベースのルーティングを処理する`LocaleRouter`コンポーネントを作成します。以下は[React Router](https://reactrouter.com/home)を使用した例です:
|
|
601
|
+
|
|
602
|
+
```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
|
|
603
|
+
// 必要な依存関係と関数をインポート
|
|
604
|
+
import { type Locales, configuration, getPathWithoutLocale } from "intlayer"; // 'intlayer'からのユーティリティ関数と型
|
|
605
|
+
import type { FC, PropsWithChildren } from "react"; // 関数型コンポーネントとプロップのReact型
|
|
606
|
+
import { IntlayerProvider } from "react-intlayer"; // 国際化コンテキストのプロバイダー
|
|
607
|
+
import {
|
|
608
|
+
BrowserRouter,
|
|
609
|
+
Routes,
|
|
610
|
+
Route,
|
|
611
|
+
Navigate,
|
|
612
|
+
useLocation,
|
|
613
|
+
} from "react-router-dom"; // ナビゲーションを管理するためのルーターコンポーネント
|
|
614
|
+
|
|
615
|
+
// Intlayerから設定を分解
|
|
616
|
+
const { internationalization, middleware } = configuration;
|
|
617
|
+
const { locales, defaultLocale } = internationalization;
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* ローカリゼーションを処理し、適切なロケールコンテキストで子要素をラップするコンポーネント。
|
|
621
|
+
* URLベースのロケール検出と検証を管理します。
|
|
622
|
+
*/
|
|
623
|
+
const AppLocalized: FC<PropsWithChildren<{ locale: Locales }>> = ({
|
|
624
|
+
children,
|
|
625
|
+
locale,
|
|
626
|
+
}) => {
|
|
627
|
+
const { pathname, search } = useLocation(); // 現在のURLパスを取得
|
|
628
|
+
|
|
629
|
+
// 現在のロケールを決定し、指定されていない場合はデフォルトにフォールバック
|
|
630
|
+
const currentLocale = locale ?? defaultLocale;
|
|
631
|
+
|
|
632
|
+
// ロケールプレフィックスをパスから削除してベースパスを構築
|
|
633
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
634
|
+
pathname // 現在のURLパス
|
|
635
|
+
);
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* middleware.prefixDefaultがtrueの場合、デフォルトのロケールは常にプレフィックスされるべきです。
|
|
639
|
+
*/
|
|
640
|
+
if (middleware.prefixDefault) {
|
|
641
|
+
// ロケールを検証
|
|
642
|
+
if (!locale || !locales.includes(locale)) {
|
|
643
|
+
// 更新されたパスでデフォルトのロケールにリダイレクト
|
|
644
|
+
return (
|
|
645
|
+
<Navigate
|
|
646
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
647
|
+
replace // 現在の履歴エントリを新しいものに置き換える
|
|
648
|
+
/>
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// 子要素をIntlayerProviderでラップし、現在のロケールを設定
|
|
653
|
+
return (
|
|
654
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
655
|
+
);
|
|
656
|
+
} else {
|
|
657
|
+
/**
|
|
658
|
+
* middleware.prefixDefaultがfalseの場合、デフォルトのロケールはプレフィックスされません。
|
|
659
|
+
* 現在のロケールが有効であり、デフォルトのロケールでないことを確認します。
|
|
660
|
+
*/
|
|
661
|
+
if (
|
|
662
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
663
|
+
!locales
|
|
664
|
+
.filter(
|
|
665
|
+
(locale) => locale.toString() !== defaultLocale.toString() // デフォルトのロケールを除外
|
|
666
|
+
)
|
|
667
|
+
.includes(currentLocale) // 現在のロケールが有効なロケールリストに含まれているか確認
|
|
668
|
+
) {
|
|
669
|
+
// ロケールプレフィックスなしのパスにリダイレクト
|
|
670
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// 子要素をIntlayerProviderでラップし、現在のロケールを設定
|
|
674
|
+
return (
|
|
675
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* ロケール固有のルートを設定するルーターコンポーネント。
|
|
682
|
+
* React Routerを使用してナビゲーションを管理し、ローカライズされたコンポーネントをレンダリングします。
|
|
683
|
+
*/
|
|
684
|
+
export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
|
|
685
|
+
<BrowserRouter>
|
|
686
|
+
<Routes>
|
|
687
|
+
{locales
|
|
688
|
+
.filter(
|
|
689
|
+
(locale) => middleware.prefixDefault || locale !== defaultLocale
|
|
690
|
+
)
|
|
691
|
+
.map((locale) => (
|
|
692
|
+
<Route
|
|
693
|
+
// ロケールをキャプチャし(例: /en/, /fr/)、すべての後続パスにマッチするルートパターン
|
|
694
|
+
path={`/${locale}/*`}
|
|
695
|
+
key={locale}
|
|
696
|
+
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // 子要素をロケール管理でラップ
|
|
697
|
+
/>
|
|
698
|
+
))}
|
|
699
|
+
|
|
700
|
+
{
|
|
701
|
+
// デフォルトのロケールのプレフィックスが無効な場合、ルートパスで子要素を直接レンダリング
|
|
702
|
+
!middleware.prefixDefault && (
|
|
703
|
+
<Route
|
|
704
|
+
path="*"
|
|
705
|
+
element={
|
|
706
|
+
<AppLocalized locale={defaultLocale}>{children}</AppLocalized>
|
|
707
|
+
} // 子要素をロケール管理でラップ
|
|
708
|
+
/>
|
|
709
|
+
)
|
|
710
|
+
}
|
|
711
|
+
</Routes>
|
|
712
|
+
</BrowserRouter>
|
|
713
|
+
);
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
```jsx fileName="src/components/LocaleRouter.mjx" codeFormat="esm"
|
|
717
|
+
// 必要な依存関係と関数をインポート
|
|
718
|
+
import { configuration, getPathWithoutLocale } from "intlayer"; // 'intlayer'からのユーティリティ関数と型
|
|
719
|
+
import { IntlayerProvider } from "react-intlayer"; // 国際化コンテキストのプロバイダー
|
|
720
|
+
import {
|
|
721
|
+
BrowserRouter,
|
|
722
|
+
Routes,
|
|
723
|
+
Route,
|
|
724
|
+
Navigate,
|
|
725
|
+
useLocation,
|
|
726
|
+
} from "react-router-dom"; // ナビゲーションを管理するためのルーターコンポーネント
|
|
727
|
+
|
|
728
|
+
// Intlayerから設定を分解
|
|
729
|
+
const { internationalization, middleware } = configuration;
|
|
730
|
+
const { locales, defaultLocale } = internationalization;
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* ローカリゼーションを処理し、適切なロケールコンテキストで子要素をラップするコンポーネント。
|
|
734
|
+
* URLベースのロケール検出と検証を管理します。
|
|
735
|
+
*/
|
|
736
|
+
const AppLocalized = ({ children, locale }) => {
|
|
737
|
+
const { pathname, search } = useLocation(); // 現在のURLパスを取得
|
|
738
|
+
|
|
739
|
+
// 現在のロケールを決定し、指定されていない場合はデフォルトにフォールバック
|
|
740
|
+
const currentLocale = locale ?? defaultLocale;
|
|
741
|
+
|
|
742
|
+
// ロケールプレフィックスをパスから削除してベースパスを構築
|
|
743
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
744
|
+
pathname // 現在のURLパス
|
|
745
|
+
);
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* middleware.prefixDefaultがtrueの場合、デフォルトのロケールは常にプレフィックスされるべきです。
|
|
749
|
+
*/
|
|
750
|
+
if (middleware.prefixDefault) {
|
|
751
|
+
// ロケールを検証
|
|
752
|
+
if (!locale || !locales.includes(locale)) {
|
|
753
|
+
// 更新されたパスでデフォルトのロケールにリダイレクト
|
|
754
|
+
return (
|
|
755
|
+
<Navigate
|
|
756
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
757
|
+
replace // 現在の履歴エントリを新しいものに置き換える
|
|
758
|
+
/>
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// 子要素をIntlayerProviderでラップし、現在のロケールを設定
|
|
763
|
+
return (
|
|
764
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
765
|
+
);
|
|
766
|
+
} else {
|
|
767
|
+
/**
|
|
768
|
+
* middleware.prefixDefaultがfalseの場合、デフォルトのロケールはプレフィックスされません。
|
|
769
|
+
* 現在のロケールが有効であり、デフォルトのロケールでないことを確認します。
|
|
770
|
+
*/
|
|
771
|
+
if (
|
|
772
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
773
|
+
!locales
|
|
774
|
+
.filter(
|
|
775
|
+
(locale) => locale.toString() !== defaultLocale.toString() // デフォルトのロケールを除外
|
|
776
|
+
)
|
|
777
|
+
.includes(currentLocale) // 現在のロケールが有効なロケールリストに含まれているか確認
|
|
778
|
+
) {
|
|
779
|
+
// ロケールプレフィックスなしのパスにリダイレクト
|
|
780
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// 子要素をIntlayerProviderでラップし、現在のロケールを設定
|
|
784
|
+
return (
|
|
785
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* React Routerを使用してナビゲーションを管理し、ローカライズされたコンポーネントをレンダリングします。
|
|
792
|
+
*/
|
|
793
|
+
export const LocaleRouter = ({ children }) => (
|
|
794
|
+
<BrowserRouter>
|
|
795
|
+
<Routes>
|
|
796
|
+
{locales
|
|
797
|
+
.filter(
|
|
798
|
+
(locale) => middleware.prefixDefault || locale !== defaultLocale
|
|
799
|
+
)
|
|
800
|
+
.map((locale) => (
|
|
801
|
+
<Route
|
|
802
|
+
// ロケールをキャプチャするルートパターン(例: /en/, /fr/)とその後のすべてのパスを一致させる
|
|
803
|
+
path={`/${locale}/*`}
|
|
804
|
+
key={locale}
|
|
805
|
+
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // 子要素をロケール管理でラップ
|
|
806
|
+
/>
|
|
807
|
+
))}
|
|
808
|
+
|
|
809
|
+
{
|
|
810
|
+
// デフォルトロケールのプレフィックスが無効化されている場合、子要素をルートパスで直接レンダリング
|
|
811
|
+
!middleware.prefixDefault && (
|
|
812
|
+
<Route
|
|
813
|
+
path="*"
|
|
814
|
+
element={
|
|
815
|
+
<AppLocalized locale={defaultLocale}>{children}</AppLocalized>
|
|
816
|
+
} // 子要素をロケール管理でラップ
|
|
817
|
+
/>
|
|
818
|
+
)
|
|
819
|
+
}
|
|
820
|
+
</Routes>
|
|
821
|
+
</BrowserRouter>
|
|
822
|
+
);
|
|
823
|
+
```
|
|
824
|
+
|
|
825
|
+
```jsx fileName="src/components/LocaleRouter.cjx" codeFormat="commonjs"
|
|
826
|
+
// 必要な依存関係と関数をインポート
|
|
827
|
+
const { configuration, getPathWithoutLocale } = require("intlayer"); // 'intlayer'からのユーティリティ関数と型
|
|
828
|
+
const { IntlayerProvider, useLocale } = require("react-intlayer"); // 国際化コンテキストのプロバイダー
|
|
829
|
+
const {
|
|
830
|
+
BrowserRouter,
|
|
831
|
+
Routes,
|
|
832
|
+
Route,
|
|
833
|
+
Navigate,
|
|
834
|
+
useLocation,
|
|
835
|
+
} = require("react-router-dom"); // ナビゲーションを管理するためのルーターコンポーネント
|
|
836
|
+
|
|
837
|
+
// Intlayerからの設定を分解
|
|
838
|
+
const { internationalization, middleware } = configuration;
|
|
839
|
+
const { locales, defaultLocale } = internationalization;
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* ローカリゼーションを処理し、適切なロケールコンテキストで子要素をラップするコンポーネント。
|
|
843
|
+
* URLベースのロケール検出と検証を管理します。
|
|
844
|
+
*/
|
|
845
|
+
const AppLocalized = ({ children, locale }) => {
|
|
846
|
+
const { pathname, search } = useLocation(); // 現在のURLパスを取得
|
|
847
|
+
|
|
848
|
+
// 現在のロケールを決定し、指定されていない場合はデフォルトにフォールバック
|
|
849
|
+
const currentLocale = locale ?? defaultLocale;
|
|
850
|
+
|
|
851
|
+
// パスからロケールプレフィックスを削除してベースパスを構築
|
|
852
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
853
|
+
pathname // 現在のURLパス
|
|
854
|
+
);
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* middleware.prefixDefaultがtrueの場合、デフォルトロケールは常にプレフィックスされるべきです。
|
|
858
|
+
*/
|
|
859
|
+
if (middleware.prefixDefault) {
|
|
860
|
+
// ロケールを検証
|
|
861
|
+
if (!locale || !locales.includes(locale)) {
|
|
862
|
+
// 更新されたパスでデフォルトロケールにリダイレクト
|
|
863
|
+
return (
|
|
864
|
+
<Navigate
|
|
865
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
866
|
+
replace // 現在の履歴エントリを新しいものに置き換え
|
|
867
|
+
/>
|
|
868
|
+
);
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
// 子要素をIntlayerProviderでラップし、現在のロケールを設定
|
|
872
|
+
return (
|
|
873
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
874
|
+
);
|
|
875
|
+
} else {
|
|
876
|
+
/**
|
|
877
|
+
* middleware.prefixDefaultがfalseの場合、デフォルトロケールはプレフィックスされません。
|
|
878
|
+
* 現在のロケールが有効であり、デフォルトロケールでないことを確認します。
|
|
879
|
+
*/
|
|
880
|
+
if (
|
|
881
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
882
|
+
!locales
|
|
883
|
+
.filter(
|
|
884
|
+
(locale) => locale.toString() !== defaultLocale.toString() // デフォルトロケールを除外
|
|
885
|
+
)
|
|
886
|
+
.includes(currentLocale) // 現在のロケールが有効なロケールリストに含まれているか確認
|
|
887
|
+
) {
|
|
888
|
+
// ロケールプレフィックスなしのパスにリダイレクト
|
|
889
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// 子要素をIntlayerProviderでラップし、現在のロケールを設定
|
|
893
|
+
return (
|
|
894
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
895
|
+
);
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* ロケール固有のルートを設定するルーターコンポーネント。
|
|
901
|
+
* React Routerを使用してナビゲーションを管理し、ローカライズされたコンポーネントをレンダリングします。
|
|
902
|
+
*/
|
|
903
|
+
const LocaleRouter = ({ children }) => (
|
|
904
|
+
<BrowserRouter>
|
|
905
|
+
<Routes>
|
|
906
|
+
{locales
|
|
907
|
+
.filter(
|
|
908
|
+
(locale) => middleware.prefixDefault || locale !== defaultLocale
|
|
909
|
+
)
|
|
910
|
+
.map((locale) => (
|
|
911
|
+
<Route
|
|
912
|
+
// ロケールをキャプチャするルートパターン(例: /en/, /fr/)とその後のすべてのパスを一致させる
|
|
913
|
+
path={`/${locale}/*`}
|
|
914
|
+
key={locale}
|
|
915
|
+
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // 子要素をロケール管理でラップ
|
|
916
|
+
/>
|
|
917
|
+
))}
|
|
918
|
+
|
|
919
|
+
{
|
|
920
|
+
// デフォルトロケールのプレフィックスが無効化されている場合、子要素をルートパスで直接レンダリング
|
|
921
|
+
!middleware.prefixDefault && (
|
|
922
|
+
<Route
|
|
923
|
+
path="*"
|
|
924
|
+
element={
|
|
925
|
+
<AppLocalized locale={defaultLocale}>{children}</AppLocalized>
|
|
926
|
+
} // 子要素をロケール管理でラップ
|
|
927
|
+
/>
|
|
928
|
+
)
|
|
929
|
+
}
|
|
930
|
+
</Routes>
|
|
931
|
+
</BrowserRouter>
|
|
932
|
+
);
|
|
933
|
+
```
|
|
934
|
+
|
|
935
|
+
次に、アプリケーションで`LocaleRouter`コンポーネントを使用できます:
|
|
936
|
+
|
|
937
|
+
```tsx fileName="src/App.tsx" codeFormat="typescript"
|
|
938
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
939
|
+
import type { FC } from "react";
|
|
940
|
+
|
|
941
|
+
// ... AppContentコンポーネント
|
|
942
|
+
|
|
943
|
+
const App: FC = () => (
|
|
944
|
+
<LocaleRouter>
|
|
945
|
+
<AppContent />
|
|
946
|
+
</LocaleRouter>
|
|
947
|
+
);
|
|
948
|
+
```
|
|
949
|
+
|
|
950
|
+
```jsx fileName="src/App.mjx" codeFormat="esm"
|
|
951
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
952
|
+
|
|
953
|
+
// ... AppContentコンポーネント
|
|
954
|
+
|
|
955
|
+
const App = () => (
|
|
956
|
+
<LocaleRouter>
|
|
957
|
+
<AppContent />
|
|
958
|
+
</LocaleRouter>
|
|
959
|
+
);
|
|
960
|
+
```
|
|
961
|
+
|
|
962
|
+
```jsx fileName="src/App.cjx" codeFormat="commonjs"
|
|
963
|
+
const { LocaleRouter } = require("./components/LocaleRouter");
|
|
964
|
+
|
|
965
|
+
// ... AppContentコンポーネント
|
|
966
|
+
|
|
967
|
+
const App = () => (
|
|
968
|
+
<LocaleRouter>
|
|
969
|
+
<AppContent />
|
|
970
|
+
</LocaleRouter>
|
|
971
|
+
);
|
|
972
|
+
```
|
|
973
|
+
|
|
974
|
+
並行して、`intLayerMiddlewarePlugin`を使用してアプリケーションにサーバーサイドルーティングを追加することもできます。このプラグインは、URLに基づいて現在のロケールを自動的に検出し、適切なロケールクッキーを設定します。ロケールが指定されていない場合、プラグインはユーザーのブラウザ言語設定に基づいて最適なロケールを決定します。ロケールが検出されない場合、デフォルトロケールにリダイレクトします。
|
|
975
|
+
|
|
976
|
+
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
977
|
+
import { defineConfig } from "vite";
|
|
978
|
+
import react from "@vitejs/plugin-react-swc";
|
|
979
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
980
|
+
|
|
981
|
+
// https://vitejs.dev/config/
|
|
982
|
+
export default defineConfig({
|
|
983
|
+
plugins: [react(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
984
|
+
});
|
|
985
|
+
```
|
|
986
|
+
|
|
987
|
+
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
988
|
+
import { defineConfig } from "vite";
|
|
989
|
+
import react from "@vitejs/plugin-react-swc";
|
|
990
|
+
import { intlayerPlugin, intLayerMiddlewarePlugin } from "vite-intlayer";
|
|
991
|
+
|
|
992
|
+
// https://vitejs.dev/config/
|
|
993
|
+
export default defineConfig({
|
|
994
|
+
plugins: [react(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
995
|
+
});
|
|
996
|
+
```
|
|
997
|
+
|
|
998
|
+
```javascript {5,10} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
999
|
+
const { defineConfig } = require("vite");
|
|
1000
|
+
const react = require("@vitejs/plugin-react-swc");
|
|
1001
|
+
const { intlayerPlugin, intLayerMiddlewarePlugin } = require("vite-intlayer");
|
|
1002
|
+
|
|
1003
|
+
// https://vitejs.dev/config/
|
|
1004
|
+
module.exports = defineConfig({
|
|
1005
|
+
plugins: [react(), intlayerPlugin(), intLayerMiddlewarePlugin()],
|
|
1006
|
+
});
|
|
1007
|
+
```
|
|
1008
|
+
|
|
1009
|
+
### (オプション)ステップ8: ロケールが変更されたときにURLを変更する
|
|
1010
|
+
|
|
1011
|
+
ロケールが変更されたときにURLを変更するには、`useLocale`フックで提供される`onLocaleChange`プロップを使用できます。同時に、`react-router-dom`の`useLocation`および`useNavigate`フックを使用してURLパスを更新できます。
|
|
1012
|
+
|
|
1013
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
1014
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
1015
|
+
import {
|
|
1016
|
+
Locales,
|
|
1017
|
+
getHTMLTextDir,
|
|
1018
|
+
getLocaleName,
|
|
1019
|
+
getLocalizedUrl,
|
|
1020
|
+
} from "intlayer";
|
|
1021
|
+
import { useLocale } from "react-intlayer";
|
|
1022
|
+
import { type FC } from "react";
|
|
1023
|
+
|
|
1024
|
+
const LocaleSwitcher: FC = () => {
|
|
1025
|
+
const { pathname, search } = useLocation(); // 現在のURLパスを取得。例: /fr/about?foo=bar
|
|
1026
|
+
const navigate = useNavigate();
|
|
1027
|
+
|
|
1028
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1029
|
+
onLocaleChange: (locale) => {
|
|
1030
|
+
// 更新されたロケールでURLを構築
|
|
1031
|
+
// 例: /es/about?foo=bar
|
|
1032
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
1033
|
+
|
|
1034
|
+
// URLパスを更新
|
|
1035
|
+
navigate(pathWithLocale);
|
|
1036
|
+
},
|
|
1037
|
+
});
|
|
1038
|
+
|
|
1039
|
+
return (
|
|
1040
|
+
<div>
|
|
1041
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1042
|
+
<div id="localePopover" popover="auto">
|
|
1043
|
+
{availableLocales.map((localeItem) => (
|
|
1044
|
+
<a
|
|
1045
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
1046
|
+
hrefLang={localeItem}
|
|
1047
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1048
|
+
onClick={(e) => {
|
|
1049
|
+
e.preventDefault();
|
|
1050
|
+
setLocale(localeItem);
|
|
1051
|
+
}}
|
|
1052
|
+
key={localeItem}
|
|
1053
|
+
>
|
|
1054
|
+
<span>
|
|
1055
|
+
{/* ロケール - 例: FR */}
|
|
1056
|
+
{localeItem}
|
|
1057
|
+
</span>
|
|
1058
|
+
<span>
|
|
1059
|
+
{/* 自身のロケールでの言語名 - 例: Français */}
|
|
1060
|
+
{getLocaleName(localeItem, locale)}
|
|
1061
|
+
</span>
|
|
1062
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1063
|
+
{/* 現在のロケールでの言語名 - 例: Francés (現在のロケールがLocales.SPANISHの場合) */}
|
|
1064
|
+
{getLocaleName(localeItem)}
|
|
1065
|
+
</span>
|
|
1066
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1067
|
+
{/* 英語での言語名 - 例: French */}
|
|
1068
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1069
|
+
</span>
|
|
1070
|
+
</a>
|
|
1071
|
+
))}
|
|
1072
|
+
</div>
|
|
1073
|
+
</div>
|
|
1074
|
+
);
|
|
1075
|
+
};
|
|
1076
|
+
```
|
|
1077
|
+
|
|
1078
|
+
```jsx fileName="src/components/LocaleSwitcher.msx" codeFormat="esm"
|
|
1079
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
1080
|
+
import {
|
|
1081
|
+
Locales,
|
|
1082
|
+
getHTMLTextDir,
|
|
1083
|
+
getLocaleName,
|
|
1084
|
+
getLocalizedUrl,
|
|
1085
|
+
} from "intlayer";
|
|
1086
|
+
import { useLocale } from "react-intlayer";
|
|
1087
|
+
|
|
1088
|
+
const LocaleSwitcher = () => {
|
|
1089
|
+
const { pathname, search } = useLocation(); // 現在のURLパスを取得。例: /fr/about?foo=bar
|
|
1090
|
+
const navigate = useNavigate();
|
|
1091
|
+
|
|
1092
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1093
|
+
onLocaleChange: (locale) => {
|
|
1094
|
+
// 更新されたロケールでURLを構築
|
|
1095
|
+
// 例: /es/about?foo=bar
|
|
1096
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
1097
|
+
|
|
1098
|
+
// URLパスを更新
|
|
1099
|
+
navigate(pathWithLocale);
|
|
1100
|
+
},
|
|
1101
|
+
});
|
|
1102
|
+
|
|
1103
|
+
return (
|
|
1104
|
+
<div>
|
|
1105
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1106
|
+
<div id="localePopover" popover="auto">
|
|
1107
|
+
{availableLocales.map((localeItem) => (
|
|
1108
|
+
<a
|
|
1109
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
1110
|
+
hrefLang={localeItem}
|
|
1111
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1112
|
+
onClick={(e) => {
|
|
1113
|
+
e.preventDefault();
|
|
1114
|
+
setLocale(localeItem);
|
|
1115
|
+
}}
|
|
1116
|
+
key={localeItem}
|
|
1117
|
+
>
|
|
1118
|
+
<span>
|
|
1119
|
+
{/* ロケール - 例: FR */}
|
|
1120
|
+
{localeItem}
|
|
1121
|
+
</span>
|
|
1122
|
+
<span>
|
|
1123
|
+
{/* 自身のロケールでの言語名 - 例: Français */}
|
|
1124
|
+
{getLocaleName(localeItem, locale)}
|
|
1125
|
+
</span>
|
|
1126
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1127
|
+
{/* 現在のロケールでの言語名 - 例: Francés (現在のロケールがLocales.SPANISHの場合) */}
|
|
1128
|
+
{getLocaleName(localeItem)}
|
|
1129
|
+
</span>
|
|
1130
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1131
|
+
{/* 英語での言語名 - 例: French */}
|
|
1132
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1133
|
+
</span>
|
|
1134
|
+
</a>
|
|
1135
|
+
))}
|
|
1136
|
+
</div>
|
|
1137
|
+
</div>
|
|
1138
|
+
);
|
|
1139
|
+
};
|
|
1140
|
+
```
|
|
1141
|
+
|
|
1142
|
+
```jsx fileName="src/components/LocaleSwitcher.csx" codeFormat="commonjs"
|
|
1143
|
+
const { useLocation, useNavigate } = require("react-router-dom");
|
|
1144
|
+
const {
|
|
1145
|
+
Locales,
|
|
1146
|
+
getHTMLTextDir,
|
|
1147
|
+
getLocaleName,
|
|
1148
|
+
getLocalizedUrl,
|
|
1149
|
+
} = require("intlayer");
|
|
1150
|
+
const { useLocale } = require("react-intlayer");
|
|
1151
|
+
|
|
1152
|
+
const LocaleSwitcher = () => {
|
|
1153
|
+
const { pathname, search } = useLocation(); // 現在のURLパスを取得。例: /fr/about?foo=bar
|
|
1154
|
+
const navigate = useNavigate();
|
|
1155
|
+
|
|
1156
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1157
|
+
onLocaleChange: (locale) => {
|
|
1158
|
+
// 更新されたロケールでURLを構築
|
|
1159
|
+
// 例: /es/about?foo=bar
|
|
1160
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
1161
|
+
|
|
1162
|
+
// URLパスを更新
|
|
1163
|
+
navigate(pathWithLocale);
|
|
1164
|
+
},
|
|
1165
|
+
});
|
|
1166
|
+
|
|
1167
|
+
return (
|
|
1168
|
+
<div>
|
|
1169
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1170
|
+
<div id="localePopover" popover="auto">
|
|
1171
|
+
{availableLocales.map((localeItem) => (
|
|
1172
|
+
<a
|
|
1173
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
1174
|
+
hrefLang={localeItem}
|
|
1175
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1176
|
+
onClick={(e) => {
|
|
1177
|
+
e.preventDefault();
|
|
1178
|
+
setLocale(localeItem);
|
|
1179
|
+
}}
|
|
1180
|
+
key={localeItem}
|
|
1181
|
+
>
|
|
1182
|
+
<span>
|
|
1183
|
+
{/* ロケール - 例: FR */}
|
|
1184
|
+
{localeItem}
|
|
1185
|
+
</span>
|
|
1186
|
+
<span>
|
|
1187
|
+
{/* 自身のロケールでの言語名 - 例: Français */}
|
|
1188
|
+
{getLocaleName(localeItem, locale)}
|
|
1189
|
+
</span>
|
|
1190
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1191
|
+
{/* 現在のロケールでの言語名 - 例: Francés (現在のロケールがLocales.SPANISHの場合) */}
|
|
1192
|
+
{getLocaleName(localeItem)}
|
|
1193
|
+
</span>
|
|
1194
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1195
|
+
{/* 英語での言語名 - 例: French */}
|
|
1196
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1197
|
+
</span>
|
|
1198
|
+
</a>
|
|
1199
|
+
))}
|
|
1200
|
+
</div>
|
|
1201
|
+
</div>
|
|
1202
|
+
);
|
|
1203
|
+
};
|
|
1204
|
+
```
|
|
1205
|
+
|
|
1206
|
+
> ドキュメント参照:
|
|
1207
|
+
|
|
1208
|
+
> - [`useLocale` フック](https://github.com/aymericzip/intlayer/blob/main/docs/ja/packages/react-intlayer/useLocale.md)
|
|
1209
|
+
|
|
1210
|
+
> - [`getLocaleName` フック](https://github.com/aymericzip/intlayer/blob/main/docs/ja/packages/intlayer/getLocaleName.md)
|
|
1211
|
+
|
|
1212
|
+
> - [`getLocalizedUrl` フック](https://github.com/aymericzip/intlayer/blob/main/docs/ja/packages/intlayer/getLocalizedUrl.md)
|
|
1213
|
+
|
|
1214
|
+
> - [`getHTMLTextDir` フック](https://github.com/aymericzip/intlayer/blob/main/docs/ja/packages/intlayer/getHTMLTextDir.md)
|
|
1215
|
+
|
|
1216
|
+
> - [`hrefLang` 属性](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
|
|
1217
|
+
|
|
1218
|
+
> - [`lang` 属性](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
|
|
1219
|
+
|
|
1220
|
+
> - [`dir` 属性](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
|
|
1221
|
+
|
|
1222
|
+
> - [`aria-current` 属性](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1223
|
+
|
|
1224
|
+
---
|
|
1225
|
+
|
|
1226
|
+
### (オプション) ステップ 9: HTMLの言語と方向属性を切り替える
|
|
1227
|
+
|
|
1228
|
+
アプリケーションが複数の言語をサポートしている場合、現在のロケールに合わせて `<html>` タグの `lang` および `dir` 属性を更新することが重要です。これにより以下が保証されます:
|
|
1229
|
+
|
|
1230
|
+
- **アクセシビリティ**: スクリーンリーダーや支援技術は正しい `lang` 属性に依存して、コンテンツを正確に発音・解釈します。
|
|
1231
|
+
- **テキストレンダリング**: `dir` (方向) 属性は、テキストが適切な順序でレンダリングされることを保証します(例: 英語は左から右、アラビア語やヘブライ語は右から左)。これは可読性にとって重要です。
|
|
1232
|
+
- **SEO**: 検索エンジンはページの言語を判断するために `lang` 属性を使用し、検索結果で適切なローカライズされたコンテンツを提供します。
|
|
1233
|
+
|
|
1234
|
+
ロケールが変更されるたびにこれらの属性を動的に更新することで、すべてのサポート言語で一貫性があり、アクセシブルなユーザー体験を提供できます。
|
|
1235
|
+
|
|
1236
|
+
#### フックの実装
|
|
1237
|
+
|
|
1238
|
+
カスタムフックを作成してHTML属性を管理します。このフックはロケールの変更を監視し、属性を適切に更新します:
|
|
1239
|
+
|
|
1240
|
+
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
|
|
1241
|
+
import { useEffect } from "react";
|
|
1242
|
+
import { useLocale } from "react-intlayer";
|
|
1243
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
|
|
1247
|
+
import { useEffect } from "react";
|
|
1248
|
+
import { useLocale } from "react-intlayer";
|
|
1249
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1250
|
+
|
|
1251
|
+
/**
|
|
1252
|
+
* 現在のロケールに基づいてHTML <html> 要素の `lang` と `dir` 属性を更新します。
|
|
1253
|
+
* - `lang`: ページの言語をブラウザや検索エンジンに通知します。
|
|
1254
|
+
* - `dir`: 正しい読み順を保証します(例: 英語の場合は 'ltr'、アラビア語の場合は 'rtl')。
|
|
1255
|
+
*
|
|
1256
|
+
* この動的な更新は、適切なテキストレンダリング、アクセシビリティ、SEOにとって重要です。
|
|
1257
|
+
*/
|
|
1258
|
+
export const useI18nHTMLAttributes = () => {
|
|
1259
|
+
const { locale } = useLocale();
|
|
1260
|
+
|
|
1261
|
+
useEffect(() => {
|
|
1262
|
+
// 言語属性を現在のロケールに更新します。
|
|
1263
|
+
document.documentElement.lang = locale;
|
|
1264
|
+
|
|
1265
|
+
// 現在のロケールに基づいてテキストの方向を設定します。
|
|
1266
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1267
|
+
}, [locale]);
|
|
1268
|
+
};
|
|
1269
|
+
```
|
|
1270
|
+
|
|
1271
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.csx" codeFormat="commonjs"
|
|
1272
|
+
const { useEffect } = require("react");
|
|
1273
|
+
const { useLocale } = require("react-intlayer");
|
|
1274
|
+
const { getHTMLTextDir } = require("intlayer");
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* 現在のロケールに基づいてHTML <html> 要素の `lang` と `dir` 属性を更新します。
|
|
1278
|
+
* - `lang`: ページの言語をブラウザや検索エンジンに通知します。
|
|
1279
|
+
* - `dir`: 正しい読み順を保証します(例: 英語の場合は 'ltr'、アラビア語の場合は 'rtl')。
|
|
1280
|
+
*
|
|
1281
|
+
* この動的な更新は、適切なテキストレンダリング、アクセシビリティ、SEOにとって重要です。
|
|
1282
|
+
*/
|
|
1283
|
+
const useI18nHTMLAttributes = () => {
|
|
1284
|
+
const { locale } = useLocale();
|
|
1285
|
+
|
|
1286
|
+
useEffect(() => {
|
|
1287
|
+
// 言語属性を現在のロケールに更新します。
|
|
1288
|
+
document.documentElement.lang = locale;
|
|
1289
|
+
|
|
1290
|
+
// 現在のロケールに基づいてテキストの方向を設定します。
|
|
1291
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1292
|
+
}, [locale]);
|
|
1293
|
+
};
|
|
1294
|
+
|
|
1295
|
+
module.exports = { useI18nHTMLAttributes };
|
|
1296
|
+
```
|
|
1297
|
+
|
|
1298
|
+
#### アプリケーションでフックを使用する
|
|
1299
|
+
|
|
1300
|
+
ロケールが変更されるたびにHTML属性が更新されるように、メインコンポーネントにフックを統合します。
|
|
1301
|
+
|
|
1302
|
+
```tsx fileName="src/App.tsx" codeFormat="typescript"
|
|
1303
|
+
import type { FC } from "react";
|
|
1304
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
1305
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1306
|
+
import "./App.css";
|
|
1307
|
+
|
|
1308
|
+
const AppContent: FC = () => {
|
|
1309
|
+
// フックを適用して、ロケールに基づいて <html> タグの lang と dir 属性を更新します。
|
|
1310
|
+
useI18nHTMLAttributes();
|
|
1311
|
+
|
|
1312
|
+
// ... 残りのコンポーネント
|
|
1313
|
+
};
|
|
1314
|
+
|
|
1315
|
+
const App: FC = () => (
|
|
1316
|
+
<IntlayerProvider>
|
|
1317
|
+
<AppContent />
|
|
1318
|
+
</IntlayerProvider>
|
|
1319
|
+
);
|
|
1320
|
+
|
|
1321
|
+
export default App;
|
|
1322
|
+
```
|
|
1323
|
+
|
|
1324
|
+
```jsx fileName="src/App.msx" codeFormat="esm"
|
|
1325
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
1326
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1327
|
+
import "./App.css";
|
|
1328
|
+
|
|
1329
|
+
const AppContent = () => {
|
|
1330
|
+
// フックを適用して、ロケールに基づいて <html> タグの lang と dir 属性を更新します。
|
|
1331
|
+
useI18nHTMLAttributes();
|
|
1332
|
+
|
|
1333
|
+
// ... 残りのコンポーネント
|
|
1334
|
+
};
|
|
1335
|
+
|
|
1336
|
+
const App = () => (
|
|
1337
|
+
<IntlayerProvider>
|
|
1338
|
+
<AppContent />
|
|
1339
|
+
</IntlayerProvider>
|
|
1340
|
+
);
|
|
1341
|
+
|
|
1342
|
+
export default App;
|
|
1343
|
+
```
|
|
1344
|
+
|
|
1345
|
+
```jsx fileName="src/App.csx" codeFormat="commonjs"
|
|
1346
|
+
const { FC } = require("react");
|
|
1347
|
+
const { IntlayerProvider, useIntlayer } = require("react-intlayer");
|
|
1348
|
+
const { useI18nHTMLAttributes } = require("./hooks/useI18nHTMLAttributes");
|
|
1349
|
+
require("./App.css");
|
|
1350
|
+
|
|
1351
|
+
const AppContent = () => {
|
|
1352
|
+
// フックを適用して、ロケールに基づいて <html> タグの lang と dir 属性を更新します。
|
|
1353
|
+
useI18nHTMLAttributes();
|
|
1354
|
+
|
|
1355
|
+
// ... 残りのコンポーネント
|
|
1356
|
+
};
|
|
1357
|
+
|
|
1358
|
+
const App = () => (
|
|
1359
|
+
<IntlayerProvider>
|
|
1360
|
+
<AppContent />
|
|
1361
|
+
</IntlayerProvider>
|
|
1362
|
+
);
|
|
1363
|
+
|
|
1364
|
+
module.exports = App;
|
|
1365
|
+
```
|
|
1366
|
+
|
|
1367
|
+
これらの変更を適用することで、アプリケーションは以下を実現します:
|
|
1368
|
+
|
|
1369
|
+
- 現在のロケールを正確に反映する **言語** (`lang`) 属性を保証し、SEOやブラウザの動作に重要な役割を果たします。
|
|
1370
|
+
- ロケールに応じて **テキストの方向** (`dir`) を調整し、異なる読み順を持つ言語の可読性と使いやすさを向上させます。
|
|
1371
|
+
- **アクセシビリティ** を向上させ、支援技術がこれらの属性に依存して最適に機能するようにします。
|
|
1372
|
+
|
|
1373
|
+
### (オプション)ステップ10: ローカライズされたリンクコンポーネントの作成
|
|
1374
|
+
|
|
1375
|
+
アプリケーションのナビゲーションが現在のロケールを尊重するようにするために、カスタム `Link` コンポーネントを作成できます。このコンポーネントは内部URLに自動的に現在の言語をプレフィックスとして付加します。例えば、フランス語を話すユーザーが「About」ページへのリンクをクリックすると、`/about` の代わりに `/fr/about` にリダイレクトされます。
|
|
1376
|
+
|
|
1377
|
+
この動作は以下の理由で有用です:
|
|
1378
|
+
|
|
1379
|
+
- **SEOとユーザーエクスペリエンス**: ローカライズされたURLは、検索エンジンが言語別のページを正確にインデックス化し、ユーザーに好みの言語でコンテンツを提供するのに役立ちます。
|
|
1380
|
+
- **一貫性**: アプリケーション全体でローカライズされたリンクを使用することで、ナビゲーションが現在のロケール内に留まり、予期しない言語切り替えを防ぎます。
|
|
1381
|
+
- **保守性**: URLのローカライズロジックを単一のコンポーネントに集中させることで、コードベースの管理が簡単になり、アプリケーションの成長に伴う拡張が容易になります。
|
|
1382
|
+
|
|
1383
|
+
以下は、TypeScriptで実装されたローカライズされた `Link` コンポーネントです:
|
|
1384
|
+
|
|
1385
|
+
```tsx fileName="src/components/Link.tsx" codeFormat="typescript"
|
|
1386
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1387
|
+
import {
|
|
1388
|
+
forwardRef,
|
|
1389
|
+
type DetailedHTMLProps,
|
|
1390
|
+
type AnchorHTMLAttributes,
|
|
1391
|
+
} from "react";
|
|
1392
|
+
import { useLocale } from "react-intlayer";
|
|
1393
|
+
|
|
1394
|
+
export interface LinkProps
|
|
1395
|
+
extends DetailedHTMLProps<
|
|
1396
|
+
AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
1397
|
+
HTMLAnchorElement
|
|
1398
|
+
> {}
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
* 指定されたURLが外部リンクかどうかを確認するユーティリティ関数。
|
|
1402
|
+
* URLが http:// または https:// で始まる場合、外部リンクと見なされます。
|
|
1403
|
+
*/
|
|
1404
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1405
|
+
/^https?:\/\//.test(href ?? "");
|
|
1406
|
+
|
|
1407
|
+
/**
|
|
1408
|
+
* 現在のロケールに基づいて href 属性を適応させるカスタム Link コンポーネント。
|
|
1409
|
+
* 内部リンクの場合、`getLocalizedUrl` を使用してURLにロケールをプレフィックスとして付加します(例: /fr/about)。
|
|
1410
|
+
* これにより、ナビゲーションが同じロケールコンテキスト内に留まることを保証します。
|
|
1411
|
+
*/
|
|
1412
|
+
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
1413
|
+
({ href, children, ...props }, ref) => {
|
|
1414
|
+
const { locale } = useLocale();
|
|
1415
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1416
|
+
|
|
1417
|
+
// リンクが内部リンクで有効な href が提供されている場合、ローカライズされたURLを取得します。
|
|
1418
|
+
const hrefI18n =
|
|
1419
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1420
|
+
|
|
1421
|
+
return (
|
|
1422
|
+
<a href={hrefI18n} ref={ref} {...props}>
|
|
1423
|
+
{children}
|
|
1424
|
+
</a>
|
|
1425
|
+
);
|
|
1426
|
+
}
|
|
1427
|
+
);
|
|
1428
|
+
|
|
1429
|
+
Link.displayName = "Link";
|
|
1430
|
+
```
|
|
1431
|
+
|
|
1432
|
+
```jsx fileName="src/components/Link.mjx" codeFormat="esm"
|
|
1433
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1434
|
+
import { useLocale } from "react-intlayer";
|
|
1435
|
+
import { forwardRef } from "react";
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* 指定されたURLが外部リンクかどうかを確認するユーティリティ関数。
|
|
1439
|
+
* URLが http:// または https:// で始まる場合、外部リンクと見なされます。
|
|
1440
|
+
*/
|
|
1441
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1442
|
+
/^https?:\/\//.test(href ?? "");
|
|
1443
|
+
|
|
1444
|
+
/**
|
|
1445
|
+
* 現在のロケールに基づいて href 属性を適応させるカスタム Link コンポーネント。
|
|
1446
|
+
* 内部リンクの場合、`getLocalizedUrl` を使用してURLにロケールをプレフィックスとして付加します(例: /fr/about)。
|
|
1447
|
+
* これにより、ナビゲーションが同じロケールコンテキスト内に留まることを保証します。
|
|
1448
|
+
*/
|
|
1449
|
+
export const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1450
|
+
|
|
1451
|
+
const { locale } = useLocale();
|
|
1452
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1453
|
+
|
|
1454
|
+
// リンクが内部リンクで有効な href が提供されている場合、ローカライズされた URL を取得します。
|
|
1455
|
+
const hrefI18n =
|
|
1456
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1457
|
+
|
|
1458
|
+
return (
|
|
1459
|
+
<a href={hrefI18n} ref={ref} {...props}>
|
|
1460
|
+
{children}
|
|
1461
|
+
</a>
|
|
1462
|
+
);
|
|
1463
|
+
});
|
|
1464
|
+
|
|
1465
|
+
Link.displayName = "Link";
|
|
1466
|
+
```
|
|
1467
|
+
|
|
1468
|
+
```jsx fileName="src/components/Link.csx" codeFormat="commonjs"
|
|
1469
|
+
const { getLocalizedUrl } = require("intlayer");
|
|
1470
|
+
const { useLocale } = require("react-intlayer");
|
|
1471
|
+
const { forwardRef } = require("react");
|
|
1472
|
+
|
|
1473
|
+
/**
|
|
1474
|
+
* 指定された URL が外部リンクかどうかを確認するユーティリティ関数。
|
|
1475
|
+
* URL が http:// または https:// で始まる場合、それは外部リンクと見なされます。
|
|
1476
|
+
*/
|
|
1477
|
+
const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1478
|
+
|
|
1479
|
+
/**
|
|
1480
|
+
* 現在のロケールに基づいて href 属性を適応させるカスタム Link コンポーネント。
|
|
1481
|
+
* 内部リンクの場合、`getLocalizedUrl` を使用して URL にロケールをプレフィックスします (例: /ja/about)。
|
|
1482
|
+
* これにより、ナビゲーションが同じロケールコンテキスト内に留まることが保証されます。
|
|
1483
|
+
*/
|
|
1484
|
+
const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1485
|
+
const { locale } = useLocale();
|
|
1486
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1487
|
+
|
|
1488
|
+
// リンクが内部リンクで有効な href が提供されている場合、ローカライズされた URL を取得します。
|
|
1489
|
+
const localizedHref = isExternalLink ? href : getLocalizedUrl(href, locale);
|
|
1490
|
+
|
|
1491
|
+
return (
|
|
1492
|
+
<a
|
|
1493
|
+
href={localizedHref}
|
|
1494
|
+
ref={ref}
|
|
1495
|
+
{...props}
|
|
1496
|
+
aria-current={isExternalLink ? "external" : undefined}
|
|
1497
|
+
>
|
|
1498
|
+
{children}
|
|
1499
|
+
</a>
|
|
1500
|
+
);
|
|
1501
|
+
});
|
|
1502
|
+
|
|
1503
|
+
Link.displayName = "Link";
|
|
1504
|
+
```
|
|
1505
|
+
|
|
1506
|
+
#### 動作の仕組み
|
|
1507
|
+
|
|
1508
|
+
- **外部リンクの検出**:
|
|
1509
|
+
ヘルパー関数 `checkIsExternalLink` は URL が外部リンクかどうかを判定します。外部リンクはローカライズを必要としないため、そのまま変更されません。
|
|
1510
|
+
|
|
1511
|
+
- **現在のロケールの取得**:
|
|
1512
|
+
`useLocale` フックは現在のロケール (例: フランス語の場合は `fr`) を提供します。
|
|
1513
|
+
|
|
1514
|
+
- **URL のローカライズ**:
|
|
1515
|
+
内部リンク (外部でないリンク) の場合、`getLocalizedUrl` を使用して URL に現在のロケールを自動的にプレフィックスします。これにより、ユーザーがフランス語を使用している場合、`/about` を `href` として渡すと `/fr/about` に変換されます。
|
|
1516
|
+
|
|
1517
|
+
- **リンクの返却**:
|
|
1518
|
+
コンポーネントはローカライズされた URL を持つ `<a>` 要素を返し、ロケールに一致したナビゲーションを保証します。
|
|
1519
|
+
|
|
1520
|
+
この `Link` コンポーネントをアプリケーション全体で統合することで、一貫性があり言語に配慮したユーザー体験を維持しつつ、SEO と使いやすさを向上させることができます。
|
|
1521
|
+
|
|
1522
|
+
### TypeScript の設定
|
|
1523
|
+
|
|
1524
|
+
Intlayer はモジュール拡張を使用して TypeScript の利点を活用し、コードベースを強化します。
|
|
1525
|
+
|
|
1526
|
+

|
|
1527
|
+
|
|
1528
|
+

|
|
1529
|
+
|
|
1530
|
+
TypeScript 設定に自動生成された型を含めてください。
|
|
1531
|
+
|
|
1532
|
+
```json5 fileName="tsconfig.json"
|
|
1533
|
+
{
|
|
1534
|
+
// ... 既存の TypeScript 設定
|
|
1535
|
+
"include": [
|
|
1536
|
+
// ... 既存の TypeScript 設定
|
|
1537
|
+
".intlayer/**/*.ts", // 自動生成された型を含める
|
|
1538
|
+
],
|
|
1539
|
+
}
|
|
1540
|
+
```
|
|
1541
|
+
|
|
1542
|
+
### Git の設定
|
|
1543
|
+
|
|
1544
|
+
Intlayer によって生成されたファイルを無視することをお勧めします。これにより、それらを Git リポジトリにコミットするのを避けることができます。
|
|
1545
|
+
|
|
1546
|
+
これを行うには、以下の指示を `.gitignore` ファイルに追加します:
|
|
1547
|
+
|
|
1548
|
+
```plaintext
|
|
1549
|
+
# Intlayer によって生成されたファイルを無視
|
|
1550
|
+
.intlayer
|
|
1551
|
+
```
|
|
1552
|
+
|
|
1553
|
+
### さらに進む
|
|
1554
|
+
|
|
1555
|
+
さらに進むために、[ビジュアルエディター](https://github.com/aymericzip/intlayer/blob/main/docs/ja/intlayer_visual_editor.md) を実装するか、[CMS](https://github.com/aymericzip/intlayer/blob/main/docs/ja/intlayer_CMS.md) を使用してコンテンツを外部化することができます。
|