@intlayer/docs 7.0.6 → 7.0.8-canary.0
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/blog/ar/i18n_using_next-i18next.md +1068 -0
- package/blog/ar/i18n_using_next-intl.md +768 -0
- package/blog/ar/intlayer_with_react-intl.md +0 -4
- package/blog/ar/next-i18next_vs_next-intl_vs_intlayer.md +5 -4
- package/blog/de/i18n_using_next-i18next.md +1107 -0
- package/blog/de/i18n_using_next-intl.md +760 -0
- package/blog/de/intlayer_with_react-intl.md +0 -4
- package/blog/de/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/en/i18n_using_next-i18next.md +1073 -0
- package/blog/en/i18n_using_next-intl.md +757 -0
- package/blog/en/intlayer_with_i18next.md +71 -8
- package/blog/en/intlayer_with_next-i18next.md +71 -8
- package/blog/en/intlayer_with_next-intl.md +71 -8
- package/blog/en/intlayer_with_react-i18next.md +69 -8
- package/blog/en/intlayer_with_react-intl.md +68 -9
- package/blog/en/intlayer_with_vue-i18n.md +68 -7
- package/blog/en/react-i18next_vs_react-intl_vs_intlayer.md +2 -0
- package/blog/en/vue-i18n_vs_intlayer.md +2 -0
- package/blog/en-GB/i18n_using_next-i18next.md +1074 -0
- package/blog/en-GB/i18n_using_next-intl.md +757 -0
- package/blog/en-GB/intlayer_with_i18next.md +15 -6
- package/blog/en-GB/intlayer_with_next-i18next.md +16 -6
- package/blog/en-GB/intlayer_with_next-intl.md +16 -6
- package/blog/en-GB/intlayer_with_react-i18next.md +16 -7
- package/blog/en-GB/intlayer_with_react-intl.md +14 -9
- package/blog/en-GB/intlayer_with_vue-i18n.md +16 -7
- package/blog/en-GB/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/en-GB/react-i18next_vs_react-intl_vs_intlayer.md +2 -0
- package/blog/en-GB/vue-i18n_vs_intlayer.md +2 -0
- package/blog/es/i18n_using_next-i18next.md +1066 -0
- package/blog/es/i18n_using_next-intl.md +757 -0
- package/blog/es/intlayer_with_react-intl.md +0 -4
- package/blog/es/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/fr/i18n_using_next-i18next.md +1078 -0
- package/blog/fr/i18n_using_next-intl.md +759 -0
- package/blog/fr/intlayer_with_react-intl.md +0 -4
- package/blog/fr/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/hi/i18n_using_next-i18next.md +1068 -0
- package/blog/hi/i18n_using_next-intl.md +758 -0
- package/blog/hi/intlayer_with_react-intl.md +0 -4
- package/blog/hi/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/id/i18n_using_next-i18next.md +1078 -0
- package/blog/id/i18n_using_next-intl.md +757 -0
- package/blog/id/index.md +69 -0
- package/blog/id/internationalization_and_SEO.md +364 -0
- package/blog/id/intlayer_with_react-intl.md +0 -4
- package/blog/id/list_i18n_technologies/CMS/drupal.md +143 -0
- package/blog/id/list_i18n_technologies/CMS/wix.md +167 -0
- package/blog/id/list_i18n_technologies/CMS/wordpress.md +188 -0
- package/blog/id/list_i18n_technologies/frameworks/angular.md +125 -0
- package/blog/id/list_i18n_technologies/frameworks/flutter.md +150 -0
- package/blog/id/list_i18n_technologies/frameworks/react-native.md +217 -0
- package/blog/id/list_i18n_technologies/frameworks/react.md +155 -0
- package/blog/id/list_i18n_technologies/frameworks/svelte.md +131 -0
- package/blog/id/list_i18n_technologies/frameworks/vue.md +130 -0
- package/blog/id/next-i18next_vs_next-intl_vs_intlayer.md +1500 -0
- package/blog/id/nextjs-multilingual-seo-comparison.md +361 -0
- package/blog/id/rag_powered_documentation_assistant.md +288 -0
- package/blog/id/react-i18next_vs_react-intl_vs_intlayer.md +164 -0
- package/blog/id/vue-i18n_vs_intlayer.md +278 -0
- package/blog/id/what_is_internationalization.md +166 -0
- package/blog/it/i18n_using_next-i18next.md +1078 -0
- package/blog/it/i18n_using_next-intl.md +758 -0
- package/blog/it/intlayer_with_react-intl.md +0 -4
- package/blog/it/react-i18next_vs_react-intl_vs_intlayer.md +4 -0
- package/blog/it/vue-i18n_vs_intlayer.md +2 -0
- package/blog/ja/i18n_using_next-i18next.md +1078 -0
- package/blog/ja/i18n_using_next-intl.md +758 -0
- package/blog/ja/intlayer_with_react-intl.md +0 -4
- package/blog/ja/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/ko/i18n_using_next-i18next.md +1075 -0
- package/blog/ko/i18n_using_next-intl.md +759 -0
- package/blog/ko/intlayer_with_react-intl.md +0 -4
- package/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/pl/i18n_using_next-i18next.md +1078 -0
- package/blog/pl/i18n_using_next-intl.md +758 -0
- package/blog/pl/index.md +69 -0
- package/blog/pl/internationalization_and_SEO.md +363 -0
- package/blog/pl/intlayer_with_react-intl.md +0 -4
- package/blog/pl/list_i18n_technologies/CMS/drupal.md +143 -0
- package/blog/pl/list_i18n_technologies/CMS/wix.md +167 -0
- package/blog/pl/list_i18n_technologies/CMS/wordpress.md +196 -0
- package/blog/pl/list_i18n_technologies/frameworks/angular.md +125 -0
- package/blog/pl/list_i18n_technologies/frameworks/flutter.md +151 -0
- package/blog/pl/list_i18n_technologies/frameworks/react-native.md +217 -0
- package/blog/pl/list_i18n_technologies/frameworks/react.md +155 -0
- package/blog/pl/list_i18n_technologies/frameworks/svelte.md +131 -0
- package/blog/pl/list_i18n_technologies/frameworks/vue.md +130 -0
- package/blog/pl/next-i18next_vs_next-intl_vs_intlayer.md +1501 -0
- package/blog/pl/nextjs-multilingual-seo-comparison.md +362 -0
- package/blog/pl/rag_powered_documentation_assistant.md +288 -0
- package/blog/pl/react-i18next_vs_react-intl_vs_intlayer.md +164 -0
- package/blog/pl/vue-i18n_vs_intlayer.md +278 -0
- package/blog/pl/what_is_internationalization.md +167 -0
- package/blog/pt/i18n_using_next-i18next.md +1067 -0
- package/blog/pt/i18n_using_next-intl.md +760 -0
- package/blog/pt/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/ru/i18n_using_next-i18next.md +1106 -0
- package/blog/ru/i18n_using_next-intl.md +759 -0
- package/blog/ru/intlayer_with_react-intl.md +0 -4
- package/blog/ru/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/tr/i18n_using_next-i18next.md +1078 -0
- package/blog/tr/i18n_using_next-intl.md +760 -0
- package/blog/tr/intlayer_with_react-intl.md +0 -4
- package/blog/tr/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/tr/react-i18next_vs_react-intl_vs_intlayer.md +2 -0
- package/blog/tr/vue-i18n_vs_intlayer.md +2 -0
- package/blog/vi/i18n_using_next-i18next.md +1080 -0
- package/blog/vi/i18n_using_next-intl.md +758 -0
- package/blog/vi/index.md +69 -0
- package/blog/vi/internationalization_and_SEO.md +363 -0
- package/blog/vi/intlayer_with_react-intl.md +0 -4
- package/blog/vi/list_i18n_technologies/CMS/drupal.md +143 -0
- package/blog/vi/list_i18n_technologies/CMS/wix.md +167 -0
- package/blog/vi/list_i18n_technologies/CMS/wordpress.md +188 -0
- package/blog/vi/list_i18n_technologies/frameworks/angular.md +125 -0
- package/blog/vi/list_i18n_technologies/frameworks/flutter.md +150 -0
- package/blog/vi/list_i18n_technologies/frameworks/react-native.md +217 -0
- package/blog/vi/list_i18n_technologies/frameworks/react.md +155 -0
- package/blog/vi/list_i18n_technologies/frameworks/svelte.md +131 -0
- package/blog/vi/list_i18n_technologies/frameworks/vue.md +130 -0
- package/blog/vi/next-i18next_vs_next-intl_vs_intlayer.md +1520 -0
- package/blog/vi/nextjs-multilingual-seo-comparison.md +362 -0
- package/blog/vi/rag_powered_documentation_assistant.md +288 -0
- package/blog/vi/react-i18next_vs_react-intl_vs_intlayer.md +164 -0
- package/blog/vi/vue-i18n_vs_intlayer.md +278 -0
- package/blog/vi/what_is_internationalization.md +168 -0
- package/blog/zh/i18n_using_next-i18next.md +1105 -0
- package/blog/zh/i18n_using_next-intl.md +758 -0
- package/blog/zh/intlayer_with_react-intl.md +0 -4
- package/blog/zh/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/zh/react-i18next_vs_react-intl_vs_intlayer.md +2 -0
- package/dist/cjs/common.cjs +0 -4
- package/dist/cjs/common.cjs.map +1 -1
- package/dist/cjs/generated/blog.entry.cjs +38 -6
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/cjs/generated/docs.entry.cjs +0 -6
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/cjs/generated/frequentQuestions.entry.cjs +0 -6
- package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
- package/dist/cjs/generated/legal.entry.cjs +0 -6
- package/dist/cjs/generated/legal.entry.cjs.map +1 -1
- package/dist/esm/generated/blog.entry.mjs +38 -0
- package/dist/esm/generated/blog.entry.mjs.map +1 -1
- package/dist/types/generated/blog.entry.d.ts +2 -0
- package/dist/types/generated/blog.entry.d.ts.map +1 -1
- package/docs/ar/component_i18n.md +1 -1
- package/docs/ar/configuration.md +6 -0
- package/docs/ar/intlayer_cli.md +8 -3
- package/docs/ar/intlayer_with_next-i18next.md +619 -0
- package/docs/ar/intlayer_with_next-intl.md +446 -0
- package/docs/ar/intlayer_with_nextjs_16.md +21 -0
- package/docs/ar/intlayer_with_tanstack.md +4 -0
- package/docs/ar/intlayer_with_vite+react.md +4 -0
- package/docs/de/component_i18n.md +1 -1
- package/docs/de/configuration.md +6 -0
- package/docs/de/intlayer_cli.md +8 -3
- package/docs/de/intlayer_with_next-i18next.md +627 -0
- package/docs/de/intlayer_with_next-intl.md +451 -0
- package/docs/de/intlayer_with_nextjs_16.md +21 -0
- package/docs/de/intlayer_with_tanstack.md +4 -0
- package/docs/de/intlayer_with_vite+react.md +4 -0
- package/docs/en/component_i18n.md +1 -1
- package/docs/en/intlayer_cli.md +8 -1
- package/docs/en/intlayer_with_astro.md +10 -2
- package/docs/en/intlayer_with_create_react_app.md +8 -0
- package/docs/en/intlayer_with_lynx+react.md +8 -0
- package/docs/en/intlayer_with_nestjs.md +10 -0
- package/docs/en/intlayer_with_nextjs_14.md +10 -2
- package/docs/en/intlayer_with_nextjs_15.md +21 -4
- package/docs/en/intlayer_with_nextjs_16.md +17 -0
- package/docs/en/intlayer_with_nuxt.md +8 -0
- package/docs/en/intlayer_with_react_native+expo.md +10 -2
- package/docs/en/intlayer_with_react_router_v7.md +8 -0
- package/docs/en/intlayer_with_tanstack.md +10 -0
- package/docs/en/intlayer_with_vite+preact.md +10 -2
- package/docs/en/intlayer_with_vite+react.md +21 -4
- package/docs/en/intlayer_with_vite+vue.md +10 -2
- package/docs/en-GB/component_i18n.md +1 -1
- package/docs/en-GB/configuration.md +6 -0
- package/docs/en-GB/intlayer_cli.md +8 -3
- package/docs/en-GB/intlayer_with_angular.md +4 -4
- package/docs/en-GB/intlayer_with_express.md +4 -4
- package/docs/en-GB/intlayer_with_lynx+react.md +12 -12
- package/{blog/en/_intlayer_with_next-i18next.md → docs/en-GB/intlayer_with_next-i18next.md} +241 -42
- package/{blog/en/_intlayer_with_next-intl.md → docs/en-GB/intlayer_with_next-intl.md} +144 -29
- package/docs/en-GB/intlayer_with_nextjs_16.md +21 -0
- package/docs/en-GB/intlayer_with_tanstack.md +5 -1
- package/docs/en-GB/intlayer_with_vite+react.md +4 -0
- package/docs/en-GB/packages/next-intlayer/t.md +2 -2
- package/docs/es/component_i18n.md +1 -1
- package/docs/es/configuration.md +6 -0
- package/docs/es/intlayer_cli.md +8 -3
- package/docs/es/intlayer_with_next-i18next.md +628 -0
- package/docs/es/intlayer_with_next-intl.md +446 -0
- package/docs/es/intlayer_with_nextjs_16.md +21 -0
- package/docs/es/intlayer_with_tanstack.md +4 -0
- package/docs/es/intlayer_with_vite+react.md +4 -0
- package/docs/fr/configuration.md +6 -0
- package/docs/fr/intlayer_cli.md +8 -3
- package/docs/fr/intlayer_with_next-i18next.md +628 -0
- package/docs/fr/intlayer_with_next-intl.md +446 -0
- package/docs/fr/intlayer_with_nextjs_16.md +23 -2
- package/docs/fr/intlayer_with_tanstack.md +4 -0
- package/docs/fr/intlayer_with_vite+react.md +4 -0
- package/docs/hi/component_i18n.md +1 -1
- package/docs/hi/configuration.md +6 -0
- package/docs/hi/intlayer_cli.md +8 -0
- package/docs/hi/intlayer_with_next-i18next.md +628 -0
- package/docs/hi/intlayer_with_next-intl.md +446 -0
- package/docs/hi/intlayer_with_nextjs_16.md +21 -0
- package/docs/hi/intlayer_with_tanstack.md +4 -0
- package/docs/hi/intlayer_with_vite+react.md +4 -0
- package/docs/id/CI_CD.md +198 -0
- package/docs/id/autoFill.md +284 -0
- package/docs/id/component_i18n.md +186 -0
- package/docs/id/configuration.md +710 -0
- package/docs/id/dictionary/condition.md +231 -0
- package/docs/id/dictionary/content_file.md +1092 -0
- package/docs/id/dictionary/enumeration.md +245 -0
- package/docs/id/dictionary/file.md +237 -0
- package/docs/id/dictionary/function_fetching.md +214 -0
- package/docs/id/dictionary/gender.md +273 -0
- package/docs/id/dictionary/insertion.md +192 -0
- package/docs/id/dictionary/markdown.md +381 -0
- package/docs/id/dictionary/nesting.md +273 -0
- package/docs/id/dictionary/translation.md +310 -0
- package/docs/id/formatters.md +596 -0
- package/docs/id/how_works_intlayer.md +256 -0
- package/docs/id/index.md +176 -0
- package/docs/id/interest_of_intlayer.md +293 -0
- package/docs/id/intlayer_CMS.md +549 -0
- package/docs/id/intlayer_cli.md +850 -0
- package/docs/id/intlayer_visual_editor.md +288 -0
- package/docs/id/intlayer_with_angular.md +694 -0
- package/docs/id/intlayer_with_astro.md +252 -0
- package/docs/id/intlayer_with_create_react_app.md +1233 -0
- package/docs/id/intlayer_with_express.md +411 -0
- package/docs/id/intlayer_with_lynx+react.md +518 -0
- package/docs/id/intlayer_with_nestjs.md +272 -0
- package/docs/id/intlayer_with_next-i18next.md +628 -0
- package/docs/id/intlayer_with_next-intl.md +446 -0
- package/docs/id/intlayer_with_nextjs_14.md +1617 -0
- package/docs/id/intlayer_with_nextjs_15.md +1698 -0
- package/docs/id/intlayer_with_nextjs_16.md +21 -0
- package/docs/id/intlayer_with_nextjs_page_router.md +1478 -0
- package/docs/id/intlayer_with_nuxt.md +808 -0
- package/docs/id/intlayer_with_react_native+expo.md +699 -0
- package/docs/id/intlayer_with_react_router_v7.md +496 -0
- package/docs/id/intlayer_with_tanstack.md +564 -0
- package/docs/id/intlayer_with_vite+preact.md +1737 -0
- package/docs/id/intlayer_with_vite+react.md +1413 -0
- package/docs/id/intlayer_with_vite+solid.md +289 -0
- package/docs/id/intlayer_with_vite+svelte.md +289 -0
- package/docs/id/intlayer_with_vite+vue.md +1088 -0
- package/docs/id/introduction.md +218 -0
- package/docs/id/locale_mapper.md +242 -0
- package/docs/id/mcp_server.md +211 -0
- package/docs/id/packages/express-intlayer/t.md +458 -0
- package/docs/id/packages/intlayer/getConfiguration.md +145 -0
- package/docs/id/packages/intlayer/getEnumeration.md +159 -0
- package/docs/id/packages/intlayer/getHTMLTextDir.md +122 -0
- package/docs/id/packages/intlayer/getLocaleLang.md +81 -0
- package/docs/id/packages/intlayer/getLocaleName.md +119 -0
- package/docs/id/packages/intlayer/getLocalizedUrl.md +309 -0
- package/docs/id/packages/intlayer/getMultilingualUrls.md +223 -0
- package/docs/id/packages/intlayer/getPathWithoutLocale.md +75 -0
- package/docs/id/packages/intlayer/getTranslation.md +190 -0
- package/docs/id/packages/intlayer/getTranslationContent.md +188 -0
- package/docs/id/packages/next-intlayer/t.md +352 -0
- package/docs/id/packages/next-intlayer/useDictionary.md +271 -0
- package/docs/id/packages/next-intlayer/useIntlayer.md +264 -0
- package/docs/id/packages/next-intlayer/useLocale.md +166 -0
- package/docs/id/packages/react-intlayer/t.md +303 -0
- package/docs/id/packages/react-intlayer/useDictionary.md +287 -0
- package/docs/id/packages/react-intlayer/useI18n.md +267 -0
- package/docs/id/packages/react-intlayer/useIntlayer.md +254 -0
- package/docs/id/packages/react-intlayer/useLocale.md +210 -0
- package/docs/id/per_locale_file.md +323 -0
- package/docs/id/readme.md +261 -0
- package/docs/id/releases/v6.md +305 -0
- package/docs/id/roadmap.md +362 -0
- package/docs/id/testing.md +202 -0
- package/docs/id/vs_code_extension.md +126 -0
- package/docs/it/component_i18n.md +1 -1
- package/docs/it/configuration.md +6 -0
- package/docs/it/intlayer_cli.md +8 -3
- package/docs/it/intlayer_with_next-i18next.md +628 -0
- package/docs/it/intlayer_with_next-intl.md +446 -0
- package/docs/it/intlayer_with_nextjs_16.md +21 -0
- package/docs/it/intlayer_with_tanstack.md +4 -0
- package/docs/it/intlayer_with_vite+react.md +4 -0
- package/docs/ja/component_i18n.md +1 -1
- package/docs/ja/configuration.md +6 -0
- package/docs/ja/intlayer_cli.md +8 -3
- package/docs/ja/intlayer_with_next-i18next.md +627 -0
- package/docs/ja/intlayer_with_next-intl.md +446 -0
- package/docs/ja/intlayer_with_nextjs_16.md +21 -0
- package/docs/ja/intlayer_with_tanstack.md +4 -0
- package/docs/ja/intlayer_with_vite+react.md +4 -0
- package/docs/ko/configuration.md +6 -0
- package/docs/ko/intlayer_cli.md +8 -3
- package/docs/ko/intlayer_with_next-i18next.md +627 -0
- package/docs/ko/intlayer_with_next-intl.md +446 -0
- package/docs/ko/intlayer_with_nextjs_16.md +21 -0
- package/docs/ko/intlayer_with_tanstack.md +4 -0
- package/docs/ko/intlayer_with_vite+react.md +4 -0
- package/docs/pl/CI_CD.md +198 -0
- package/docs/pl/autoFill.md +284 -0
- package/docs/pl/component_i18n.md +186 -0
- package/docs/pl/configuration.md +710 -0
- package/docs/pl/dictionary/condition.md +232 -0
- package/docs/pl/dictionary/content_file.md +1130 -0
- package/docs/pl/dictionary/enumeration.md +245 -0
- package/docs/pl/dictionary/file.md +234 -0
- package/docs/pl/dictionary/function_fetching.md +214 -0
- package/docs/pl/dictionary/gender.md +276 -0
- package/docs/pl/dictionary/insertion.md +188 -0
- package/docs/pl/dictionary/markdown.md +408 -0
- package/docs/pl/dictionary/nesting.md +273 -0
- package/docs/pl/dictionary/translation.md +310 -0
- package/docs/pl/formatters.md +596 -0
- package/docs/pl/how_works_intlayer.md +256 -0
- package/docs/pl/index.md +176 -0
- package/docs/pl/interest_of_intlayer.md +291 -0
- package/docs/pl/intlayer_CMS.md +549 -0
- package/docs/pl/intlayer_cli.md +857 -0
- package/docs/pl/intlayer_visual_editor.md +288 -0
- package/docs/pl/intlayer_with_angular.md +690 -0
- package/docs/pl/intlayer_with_astro.md +280 -0
- package/docs/pl/intlayer_with_create_react_app.md +1235 -0
- package/docs/pl/intlayer_with_express.md +411 -0
- package/docs/pl/intlayer_with_lynx+react.md +518 -0
- package/docs/pl/intlayer_with_nestjs.md +272 -0
- package/docs/pl/intlayer_with_next-i18next.md +628 -0
- package/docs/pl/intlayer_with_next-intl.md +446 -0
- package/docs/pl/intlayer_with_nextjs_14.md +1594 -0
- package/docs/pl/intlayer_with_nextjs_15.md +1701 -0
- package/docs/pl/intlayer_with_nextjs_16.md +21 -0
- package/docs/pl/intlayer_with_nextjs_page_router.md +1513 -0
- package/docs/pl/intlayer_with_nuxt.md +885 -0
- package/docs/pl/intlayer_with_react_native+expo.md +698 -0
- package/docs/pl/intlayer_with_react_router_v7.md +503 -0
- package/docs/pl/intlayer_with_tanstack.md +562 -0
- package/docs/pl/intlayer_with_vite+preact.md +1736 -0
- package/docs/pl/intlayer_with_vite+react.md +1438 -0
- package/docs/pl/intlayer_with_vite+solid.md +290 -0
- package/docs/pl/intlayer_with_vite+svelte.md +289 -0
- package/docs/pl/intlayer_with_vite+vue.md +1116 -0
- package/docs/pl/introduction.md +209 -0
- package/docs/pl/locale_mapper.md +242 -0
- package/docs/pl/mcp_server.md +211 -0
- package/docs/pl/packages/express-intlayer/t.md +458 -0
- package/docs/pl/packages/intlayer/getConfiguration.md +146 -0
- package/docs/pl/packages/intlayer/getEnumeration.md +160 -0
- package/docs/pl/packages/intlayer/getHTMLTextDir.md +121 -0
- package/docs/pl/packages/intlayer/getLocaleLang.md +81 -0
- package/docs/pl/packages/intlayer/getLocaleName.md +118 -0
- package/docs/pl/packages/intlayer/getLocalizedUrl.md +300 -0
- package/docs/pl/packages/intlayer/getMultilingualUrls.md +221 -0
- package/docs/pl/packages/intlayer/getPathWithoutLocale.md +75 -0
- package/docs/pl/packages/intlayer/getTranslation.md +190 -0
- package/docs/pl/packages/intlayer/getTranslationContent.md +189 -0
- package/docs/pl/packages/next-intlayer/t.md +353 -0
- package/docs/pl/packages/next-intlayer/useDictionary.md +270 -0
- package/docs/pl/packages/next-intlayer/useIntlayer.md +263 -0
- package/docs/pl/packages/next-intlayer/useLocale.md +166 -0
- package/docs/pl/packages/react-intlayer/t.md +303 -0
- package/docs/pl/packages/react-intlayer/useDictionary.md +289 -0
- package/docs/pl/packages/react-intlayer/useI18n.md +249 -0
- package/docs/pl/packages/react-intlayer/useIntlayer.md +256 -0
- package/docs/pl/packages/react-intlayer/useLocale.md +210 -0
- package/docs/pl/per_locale_file.md +321 -0
- package/docs/pl/readme.md +261 -0
- package/docs/pl/releases/v6.md +305 -0
- package/docs/pl/roadmap.md +362 -0
- package/docs/pl/testing.md +202 -0
- package/docs/pl/vs_code_extension.md +126 -0
- package/docs/pt/component_i18n.md +1 -1
- package/docs/pt/configuration.md +6 -0
- package/docs/pt/intlayer_cli.md +8 -3
- package/docs/pt/intlayer_with_next-i18next.md +627 -0
- package/docs/pt/intlayer_with_next-intl.md +446 -0
- package/docs/pt/intlayer_with_nextjs_16.md +21 -0
- package/docs/pt/intlayer_with_tanstack.md +4 -0
- package/docs/pt/intlayer_with_vite+react.md +4 -0
- package/docs/ru/component_i18n.md +1 -1
- package/docs/ru/configuration.md +6 -0
- package/docs/ru/intlayer_cli.md +301 -22
- package/docs/ru/intlayer_with_next-i18next.md +629 -0
- package/docs/ru/intlayer_with_next-intl.md +448 -0
- package/docs/ru/intlayer_with_nextjs_16.md +21 -0
- package/docs/ru/intlayer_with_tanstack.md +4 -0
- package/docs/ru/intlayer_with_vite+react.md +4 -0
- package/docs/tr/component_i18n.md +1 -1
- package/docs/tr/configuration.md +6 -0
- package/docs/tr/intlayer_cli.md +8 -0
- package/docs/tr/intlayer_with_next-i18next.md +627 -0
- package/docs/tr/intlayer_with_next-intl.md +446 -0
- package/docs/tr/intlayer_with_nextjs_16.md +21 -0
- package/docs/tr/intlayer_with_tanstack.md +4 -0
- package/docs/tr/intlayer_with_vite+react.md +4 -0
- package/docs/vi/CI_CD.md +198 -0
- package/docs/vi/autoFill.md +284 -0
- package/docs/vi/component_i18n.md +186 -0
- package/docs/vi/configuration.md +710 -0
- package/docs/vi/dictionary/condition.md +237 -0
- package/docs/vi/dictionary/content_file.md +1115 -0
- package/docs/vi/dictionary/enumeration.md +255 -0
- package/docs/vi/dictionary/file.md +234 -0
- package/docs/vi/dictionary/function_fetching.md +212 -0
- package/docs/vi/dictionary/gender.md +275 -0
- package/docs/vi/dictionary/insertion.md +191 -0
- package/docs/vi/dictionary/markdown.md +381 -0
- package/docs/vi/dictionary/nesting.md +273 -0
- package/docs/vi/dictionary/translation.md +309 -0
- package/docs/vi/formatters.md +595 -0
- package/docs/vi/how_works_intlayer.md +256 -0
- package/docs/vi/index.md +174 -0
- package/docs/vi/interest_of_intlayer.md +292 -0
- package/docs/vi/intlayer_CMS.md +549 -0
- package/docs/vi/intlayer_cli.md +850 -0
- package/docs/vi/intlayer_visual_editor.md +288 -0
- package/docs/vi/intlayer_with_angular.md +692 -0
- package/docs/vi/intlayer_with_astro.md +252 -0
- package/docs/vi/intlayer_with_create_react_app.md +1230 -0
- package/docs/vi/intlayer_with_express.md +409 -0
- package/docs/vi/intlayer_with_lynx+react.md +520 -0
- package/docs/vi/intlayer_with_nestjs.md +272 -0
- package/docs/vi/intlayer_with_next-i18next.md +628 -0
- package/docs/vi/intlayer_with_next-intl.md +446 -0
- package/docs/vi/intlayer_with_nextjs_14.md +1584 -0
- package/docs/vi/intlayer_with_nextjs_15.md +1738 -0
- package/docs/vi/intlayer_with_nextjs_16.md +21 -0
- package/docs/vi/intlayer_with_nextjs_page_router.md +1504 -0
- package/docs/vi/intlayer_with_nuxt.md +821 -0
- package/docs/vi/intlayer_with_react_native+expo.md +700 -0
- package/docs/vi/intlayer_with_react_router_v7.md +498 -0
- package/docs/vi/intlayer_with_tanstack.md +562 -0
- package/docs/vi/intlayer_with_vite+preact.md +1722 -0
- package/docs/vi/intlayer_with_vite+react.md +1407 -0
- package/docs/vi/intlayer_with_vite+solid.md +287 -0
- package/docs/vi/intlayer_with_vite+svelte.md +289 -0
- package/docs/vi/intlayer_with_vite+vue.md +1071 -0
- package/docs/vi/introduction.md +215 -0
- package/docs/vi/locale_mapper.md +242 -0
- package/docs/vi/mcp_server.md +211 -0
- package/docs/vi/packages/express-intlayer/t.md +457 -0
- package/docs/vi/packages/intlayer/getConfiguration.md +145 -0
- package/docs/vi/packages/intlayer/getEnumeration.md +162 -0
- package/docs/vi/packages/intlayer/getHTMLTextDir.md +121 -0
- package/docs/vi/packages/intlayer/getLocaleLang.md +81 -0
- package/docs/vi/packages/intlayer/getLocaleName.md +129 -0
- package/docs/vi/packages/intlayer/getLocalizedUrl.md +309 -0
- package/docs/vi/packages/intlayer/getMultilingualUrls.md +221 -0
- package/docs/vi/packages/intlayer/getPathWithoutLocale.md +75 -0
- package/docs/vi/packages/intlayer/getTranslation.md +201 -0
- package/docs/vi/packages/intlayer/getTranslationContent.md +188 -0
- package/docs/vi/packages/next-intlayer/t.md +352 -0
- package/docs/vi/packages/next-intlayer/useDictionary.md +273 -0
- package/docs/vi/packages/next-intlayer/useIntlayer.md +264 -0
- package/docs/vi/packages/next-intlayer/useLocale.md +166 -0
- package/docs/vi/packages/react-intlayer/t.md +304 -0
- package/docs/vi/packages/react-intlayer/useDictionary.md +288 -0
- package/docs/vi/packages/react-intlayer/useI18n.md +295 -0
- package/docs/vi/packages/react-intlayer/useIntlayer.md +256 -0
- package/docs/vi/packages/react-intlayer/useLocale.md +210 -0
- package/docs/vi/per_locale_file.md +326 -0
- package/docs/vi/readme.md +261 -0
- package/docs/vi/releases/v6.md +305 -0
- package/docs/vi/roadmap.md +346 -0
- package/docs/vi/testing.md +202 -0
- package/docs/vi/vs_code_extension.md +126 -0
- package/docs/zh/configuration.md +6 -0
- package/docs/zh/intlayer_cli.md +8 -3
- package/docs/zh/intlayer_with_next-i18next.md +628 -0
- package/docs/zh/intlayer_with_next-intl.md +448 -0
- package/docs/zh/intlayer_with_nextjs_16.md +21 -0
- package/docs/zh/intlayer_with_tanstack.md +4 -0
- package/docs/zh/intlayer_with_vite+react.md +4 -0
- package/frequent_questions/ar/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/ar/array_as_content_declaration.md +1 -2
- package/frequent_questions/ar/build_dictionaries.md +1 -2
- package/frequent_questions/ar/build_error_CI_CD.md +1 -2
- package/frequent_questions/ar/bun_set_up.md +1 -2
- package/frequent_questions/ar/customized_locale_list.md +1 -2
- package/frequent_questions/ar/domain_routing.md +1 -2
- package/frequent_questions/ar/esbuild_error.md +1 -2
- package/frequent_questions/ar/get_locale_cookie.md +1 -2
- package/frequent_questions/ar/intlayer_command_undefined.md +1 -2
- package/frequent_questions/ar/locale_incorect_in_url.md +1 -2
- package/frequent_questions/ar/static_rendering.md +1 -3
- package/frequent_questions/ar/translated_path_url.md +1 -2
- package/frequent_questions/ar/unknown_command.md +1 -2
- package/frequent_questions/de/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/de/array_as_content_declaration.md +1 -2
- package/frequent_questions/de/build_dictionaries.md +1 -2
- package/frequent_questions/de/build_error_CI_CD.md +1 -2
- package/frequent_questions/de/bun_set_up.md +1 -2
- package/frequent_questions/de/customized_locale_list.md +1 -2
- package/frequent_questions/de/domain_routing.md +1 -2
- package/frequent_questions/de/esbuild_error.md +1 -2
- package/frequent_questions/de/get_locale_cookie.md +1 -2
- package/frequent_questions/de/intlayer_command_undefined.md +1 -2
- package/frequent_questions/de/locale_incorect_in_url.md +1 -2
- package/frequent_questions/de/static_rendering.md +1 -3
- package/frequent_questions/de/translated_path_url.md +1 -2
- package/frequent_questions/de/unknown_command.md +1 -2
- package/frequent_questions/en/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/en/array_as_content_declaration.md +1 -2
- package/frequent_questions/en/build_dictionaries.md +1 -2
- package/frequent_questions/en/build_error_CI_CD.md +1 -2
- package/frequent_questions/en/bun_set_up.md +1 -2
- package/frequent_questions/en/customized_locale_list.md +1 -2
- package/frequent_questions/en/domain_routing.md +1 -2
- package/frequent_questions/en/esbuild_error.md +1 -2
- package/frequent_questions/en/get_locale_cookie.md +1 -2
- package/frequent_questions/en/intlayer_command_undefined.md +1 -2
- package/frequent_questions/en/locale_incorect_in_url.md +1 -2
- package/frequent_questions/en/static_rendering.md +1 -3
- package/frequent_questions/en/translated_path_url.md +1 -2
- package/frequent_questions/en/unknown_command.md +1 -2
- package/frequent_questions/en-GB/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/en-GB/array_as_content_declaration.md +1 -2
- package/frequent_questions/en-GB/build_dictionaries.md +1 -2
- package/frequent_questions/en-GB/build_error_CI_CD.md +1 -2
- package/frequent_questions/en-GB/bun_set_up.md +1 -2
- package/frequent_questions/en-GB/customized_locale_list.md +1 -2
- package/frequent_questions/en-GB/domain_routing.md +1 -2
- package/frequent_questions/en-GB/esbuild_error.md +1 -2
- package/frequent_questions/en-GB/get_locale_cookie.md +1 -2
- package/frequent_questions/en-GB/intlayer_command_undefined.md +1 -2
- package/frequent_questions/en-GB/locale_incorect_in_url.md +1 -2
- package/frequent_questions/en-GB/static_rendering.md +1 -3
- package/frequent_questions/en-GB/translated_path_url.md +1 -2
- package/frequent_questions/en-GB/unknown_command.md +1 -2
- package/frequent_questions/es/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/es/array_as_content_declaration.md +1 -2
- package/frequent_questions/es/build_dictionaries.md +1 -2
- package/frequent_questions/es/build_error_CI_CD.md +1 -2
- package/frequent_questions/es/bun_set_up.md +1 -2
- package/frequent_questions/es/customized_locale_list.md +1 -2
- package/frequent_questions/es/domain_routing.md +1 -2
- package/frequent_questions/es/esbuild_error.md +1 -2
- package/frequent_questions/es/get_locale_cookie.md +1 -2
- package/frequent_questions/es/intlayer_command_undefined.md +1 -2
- package/frequent_questions/es/locale_incorect_in_url.md +1 -2
- package/frequent_questions/es/static_rendering.md +1 -3
- package/frequent_questions/es/translated_path_url.md +1 -2
- package/frequent_questions/es/unknown_command.md +1 -2
- package/frequent_questions/fr/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/fr/array_as_content_declaration.md +1 -2
- package/frequent_questions/fr/build_dictionaries.md +1 -2
- package/frequent_questions/fr/build_error_CI_CD.md +1 -2
- package/frequent_questions/fr/bun_set_up.md +1 -2
- package/frequent_questions/fr/customized_locale_list.md +1 -2
- package/frequent_questions/fr/domain_routing.md +1 -2
- package/frequent_questions/fr/esbuild_error.md +1 -2
- package/frequent_questions/fr/get_locale_cookie.md +1 -2
- package/frequent_questions/fr/intlayer_command_undefined.md +1 -2
- package/frequent_questions/fr/locale_incorect_in_url.md +1 -2
- package/frequent_questions/fr/static_rendering.md +1 -3
- package/frequent_questions/fr/translated_path_url.md +1 -2
- package/frequent_questions/fr/unknown_command.md +1 -2
- package/frequent_questions/hi/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/hi/array_as_content_declaration.md +1 -2
- package/frequent_questions/hi/build_dictionaries.md +1 -2
- package/frequent_questions/hi/build_error_CI_CD.md +1 -2
- package/frequent_questions/hi/bun_set_up.md +1 -2
- package/frequent_questions/hi/customized_locale_list.md +1 -2
- package/frequent_questions/hi/domain_routing.md +1 -2
- package/frequent_questions/hi/esbuild_error.md +1 -2
- package/frequent_questions/hi/get_locale_cookie.md +1 -2
- package/frequent_questions/hi/intlayer_command_undefined.md +1 -2
- package/frequent_questions/hi/locale_incorect_in_url.md +1 -2
- package/frequent_questions/hi/static_rendering.md +1 -3
- package/frequent_questions/hi/translated_path_url.md +1 -2
- package/frequent_questions/hi/unknown_command.md +1 -2
- package/frequent_questions/id/SSR_Next_no_[locale].md +104 -0
- package/frequent_questions/id/array_as_content_declaration.md +71 -0
- package/frequent_questions/id/build_dictionaries.md +58 -0
- package/frequent_questions/id/build_error_CI_CD.md +74 -0
- package/frequent_questions/id/bun_set_up.md +53 -0
- package/frequent_questions/id/customized_locale_list.md +64 -0
- package/frequent_questions/id/domain_routing.md +113 -0
- package/frequent_questions/id/esbuild_error.md +29 -0
- package/frequent_questions/id/get_locale_cookie.md +142 -0
- package/frequent_questions/id/intlayer_command_undefined.md +155 -0
- package/frequent_questions/id/locale_incorect_in_url.md +73 -0
- package/frequent_questions/id/static_rendering.md +44 -0
- package/frequent_questions/id/translated_path_url.md +55 -0
- package/frequent_questions/id/unknown_command.md +97 -0
- package/frequent_questions/it/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/it/array_as_content_declaration.md +1 -2
- package/frequent_questions/it/build_dictionaries.md +1 -2
- package/frequent_questions/it/build_error_CI_CD.md +1 -2
- package/frequent_questions/it/bun_set_up.md +1 -2
- package/frequent_questions/it/customized_locale_list.md +1 -2
- package/frequent_questions/it/domain_routing.md +1 -2
- package/frequent_questions/it/esbuild_error.md +1 -2
- package/frequent_questions/it/get_locale_cookie.md +1 -2
- package/frequent_questions/it/intlayer_command_undefined.md +1 -2
- package/frequent_questions/it/locale_incorect_in_url.md +1 -2
- package/frequent_questions/it/static_rendering.md +1 -3
- package/frequent_questions/it/translated_path_url.md +1 -2
- package/frequent_questions/it/unknown_command.md +1 -2
- package/frequent_questions/ja/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/ja/array_as_content_declaration.md +1 -2
- package/frequent_questions/ja/build_dictionaries.md +1 -2
- package/frequent_questions/ja/build_error_CI_CD.md +1 -2
- package/frequent_questions/ja/bun_set_up.md +1 -2
- package/frequent_questions/ja/customized_locale_list.md +1 -2
- package/frequent_questions/ja/domain_routing.md +1 -2
- package/frequent_questions/ja/esbuild_error.md +1 -2
- package/frequent_questions/ja/get_locale_cookie.md +1 -2
- package/frequent_questions/ja/intlayer_command_undefined.md +1 -2
- package/frequent_questions/ja/locale_incorect_in_url.md +1 -2
- package/frequent_questions/ja/static_rendering.md +1 -3
- package/frequent_questions/ja/translated_path_url.md +1 -2
- package/frequent_questions/ja/unknown_command.md +1 -2
- package/frequent_questions/ko/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/ko/array_as_content_declaration.md +1 -2
- package/frequent_questions/ko/build_dictionaries.md +1 -2
- package/frequent_questions/ko/build_error_CI_CD.md +1 -2
- package/frequent_questions/ko/bun_set_up.md +1 -2
- package/frequent_questions/ko/customized_locale_list.md +1 -2
- package/frequent_questions/ko/domain_routing.md +1 -2
- package/frequent_questions/ko/esbuild_error.md +1 -2
- package/frequent_questions/ko/get_locale_cookie.md +1 -2
- package/frequent_questions/ko/intlayer_command_undefined.md +1 -2
- package/frequent_questions/ko/locale_incorect_in_url.md +1 -2
- package/frequent_questions/ko/static_rendering.md +1 -3
- package/frequent_questions/ko/translated_path_url.md +1 -2
- package/frequent_questions/ko/unknown_command.md +1 -2
- package/frequent_questions/pl/SSR_Next_no_[locale].md +104 -0
- package/frequent_questions/pl/array_as_content_declaration.md +71 -0
- package/frequent_questions/pl/build_dictionaries.md +58 -0
- package/frequent_questions/pl/build_error_CI_CD.md +74 -0
- package/frequent_questions/pl/bun_set_up.md +54 -0
- package/frequent_questions/pl/customized_locale_list.md +64 -0
- package/frequent_questions/pl/domain_routing.md +113 -0
- package/frequent_questions/pl/esbuild_error.md +29 -0
- package/frequent_questions/pl/get_locale_cookie.md +142 -0
- package/frequent_questions/pl/intlayer_command_undefined.md +155 -0
- package/frequent_questions/pl/locale_incorect_in_url.md +73 -0
- package/frequent_questions/pl/static_rendering.md +44 -0
- package/frequent_questions/pl/translated_path_url.md +55 -0
- package/frequent_questions/pl/unknown_command.md +97 -0
- package/frequent_questions/pt/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/pt/array_as_content_declaration.md +1 -2
- package/frequent_questions/pt/build_dictionaries.md +1 -2
- package/frequent_questions/pt/build_error_CI_CD.md +1 -2
- package/frequent_questions/pt/bun_set_up.md +1 -2
- package/frequent_questions/pt/customized_locale_list.md +1 -2
- package/frequent_questions/pt/domain_routing.md +1 -2
- package/frequent_questions/pt/esbuild_error.md +1 -2
- package/frequent_questions/pt/get_locale_cookie.md +1 -2
- package/frequent_questions/pt/intlayer_command_undefined.md +1 -2
- package/frequent_questions/pt/locale_incorect_in_url.md +1 -2
- package/frequent_questions/pt/static_rendering.md +1 -3
- package/frequent_questions/pt/translated_path_url.md +1 -2
- package/frequent_questions/pt/unknown_command.md +1 -2
- package/frequent_questions/ru/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/ru/array_as_content_declaration.md +1 -2
- package/frequent_questions/ru/build_dictionaries.md +1 -2
- package/frequent_questions/ru/build_error_CI_CD.md +1 -2
- package/frequent_questions/ru/bun_set_up.md +1 -2
- package/frequent_questions/ru/customized_locale_list.md +1 -2
- package/frequent_questions/ru/domain_routing.md +1 -2
- package/frequent_questions/ru/esbuild_error.md +1 -2
- package/frequent_questions/ru/get_locale_cookie.md +1 -2
- package/frequent_questions/ru/intlayer_command_undefined.md +1 -2
- package/frequent_questions/ru/locale_incorect_in_url.md +1 -2
- package/frequent_questions/ru/static_rendering.md +1 -2
- package/frequent_questions/ru/translated_path_url.md +1 -2
- package/frequent_questions/ru/unknown_command.md +1 -2
- package/frequent_questions/tr/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/tr/array_as_content_declaration.md +1 -2
- package/frequent_questions/tr/build_dictionaries.md +1 -2
- package/frequent_questions/tr/build_error_CI_CD.md +1 -2
- package/frequent_questions/tr/bun_set_up.md +1 -2
- package/frequent_questions/tr/customized_locale_list.md +1 -2
- package/frequent_questions/tr/domain_routing.md +1 -2
- package/frequent_questions/tr/esbuild_error.md +1 -2
- package/frequent_questions/tr/get_locale_cookie.md +1 -2
- package/frequent_questions/tr/intlayer_command_undefined.md +1 -2
- package/frequent_questions/tr/locale_incorect_in_url.md +1 -2
- package/frequent_questions/tr/static_rendering.md +1 -2
- package/frequent_questions/tr/translated_path_url.md +1 -2
- package/frequent_questions/tr/unknown_command.md +1 -2
- package/frequent_questions/vi/SSR_Next_no_[locale].md +106 -0
- package/frequent_questions/vi/array_as_content_declaration.md +71 -0
- package/frequent_questions/vi/build_dictionaries.md +58 -0
- package/frequent_questions/vi/build_error_CI_CD.md +74 -0
- package/frequent_questions/vi/bun_set_up.md +53 -0
- package/frequent_questions/vi/customized_locale_list.md +64 -0
- package/frequent_questions/vi/domain_routing.md +113 -0
- package/frequent_questions/vi/esbuild_error.md +29 -0
- package/frequent_questions/vi/get_locale_cookie.md +142 -0
- package/frequent_questions/vi/intlayer_command_undefined.md +155 -0
- package/frequent_questions/vi/locale_incorect_in_url.md +73 -0
- package/frequent_questions/vi/static_rendering.md +44 -0
- package/frequent_questions/vi/translated_path_url.md +55 -0
- package/frequent_questions/vi/unknown_command.md +97 -0
- package/frequent_questions/zh/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/zh/array_as_content_declaration.md +1 -2
- package/frequent_questions/zh/build_dictionaries.md +1 -2
- package/frequent_questions/zh/build_error_CI_CD.md +1 -2
- package/frequent_questions/zh/bun_set_up.md +1 -2
- package/frequent_questions/zh/customized_locale_list.md +1 -2
- package/frequent_questions/zh/domain_routing.md +1 -2
- package/frequent_questions/zh/esbuild_error.md +1 -2
- package/frequent_questions/zh/get_locale_cookie.md +1 -2
- package/frequent_questions/zh/intlayer_command_undefined.md +1 -2
- package/frequent_questions/zh/locale_incorect_in_url.md +1 -2
- package/frequent_questions/zh/static_rendering.md +1 -3
- package/frequent_questions/zh/translated_path_url.md +1 -2
- package/frequent_questions/zh/unknown_command.md +1 -2
- package/legal/id/privacy_notice.md +83 -0
- package/legal/id/terms_of_service.md +55 -0
- package/legal/pl/privacy_notice.md +83 -0
- package/legal/pl/terms_of_service.md +55 -0
- package/legal/vi/privacy_notice.md +83 -0
- package/legal/vi/terms_of_service.md +55 -0
- package/package.json +19 -18
- package/src/generated/blog.entry.ts +38 -0
|
@@ -0,0 +1,1413 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2024-03-07
|
|
3
|
+
updatedAt: 2024-03-07
|
|
4
|
+
title: Cara menerjemahkan aplikasi Vite dan React Anda – panduan i18n 2025
|
|
5
|
+
description: Pelajari cara menambahkan internasionalisasi (i18n) ke aplikasi Vite dan React Anda menggunakan Intlayer. Ikuti panduan ini untuk membuat aplikasi Anda multibahasa.
|
|
6
|
+
keywords:
|
|
7
|
+
- Internasionalisasi
|
|
8
|
+
- Dokumentasi
|
|
9
|
+
- Intlayer
|
|
10
|
+
- Vite
|
|
11
|
+
- React
|
|
12
|
+
- i18n
|
|
13
|
+
- JavaScript
|
|
14
|
+
slugs:
|
|
15
|
+
- doc
|
|
16
|
+
- environment
|
|
17
|
+
- vite-and-react
|
|
18
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-vite-react-template
|
|
19
|
+
youtubeVideo: https://www.youtube.com/watch?v=dS9L7uJeak4
|
|
20
|
+
history:
|
|
21
|
+
- version: 5.5.10
|
|
22
|
+
date: 2025-06-29
|
|
23
|
+
changes: Inisialisasi riwayat
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
# Terjemahkan situs web Vite dan React Anda menggunakan Intlayer | Internasionalisasi (i18n)
|
|
27
|
+
|
|
28
|
+
## Daftar Isi
|
|
29
|
+
|
|
30
|
+
<TOC/>
|
|
31
|
+
|
|
32
|
+
## Apa itu Intlayer?
|
|
33
|
+
|
|
34
|
+
**Intlayer** adalah perpustakaan internasionalisasi (i18n) open-source yang inovatif, dirancang untuk menyederhanakan dukungan multibahasa dalam aplikasi web modern.
|
|
35
|
+
|
|
36
|
+
Dengan Intlayer, Anda dapat:
|
|
37
|
+
|
|
38
|
+
- **Mengelola terjemahan dengan mudah** menggunakan kamus deklaratif di tingkat komponen.
|
|
39
|
+
- **Melokalkan metadata**, rute, dan konten secara dinamis.
|
|
40
|
+
- **Memastikan dukungan TypeScript** dengan tipe yang dihasilkan secara otomatis, meningkatkan autocompletion dan deteksi kesalahan.
|
|
41
|
+
- **Memanfaatkan fitur canggih**, seperti deteksi dan pergantian locale secara dinamis.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Panduan Langkah demi Langkah untuk Mengatur Intlayer dalam Aplikasi Vite dan React
|
|
46
|
+
|
|
47
|
+
<Tab defaultTab="video">
|
|
48
|
+
<TabItem label="Video" value="video">
|
|
49
|
+
|
|
50
|
+
<iframe title="Solusi i18n terbaik untuk Vite dan React? Temukan 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?si=VaKmrYMmXjo3xpk2"/>
|
|
51
|
+
|
|
52
|
+
</TabItem>
|
|
53
|
+
<TabItem label="Kode" value="code">
|
|
54
|
+
|
|
55
|
+
<iframe
|
|
56
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-vite-react-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
57
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
58
|
+
title="Demo CodeSandbox - Cara Menginternasionalisasi aplikasi Anda menggunakan Intlayer"
|
|
59
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
60
|
+
loading="lazy"
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
</TabItem>
|
|
64
|
+
</Tab>
|
|
65
|
+
|
|
66
|
+
Lihat [Application Template](https://github.com/aymericzip/intlayer-vite-react-template) di GitHub.
|
|
67
|
+
|
|
68
|
+
### Langkah 1: Instalasi Dependencies
|
|
69
|
+
|
|
70
|
+
Instal paket yang diperlukan menggunakan npm:
|
|
71
|
+
|
|
72
|
+
```bash packageManager="npm"
|
|
73
|
+
npm install intlayer react-intlayer
|
|
74
|
+
npm install vite-intlayer --save-dev
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```bash packageManager="pnpm"
|
|
78
|
+
pnpm add intlayer react-intlayer
|
|
79
|
+
pnpm add vite-intlayer --save-dev
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
```bash packageManager="yarn"
|
|
83
|
+
yarn add intlayer react-intlayer
|
|
84
|
+
yarn add vite-intlayer --save-dev
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- **intlayer**
|
|
88
|
+
|
|
89
|
+
- **intlayer**
|
|
90
|
+
|
|
91
|
+
Paket inti yang menyediakan alat internasionalisasi untuk manajemen konfigurasi, terjemahan, [deklarasi konten](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/content_file.md), transpile, dan [perintah CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_cli.md).
|
|
92
|
+
|
|
93
|
+
- **react-intlayer**
|
|
94
|
+
Paket yang mengintegrasikan Intlayer dengan aplikasi React. Paket ini menyediakan context providers dan hooks untuk internasionalisasi React.
|
|
95
|
+
|
|
96
|
+
- **vite-intlayer**
|
|
97
|
+
Termasuk plugin Vite untuk mengintegrasikan Intlayer dengan [Vite bundler](https://vite.dev/guide/why.html#why-bundle-for-production), serta middleware untuk mendeteksi locale yang dipilih pengguna, mengelola cookie, dan menangani pengalihan URL.
|
|
98
|
+
|
|
99
|
+
### Langkah 2: Konfigurasi proyek Anda
|
|
100
|
+
|
|
101
|
+
Buat file konfigurasi untuk mengatur bahasa aplikasi Anda:
|
|
102
|
+
|
|
103
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
104
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
105
|
+
|
|
106
|
+
const config: IntlayerConfig = {
|
|
107
|
+
internationalization: {
|
|
108
|
+
locales: [
|
|
109
|
+
Locales.ENGLISH,
|
|
110
|
+
Locales.FRENCH,
|
|
111
|
+
Locales.SPANISH,
|
|
112
|
+
// Bahasa lain yang Anda gunakan
|
|
113
|
+
],
|
|
114
|
+
defaultLocale: Locales.ENGLISH,
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export default config;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
122
|
+
import { Locales } from "intlayer";
|
|
123
|
+
|
|
124
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
125
|
+
// Konfigurasi internasionalisasi
|
|
126
|
+
const config = {
|
|
127
|
+
internationalization: {
|
|
128
|
+
locales: [
|
|
129
|
+
Locales.ENGLISH,
|
|
130
|
+
Locales.FRENCH,
|
|
131
|
+
Locales.SPANISH,
|
|
132
|
+
// Bahasa lain yang Anda gunakan
|
|
133
|
+
],
|
|
134
|
+
defaultLocale: Locales.ENGLISH,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export default config;
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
142
|
+
const { Locales } = require("intlayer");
|
|
143
|
+
|
|
144
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
145
|
+
// Konfigurasi internasionalisasi
|
|
146
|
+
const config = {
|
|
147
|
+
internationalization: {
|
|
148
|
+
locales: [
|
|
149
|
+
Locales.ENGLISH,
|
|
150
|
+
Locales.FRENCH,
|
|
151
|
+
Locales.SPANISH,
|
|
152
|
+
// Bahasa lain yang Anda gunakan
|
|
153
|
+
],
|
|
154
|
+
defaultLocale: Locales.ENGLISH,
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
module.exports = config;
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
> Melalui file konfigurasi ini, Anda dapat mengatur URL yang dilokalkan, pengalihan middleware, nama cookie, lokasi dan ekstensi deklarasi konten Anda, menonaktifkan log Intlayer di konsol, dan lainnya. Untuk daftar lengkap parameter yang tersedia, lihat [dokumentasi konfigurasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/configuration.md).
|
|
162
|
+
|
|
163
|
+
### Langkah 3: Integrasikan Intlayer dalam Konfigurasi Vite Anda
|
|
164
|
+
|
|
165
|
+
Tambahkan plugin intlayer ke dalam konfigurasi Anda.
|
|
166
|
+
|
|
167
|
+
```typescript fileName="vite.config.ts" codeFormat="typescript"
|
|
168
|
+
import { defineConfig } from "vite";
|
|
169
|
+
import react from "@vitejs/plugin-react-swc";
|
|
170
|
+
import { intlayer } from "vite-intlayer";
|
|
171
|
+
|
|
172
|
+
// https://vitejs.dev/config/
|
|
173
|
+
export default defineConfig({
|
|
174
|
+
plugins: [react(), intlayer()],
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
```javascript fileName="vite.config.mjs" codeFormat="esm"
|
|
179
|
+
import { defineConfig } from "vite";
|
|
180
|
+
import react from "@vitejs/plugin-react-swc";
|
|
181
|
+
import { intlayer } from "vite-intlayer";
|
|
182
|
+
|
|
183
|
+
// https://vitejs.dev/config/
|
|
184
|
+
export default defineConfig({
|
|
185
|
+
plugins: [react(), intlayer()],
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
```javascript fileName="vite.config.cjs" codeFormat="commonjs"
|
|
190
|
+
const { defineConfig } = require("vite");
|
|
191
|
+
const react = require("@vitejs/plugin-react-swc");
|
|
192
|
+
const { intlayer } = require("vite-intlayer");
|
|
193
|
+
|
|
194
|
+
// https://vitejs.dev/config/
|
|
195
|
+
module.exports = defineConfig({
|
|
196
|
+
plugins: [react(), intlayer()],
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
> Plugin Vite `intlayer()` digunakan untuk mengintegrasikan Intlayer dengan Vite. Plugin ini memastikan pembuatan file deklarasi konten dan memantau file tersebut dalam mode pengembangan. Plugin ini juga mendefinisikan variabel lingkungan Intlayer dalam aplikasi Vite. Selain itu, plugin ini menyediakan alias untuk mengoptimalkan performa.
|
|
201
|
+
|
|
202
|
+
### Langkah 4: Deklarasikan Konten Anda
|
|
203
|
+
|
|
204
|
+
Buat dan kelola deklarasi konten Anda untuk menyimpan terjemahan:
|
|
205
|
+
|
|
206
|
+
```tsx fileName="src/app.content.tsx" contentDeclarationFormat="typescript"
|
|
207
|
+
import { t, type Dictionary } from "intlayer";
|
|
208
|
+
import type { ReactNode } from "react";
|
|
209
|
+
|
|
210
|
+
const appContent = {
|
|
211
|
+
key: "app",
|
|
212
|
+
content: {
|
|
213
|
+
viteLogo: t({
|
|
214
|
+
en: "Vite logo",
|
|
215
|
+
fr: "Logo Vite",
|
|
216
|
+
es: "Logo Vite",
|
|
217
|
+
}),
|
|
218
|
+
reactLogo: t({
|
|
219
|
+
en: "React logo",
|
|
220
|
+
fr: "Logo React",
|
|
221
|
+
es: "Logo React",
|
|
222
|
+
}),
|
|
223
|
+
|
|
224
|
+
title: "Vite + React",
|
|
225
|
+
|
|
226
|
+
count: t({
|
|
227
|
+
en: "count is ",
|
|
228
|
+
fr: "le compte est ",
|
|
229
|
+
es: "el recuento es ",
|
|
230
|
+
}),
|
|
231
|
+
|
|
232
|
+
edit: t<ReactNode>({
|
|
233
|
+
en: (
|
|
234
|
+
<>
|
|
235
|
+
Edit <code>src/App.tsx</code> dan simpan untuk menguji HMR
|
|
236
|
+
</>
|
|
237
|
+
),
|
|
238
|
+
fr: (
|
|
239
|
+
<>
|
|
240
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
241
|
+
</>
|
|
242
|
+
),
|
|
243
|
+
es: (
|
|
244
|
+
<>
|
|
245
|
+
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
246
|
+
</>
|
|
247
|
+
),
|
|
248
|
+
}),
|
|
249
|
+
|
|
250
|
+
readTheDocs: t({
|
|
251
|
+
en: "Klik pada logo Vite dan React untuk mempelajari lebih lanjut",
|
|
252
|
+
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
253
|
+
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
254
|
+
}),
|
|
255
|
+
},
|
|
256
|
+
} satisfies Dictionary;
|
|
257
|
+
|
|
258
|
+
export default appContent;
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
```javascript fileName="src/app.content.mjs" contentDeclarationFormat="esm"
|
|
262
|
+
import { t } from "intlayer";
|
|
263
|
+
|
|
264
|
+
/** @type {import('intlayer').Dictionary} */
|
|
265
|
+
const appContent = {
|
|
266
|
+
key: "app",
|
|
267
|
+
content: {
|
|
268
|
+
viteLogo: t({
|
|
269
|
+
en: "Vite logo",
|
|
270
|
+
fr: "Logo Vite",
|
|
271
|
+
es: "Logo Vite",
|
|
272
|
+
}),
|
|
273
|
+
reactLogo: t({
|
|
274
|
+
en: "React logo",
|
|
275
|
+
fr: "Logo React",
|
|
276
|
+
es: "Logo React",
|
|
277
|
+
}),
|
|
278
|
+
|
|
279
|
+
title: "Vite + React",
|
|
280
|
+
|
|
281
|
+
count: t({
|
|
282
|
+
en: "count is ",
|
|
283
|
+
fr: "le compte est ",
|
|
284
|
+
es: "el recuento es ",
|
|
285
|
+
}),
|
|
286
|
+
|
|
287
|
+
edit:
|
|
288
|
+
t <
|
|
289
|
+
ReactNode >
|
|
290
|
+
{
|
|
291
|
+
// Jangan lupa impor React jika Anda menggunakan node React dalam konten Anda
|
|
292
|
+
en: (
|
|
293
|
+
<>
|
|
294
|
+
Edit <code>src/App.tsx</code> dan simpan untuk menguji HMR
|
|
295
|
+
</>
|
|
296
|
+
),
|
|
297
|
+
fr: (
|
|
298
|
+
<>
|
|
299
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
300
|
+
</>
|
|
301
|
+
),
|
|
302
|
+
es: (
|
|
303
|
+
<>
|
|
304
|
+
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
305
|
+
</>
|
|
306
|
+
),
|
|
307
|
+
},
|
|
308
|
+
|
|
309
|
+
readTheDocs: t({
|
|
310
|
+
en: "Click on the Vite and React logos to learn more",
|
|
311
|
+
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
312
|
+
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
313
|
+
id: "Klik pada logo Vite dan React untuk mempelajari lebih lanjut",
|
|
314
|
+
}),
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export default appContent;
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
```javascript fileName="src/app.content.cjs" contentDeclarationFormat="commonjs"
|
|
322
|
+
const { t } = require("intlayer");
|
|
323
|
+
|
|
324
|
+
/** @type {import('intlayer').Dictionary} */
|
|
325
|
+
const appContent = {
|
|
326
|
+
key: "app",
|
|
327
|
+
content: {
|
|
328
|
+
viteLogo: t({
|
|
329
|
+
en: "Logo Vite",
|
|
330
|
+
fr: "Logo Vite",
|
|
331
|
+
es: "Logo Vite",
|
|
332
|
+
}),
|
|
333
|
+
reactLogo: t({
|
|
334
|
+
en: "Logo React",
|
|
335
|
+
fr: "Logo React",
|
|
336
|
+
es: "Logo React",
|
|
337
|
+
}),
|
|
338
|
+
|
|
339
|
+
title: "Vite + React",
|
|
340
|
+
|
|
341
|
+
count: t({
|
|
342
|
+
en: "jumlah adalah ",
|
|
343
|
+
fr: "le compte est ",
|
|
344
|
+
es: "el recuento es ",
|
|
345
|
+
}),
|
|
346
|
+
|
|
347
|
+
edit:
|
|
348
|
+
t <
|
|
349
|
+
ReactNode >
|
|
350
|
+
{
|
|
351
|
+
// Jangan lupa impor React jika Anda menggunakan node React dalam konten Anda
|
|
352
|
+
en: (
|
|
353
|
+
<>
|
|
354
|
+
Edit <code>src/App.tsx</code> dan simpan untuk menguji HMR
|
|
355
|
+
</>
|
|
356
|
+
),
|
|
357
|
+
fr: (
|
|
358
|
+
<>
|
|
359
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
360
|
+
</>
|
|
361
|
+
),
|
|
362
|
+
es: (
|
|
363
|
+
<>
|
|
364
|
+
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
365
|
+
</>
|
|
366
|
+
/ ),
|
|
367
|
+
},
|
|
368
|
+
|
|
369
|
+
readTheDocs: t({
|
|
370
|
+
en: "Klik pada logo Vite dan React untuk mempelajari lebih lanjut",
|
|
371
|
+
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
372
|
+
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
373
|
+
}),
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
module.exports = appContent;
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
```json fileName="src/app.content.json" contentDeclarationFormat="json"
|
|
381
|
+
{
|
|
382
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
383
|
+
"key": "app",
|
|
384
|
+
"content": {
|
|
385
|
+
"viteLogo": {
|
|
386
|
+
"nodeType": "translation",
|
|
387
|
+
"translation": {
|
|
388
|
+
"en": "Logo Vite",
|
|
389
|
+
"fr": "Logo Vite",
|
|
390
|
+
"es": "Logo Vite"
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
"reactLogo": {
|
|
394
|
+
"nodeType": "translation",
|
|
395
|
+
"translation": {
|
|
396
|
+
"en": "Logo React",
|
|
397
|
+
"fr": "Logo React",
|
|
398
|
+
"es": "Logo React"
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
"title": {
|
|
402
|
+
"nodeType": "translation",
|
|
403
|
+
"translation": {
|
|
404
|
+
"en": "Vite + React",
|
|
405
|
+
"fr": "Vite + React",
|
|
406
|
+
"es": "Vite + React",
|
|
407
|
+
"id": "Vite + React"
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
"count": {
|
|
411
|
+
"nodeType": "translation",
|
|
412
|
+
"translation": {
|
|
413
|
+
"en": "count is ",
|
|
414
|
+
"fr": "le compte est ",
|
|
415
|
+
"es": "el recuento es ",
|
|
416
|
+
"id": "jumlah adalah "
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
"edit": {
|
|
420
|
+
"nodeType": "translation",
|
|
421
|
+
"translation": {
|
|
422
|
+
"en": "Edit src/App.tsx and save to test HMR",
|
|
423
|
+
"fr": "Éditez src/App.tsx et enregistrez pour tester HMR",
|
|
424
|
+
"es": "Edita src/App.tsx y guarda para probar HMR",
|
|
425
|
+
"id": "Edit src/App.tsx dan simpan untuk menguji HMR"
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
"readTheDocs": {
|
|
429
|
+
"nodeType": "translation",
|
|
430
|
+
"translation": {
|
|
431
|
+
"en": "Click on the Vite and React logos to learn more",
|
|
432
|
+
"fr": "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
433
|
+
"es": "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
434
|
+
"id": "Klik pada logo Vite dan React untuk mempelajari lebih lanjut"
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
"id": "Klik pada logo Vite dan React untuk mempelajari lebih lanjut"
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
> Deklarasi konten Anda dapat didefinisikan di mana saja dalam aplikasi Anda selama sudah termasuk ke dalam direktori `contentDir` (secara default, `./src`). Dan sesuai dengan ekstensi file deklarasi konten (secara default, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
445
|
+
|
|
446
|
+
> Untuk detail lebih lanjut, lihat [dokumentasi deklarasi konten](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/content_file.md).
|
|
447
|
+
|
|
448
|
+
> Jika file konten Anda menyertakan kode TSX, Anda harus mempertimbangkan untuk mengimpor `import React from "react";` dalam file konten Anda.
|
|
449
|
+
|
|
450
|
+
### Langkah 5: Gunakan Intlayer dalam Kode Anda
|
|
451
|
+
|
|
452
|
+
Akses kamus konten Anda di seluruh aplikasi Anda:
|
|
453
|
+
|
|
454
|
+
```tsx {5,9} fileName="src/App.tsx" codeFormat="typescript"
|
|
455
|
+
import { useState, type FC } from "react";
|
|
456
|
+
import reactLogo from "./assets/react.svg";
|
|
457
|
+
import viteLogo from "/vite.svg";
|
|
458
|
+
import "./App.css";
|
|
459
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
460
|
+
|
|
461
|
+
const AppContent: FC = () => {
|
|
462
|
+
const [count, setCount] = useState(0);
|
|
463
|
+
const content = useIntlayer("app");
|
|
464
|
+
|
|
465
|
+
return (
|
|
466
|
+
<>
|
|
467
|
+
<div>
|
|
468
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
469
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
470
|
+
</a>
|
|
471
|
+
<a href="https://react.dev" target="_blank">
|
|
472
|
+
<img
|
|
473
|
+
src={reactLogo}
|
|
474
|
+
className="logo react"
|
|
475
|
+
alt={content.reactLogo.value}
|
|
476
|
+
/>
|
|
477
|
+
</a>
|
|
478
|
+
</div>
|
|
479
|
+
<h1>{content.title}</h1>
|
|
480
|
+
<div className="card">
|
|
481
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
482
|
+
{content.count}
|
|
483
|
+
{count}
|
|
484
|
+
</button>
|
|
485
|
+
<p>{content.edit}</p>
|
|
486
|
+
</div>
|
|
487
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
488
|
+
</>
|
|
489
|
+
);
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
const App: FC = () => (
|
|
493
|
+
<IntlayerProvider>
|
|
494
|
+
<AppContent />
|
|
495
|
+
</IntlayerProvider>
|
|
496
|
+
);
|
|
497
|
+
|
|
498
|
+
export default App;
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
```tsx {5,9} fileName="src/App.msx" codeFormat="esm"
|
|
502
|
+
import { useState } from "react";
|
|
503
|
+
import reactLogo from "./assets/react.svg";
|
|
504
|
+
import viteLogo from "/vite.svg";
|
|
505
|
+
import "./App.css";
|
|
506
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
507
|
+
|
|
508
|
+
const AppContent = () => {
|
|
509
|
+
const [count, setCount] = useState(0);
|
|
510
|
+
const content = useIntlayer("app");
|
|
511
|
+
|
|
512
|
+
return (
|
|
513
|
+
<>
|
|
514
|
+
<div>
|
|
515
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
516
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
517
|
+
</a>
|
|
518
|
+
<a href="https://react.dev" target="_blank">
|
|
519
|
+
<img
|
|
520
|
+
src={reactLogo}
|
|
521
|
+
className="logo react"
|
|
522
|
+
alt={content.reactLogo.value}
|
|
523
|
+
/>
|
|
524
|
+
</a>
|
|
525
|
+
</div>
|
|
526
|
+
<h1>{content.title}</h1>
|
|
527
|
+
<div className="card">
|
|
528
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
529
|
+
{content.count}
|
|
530
|
+
{count}
|
|
531
|
+
</button>
|
|
532
|
+
<p>{content.edit}</p>
|
|
533
|
+
</div>
|
|
534
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
535
|
+
</>
|
|
536
|
+
);
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
const App = () => (
|
|
540
|
+
<IntlayerProvider>
|
|
541
|
+
<AppContent />
|
|
542
|
+
</IntlayerProvider>
|
|
543
|
+
);
|
|
544
|
+
|
|
545
|
+
export default App;
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
```tsx {5,9} fileName="src/App.csx" codeFormat="commonjs"
|
|
549
|
+
const { useState } = require("react");
|
|
550
|
+
const reactLogo = require("./assets/react.svg");
|
|
551
|
+
const viteLogo = require("/vite.svg");
|
|
552
|
+
require("./App.css");
|
|
553
|
+
const { IntlayerProvider, useIntlayer } = require("react-intlayer");
|
|
554
|
+
|
|
555
|
+
const AppContent = () => {
|
|
556
|
+
const [count, setCount] = useState(0);
|
|
557
|
+
const content = useIntlayer("app");
|
|
558
|
+
|
|
559
|
+
return (
|
|
560
|
+
<>
|
|
561
|
+
<div>
|
|
562
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
563
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
564
|
+
</a>
|
|
565
|
+
<a href="https://react.dev" target="_blank">
|
|
566
|
+
<img
|
|
567
|
+
src={reactLogo}
|
|
568
|
+
className="logo react"
|
|
569
|
+
alt={content.reactLogo.value}
|
|
570
|
+
/>
|
|
571
|
+
</a>
|
|
572
|
+
</div>
|
|
573
|
+
<h1>{content.title}</h1>
|
|
574
|
+
<div className="card">
|
|
575
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
576
|
+
{content.count}
|
|
577
|
+
{count}
|
|
578
|
+
</button>
|
|
579
|
+
<p>{content.edit}</p>
|
|
580
|
+
</div>
|
|
581
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
582
|
+
</>
|
|
583
|
+
);
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
const App = () => (
|
|
587
|
+
<IntlayerProvider>
|
|
588
|
+
<AppContent />
|
|
589
|
+
</IntlayerProvider>
|
|
590
|
+
);
|
|
591
|
+
|
|
592
|
+
module.exports = App;
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
> Jika Anda ingin menggunakan konten Anda dalam atribut `string`, seperti `alt`, `title`, `href`, `aria-label`, dll., Anda harus memanggil nilai fungsi tersebut, seperti:
|
|
596
|
+
|
|
597
|
+
> ```jsx
|
|
598
|
+
> <img src={content.image.src.value} alt={content.image.value} />
|
|
599
|
+
> ```
|
|
600
|
+
|
|
601
|
+
> Untuk mempelajari lebih lanjut tentang hook `useIntlayer`, lihat [dokumentasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/react-intlayer/useIntlayer.md).
|
|
602
|
+
|
|
603
|
+
### (Opsional) Langkah 6: Ubah bahasa konten Anda
|
|
604
|
+
|
|
605
|
+
Untuk mengubah bahasa konten Anda, Anda dapat menggunakan fungsi `setLocale` yang disediakan oleh hook `useLocale`. Fungsi ini memungkinkan Anda untuk mengatur locale aplikasi dan memperbarui konten sesuai dengan locale tersebut.
|
|
606
|
+
|
|
607
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
608
|
+
import type { FC } from "react";
|
|
609
|
+
import { Locales } from "intlayer";
|
|
610
|
+
import { useLocale } from "react-intlayer";
|
|
611
|
+
|
|
612
|
+
const LocaleSwitcher: FC = () => {
|
|
613
|
+
const { setLocale } = useLocale();
|
|
614
|
+
|
|
615
|
+
return (
|
|
616
|
+
<button onClick={() => setLocale(Locales.English)}>
|
|
617
|
+
Ubah Bahasa ke Bahasa Inggris
|
|
618
|
+
</button>
|
|
619
|
+
);
|
|
620
|
+
};
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
```jsx fileName="src/components/LocaleSwitcher.msx" codeFormat="esm"
|
|
624
|
+
import { Locales } from "intlayer";
|
|
625
|
+
import { useLocale } from "react-intlayer";
|
|
626
|
+
|
|
627
|
+
const LocaleSwitcher = () => {
|
|
628
|
+
const { setLocale } = useLocale();
|
|
629
|
+
|
|
630
|
+
return (
|
|
631
|
+
<button onClick={() => setLocale(Locales.English)}>
|
|
632
|
+
Ubah Bahasa ke Bahasa Inggris
|
|
633
|
+
</button>
|
|
634
|
+
);
|
|
635
|
+
};
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
```jsx fileName="src/components/LocaleSwitcher.csx" codeFormat="commonjs"
|
|
639
|
+
const { Locales } = require("intlayer");
|
|
640
|
+
const { useLocale } = require("react-intlayer");
|
|
641
|
+
|
|
642
|
+
const LocaleSwitcher = () => {
|
|
643
|
+
const { setLocale } = useLocale();
|
|
644
|
+
|
|
645
|
+
return (
|
|
646
|
+
<button onClick={() => setLocale(Locales.English)}>
|
|
647
|
+
Ubah Bahasa ke Bahasa Inggris
|
|
648
|
+
</button>
|
|
649
|
+
);
|
|
650
|
+
};
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
> Untuk mempelajari lebih lanjut tentang hook `useLocale`, lihat [dokumentasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/react-intlayer/useLocale.md).
|
|
654
|
+
|
|
655
|
+
### (Opsional) Langkah 7: Tambahkan Routing yang Dilokalkan ke aplikasi Anda
|
|
656
|
+
|
|
657
|
+
Tujuan dari langkah ini adalah untuk membuat rute unik untuk setiap bahasa. Ini berguna untuk SEO dan URL yang ramah SEO.
|
|
658
|
+
Contoh:
|
|
659
|
+
|
|
660
|
+
```plaintext
|
|
661
|
+
- https://example.com/about
|
|
662
|
+
- https://example.com/es/about
|
|
663
|
+
- https://example.com/fr/about
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
> Secara default, rute tidak diberi awalan untuk locale default. Jika Anda ingin memberi awalan pada locale default, Anda dapat mengatur opsi `middleware.prefixDefault` ke `true` dalam konfigurasi Anda. Lihat [dokumentasi konfigurasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/configuration.md) untuk informasi lebih lanjut.
|
|
667
|
+
|
|
668
|
+
Untuk menambahkan routing yang dilokalkan ke aplikasi Anda, Anda dapat membuat komponen `LocaleRouter` yang membungkus rute aplikasi Anda dan menangani routing berbasis locale. Berikut adalah contoh menggunakan [React Router](https://reactrouter.com/home):
|
|
669
|
+
|
|
670
|
+
```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
|
|
671
|
+
import { localeMap } from "intlayer"; // Fungsi utilitas dan tipe dari 'intlayer'
|
|
672
|
+
import type { FC, PropsWithChildren } from "react"; // Tipe React untuk komponen fungsional dan props
|
|
673
|
+
import { IntlayerProvider } from "react-intlayer"; // Provider untuk konteks internasionalisasi
|
|
674
|
+
import { BrowserRouter, Route, Routes } from "react-router-dom"; // Komponen router untuk mengelola navigasi
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Komponen router yang mengatur rute spesifik berdasarkan locale.
|
|
678
|
+
* Menggunakan React Router untuk mengelola navigasi dan merender komponen yang dilokalkan.
|
|
679
|
+
*/
|
|
680
|
+
export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
|
|
681
|
+
<BrowserRouter>
|
|
682
|
+
<Routes>
|
|
683
|
+
{localeMap(({ locale, urlPrefix }) => (
|
|
684
|
+
<Route
|
|
685
|
+
// Pola rute untuk menangkap locale (misal: /en/, /fr/) dan mencocokkan semua path berikutnya
|
|
686
|
+
path={`${urlPrefix}/*`}
|
|
687
|
+
key={locale}
|
|
688
|
+
element={
|
|
689
|
+
<IntlayerProvider locale={locale}>{children}</IntlayerProvider>
|
|
690
|
+
} // Membungkus children dengan pengelolaan locale
|
|
691
|
+
/>
|
|
692
|
+
))}
|
|
693
|
+
</Routes>
|
|
694
|
+
</BrowserRouter>
|
|
695
|
+
);
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
```jsx fileName="src/components/LocaleRouter.mjx" codeFormat="esm"
|
|
699
|
+
import { localeMap } from 'intlayer'; // Fungsi utilitas dan tipe dari 'intlayer'
|
|
700
|
+
import type { FC, PropsWithChildren } from 'react'; // Tipe React untuk komponen fungsional dan props
|
|
701
|
+
import { IntlayerProvider } from 'react-intlayer'; // Provider untuk konteks internasionalisasi
|
|
702
|
+
import { BrowserRouter, Route, Routes } from 'react-router-dom'; // Komponen router untuk mengelola navigasi
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Komponen router yang mengatur rute spesifik locale.
|
|
706
|
+
* Menggunakan React Router untuk mengelola navigasi dan merender komponen yang dilokalkan.
|
|
707
|
+
*/
|
|
708
|
+
export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
|
|
709
|
+
<BrowserRouter>
|
|
710
|
+
<Routes>
|
|
711
|
+
{localeMap(({ locale, urlPrefix }) => (
|
|
712
|
+
<Route
|
|
713
|
+
// Pola rute untuk menangkap locale (misal: /en/, /fr/) dan mencocokkan semua path berikutnya
|
|
714
|
+
path={`${urlPrefix}/*`}
|
|
715
|
+
key={locale}
|
|
716
|
+
element={
|
|
717
|
+
<IntlayerProvider locale={locale}>{children}</IntlayerProvider>
|
|
718
|
+
} // Membungkus children dengan manajemen locale
|
|
719
|
+
/>
|
|
720
|
+
))}
|
|
721
|
+
</Routes>
|
|
722
|
+
</BrowserRouter>
|
|
723
|
+
);
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
```jsx fileName="src/components/LocaleRouter.cjx" codeFormat="commonjs"
|
|
727
|
+
const { localeMap } = require("intlayer"); // Fungsi utilitas dan tipe dari 'intlayer'
|
|
728
|
+
const React = require("react"); // Import React
|
|
729
|
+
const { IntlayerProvider } = require("react-intlayer"); // Provider untuk konteks internasionalisasi
|
|
730
|
+
const { BrowserRouter, Route, Routes } = require("react-router-dom"); // Komponen router untuk mengelola navigasi
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Komponen router yang mengatur rute spesifik locale.
|
|
734
|
+
* Menggunakan React Router untuk mengelola navigasi dan merender komponen yang dilokalisasi.
|
|
735
|
+
*/
|
|
736
|
+
const LocaleRouter = ({ children }) =>
|
|
737
|
+
React.createElement(
|
|
738
|
+
BrowserRouter,
|
|
739
|
+
{},
|
|
740
|
+
React.createElement(
|
|
741
|
+
Routes,
|
|
742
|
+
{},
|
|
743
|
+
localeMap(({ locale, urlPrefix }) =>
|
|
744
|
+
React.createElement(Route, {
|
|
745
|
+
path: `${urlPrefix}/*`,
|
|
746
|
+
key: locale,
|
|
747
|
+
element: React.createElement(IntlayerProvider, { locale }, children),
|
|
748
|
+
})
|
|
749
|
+
)
|
|
750
|
+
)
|
|
751
|
+
);
|
|
752
|
+
|
|
753
|
+
exports.LocaleRouter = LocaleRouter;
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
> Catatan: Jika Anda menggunakan `routing.mode: 'no-prefix' | 'search-params'`, Anda mungkin tidak perlu menggunakan fungsi `localeMap`.
|
|
757
|
+
|
|
758
|
+
Kemudian, Anda dapat menggunakan komponen `LocaleRouter` dalam aplikasi Anda:
|
|
759
|
+
|
|
760
|
+
```tsx fileName="src/App.tsx" codeFormat="typescript"
|
|
761
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
762
|
+
import type { FC } from "react";
|
|
763
|
+
|
|
764
|
+
// ... Komponen AppContent Anda
|
|
765
|
+
|
|
766
|
+
const App: FC = () => (
|
|
767
|
+
<LocaleRouter>
|
|
768
|
+
<AppContent />
|
|
769
|
+
</LocaleRouter>
|
|
770
|
+
);
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
```jsx fileName="src/App.mjx" codeFormat="esm"
|
|
774
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
775
|
+
|
|
776
|
+
// ... Komponen AppContent Anda
|
|
777
|
+
|
|
778
|
+
const App = () => (
|
|
779
|
+
<LocaleRouter>
|
|
780
|
+
<AppContent />
|
|
781
|
+
</LocaleRouter>
|
|
782
|
+
);
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
```jsx fileName="src/App.cjx" codeFormat="commonjs"
|
|
786
|
+
const { LocaleRouter } = require("./components/LocaleRouter");
|
|
787
|
+
|
|
788
|
+
jsx fileName="src/App.cjx" codeFormat="commonjs"
|
|
789
|
+
// ... Komponen AppContent Anda
|
|
790
|
+
|
|
791
|
+
const App = () => (
|
|
792
|
+
<LocaleRouter>
|
|
793
|
+
<AppContent />
|
|
794
|
+
</LocaleRouter>
|
|
795
|
+
);
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
Secara paralel, Anda juga dapat menggunakan `intlayerMiddleware` untuk menambahkan routing sisi server ke aplikasi Anda. Plugin ini akan secara otomatis mendeteksi locale saat ini berdasarkan URL dan mengatur cookie locale yang sesuai. Jika tidak ada locale yang ditentukan, plugin akan menentukan locale yang paling sesuai berdasarkan preferensi bahasa browser pengguna. Jika tidak ada locale yang terdeteksi, maka akan mengarahkan ulang ke locale default.
|
|
799
|
+
|
|
800
|
+
> Perlu dicatat bahwa untuk menggunakan `intlayerMiddleware` dalam produksi, Anda perlu memindahkan paket `vite-intlayer` dari `devDependencies` ke `dependencies`.
|
|
801
|
+
|
|
802
|
+
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
803
|
+
import { defineConfig } from "vite";
|
|
804
|
+
import react from "@vitejs/plugin-react-swc";
|
|
805
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
806
|
+
|
|
807
|
+
// https://vitejs.dev/config/
|
|
808
|
+
export default defineConfig({
|
|
809
|
+
plugins: [react(), intlayer(), intlayerMiddleware()],
|
|
810
|
+
});
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
814
|
+
import { defineConfig } from "vite";
|
|
815
|
+
import react from "@vitejs/plugin-react-swc";
|
|
816
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
817
|
+
|
|
818
|
+
// https://vitejs.dev/config/
|
|
819
|
+
export default defineConfig({
|
|
820
|
+
plugins: [react(), intlayer(), intlayerMiddleware()],
|
|
821
|
+
});
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
```javascript {3,7} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
825
|
+
const { defineConfig } = require("vite");
|
|
826
|
+
const react = require("@vitejs/plugin-react-swc");
|
|
827
|
+
const { intlayer, intlayerMiddleware } = require("vite-intlayer");
|
|
828
|
+
|
|
829
|
+
// https://vitejs.dev/config/
|
|
830
|
+
module.exports = defineConfig({
|
|
831
|
+
plugins: [react(), intlayer(), intlayerMiddleware()],
|
|
832
|
+
});
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
### (Opsional) Langkah 8: Ubah URL saat locale berubah
|
|
836
|
+
|
|
837
|
+
Untuk mengubah URL saat locale berubah, Anda dapat menggunakan properti `onLocaleChange` yang disediakan oleh hook `useLocale`. Secara paralel, Anda dapat menggunakan hook `useLocation` dan `useNavigate` dari `react-router-dom` untuk memperbarui path URL.
|
|
838
|
+
|
|
839
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
840
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
841
|
+
import {
|
|
842
|
+
Locales,
|
|
843
|
+
getHTMLTextDir,
|
|
844
|
+
getLocaleName,
|
|
845
|
+
getLocalizedUrl,
|
|
846
|
+
} from "intlayer";
|
|
847
|
+
import { useLocale } from "react-intlayer";
|
|
848
|
+
import { type FC } from "react";
|
|
849
|
+
|
|
850
|
+
const LocaleSwitcher: FC = () => {
|
|
851
|
+
const { pathname, search } = useLocation(); // Dapatkan path URL saat ini. Contoh: /fr/about?foo=bar
|
|
852
|
+
const navigate = useNavigate();
|
|
853
|
+
|
|
854
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
855
|
+
onLocaleChange: (locale) => {
|
|
856
|
+
// Bangun URL dengan locale yang diperbarui
|
|
857
|
+
// Contoh: /es/about?foo=bar
|
|
858
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
859
|
+
|
|
860
|
+
// Perbarui path URL
|
|
861
|
+
navigate(pathWithLocale);
|
|
862
|
+
},
|
|
863
|
+
});
|
|
864
|
+
|
|
865
|
+
return (
|
|
866
|
+
<div>
|
|
867
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
868
|
+
<div id="localePopover" popover="auto">
|
|
869
|
+
{availableLocales.map((localeItem) => (
|
|
870
|
+
<a
|
|
871
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
872
|
+
hrefLang={localeItem}
|
|
873
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
874
|
+
onClick={(e) => {
|
|
875
|
+
e.preventDefault();
|
|
876
|
+
setLocale(localeItem);
|
|
877
|
+
}}
|
|
878
|
+
key={localeItem}
|
|
879
|
+
>
|
|
880
|
+
<span>
|
|
881
|
+
{/* Lokal - misal FR */}
|
|
882
|
+
{localeItem}
|
|
883
|
+
</span>
|
|
884
|
+
<span>
|
|
885
|
+
{/* Bahasa dalam Lokal sendiri - misal Français */}
|
|
886
|
+
{getLocaleName(localeItem, locale)}
|
|
887
|
+
</span>
|
|
888
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
889
|
+
{/* Bahasa dalam Lokal saat ini - misal Francés dengan lokal saat ini diset ke Locales.SPANISH */}
|
|
890
|
+
{getLocaleName(localeItem)}
|
|
891
|
+
</span>
|
|
892
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
893
|
+
{/* Bahasa dalam Bahasa Inggris - misalnya French */}
|
|
894
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
895
|
+
</span>
|
|
896
|
+
</a>
|
|
897
|
+
))}
|
|
898
|
+
</div>
|
|
899
|
+
</div>
|
|
900
|
+
);
|
|
901
|
+
};
|
|
902
|
+
```
|
|
903
|
+
|
|
904
|
+
```jsx fileName="src/components/LocaleSwitcher.msx" codeFormat="esm"
|
|
905
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
906
|
+
import {
|
|
907
|
+
Locales,
|
|
908
|
+
getHTMLTextDir,
|
|
909
|
+
getLocaleName,
|
|
910
|
+
getLocalizedUrl,
|
|
911
|
+
} from "intlayer";
|
|
912
|
+
import { useLocale } from "react-intlayer";
|
|
913
|
+
|
|
914
|
+
const LocaleSwitcher = () => {
|
|
915
|
+
const { pathname, search } = useLocation(); // Mendapatkan path URL saat ini. Contoh: /fr/about?foo=bar
|
|
916
|
+
const navigate = useNavigate();
|
|
917
|
+
|
|
918
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
919
|
+
onLocaleChange: (locale) => {
|
|
920
|
+
// Membangun URL dengan locale yang diperbarui
|
|
921
|
+
// Contoh: /es/about?foo=bar
|
|
922
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
923
|
+
|
|
924
|
+
// Perbarui path URL
|
|
925
|
+
navigate(pathWithLocale);
|
|
926
|
+
},
|
|
927
|
+
});
|
|
928
|
+
|
|
929
|
+
return (
|
|
930
|
+
<div>
|
|
931
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
932
|
+
<div id="localePopover" popover="auto">
|
|
933
|
+
{availableLocales.map((localeItem) => (
|
|
934
|
+
<a
|
|
935
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
936
|
+
hrefLang={localeItem}
|
|
937
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
938
|
+
onClick={(e) => {
|
|
939
|
+
e.preventDefault();
|
|
940
|
+
setLocale(localeItem);
|
|
941
|
+
}}
|
|
942
|
+
key={localeItem}
|
|
943
|
+
>
|
|
944
|
+
<span>
|
|
945
|
+
{/* Lokal - misal FR */}
|
|
946
|
+
{localeItem}
|
|
947
|
+
</span>
|
|
948
|
+
<span>
|
|
949
|
+
{/* Bahasa dalam Locale-nya sendiri - misal Français */}
|
|
950
|
+
{getLocaleName(localeItem, locale)}
|
|
951
|
+
</span>
|
|
952
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
953
|
+
{/* Bahasa dalam Locale saat ini - misal Francés dengan locale saat ini diset ke Locales.SPANISH */}
|
|
954
|
+
{getLocaleName(localeItem)}
|
|
955
|
+
</span>
|
|
956
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
957
|
+
{/* Bahasa dalam Bahasa Inggris - misal French */}
|
|
958
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
959
|
+
</span>
|
|
960
|
+
</a>
|
|
961
|
+
))}
|
|
962
|
+
</div>
|
|
963
|
+
</div>
|
|
964
|
+
);
|
|
965
|
+
};
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
```jsx fileName="src/components/LocaleSwitcher.csx" codeFormat="commonjs"
|
|
969
|
+
const { useLocation, useNavigate } = require("react-router-dom");
|
|
970
|
+
const {
|
|
971
|
+
Locales,
|
|
972
|
+
getHTMLTextDir,
|
|
973
|
+
getLocaleName,
|
|
974
|
+
getLocalizedUrl,
|
|
975
|
+
} = require("intlayer");
|
|
976
|
+
const { useLocale } = require("react-intlayer");
|
|
977
|
+
|
|
978
|
+
const LocaleSwitcher = () => {
|
|
979
|
+
const { pathname, search } = useLocation(); // Mendapatkan path URL saat ini. Contoh: /fr/about?foo=bar
|
|
980
|
+
const navigate = useNavigate();
|
|
981
|
+
|
|
982
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
983
|
+
onLocaleChange: (locale) => {
|
|
984
|
+
// Membangun URL dengan locale yang diperbarui
|
|
985
|
+
// Contoh: /es/about?foo=bar
|
|
986
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
987
|
+
|
|
988
|
+
// Memperbarui path URL
|
|
989
|
+
navigate(pathWithLocale);
|
|
990
|
+
},
|
|
991
|
+
});
|
|
992
|
+
|
|
993
|
+
return (
|
|
994
|
+
<div>
|
|
995
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
996
|
+
<div id="localePopover" popover="auto">
|
|
997
|
+
{availableLocales.map((localeItem) => (
|
|
998
|
+
<a
|
|
999
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
1000
|
+
hrefLang={localeItem}
|
|
1001
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1002
|
+
onClick={(e) => {
|
|
1003
|
+
e.preventDefault();
|
|
1004
|
+
setLocale(localeItem);
|
|
1005
|
+
}}
|
|
1006
|
+
key={localeItem}
|
|
1007
|
+
>
|
|
1008
|
+
<span>
|
|
1009
|
+
{/* Lokalisasi - misal FR */}
|
|
1010
|
+
{localeItem}
|
|
1011
|
+
</span>
|
|
1012
|
+
<span>
|
|
1013
|
+
{/* Bahasa dalam Lokalisasi sendiri - misal Français */}
|
|
1014
|
+
{getLocaleName(localeItem, locale)}
|
|
1015
|
+
</span>
|
|
1016
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1017
|
+
{/* Bahasa dalam Locale saat ini - misalnya Francés dengan locale saat ini disetel ke Locales.SPANISH */}
|
|
1018
|
+
{getLocaleName(localeItem)}
|
|
1019
|
+
</span>
|
|
1020
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1021
|
+
{/* Bahasa dalam Bahasa Inggris - misalnya French */}
|
|
1022
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1023
|
+
</span>
|
|
1024
|
+
</a>
|
|
1025
|
+
))}
|
|
1026
|
+
</div>
|
|
1027
|
+
</div>
|
|
1028
|
+
);
|
|
1029
|
+
};
|
|
1030
|
+
```
|
|
1031
|
+
|
|
1032
|
+
> Referensi dokumentasi:
|
|
1033
|
+
>
|
|
1034
|
+
> - [`useLocale` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/react-intlayer/useLocale.md)
|
|
1035
|
+
> - [`getLocaleName` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/intlayer/getLocaleName.md)
|
|
1036
|
+
> - [`getLocalizedUrl` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/intlayer/getLocalizedUrl.md)
|
|
1037
|
+
> - [`getHTMLTextDir` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/intlayer/getHTMLTextDir.md)
|
|
1038
|
+
> - [`hrefLang` attribute](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
|
|
1039
|
+
> - [`lang` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
|
|
1040
|
+
> - [`dir` attribute`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
|
|
1041
|
+
> - [`aria-current` attribute`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1042
|
+
|
|
1043
|
+
Berikut adalah **Langkah 9** yang diperbarui dengan penjelasan tambahan dan contoh kode yang disempurnakan:
|
|
1044
|
+
|
|
1045
|
+
---
|
|
1046
|
+
|
|
1047
|
+
### (Opsional) Langkah 9: Mengganti Atribut Bahasa dan Arah pada HTML
|
|
1048
|
+
|
|
1049
|
+
Ketika aplikasi Anda mendukung banyak bahasa, sangat penting untuk memperbarui atribut `lang` dan `dir` pada tag `<html>` agar sesuai dengan locale saat ini. Melakukan hal ini memastikan:
|
|
1050
|
+
|
|
1051
|
+
- **Aksesibilitas**: Pembaca layar dan teknologi bantu bergantung pada atribut `lang` yang benar untuk mengucapkan dan menginterpretasikan konten dengan akurat.
|
|
1052
|
+
- **Rendering Teks**: Atribut `dir` (arah) memastikan teks ditampilkan dalam urutan yang tepat (misalnya, kiri-ke-kanan untuk bahasa Inggris, kanan-ke-kiri untuk bahasa Arab atau Ibrani), yang sangat penting untuk keterbacaan.
|
|
1053
|
+
- **SEO**: Mesin pencari menggunakan atribut `lang` untuk menentukan bahasa halaman Anda, membantu menyajikan konten lokal yang tepat dalam hasil pencarian.
|
|
1054
|
+
|
|
1055
|
+
Dengan memperbarui atribut ini secara dinamis saat locale berubah, Anda menjamin pengalaman yang konsisten dan dapat diakses bagi pengguna di semua bahasa yang didukung.
|
|
1056
|
+
|
|
1057
|
+
#### Mengimplementasikan Hook
|
|
1058
|
+
|
|
1059
|
+
Buat hook kustom untuk mengelola atribut HTML. Hook ini mendengarkan perubahan locale dan memperbarui atribut sesuai:
|
|
1060
|
+
|
|
1061
|
+
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
|
|
1062
|
+
import { useEffect } from "react";
|
|
1063
|
+
import { useLocale } from "react-intlayer";
|
|
1064
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Memperbarui atribut `lang` dan `dir` elemen HTML <html> berdasarkan locale saat ini.
|
|
1068
|
+
* - `lang`: Memberitahu browser dan mesin pencari tentang bahasa halaman.
|
|
1069
|
+
* - `dir`: Memastikan urutan bacaan yang benar (misalnya, 'ltr' untuk Bahasa Inggris, 'rtl' untuk Bahasa Arab).
|
|
1070
|
+
*
|
|
1071
|
+
* Pembaruan dinamis ini penting untuk rendering teks yang tepat, aksesibilitas, dan SEO.
|
|
1072
|
+
*/
|
|
1073
|
+
export const useI18nHTMLAttributes = () => {
|
|
1074
|
+
const { locale } = useLocale();
|
|
1075
|
+
|
|
1076
|
+
useEffect(() => {
|
|
1077
|
+
// Perbarui atribut bahasa ke locale saat ini.
|
|
1078
|
+
document.documentElement.lang = locale;
|
|
1079
|
+
|
|
1080
|
+
// Atur arah teks berdasarkan locale saat ini.
|
|
1081
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1082
|
+
}, [locale]);
|
|
1083
|
+
};
|
|
1084
|
+
```
|
|
1085
|
+
|
|
1086
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.msx" codeFormat="esm"
|
|
1087
|
+
import { useEffect } from "react";
|
|
1088
|
+
import { useLocale } from "react-intlayer";
|
|
1089
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* Memperbarui atribut `lang` dan `dir` elemen HTML <html> berdasarkan locale saat ini.
|
|
1093
|
+
* - `lang`: Memberitahu browser dan mesin pencari tentang bahasa halaman.
|
|
1094
|
+
* - `dir`: Memastikan urutan pembacaan yang benar (misalnya, 'ltr' untuk bahasa Inggris, 'rtl' untuk bahasa Arab).
|
|
1095
|
+
*
|
|
1096
|
+
* Pembaruan dinamis ini penting untuk rendering teks yang tepat, aksesibilitas, dan SEO.
|
|
1097
|
+
*/
|
|
1098
|
+
export const useI18nHTMLAttributes = () => {
|
|
1099
|
+
const { locale } = useLocale();
|
|
1100
|
+
|
|
1101
|
+
useEffect(() => {
|
|
1102
|
+
// Perbarui atribut bahasa ke locale saat ini.
|
|
1103
|
+
document.documentElement.lang = locale;
|
|
1104
|
+
|
|
1105
|
+
// Atur arah teks berdasarkan locale saat ini.
|
|
1106
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1107
|
+
}, [locale]);
|
|
1108
|
+
};
|
|
1109
|
+
```
|
|
1110
|
+
|
|
1111
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.csx" codeFormat="commonjs"
|
|
1112
|
+
const { useEffect } = require("react");
|
|
1113
|
+
const { useLocale } = require("react-intlayer");
|
|
1114
|
+
const { getHTMLTextDir } = require("intlayer");
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* Memperbarui atribut `lang` dan `dir` elemen HTML <html> berdasarkan locale saat ini.
|
|
1118
|
+
* - `lang`: Memberitahu browser dan mesin pencari tentang bahasa halaman.
|
|
1119
|
+
* - `dir`: Menjamin urutan pembacaan yang benar (misalnya, 'ltr' untuk Bahasa Inggris, 'rtl' untuk Bahasa Arab).
|
|
1120
|
+
*
|
|
1121
|
+
* Pembaruan dinamis ini penting untuk rendering teks yang tepat, aksesibilitas, dan SEO.
|
|
1122
|
+
*/
|
|
1123
|
+
const useI18nHTMLAttributes = () => {
|
|
1124
|
+
const { locale } = useLocale();
|
|
1125
|
+
|
|
1126
|
+
useEffect(() => {
|
|
1127
|
+
// Perbarui atribut bahasa ke locale saat ini.
|
|
1128
|
+
document.documentElement.lang = locale;
|
|
1129
|
+
|
|
1130
|
+
// Atur arah teks berdasarkan locale saat ini.
|
|
1131
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1132
|
+
}, [locale]);
|
|
1133
|
+
};
|
|
1134
|
+
|
|
1135
|
+
module.exports = { useI18nHTMLAttributes };
|
|
1136
|
+
```
|
|
1137
|
+
|
|
1138
|
+
#### Menggunakan Hook di Aplikasi Anda
|
|
1139
|
+
|
|
1140
|
+
Integrasikan hook ini ke dalam komponen utama Anda sehingga atribut HTML akan diperbarui setiap kali locale berubah:
|
|
1141
|
+
|
|
1142
|
+
```tsx fileName="src/App.tsx" codeFormat="typescript"
|
|
1143
|
+
import type { FC } from "react";
|
|
1144
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
1145
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1146
|
+
import "./App.css";
|
|
1147
|
+
|
|
1148
|
+
const AppContent: FC = () => {
|
|
1149
|
+
// Terapkan hook untuk memperbarui atribut lang dan dir pada tag <html> berdasarkan locale.
|
|
1150
|
+
useI18nHTMLAttributes();
|
|
1151
|
+
|
|
1152
|
+
// ... Sisa komponen Anda
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
const App: FC = () => (
|
|
1156
|
+
<IntlayerProvider>
|
|
1157
|
+
<AppContent />
|
|
1158
|
+
</IntlayerProvider>
|
|
1159
|
+
);
|
|
1160
|
+
|
|
1161
|
+
export default App;
|
|
1162
|
+
```
|
|
1163
|
+
|
|
1164
|
+
```jsx fileName="src/App.msx" codeFormat="esm"
|
|
1165
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
1166
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1167
|
+
import "./App.css";
|
|
1168
|
+
|
|
1169
|
+
const AppContent = () => {
|
|
1170
|
+
// Terapkan hook untuk memperbarui atribut lang dan dir pada tag <html> berdasarkan locale.
|
|
1171
|
+
useI18nHTMLAttributes();
|
|
1172
|
+
|
|
1173
|
+
// ... Sisa komponen Anda
|
|
1174
|
+
};
|
|
1175
|
+
|
|
1176
|
+
const App = () => (
|
|
1177
|
+
<IntlayerProvider>
|
|
1178
|
+
<AppContent />
|
|
1179
|
+
</IntlayerProvider>
|
|
1180
|
+
);
|
|
1181
|
+
|
|
1182
|
+
export default App;
|
|
1183
|
+
```
|
|
1184
|
+
|
|
1185
|
+
```jsx fileName="src/App.csx" codeFormat="commonjs"
|
|
1186
|
+
const { FC } = require("react");
|
|
1187
|
+
const { IntlayerProvider, useIntlayer } = require("react-intlayer");
|
|
1188
|
+
const { useI18nHTMLAttributes } = require("./hooks/useI18nHTMLAttributes");
|
|
1189
|
+
require("./App.css");
|
|
1190
|
+
|
|
1191
|
+
const AppContent = () => {
|
|
1192
|
+
// Terapkan hook untuk memperbarui atribut lang dan dir pada tag <html> berdasarkan locale.
|
|
1193
|
+
useI18nHTMLAttributes();
|
|
1194
|
+
|
|
1195
|
+
// ... Sisa komponen Anda
|
|
1196
|
+
};
|
|
1197
|
+
|
|
1198
|
+
const App = () => (
|
|
1199
|
+
<IntlayerProvider>
|
|
1200
|
+
<AppContent />
|
|
1201
|
+
</IntlayerProvider>
|
|
1202
|
+
);
|
|
1203
|
+
|
|
1204
|
+
module.exports = App;
|
|
1205
|
+
```
|
|
1206
|
+
|
|
1207
|
+
Dengan menerapkan perubahan ini, aplikasi Anda akan:
|
|
1208
|
+
|
|
1209
|
+
- Memastikan atribut **bahasa** (`lang`) mencerminkan locale saat ini dengan benar, yang penting untuk SEO dan perilaku browser.
|
|
1210
|
+
- Menyesuaikan **arah teks** (`dir`) sesuai dengan locale, meningkatkan keterbacaan dan kegunaan untuk bahasa dengan urutan baca yang berbeda.
|
|
1211
|
+
- Memberikan pengalaman yang lebih **aksesibel**, karena teknologi bantu bergantung pada atribut ini agar berfungsi secara optimal.
|
|
1212
|
+
|
|
1213
|
+
### (Opsional) Langkah 10: Membuat Komponen Link yang Dilokalkan
|
|
1214
|
+
|
|
1215
|
+
Untuk memastikan navigasi aplikasi Anda menghormati locale saat ini, Anda dapat membuat komponen `Link` kustom. Komponen ini secara otomatis menambahkan prefix bahasa saat ini pada URL internal, sehingga. Misalnya, ketika pengguna berbahasa Prancis mengklik tautan ke halaman "About", mereka akan diarahkan ke `/fr/about` bukan `/about`.
|
|
1216
|
+
|
|
1217
|
+
Perilaku ini berguna untuk beberapa alasan:
|
|
1218
|
+
|
|
1219
|
+
- **SEO dan Pengalaman Pengguna**: URL yang dilokalisasi membantu mesin pencari mengindeks halaman spesifik bahasa dengan benar dan menyediakan konten kepada pengguna dalam bahasa pilihan mereka.
|
|
1220
|
+
- **Konsistensi**: Dengan menggunakan tautan yang dilokalisasi di seluruh aplikasi Anda, Anda menjamin navigasi tetap dalam locale saat ini, mencegah perubahan bahasa yang tidak diinginkan.
|
|
1221
|
+
- **Maintainability**: Memusatkan logika lokalisasi dalam satu komponen menyederhanakan pengelolaan URL, sehingga codebase Anda lebih mudah dipelihara dan dikembangkan seiring pertumbuhan aplikasi Anda.
|
|
1222
|
+
|
|
1223
|
+
Berikut adalah implementasi komponen `Link` yang dilokalisasi dalam TypeScript:
|
|
1224
|
+
|
|
1225
|
+
```tsx fileName="src/components/Link.tsx" codeFormat="typescript"
|
|
1226
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1227
|
+
import {
|
|
1228
|
+
forwardRef,
|
|
1229
|
+
type DetailedHTMLProps,
|
|
1230
|
+
type AnchorHTMLAttributes,
|
|
1231
|
+
} from "react";
|
|
1232
|
+
import { useLocale } from "react-intlayer";
|
|
1233
|
+
|
|
1234
|
+
export interface LinkProps
|
|
1235
|
+
extends DetailedHTMLProps<
|
|
1236
|
+
AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
1237
|
+
HTMLAnchorElement
|
|
1238
|
+
> {}
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* Fungsi utilitas untuk memeriksa apakah URL yang diberikan bersifat eksternal.
|
|
1242
|
+
* Jika URL dimulai dengan http:// atau https://, maka dianggap eksternal.
|
|
1243
|
+
*/
|
|
1244
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1245
|
+
/^https?:\/\//.test(href ?? "");
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* Komponen Link kustom yang menyesuaikan atribut href berdasarkan locale saat ini.
|
|
1249
|
+
* Untuk tautan internal, menggunakan `getLocalizedUrl` untuk menambahkan prefix locale pada URL (misalnya, /fr/about).
|
|
1250
|
+
* Ini memastikan navigasi tetap dalam konteks locale yang sama.
|
|
1251
|
+
*/
|
|
1252
|
+
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
1253
|
+
({ href, children, ...props }, ref) => {
|
|
1254
|
+
const { locale } = useLocale();
|
|
1255
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1256
|
+
|
|
1257
|
+
// Jika tautan bersifat internal dan href valid disediakan, dapatkan URL yang sudah dilokalkan.
|
|
1258
|
+
const hrefI18n =
|
|
1259
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1260
|
+
|
|
1261
|
+
return (
|
|
1262
|
+
<a href={hrefI18n} ref={ref} {...props}>
|
|
1263
|
+
{children}
|
|
1264
|
+
</a>
|
|
1265
|
+
);
|
|
1266
|
+
}
|
|
1267
|
+
);
|
|
1268
|
+
|
|
1269
|
+
Link.displayName = "Link";
|
|
1270
|
+
```
|
|
1271
|
+
|
|
1272
|
+
```jsx fileName="src/components/Link.mjx" codeFormat="esm"
|
|
1273
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1274
|
+
import { useLocale } from "react-intlayer";
|
|
1275
|
+
import { forwardRef } from "react";
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Fungsi utilitas untuk memeriksa apakah URL yang diberikan adalah eksternal.
|
|
1279
|
+
* Jika URL dimulai dengan http:// atau https://, maka dianggap eksternal.
|
|
1280
|
+
*/
|
|
1281
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1282
|
+
/^https?:\/\//.test(href ?? "");
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* Komponen Link kustom yang menyesuaikan atribut href berdasarkan locale saat ini.
|
|
1286
|
+
* Untuk tautan internal, menggunakan `getLocalizedUrl` untuk menambahkan prefix locale pada URL (misalnya, /fr/about).
|
|
1287
|
+
* Ini memastikan navigasi tetap dalam konteks locale yang sama.
|
|
1288
|
+
*/
|
|
1289
|
+
export const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1290
|
+
const { locale } = useLocale();
|
|
1291
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1292
|
+
|
|
1293
|
+
// Jika tautan bersifat internal dan href yang valid diberikan, dapatkan URL yang sudah dilokalkan.
|
|
1294
|
+
const hrefI18n =
|
|
1295
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1296
|
+
|
|
1297
|
+
return (
|
|
1298
|
+
<a href={hrefI18n} ref={ref} {...props}>
|
|
1299
|
+
{children}
|
|
1300
|
+
</a>
|
|
1301
|
+
);
|
|
1302
|
+
});
|
|
1303
|
+
|
|
1304
|
+
Link.displayName = "Link";
|
|
1305
|
+
```
|
|
1306
|
+
|
|
1307
|
+
```jsx fileName="src/components/Link.csx" codeFormat="commonjs"
|
|
1308
|
+
const { getLocalizedUrl } = require("intlayer");
|
|
1309
|
+
const { useLocale } = require("react-intlayer");
|
|
1310
|
+
const { forwardRef } = require("react");
|
|
1311
|
+
|
|
1312
|
+
/**
|
|
1313
|
+
* Fungsi utilitas untuk memeriksa apakah URL yang diberikan bersifat eksternal.
|
|
1314
|
+
* Jika URL dimulai dengan http:// atau https://, maka dianggap eksternal.
|
|
1315
|
+
*/
|
|
1316
|
+
const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* Komponen Link kustom yang menyesuaikan atribut href berdasarkan locale saat ini.
|
|
1320
|
+
* Untuk tautan internal, menggunakan `getLocalizedUrl` untuk menambahkan prefix locale pada URL (misalnya, /fr/about).
|
|
1321
|
+
* Ini memastikan navigasi tetap dalam konteks locale yang sama.
|
|
1322
|
+
*/
|
|
1323
|
+
const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1324
|
+
const { locale } = useLocale();
|
|
1325
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1326
|
+
|
|
1327
|
+
// Jika tautan adalah internal dan href valid diberikan, dapatkan URL yang sudah dilokalkan.
|
|
1328
|
+
const localizedHref = isExternalLink ? href : getLocalizedUrl(href, locale);
|
|
1329
|
+
|
|
1330
|
+
return (
|
|
1331
|
+
<a
|
|
1332
|
+
href={localizedHref}
|
|
1333
|
+
ref={ref}
|
|
1334
|
+
{...props}
|
|
1335
|
+
aria-current={isExternalLink ? "external" : undefined}
|
|
1336
|
+
>
|
|
1337
|
+
{children}
|
|
1338
|
+
</a>
|
|
1339
|
+
);
|
|
1340
|
+
});
|
|
1341
|
+
|
|
1342
|
+
Link.displayName = "Link";
|
|
1343
|
+
```
|
|
1344
|
+
|
|
1345
|
+
#### Cara Kerjanya
|
|
1346
|
+
|
|
1347
|
+
- **Mendeteksi Tautan Eksternal**:
|
|
1348
|
+
Fungsi pembantu `checkIsExternalLink` menentukan apakah sebuah URL adalah eksternal. Tautan eksternal dibiarkan tidak berubah karena tidak memerlukan lokalisasi.
|
|
1349
|
+
|
|
1350
|
+
- **Mengambil Locale Saat Ini**:
|
|
1351
|
+
Hook `useLocale` menyediakan locale saat ini (misalnya, `fr` untuk bahasa Perancis).
|
|
1352
|
+
|
|
1353
|
+
- **Melokalisasi URL**:
|
|
1354
|
+
Untuk tautan internal (yaitu, bukan eksternal), `getLocalizedUrl` digunakan untuk secara otomatis menambahkan prefix locale pada URL. Ini berarti jika pengguna Anda menggunakan bahasa Perancis, memberikan `/about` sebagai `href` akan mengubahnya menjadi `/fr/about`.
|
|
1355
|
+
|
|
1356
|
+
- **Mengembalikan Link**:
|
|
1357
|
+
Komponen mengembalikan elemen `<a>` dengan URL yang sudah dilokalisasi, memastikan navigasi konsisten dengan locale.
|
|
1358
|
+
|
|
1359
|
+
Dengan mengintegrasikan komponen `Link` ini di seluruh aplikasi Anda, Anda mempertahankan pengalaman pengguna yang koheren dan sadar bahasa sekaligus mendapatkan manfaat dari peningkatan SEO dan kegunaan.
|
|
1360
|
+
|
|
1361
|
+
### Konfigurasi TypeScript
|
|
1362
|
+
|
|
1363
|
+
Intlayer menggunakan module augmentation untuk mendapatkan manfaat dari TypeScript dan membuat codebase Anda lebih kuat.
|
|
1364
|
+
|
|
1365
|
+

|
|
1366
|
+
|
|
1367
|
+

|
|
1368
|
+
|
|
1369
|
+
Pastikan konfigurasi TypeScript Anda menyertakan tipe yang dihasilkan secara otomatis.
|
|
1370
|
+
|
|
1371
|
+
```json5 fileName="tsconfig.json"
|
|
1372
|
+
{
|
|
1373
|
+
// ... Konfigurasi TypeScript Anda yang sudah ada
|
|
1374
|
+
"include": [
|
|
1375
|
+
// ... Konfigurasi TypeScript Anda yang sudah ada
|
|
1376
|
+
".intlayer/**/*.ts", // Sertakan tipe yang dihasilkan secara otomatis
|
|
1377
|
+
],
|
|
1378
|
+
}
|
|
1379
|
+
```
|
|
1380
|
+
|
|
1381
|
+
### Konfigurasi Git
|
|
1382
|
+
|
|
1383
|
+
Disarankan untuk mengabaikan file-file yang dihasilkan oleh Intlayer. Ini memungkinkan Anda untuk menghindari meng-commit file tersebut ke repositori Git Anda.
|
|
1384
|
+
|
|
1385
|
+
Untuk melakukan ini, Anda dapat menambahkan instruksi berikut ke file `.gitignore` Anda:
|
|
1386
|
+
|
|
1387
|
+
```plaintext
|
|
1388
|
+
# Abaikan file yang dihasilkan oleh Intlayer
|
|
1389
|
+
.intlayer
|
|
1390
|
+
```
|
|
1391
|
+
|
|
1392
|
+
### Ekstensi VS Code
|
|
1393
|
+
|
|
1394
|
+
Untuk meningkatkan pengalaman pengembangan Anda dengan Intlayer, Anda dapat menginstal **Ekstensi VS Code Intlayer** resmi.
|
|
1395
|
+
|
|
1396
|
+
[Pasang dari VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
1397
|
+
|
|
1398
|
+
Ekstensi ini menyediakan:
|
|
1399
|
+
|
|
1400
|
+
- **Autocompletion** untuk kunci terjemahan.
|
|
1401
|
+
- **Deteksi kesalahan waktu nyata** untuk terjemahan yang hilang.
|
|
1402
|
+
- **Pratinjau inline** dari konten yang diterjemahkan.
|
|
1403
|
+
- **Tindakan cepat** untuk dengan mudah membuat dan memperbarui terjemahan.
|
|
1404
|
+
|
|
1405
|
+
Untuk detail lebih lanjut tentang cara menggunakan ekstensi ini, lihat [dokumentasi Ekstensi VS Code Intlayer](https://intlayer.org/doc/vs-code-extension).
|
|
1406
|
+
|
|
1407
|
+
---
|
|
1408
|
+
|
|
1409
|
+
### Melangkah Lebih Jauh
|
|
1410
|
+
|
|
1411
|
+
Untuk melangkah lebih jauh, Anda dapat mengimplementasikan [editor visual](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_visual_editor.md) atau mengeksternalisasi konten Anda menggunakan [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_CMS.md).
|
|
1412
|
+
|
|
1413
|
+
---
|