@intlayer/docs 7.0.7 → 7.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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,1478 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2024-12-07
|
|
3
|
+
updatedAt: 2025-06-29
|
|
4
|
+
title: Cara menerjemahkan aplikasi Next.js dan Page Router Anda – panduan i18n 2025
|
|
5
|
+
description: Temukan cara membuat situs web Next.js Anda yang menggunakan Page Router menjadi multibahasa. Ikuti dokumentasi untuk melakukan internasionalisasi (i18n) dan menerjemahkannya.
|
|
6
|
+
keywords:
|
|
7
|
+
- Internasionalisasi
|
|
8
|
+
- Dokumentasi
|
|
9
|
+
- Intlayer
|
|
10
|
+
- Page Router
|
|
11
|
+
- Next.js
|
|
12
|
+
- JavaScript
|
|
13
|
+
- React
|
|
14
|
+
slugs:
|
|
15
|
+
- doc
|
|
16
|
+
- environment
|
|
17
|
+
- nextjs
|
|
18
|
+
- next-with-page-router
|
|
19
|
+
history:
|
|
20
|
+
- version: 5.6.0
|
|
21
|
+
date: 2025-07-06
|
|
22
|
+
changes: Mengubah fungsi `withIntlayer()` menjadi fungsi berbasis promise
|
|
23
|
+
- version: 5.5.10
|
|
24
|
+
date: 2025-06-29
|
|
25
|
+
changes: Inisialisasi riwayat
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# Terjemahkan situs web Next.js dan Page Router Anda menggunakan Intlayer | Internasionalisasi (i18n)
|
|
29
|
+
|
|
30
|
+
## Daftar Isi
|
|
31
|
+
|
|
32
|
+
<TOC/>
|
|
33
|
+
|
|
34
|
+
## Apa itu Intlayer?
|
|
35
|
+
|
|
36
|
+
**Intlayer** adalah perpustakaan internasionalisasi (i18n) sumber terbuka yang inovatif, dirancang untuk mempermudah dukungan multibahasa dalam aplikasi web modern. Intlayer terintegrasi dengan mulus dengan kerangka kerja **Next.js** terbaru, termasuk **Page Router** tradisionalnya.
|
|
37
|
+
|
|
38
|
+
Dengan Intlayer, Anda dapat:
|
|
39
|
+
|
|
40
|
+
- **Mengelola terjemahan dengan mudah** menggunakan kamus deklaratif di tingkat komponen.
|
|
41
|
+
- **Melokalkan metadata**, rute, dan konten secara dinamis.
|
|
42
|
+
- **Memastikan dukungan TypeScript** dengan tipe yang dihasilkan secara otomatis, meningkatkan autocompletion dan deteksi kesalahan.
|
|
43
|
+
- **Memanfaatkan fitur canggih**, seperti deteksi dan pengalihan locale secara dinamis.
|
|
44
|
+
|
|
45
|
+
> Intlayer kompatibel dengan Next.js 12, 13, 14, dan 15. Jika Anda menggunakan Next.js App Router, lihat [panduan App Router](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_with_nextjs_14.md). Untuk Next.js 15, ikuti [panduan ini](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_with_nextjs_15.md).
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Panduan Langkah demi Langkah untuk Mengatur Intlayer dalam Aplikasi Next.js Menggunakan Page Router
|
|
50
|
+
|
|
51
|
+
### Langkah 1: Instalasi Dependensi
|
|
52
|
+
|
|
53
|
+
Instal paket yang diperlukan menggunakan manajer paket pilihan Anda:
|
|
54
|
+
|
|
55
|
+
```bash packageManager="npm"
|
|
56
|
+
npm install intlayer next-intlayer
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```bash packageManager="pnpm"
|
|
60
|
+
pnpm add intlayer next-intlayer
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```bash packageManager="yarn"
|
|
64
|
+
yarn add intlayer next-intlayer
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- **intlayer**
|
|
68
|
+
|
|
69
|
+
- **intlayer**
|
|
70
|
+
|
|
71
|
+
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).
|
|
72
|
+
|
|
73
|
+
- **next-intlayer**
|
|
74
|
+
|
|
75
|
+
Paket yang mengintegrasikan Intlayer dengan Next.js. Paket ini menyediakan context provider dan hook untuk internasionalisasi Next.js. Selain itu, paket ini juga menyertakan plugin Next.js untuk mengintegrasikan Intlayer dengan [Webpack](https://webpack.js.org/) atau [Turbopack](https://nextjs.org/docs/app/api-reference/turbopack), serta middleware untuk mendeteksi locale yang dipilih pengguna, mengelola cookie, dan menangani pengalihan URL.
|
|
76
|
+
|
|
77
|
+
### Langkah 2: Konfigurasikan Proyek Anda
|
|
78
|
+
|
|
79
|
+
Buat file konfigurasi untuk mendefinisikan bahasa yang didukung oleh aplikasi Anda:
|
|
80
|
+
|
|
81
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
82
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
83
|
+
|
|
84
|
+
const config: IntlayerConfig = {
|
|
85
|
+
internationalization: {
|
|
86
|
+
locales: [
|
|
87
|
+
Locales.ENGLISH,
|
|
88
|
+
Locales.FRENCH,
|
|
89
|
+
Locales.SPANISH,
|
|
90
|
+
// Tambahkan locale lain Anda di sini
|
|
91
|
+
],
|
|
92
|
+
defaultLocale: Locales.ENGLISH,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export default config;
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
100
|
+
import { Locales } from "intlayer";
|
|
101
|
+
|
|
102
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
103
|
+
const config = {
|
|
104
|
+
internationalization: {
|
|
105
|
+
locales: [
|
|
106
|
+
Locales.ENGLISH,
|
|
107
|
+
Locales.FRENCH,
|
|
108
|
+
Locales.SPANISH,
|
|
109
|
+
// Tambahkan locale lain Anda di sini
|
|
110
|
+
],
|
|
111
|
+
defaultLocale: Locales.ENGLISH,
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export default config;
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
119
|
+
const { Locales } = require("intlayer");
|
|
120
|
+
|
|
121
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
122
|
+
const config = {
|
|
123
|
+
internationalization: {
|
|
124
|
+
locales: [
|
|
125
|
+
Locales.ENGLISH,
|
|
126
|
+
Locales.FRENCH,
|
|
127
|
+
Locales.SPANISH,
|
|
128
|
+
// Tambahkan locale lain Anda di sini
|
|
129
|
+
],
|
|
130
|
+
defaultLocale: Locales.ENGLISH,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
module.exports = config;
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
> 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).
|
|
138
|
+
|
|
139
|
+
### Langkah 3: Integrasikan Intlayer dengan Konfigurasi Next.js
|
|
140
|
+
|
|
141
|
+
Ubah konfigurasi Next.js Anda untuk menggabungkan Intlayer:
|
|
142
|
+
|
|
143
|
+
```typescript fileName="next.config.mjs"
|
|
144
|
+
import { withIntlayer } from "next-intlayer/server";
|
|
145
|
+
|
|
146
|
+
/** @type {import('next').NextConfig} */
|
|
147
|
+
const nextConfig = {
|
|
148
|
+
// Konfigurasi Next.js Anda yang sudah ada
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export default withIntlayer(nextConfig);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
> Plugin Next.js `withIntlayer()` digunakan untuk mengintegrasikan Intlayer dengan Next.js. Plugin ini memastikan pembuatan file deklarasi konten dan memantau file tersebut dalam mode pengembangan. Plugin ini juga mendefinisikan variabel lingkungan Intlayer dalam lingkungan [Webpack](https://webpack.js.org/) atau [Turbopack](https://nextjs.org/docs/app/api-reference/turbopack). Selain itu, plugin ini menyediakan alias untuk mengoptimalkan performa dan memastikan kompatibilitas dengan komponen server.
|
|
155
|
+
|
|
156
|
+
> Fungsi `withIntlayer()` adalah fungsi promise. Jika Anda ingin menggunakannya bersama plugin lain, Anda dapat menggunakan `await`. Contoh:
|
|
157
|
+
>
|
|
158
|
+
> ```tsx
|
|
159
|
+
> const nextConfig = await withIntlayer(nextConfig);
|
|
160
|
+
> const nextConfigWithOtherPlugins = withOtherPlugins(nextConfig);
|
|
161
|
+
>
|
|
162
|
+
> export default nextConfigWithOtherPlugins;
|
|
163
|
+
> ```
|
|
164
|
+
|
|
165
|
+
### Langkah 4: Konfigurasikan Middleware untuk Deteksi Locale
|
|
166
|
+
|
|
167
|
+
Siapkan middleware untuk secara otomatis mendeteksi dan menangani locale yang dipilih pengguna:
|
|
168
|
+
|
|
169
|
+
```typescript fileName="src/middleware.ts" codeFormat="typescript"
|
|
170
|
+
export { intlayerMiddleware as middleware } from "next-intlayer/middleware";
|
|
171
|
+
|
|
172
|
+
export const config = {
|
|
173
|
+
matcher:
|
|
174
|
+
"/((?!api|static|assets|robots|sitemap|sw|service-worker|manifest|.*\\..*|_next).*)",
|
|
175
|
+
};
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
```javascript fileName="src/middleware.mjs" codeFormat="esm"
|
|
179
|
+
export { intlayerMiddleware as middleware } from "next-intlayer/middleware";
|
|
180
|
+
|
|
181
|
+
export const config = {
|
|
182
|
+
matcher:
|
|
183
|
+
"/((?!api|static|assets|robots|sitemap|sw|service-worker|manifest|.*\\..*|_next).*)",
|
|
184
|
+
};
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
```javascript fileName="src/middleware.cjs" codeFormat="commonjs"
|
|
188
|
+
const { intlayerMiddleware } = require("next-intlayer/middleware");
|
|
189
|
+
|
|
190
|
+
const config = {
|
|
191
|
+
matcher:
|
|
192
|
+
"/((?!api|static|assets|robots|sitemap|sw|service-worker|manifest|.*\\..*|_next).*)",
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
module.exports = { middleware: intlayerMiddleware, config };
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
> Sesuaikan parameter `matcher` untuk mencocokkan rute aplikasi Anda. Untuk informasi lebih lanjut, lihat [dokumentasi Next.js tentang konfigurasi matcher](https://nextjs.org/docs/app/building-your-application/routing/middleware).
|
|
199
|
+
|
|
200
|
+
### Langkah 5: Definisikan Rute Locale Dinamis
|
|
201
|
+
|
|
202
|
+
Implementasikan routing dinamis untuk menyajikan konten yang dilokalkan berdasarkan locale pengguna.
|
|
203
|
+
|
|
204
|
+
1. **Buat Halaman Khusus Locale:**
|
|
205
|
+
|
|
206
|
+
Ganti nama file halaman utama Anda untuk menyertakan segmen dinamis `[locale]`.
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
mv src/pages/index.tsx src/pages/[locale]/index.tsx
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
2. **Perbarui `_app.tsx` untuk Menangani Lokalisasi:**
|
|
213
|
+
|
|
214
|
+
Modifikasi `_app.tsx` Anda untuk menyertakan penyedia Intlayer.
|
|
215
|
+
|
|
216
|
+
```tsx fileName="src/pages/_app.tsx" codeFormat="typescript"
|
|
217
|
+
import type { FC } from "react";
|
|
218
|
+
import type { AppProps } from "next/app";
|
|
219
|
+
import { IntlayerClientProvider } from "next-intlayer";
|
|
220
|
+
|
|
221
|
+
const App = FC<AppProps>({ Component, pageProps }) => {
|
|
222
|
+
const { locale } = pageProps;
|
|
223
|
+
|
|
224
|
+
return (
|
|
225
|
+
<IntlayerClientProvider locale={locale}>
|
|
226
|
+
<Component {...pageProps} />
|
|
227
|
+
</IntlayerClientProvider>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export default MyApp;
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
```jsx fileName="src/pages/_app.mjx" codeFormat="esm"
|
|
235
|
+
import { IntlayerClientProvider } from "next-intlayer";
|
|
236
|
+
|
|
237
|
+
const App = ({ Component, pageProps }) => (
|
|
238
|
+
<IntlayerClientProvider locale={locale}>
|
|
239
|
+
<Component {...pageProps} />
|
|
240
|
+
</IntlayerClientProvider>
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
export default App;
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
```jsx fileName="src/pages/_app.csx" codeFormat="commonjs"
|
|
247
|
+
const { IntlayerClientProvider } = require("next-intlayer");
|
|
248
|
+
|
|
249
|
+
const App = ({ Component, pageProps }) => (
|
|
250
|
+
<IntlayerClientProvider locale={locale}>
|
|
251
|
+
<Component {...pageProps} />
|
|
252
|
+
</IntlayerClientProvider>
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
module.exports = App;
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
3. **Atur `getStaticPaths` dan `getStaticProps`:**
|
|
259
|
+
|
|
260
|
+
Di `[locale]/index.tsx` Anda, definisikan paths dan props untuk menangani berbagai locale.
|
|
261
|
+
|
|
262
|
+
```jsx fileName="src/pages/[locale]/index.mjx" codeFormat="esm"
|
|
263
|
+
import { getConfiguration } from "intlayer";
|
|
264
|
+
import { ComponentExample } from "@components/ComponentExample";
|
|
265
|
+
|
|
266
|
+
const HomePage = () => <div>{/* Konten Anda di sini */}</div>;
|
|
267
|
+
|
|
268
|
+
export const getStaticPaths = () => {
|
|
269
|
+
const { internationalization } = getConfiguration();
|
|
270
|
+
const { locales } = internationalization;
|
|
271
|
+
|
|
272
|
+
const paths = locales.map((locale) => ({
|
|
273
|
+
params: { locale },
|
|
274
|
+
}));
|
|
275
|
+
|
|
276
|
+
return { paths, fallback: false };
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export const getStaticProps = ({ params }) => {
|
|
280
|
+
const locale = params?.locale;
|
|
281
|
+
|
|
282
|
+
return {
|
|
283
|
+
props: {
|
|
284
|
+
locale,
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
```jsx fileName="src/pages/[locale]/index.csx" codeFormat="commonjs"
|
|
291
|
+
const { getConfiguration } = require("intlayer");
|
|
292
|
+
const { ComponentExample } = require("@components/ComponentExample");
|
|
293
|
+
|
|
294
|
+
const HomePage = () => <div>{/* Konten Anda di sini */}</div>;
|
|
295
|
+
|
|
296
|
+
const getStaticPaths = async () => {
|
|
297
|
+
const { internationalization } = getConfiguration();
|
|
298
|
+
const { locales } = internationalization;
|
|
299
|
+
|
|
300
|
+
const paths = locales.map((locale) => ({
|
|
301
|
+
params: { locale },
|
|
302
|
+
}));
|
|
303
|
+
|
|
304
|
+
return { paths, fallback: false };
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
const getStaticProps = async ({ params }) => {
|
|
308
|
+
const locale = params?.locale;
|
|
309
|
+
|
|
310
|
+
return {
|
|
311
|
+
props: {
|
|
312
|
+
locale,
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
module.exports = {
|
|
318
|
+
getStaticProps,
|
|
319
|
+
getStaticPaths,
|
|
320
|
+
default: HomePage,
|
|
321
|
+
};
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
> `getStaticPaths` dan `getStaticProps` memastikan bahwa aplikasi Anda membangun terlebih dahulu halaman-halaman yang diperlukan untuk semua locale di Next.js Page Router. Pendekatan ini mengurangi komputasi saat runtime dan menghasilkan pengalaman pengguna yang lebih baik. Untuk detail lebih lanjut, lihat dokumentasi Next.js tentang [`getStaticPaths`](https://nextjs.org/docs/pages/building-your-application/data-fetching/get-static-paths) dan [`getStaticProps`](https://nextjs.org/docs/pages/building-your-application/data-fetching/get-static-props).
|
|
325
|
+
|
|
326
|
+
### Langkah 6: Deklarasikan Konten Anda
|
|
327
|
+
|
|
328
|
+
Buat dan kelola deklarasi konten Anda untuk menyimpan terjemahan.
|
|
329
|
+
|
|
330
|
+
```tsx fileName="src/pages/[locale]/home.content.ts" contentDeclarationFormat="typescript"
|
|
331
|
+
import { t, type Dictionary } from "intlayer";
|
|
332
|
+
|
|
333
|
+
const homeContent = {
|
|
334
|
+
key: "home",
|
|
335
|
+
content: {
|
|
336
|
+
title: t({
|
|
337
|
+
en: "Welcome to My Website",
|
|
338
|
+
fr: "Bienvenue sur mon site Web",
|
|
339
|
+
es: "Bienvenido a mi sitio web",
|
|
340
|
+
}),
|
|
341
|
+
description: t({
|
|
342
|
+
en: "Mulailah dengan mengedit halaman ini.",
|
|
343
|
+
fr: "Commencez par éditer cette page.",
|
|
344
|
+
es: "Comience por editar esta página.",
|
|
345
|
+
}),
|
|
346
|
+
},
|
|
347
|
+
} satisfies Dictionary;
|
|
348
|
+
|
|
349
|
+
export default homeContent;
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
```javascript fileName="src/pages/[locale]/home.content.mjs" contentDeclarationFormat="esm"
|
|
353
|
+
import { t } from "intlayer";
|
|
354
|
+
|
|
355
|
+
/** @type {import('intlayer').Dictionary} */
|
|
356
|
+
const homeContent = {
|
|
357
|
+
key: "home",
|
|
358
|
+
content: {
|
|
359
|
+
getStarted: {
|
|
360
|
+
main: t({
|
|
361
|
+
en: "Mulailah dengan mengedit halaman ini.",
|
|
362
|
+
fr: "Commencez par éditer cette page.",
|
|
363
|
+
es: "Comience por editar esta página.",
|
|
364
|
+
}),
|
|
365
|
+
pageLink: "src/app/page.tsx",
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
export default homeContent;
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
```javascript fileName="src/pages/[locale]/home.content.cjs" contentDeclarationFormat="commonjs"
|
|
374
|
+
const { t } = require("intlayer");
|
|
375
|
+
|
|
376
|
+
/** @type {import('intlayer').Dictionary} */
|
|
377
|
+
const homeContent = {
|
|
378
|
+
key: "home",
|
|
379
|
+
content: {
|
|
380
|
+
getStarted: {
|
|
381
|
+
main: t({
|
|
382
|
+
en: "Mulailah dengan mengedit halaman ini.",
|
|
383
|
+
fr: "Commencez par éditer cette page.",
|
|
384
|
+
es: "Comience por editar esta página.",
|
|
385
|
+
}),
|
|
386
|
+
pageLink: "src/app/page.tsx",
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
module.exports = homeContent;
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
```json fileName="src/pages/[locale]/home.content.json" contentDeclarationFormat="json"
|
|
395
|
+
{
|
|
396
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
397
|
+
"key": "home",
|
|
398
|
+
"content": {
|
|
399
|
+
"getStarted": {
|
|
400
|
+
"nodeType": "translation",
|
|
401
|
+
"translation": {
|
|
402
|
+
"id": "Mulailah dengan mengedit halaman ini.",
|
|
403
|
+
"en": "Get started by editing this page.",
|
|
404
|
+
"fr": "Commencez par éditer cette page.",
|
|
405
|
+
"es": "Comience por editar esta página."
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
"pageLink": {
|
|
409
|
+
"nodeType": "translation",
|
|
410
|
+
"translation": {
|
|
411
|
+
"id": "src/app/page.tsx",
|
|
412
|
+
"en": "src/app/page.tsx",
|
|
413
|
+
"fr": "src/app/page.tsx",
|
|
414
|
+
"es": "src/app/page.tsx"
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
Untuk informasi lebih lanjut tentang deklarasi konten, lihat [panduan deklarasi konten](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/content_file.md).
|
|
422
|
+
|
|
423
|
+
### Langkah 7: Gunakan Konten dalam Kode Anda
|
|
424
|
+
|
|
425
|
+
Akses kamus konten Anda di seluruh aplikasi untuk menampilkan konten yang diterjemahkan.
|
|
426
|
+
|
|
427
|
+
```tsx {2,6} fileName="src/pages/[locale]/index.tsx" codeFormat="typescript"
|
|
428
|
+
import type { FC } from "react";
|
|
429
|
+
import { useIntlayer } from "next-intlayer";
|
|
430
|
+
import { ComponentExample } from "@components/ComponentExample";
|
|
431
|
+
|
|
432
|
+
const HomePage: FC = () => {
|
|
433
|
+
const content = useIntlayer("home");
|
|
434
|
+
|
|
435
|
+
return (
|
|
436
|
+
<div>
|
|
437
|
+
<h1>{content.title}</h1>
|
|
438
|
+
<p>{content.description}</p>
|
|
439
|
+
<ComponentExample />
|
|
440
|
+
{/* Komponen tambahan */}
|
|
441
|
+
</div>
|
|
442
|
+
);
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
// ... Sisa kode, termasuk getStaticPaths dan getStaticProps
|
|
446
|
+
|
|
447
|
+
export default HomePage;
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
```jsx {1,5} fileName="src/pages/[locale]/index.mjx" codeFormat="esm"
|
|
451
|
+
import { useIntlayer } from "next-intlayer";
|
|
452
|
+
import { ComponentExample } from "@components/ComponentExample";
|
|
453
|
+
|
|
454
|
+
const HomePage = () => {
|
|
455
|
+
const content = useIntlayer("home");
|
|
456
|
+
|
|
457
|
+
return (
|
|
458
|
+
<div>
|
|
459
|
+
<h1>{content.getStarted.main}</h1>
|
|
460
|
+
<code>{content.getStarted.pageLink}</code>
|
|
461
|
+
|
|
462
|
+
<ComponentExample />
|
|
463
|
+
{/* Komponen tambahan */}
|
|
464
|
+
</div>
|
|
465
|
+
);
|
|
466
|
+
};
|
|
467
|
+
|
|
468
|
+
// ... Sisa kode, termasuk getStaticPaths dan getStaticProps
|
|
469
|
+
|
|
470
|
+
export default HomePage;
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
```jsx {1,5} fileName="src/pages/[locale]/index.csx" codeFormat="commonjs"
|
|
474
|
+
const { useIntlayer } = require("next-intlayer");
|
|
475
|
+
const { ComponentExample } = require("@components/ComponentExample");
|
|
476
|
+
|
|
477
|
+
const HomePage = () => {
|
|
478
|
+
const content = useIntlayer("home");
|
|
479
|
+
|
|
480
|
+
return (
|
|
481
|
+
<div>
|
|
482
|
+
<h1>{content.getStarted.main}</h1>
|
|
483
|
+
<code>{content.getStarted.pageLink}</code>
|
|
484
|
+
|
|
485
|
+
<ComponentExample />
|
|
486
|
+
{/* Komponen tambahan */}
|
|
487
|
+
</div>
|
|
488
|
+
);
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
// ... Sisa kode, termasuk getStaticPaths dan getStaticProps
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
```tsx fileName="src/components/ComponentExample.tsx" codeFormat="typescript"
|
|
495
|
+
import type { FC } from "react";
|
|
496
|
+
import { useIntlayer } from "next-intlayer";
|
|
497
|
+
|
|
498
|
+
export const ComponentExample: FC = () => {
|
|
499
|
+
const content = useIntlayer("component-example"); // Pastikan Anda memiliki deklarasi konten yang sesuai
|
|
500
|
+
|
|
501
|
+
return (
|
|
502
|
+
<div>
|
|
503
|
+
<h2>{content.title}</h2>
|
|
504
|
+
<p>{content.content}</p>
|
|
505
|
+
</div>
|
|
506
|
+
);
|
|
507
|
+
};
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
```jsx fileName="src/components/ComponentExample.mjx" codeFormat="esm"
|
|
511
|
+
import { useIntlayer } from "next-intlayer";
|
|
512
|
+
|
|
513
|
+
const ComponentExample = () => {
|
|
514
|
+
const content = useIntlayer("component-example"); // Pastikan Anda memiliki deklarasi konten yang sesuai
|
|
515
|
+
|
|
516
|
+
return (
|
|
517
|
+
<div>
|
|
518
|
+
<h2>{content.title}</h2>
|
|
519
|
+
<p>{content.content}</p>
|
|
520
|
+
</div>
|
|
521
|
+
);
|
|
522
|
+
};
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
```jsx fileName="src/components/ComponentExample.csx" codeFormat="commonjs"
|
|
526
|
+
const { useIntlayer } = require("next-intlayer");
|
|
527
|
+
|
|
528
|
+
const ComponentExample = () => {
|
|
529
|
+
const content = useIntlayer("component-example"); // Pastikan Anda memiliki deklarasi konten yang sesuai
|
|
530
|
+
|
|
531
|
+
return (
|
|
532
|
+
<div>
|
|
533
|
+
<h2>{content.title}</h2>
|
|
534
|
+
<p>{content.content}</p>
|
|
535
|
+
</div>
|
|
536
|
+
);
|
|
537
|
+
};
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
> Saat menggunakan terjemahan dalam atribut `string` (misalnya, `alt`, `title`, `href`, `aria-label`), panggil
|
|
541
|
+
|
|
542
|
+
> nilai fungsi sebagai berikut:
|
|
543
|
+
|
|
544
|
+
> ```jsx
|
|
545
|
+
> <img src={content.image.src.value} alt={content.image.value} />
|
|
546
|
+
> ```
|
|
547
|
+
|
|
548
|
+
> Untuk mempelajari lebih lanjut tentang hook `useIntlayer`, lihat [dokumentasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/next-intlayer/useIntlayer.md).
|
|
549
|
+
|
|
550
|
+
### (Opsional) Langkah 8: Internasionalisasi metadata Anda
|
|
551
|
+
|
|
552
|
+
Jika Anda ingin menginternasionalisasi metadata Anda, seperti judul halaman Anda, Anda dapat menggunakan fungsi `getStaticProps` yang disediakan oleh Next.js Page Router. Di dalamnya, Anda dapat mengambil konten dari fungsi `getIntlayer` untuk menerjemahkan metadata Anda.
|
|
553
|
+
|
|
554
|
+
```typescript fileName="src/pages/[locale]/metadata.content.ts" contentDeclarationFormat="typescript"
|
|
555
|
+
import { type Dictionary, t } from "intlayer";
|
|
556
|
+
import { type Metadata } from "next";
|
|
557
|
+
|
|
558
|
+
const metadataContent = {
|
|
559
|
+
key: "page-metadata",
|
|
560
|
+
content: {
|
|
561
|
+
title: t({
|
|
562
|
+
en: "Create Next App",
|
|
563
|
+
fr: "Créer une application Next.js",
|
|
564
|
+
es: "Crear una aplicación Next.js",
|
|
565
|
+
}),
|
|
566
|
+
description: t({
|
|
567
|
+
en: "Generated by create next app",
|
|
568
|
+
fr: "Généré par create next app",
|
|
569
|
+
es: "Generado por create next app",
|
|
570
|
+
}),
|
|
571
|
+
},
|
|
572
|
+
} satisfies Dictionary<Metadata>;
|
|
573
|
+
|
|
574
|
+
export default metadataContent;
|
|
575
|
+
```
|
|
576
|
+
|
|
577
|
+
```javascript fileName="src/pages/[locale]/metadata.content.mjs" contentDeclarationFormat="esm"
|
|
578
|
+
import { t } from "intlayer";
|
|
579
|
+
|
|
580
|
+
/** @type {import('intlayer').Dictionary<import('next').Metadata>} */
|
|
581
|
+
const metadataContent = {
|
|
582
|
+
key: "page-metadata",
|
|
583
|
+
content: {
|
|
584
|
+
title: t({
|
|
585
|
+
en: "Create Next App",
|
|
586
|
+
fr: "Créer une application Next.js",
|
|
587
|
+
es: "Crear una aplicación Next.js",
|
|
588
|
+
}),
|
|
589
|
+
description: t({
|
|
590
|
+
en: "Dihasilkan oleh create next app",
|
|
591
|
+
fr: "Généré par create next app",
|
|
592
|
+
es: "Generado por create next app",
|
|
593
|
+
}),
|
|
594
|
+
},
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
export default metadataContent;
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
```javascript fileName="src/pages/[locale]/metadata.content.cjs" contentDeclarationFormat="commonjs"
|
|
601
|
+
const { t } = require("intlayer");
|
|
602
|
+
|
|
603
|
+
/** @type {import('intlayer').Dictionary<import('next').Metadata>} */
|
|
604
|
+
const metadataContent = {
|
|
605
|
+
key: "page-metadata",
|
|
606
|
+
content: {
|
|
607
|
+
title: t({
|
|
608
|
+
en: "Create Next App",
|
|
609
|
+
fr: "Créer une application Next.js",
|
|
610
|
+
es: "Crear una aplicación Next.js",
|
|
611
|
+
}),
|
|
612
|
+
description: t({
|
|
613
|
+
en: "Generated by create next app",
|
|
614
|
+
fr: "Généré par create next app",
|
|
615
|
+
es: "Generado por create next app",
|
|
616
|
+
}),
|
|
617
|
+
},
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
module.exports = metadataContent;
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
```json fileName="src/pages/[locale]/metadata.content.json" contentDeclarationFormat="json"
|
|
624
|
+
{
|
|
625
|
+
"key": "page-metadata",
|
|
626
|
+
"content": {
|
|
627
|
+
"title": {
|
|
628
|
+
"nodeType": "translation",
|
|
629
|
+
"translation": {
|
|
630
|
+
"en": "Preact logo",
|
|
631
|
+
"fr": "Logo Preact",
|
|
632
|
+
"es": "Logo Preact",
|
|
633
|
+
"id": "Logo Preact"
|
|
634
|
+
},
|
|
635
|
+
},
|
|
636
|
+
"description": {
|
|
637
|
+
"nodeType": "translation",
|
|
638
|
+
"translation": {
|
|
639
|
+
"en": "Generated by create next app",
|
|
640
|
+
"fr": "Généré par create next app",
|
|
641
|
+
"es": "Generado por create next app",
|
|
642
|
+
"id": "Dihasilkan oleh create next app"
|
|
643
|
+
},
|
|
644
|
+
},
|
|
645
|
+
},
|
|
646
|
+
};
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
````tsx fileName="src/pages/[locale]/index.tsx" codeFormat="typescript"
|
|
650
|
+
import { GetStaticPaths, GetStaticProps } from "next";
|
|
651
|
+
import { getIntlayer, getMultilingualUrls } from "intlayer";
|
|
652
|
+
import { useIntlayer } from "next-intlayer";
|
|
653
|
+
import Head from "next/head";
|
|
654
|
+
import type { FC } from "react";
|
|
655
|
+
|
|
656
|
+
interface HomePageProps {
|
|
657
|
+
locale: string;
|
|
658
|
+
metadata: {
|
|
659
|
+
title: string;
|
|
660
|
+
description: string;
|
|
661
|
+
};
|
|
662
|
+
multilingualUrls: Record<string, string>;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
const HomePage: FC<HomePageProps> = ({
|
|
666
|
+
metadata,
|
|
667
|
+
multilingualUrls,
|
|
668
|
+
locale,
|
|
669
|
+
}) => {
|
|
670
|
+
const content = useIntlayer("page");
|
|
671
|
+
|
|
672
|
+
return (
|
|
673
|
+
<div>
|
|
674
|
+
<Head>
|
|
675
|
+
<title>{metadata.title}</title>
|
|
676
|
+
<meta name="description" content={metadata.description} />
|
|
677
|
+
{/* Menghasilkan tag hreflang untuk SEO */}
|
|
678
|
+
{Object.entries(multilingualUrls).map(([lang, url]) => (
|
|
679
|
+
<link key={lang} rel="alternate" hrefLang={lang} href={url} />
|
|
680
|
+
))}
|
|
681
|
+
<link rel="canonical" href={multilingualUrls[locale]} />
|
|
682
|
+
</Head>
|
|
683
|
+
|
|
684
|
+
{/* Konten halaman */}
|
|
685
|
+
<main>{/* Konten halaman Anda di sini */}</main>
|
|
686
|
+
</div>
|
|
687
|
+
);
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
export const getStaticProps: GetStaticProps<HomePageProps> = async ({
|
|
691
|
+
params,
|
|
692
|
+
}) => {
|
|
693
|
+
const locale = params?.locale as string;
|
|
694
|
+
|
|
695
|
+
const metadata = getIntlayer("page-metadata", locale);
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Menghasilkan objek yang berisi semua url untuk setiap locale.
|
|
699
|
+
*
|
|
700
|
+
* Contoh:
|
|
701
|
+
* ```ts
|
|
702
|
+
* getMultilingualUrls('/about');
|
|
703
|
+
*
|
|
704
|
+
* // Mengembalikan
|
|
705
|
+
* // {
|
|
706
|
+
* // en: '/about',
|
|
707
|
+
* // fr: '/fr/about',
|
|
708
|
+
* // es: '/es/about',
|
|
709
|
+
* // }
|
|
710
|
+
* ```
|
|
711
|
+
*/
|
|
712
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
713
|
+
|
|
714
|
+
return {
|
|
715
|
+
props: {
|
|
716
|
+
locale,
|
|
717
|
+
metadata,
|
|
718
|
+
multilingualUrls,
|
|
719
|
+
},
|
|
720
|
+
};
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
export default HomePage;
|
|
724
|
+
|
|
725
|
+
// ... Sisa kode termasuk getStaticPaths
|
|
726
|
+
````
|
|
727
|
+
|
|
728
|
+
````jsx fileName="src/pages/[locale]/index.mjx" codeFormat="esm"
|
|
729
|
+
import { getIntlayer, getMultilingualUrls } from "intlayer";
|
|
730
|
+
import { useIntlayer } from "next-intlayer";
|
|
731
|
+
import Head from "next/head";
|
|
732
|
+
|
|
733
|
+
const HomePage = ({ metadata, multilingualUrls, locale }) => {
|
|
734
|
+
const content = useIntlayer("page");
|
|
735
|
+
|
|
736
|
+
return (
|
|
737
|
+
<div>
|
|
738
|
+
<Head>
|
|
739
|
+
<title>{metadata.title}</title>
|
|
740
|
+
<meta name="description" content={metadata.description} />
|
|
741
|
+
{/* Menghasilkan tag hreflang untuk SEO */}
|
|
742
|
+
{Object.entries(multilingualUrls).map(([lang, url]) => (
|
|
743
|
+
<link key={lang} rel="alternate" hrefLang={lang} href={url} />
|
|
744
|
+
))}
|
|
745
|
+
<link rel="canonical" href={multilingualUrls[locale]} />
|
|
746
|
+
</Head>
|
|
747
|
+
|
|
748
|
+
{/* Konten halaman */}
|
|
749
|
+
<main>{/* Konten halaman Anda di sini */}</main>
|
|
750
|
+
</div>
|
|
751
|
+
);
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
export const getStaticProps = async ({ params }) => {
|
|
755
|
+
const locale = params?.locale;
|
|
756
|
+
|
|
757
|
+
const metadata = getIntlayer("page-metadata", locale);
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Menghasilkan objek yang berisi semua url untuk setiap locale.
|
|
761
|
+
*
|
|
762
|
+
* Contoh:
|
|
763
|
+
* ```ts
|
|
764
|
+
* getMultilingualUrls('/about');
|
|
765
|
+
*
|
|
766
|
+
* // Mengembalikan
|
|
767
|
+
* // {
|
|
768
|
+
* // en: '/about',
|
|
769
|
+
* // fr: '/fr/about',
|
|
770
|
+
* // es: '/es/about',
|
|
771
|
+
* // }
|
|
772
|
+
* ```
|
|
773
|
+
*/
|
|
774
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
775
|
+
|
|
776
|
+
return {
|
|
777
|
+
props: {
|
|
778
|
+
locale,
|
|
779
|
+
metadata,
|
|
780
|
+
multilingualUrls,
|
|
781
|
+
},
|
|
782
|
+
};
|
|
783
|
+
};
|
|
784
|
+
|
|
785
|
+
export default HomePage;
|
|
786
|
+
|
|
787
|
+
// ... Sisa kode termasuk getStaticPaths
|
|
788
|
+
````
|
|
789
|
+
|
|
790
|
+
````jsx fileName="src/pages/[locale]/index.csx" codeFormat="commonjs"
|
|
791
|
+
const { getIntlayer, getMultilingualUrls } = require("intlayer");
|
|
792
|
+
const { useIntlayer } = require("next-intlayer");
|
|
793
|
+
const Head = require("next/head");
|
|
794
|
+
|
|
795
|
+
const HomePage = ({ metadata, multilingualUrls, locale }) => {
|
|
796
|
+
const content = useIntlayer("page");
|
|
797
|
+
|
|
798
|
+
return (
|
|
799
|
+
<div>
|
|
800
|
+
<Head>
|
|
801
|
+
<title>{metadata.title}</title>
|
|
802
|
+
<meta name="description" content={metadata.description} />
|
|
803
|
+
{/* Menghasilkan tag hreflang untuk SEO */}
|
|
804
|
+
{Object.entries(multilingualUrls).map(([lang, url]) => (
|
|
805
|
+
<link key={lang} rel="alternate" hrefLang={lang} href={url} />
|
|
806
|
+
))}
|
|
807
|
+
<link rel="canonical" href={multilingualUrls[locale]} />
|
|
808
|
+
</Head>
|
|
809
|
+
|
|
810
|
+
{/* Konten halaman */}
|
|
811
|
+
<main>{/* Konten halaman Anda di sini */}</main>
|
|
812
|
+
</div>
|
|
813
|
+
);
|
|
814
|
+
};
|
|
815
|
+
|
|
816
|
+
const getStaticProps = async ({ params }) => {
|
|
817
|
+
const locale = params?.locale;
|
|
818
|
+
|
|
819
|
+
const metadata = getIntlayer("page-metadata", locale);
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* Menghasilkan objek yang berisi semua url untuk setiap locale.
|
|
823
|
+
*
|
|
824
|
+
* Contoh:
|
|
825
|
+
* ```ts
|
|
826
|
+
* getMultilingualUrls('/about');
|
|
827
|
+
*
|
|
828
|
+
* // Mengembalikan
|
|
829
|
+
* // {
|
|
830
|
+
* // en: '/about',
|
|
831
|
+
* // fr: '/fr/about',
|
|
832
|
+
* // es: '/es/about',
|
|
833
|
+
* // }
|
|
834
|
+
* ```
|
|
835
|
+
*/
|
|
836
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
837
|
+
|
|
838
|
+
return {
|
|
839
|
+
props: {
|
|
840
|
+
locale,
|
|
841
|
+
metadata,
|
|
842
|
+
multilingualUrls,
|
|
843
|
+
},
|
|
844
|
+
};
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
module.exports = {
|
|
848
|
+
getStaticProps,
|
|
849
|
+
getStaticPaths,
|
|
850
|
+
default: HomePage,
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
// ... Sisa kode termasuk getStaticPaths
|
|
854
|
+
````
|
|
855
|
+
|
|
856
|
+
> Perlu dicatat bahwa fungsi `getIntlayer` yang diimpor dari `next-intlayer` mengembalikan konten Anda yang dibungkus dalam `IntlayerNode`, memungkinkan integrasi dengan visual editor. Sebaliknya, fungsi `getIntlayer` yang diimpor dari `intlayer` mengembalikan konten Anda secara langsung tanpa properti tambahan.
|
|
857
|
+
|
|
858
|
+
Sebagai alternatif, Anda dapat menggunakan fungsi `getTranslation` untuk mendeklarasikan metadata Anda. Namun, menggunakan file deklarasi konten direkomendasikan untuk mengotomatisasi terjemahan metadata Anda dan mengeksternalisasi konten pada suatu titik.
|
|
859
|
+
|
|
860
|
+
```tsx fileName="src/pages/[locale]/index.tsx" codeFormat="typescript"
|
|
861
|
+
import { GetStaticPaths, GetStaticProps } from "next";
|
|
862
|
+
import {
|
|
863
|
+
type IConfigLocales,
|
|
864
|
+
getTranslation,
|
|
865
|
+
getMultilingualUrls,
|
|
866
|
+
} from "intlayer";
|
|
867
|
+
import { useIntlayer } from "next-intlayer";
|
|
868
|
+
import Head from "next/head";
|
|
869
|
+
import type { FC } from "react";
|
|
870
|
+
|
|
871
|
+
interface HomePageProps {
|
|
872
|
+
locale: string;
|
|
873
|
+
metadata: {
|
|
874
|
+
title: string;
|
|
875
|
+
description: string;
|
|
876
|
+
};
|
|
877
|
+
multilingualUrls: Record<string, string>;
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
const HomePage: FC<HomePageProps> = ({ metadata, multilingualUrls, locale }) => {
|
|
881
|
+
const content = useIntlayer("page");
|
|
882
|
+
|
|
883
|
+
return (
|
|
884
|
+
<div>
|
|
885
|
+
<Head>
|
|
886
|
+
<title>{metadata.title}</title>
|
|
887
|
+
<meta name="description" content={metadata.description} />
|
|
888
|
+
{/* Menghasilkan tag hreflang untuk SEO */}
|
|
889
|
+
{Object.entries(multilingualUrls).map(([lang, url]) => (
|
|
890
|
+
<link
|
|
891
|
+
key={lang}
|
|
892
|
+
rel="alternate"
|
|
893
|
+
hrefLang={lang}
|
|
894
|
+
href={url}
|
|
895
|
+
/>
|
|
896
|
+
))}
|
|
897
|
+
<link rel="canonical" href={multilingualUrls[locale]} />
|
|
898
|
+
</Head>
|
|
899
|
+
|
|
900
|
+
{/* Konten halaman */}
|
|
901
|
+
<main>
|
|
902
|
+
{/* Konten halaman Anda di sini */}
|
|
903
|
+
</main>
|
|
904
|
+
</div>
|
|
905
|
+
);
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
export const getStaticProps: GetStaticProps<HomePageProps> = async ({
|
|
909
|
+
params
|
|
910
|
+
}) => {
|
|
911
|
+
const locale = params?.locale as string;
|
|
912
|
+
const t = <T>(content: IConfigLocales<T>) => getTranslation(content, locale);
|
|
913
|
+
|
|
914
|
+
const metadata = {
|
|
915
|
+
title: t<string>({
|
|
916
|
+
en: "My title",
|
|
917
|
+
fr: "Mon titre",
|
|
918
|
+
es: "Mi título",
|
|
919
|
+
}),
|
|
920
|
+
description: t({
|
|
921
|
+
en: "My description",
|
|
922
|
+
fr: "Ma description",
|
|
923
|
+
es: "Mi descripción",
|
|
924
|
+
}),
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
928
|
+
|
|
929
|
+
return {
|
|
930
|
+
props: {
|
|
931
|
+
locale,
|
|
932
|
+
metadata,
|
|
933
|
+
multilingualUrls,
|
|
934
|
+
},
|
|
935
|
+
};
|
|
936
|
+
};
|
|
937
|
+
|
|
938
|
+
export default HomePage;
|
|
939
|
+
|
|
940
|
+
// ... Sisa kode termasuk getStaticPaths
|
|
941
|
+
```
|
|
942
|
+
|
|
943
|
+
```jsx fileName="src/pages/[locale]/index.mjx" codeFormat="esm"
|
|
944
|
+
import { getTranslation, getMultilingualUrls } from "intlayer";
|
|
945
|
+
import { useIntlayer } from "next-intlayer";
|
|
946
|
+
import Head from "next/head";
|
|
947
|
+
|
|
948
|
+
const HomePage = ({ metadata, multilingualUrls, locale }) => {
|
|
949
|
+
const content = useIntlayer("page");
|
|
950
|
+
|
|
951
|
+
return (
|
|
952
|
+
<div>
|
|
953
|
+
<Head>
|
|
954
|
+
<title>{metadata.title}</title>
|
|
955
|
+
<meta name="description" content={metadata.description} />
|
|
956
|
+
{/* Menghasilkan tag hreflang untuk SEO */}
|
|
957
|
+
{Object.entries(multilingualUrls).map(([lang, url]) => (
|
|
958
|
+
<link key={lang} rel="alternate" hrefLang={lang} href={url} />
|
|
959
|
+
))}
|
|
960
|
+
<link rel="canonical" href={multilingualUrls[locale]} />
|
|
961
|
+
</Head>
|
|
962
|
+
|
|
963
|
+
{/* Konten halaman */}
|
|
964
|
+
<main>{/* Konten halaman Anda di sini */}</main>
|
|
965
|
+
</div>
|
|
966
|
+
);
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
export const getStaticProps = async ({ params }) => {
|
|
970
|
+
const locale = params?.locale;
|
|
971
|
+
const t = (content) => getTranslation(content, locale);
|
|
972
|
+
|
|
973
|
+
const metadata = {
|
|
974
|
+
title: t({
|
|
975
|
+
en: "My title",
|
|
976
|
+
fr: "Mon titre",
|
|
977
|
+
es: "Mi título",
|
|
978
|
+
}),
|
|
979
|
+
description: t({
|
|
980
|
+
en: "My description",
|
|
981
|
+
fr: "Ma description",
|
|
982
|
+
es: "Mi descripción",
|
|
983
|
+
}),
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
987
|
+
|
|
988
|
+
return {
|
|
989
|
+
props: {
|
|
990
|
+
locale,
|
|
991
|
+
metadata,
|
|
992
|
+
multilingualUrls,
|
|
993
|
+
},
|
|
994
|
+
};
|
|
995
|
+
};
|
|
996
|
+
|
|
997
|
+
export default HomePage;
|
|
998
|
+
|
|
999
|
+
// ... Sisa kode termasuk getStaticPaths
|
|
1000
|
+
```
|
|
1001
|
+
|
|
1002
|
+
```jsx fileName="src/pages/[locale]/index.csx" codeFormat="commonjs"
|
|
1003
|
+
const { getTranslation, getMultilingualUrls } = require("intlayer");
|
|
1004
|
+
const { useIntlayer } = require("next-intlayer");
|
|
1005
|
+
const Head = require("next/head");
|
|
1006
|
+
|
|
1007
|
+
const HomePage = ({ metadata, multilingualUrls, locale }) => {
|
|
1008
|
+
const content = useIntlayer("page");
|
|
1009
|
+
|
|
1010
|
+
return (
|
|
1011
|
+
<div>
|
|
1012
|
+
<Head>
|
|
1013
|
+
<title>{metadata.title}</title>
|
|
1014
|
+
<meta name="description" content={metadata.description} />
|
|
1015
|
+
{/* Menghasilkan tag hreflang untuk SEO */}
|
|
1016
|
+
{Object.entries(multilingualUrls).map(([lang, url]) => (
|
|
1017
|
+
<link key={lang} rel="alternate" hrefLang={lang} href={url} />
|
|
1018
|
+
))}
|
|
1019
|
+
<link rel="canonical" href={multilingualUrls[locale]} />
|
|
1020
|
+
</Head>
|
|
1021
|
+
|
|
1022
|
+
{/* Konten halaman */}
|
|
1023
|
+
<main>{/* Konten halaman Anda di sini */}</main>
|
|
1024
|
+
</div>
|
|
1025
|
+
);
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
const getStaticProps = async ({ params }) => {
|
|
1029
|
+
const locale = params?.locale;
|
|
1030
|
+
const t = (content) => getTranslation(content, locale);
|
|
1031
|
+
|
|
1032
|
+
const metadata = {
|
|
1033
|
+
title: t({
|
|
1034
|
+
en: "My title",
|
|
1035
|
+
fr: "Mon titre",
|
|
1036
|
+
es: "Mi título",
|
|
1037
|
+
}),
|
|
1038
|
+
description: t({
|
|
1039
|
+
en: "My description",
|
|
1040
|
+
fr: "Ma description",
|
|
1041
|
+
es: "Mi descripción",
|
|
1042
|
+
}),
|
|
1043
|
+
};
|
|
1044
|
+
|
|
1045
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
1046
|
+
|
|
1047
|
+
return {
|
|
1048
|
+
props: {
|
|
1049
|
+
locale,
|
|
1050
|
+
metadata,
|
|
1051
|
+
multilingualUrls,
|
|
1052
|
+
},
|
|
1053
|
+
};
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
module.exports = {
|
|
1057
|
+
getStaticProps,
|
|
1058
|
+
getStaticPaths,
|
|
1059
|
+
default: HomePage,
|
|
1060
|
+
};
|
|
1061
|
+
|
|
1062
|
+
// ... Sisa kode termasuk getStaticPaths
|
|
1063
|
+
```
|
|
1064
|
+
|
|
1065
|
+
> Pelajari lebih lanjut tentang optimasi metadata [di dokumentasi resmi Next.js](https://nextjs.org/docs/pages/building-your-application/optimizing/metadata).
|
|
1066
|
+
|
|
1067
|
+
### (Opsional) Langkah 9: Ubah bahasa konten Anda
|
|
1068
|
+
|
|
1069
|
+
Untuk mengubah bahasa konten Anda di Next.js, cara yang direkomendasikan adalah menggunakan komponen `Link` untuk mengarahkan pengguna ke halaman lokal yang sesuai. Komponen `Link` memungkinkan prefetching halaman, yang membantu menghindari pemuatan ulang halaman secara penuh.
|
|
1070
|
+
|
|
1071
|
+
```tsx fileName="src/components/LanguageSwitcher.tsx" codeFormat="typescript"
|
|
1072
|
+
import {
|
|
1073
|
+
Locales,
|
|
1074
|
+
getHTMLTextDir,
|
|
1075
|
+
getLocaleName,
|
|
1076
|
+
getLocalizedUrl,
|
|
1077
|
+
} from "intlayer";
|
|
1078
|
+
import { useLocalePageRouter } from "next-intlayer";
|
|
1079
|
+
import { type FC } from "react";
|
|
1080
|
+
import Link from "next/link";
|
|
1081
|
+
|
|
1082
|
+
const LocaleSwitcher: FC = () => {
|
|
1083
|
+
const { locale, pathWithoutLocale, availableLocales } = useLocalePageRouter();
|
|
1084
|
+
const { setLocaleCookie } = useLocaleCookie();
|
|
1085
|
+
|
|
1086
|
+
return (
|
|
1087
|
+
<div>
|
|
1088
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1089
|
+
<div id="localePopover" popover="auto">
|
|
1090
|
+
{availableLocales.map((localeItem) => (
|
|
1091
|
+
<Link
|
|
1092
|
+
href={getLocalizedUrl(pathWithoutLocale, localeItem)}
|
|
1093
|
+
hrefLang={localeItem}
|
|
1094
|
+
key={localeItem}
|
|
1095
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1096
|
+
onClick={() => setLocaleCookie(localeItem)}
|
|
1097
|
+
>
|
|
1098
|
+
<span>
|
|
1099
|
+
{/* Locale - misal FR */}
|
|
1100
|
+
{localeItem}
|
|
1101
|
+
</span>
|
|
1102
|
+
<span>
|
|
1103
|
+
{/* Bahasa dalam Locale-nya sendiri - misal Français */}
|
|
1104
|
+
{getLocaleName(localeItem, locale)}
|
|
1105
|
+
</span>
|
|
1106
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1107
|
+
{/* Bahasa dalam Locale saat ini - misalnya Francés dengan locale saat ini disetel ke Locales.SPANISH */}
|
|
1108
|
+
{getLocaleName(localeItem)}
|
|
1109
|
+
</span>
|
|
1110
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1111
|
+
{/* Bahasa dalam Bahasa Inggris - misalnya French */}
|
|
1112
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1113
|
+
</span>
|
|
1114
|
+
</Link>
|
|
1115
|
+
))}
|
|
1116
|
+
</div>
|
|
1117
|
+
</div>
|
|
1118
|
+
);
|
|
1119
|
+
};
|
|
1120
|
+
```
|
|
1121
|
+
|
|
1122
|
+
```jsx fileName="src/components/LanguageSwitcher.msx" codeFormat="esm"
|
|
1123
|
+
import {
|
|
1124
|
+
Locales,
|
|
1125
|
+
getHTMLTextDir,
|
|
1126
|
+
getLocaleName,
|
|
1127
|
+
getLocalizedUrl,
|
|
1128
|
+
} from "intlayer";
|
|
1129
|
+
import { useLocalePageRouter } from "next-intlayer";
|
|
1130
|
+
import Link from "next/link";
|
|
1131
|
+
|
|
1132
|
+
const LocaleSwitcher = () => {
|
|
1133
|
+
const { locale, pathWithoutLocale, availableLocales } = useLocalePageRouter();
|
|
1134
|
+
const { setLocaleCookie } = useLocaleCookie();
|
|
1135
|
+
|
|
1136
|
+
return (
|
|
1137
|
+
<div>
|
|
1138
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1139
|
+
<div id="localePopover" popover="auto">
|
|
1140
|
+
{availableLocales.map((localeItem) => (
|
|
1141
|
+
<Link
|
|
1142
|
+
href={getLocalizedUrl(pathWithoutLocale, localeItem)}
|
|
1143
|
+
hrefLang={localeItem}
|
|
1144
|
+
key={localeItem}
|
|
1145
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1146
|
+
onClick={() => setLocaleCookie(localeItem)}
|
|
1147
|
+
>
|
|
1148
|
+
<span>
|
|
1149
|
+
{/* Locale - misal FR */}
|
|
1150
|
+
{localeItem}
|
|
1151
|
+
</span>
|
|
1152
|
+
<span>
|
|
1153
|
+
{/* Bahasa dalam Locale-nya sendiri - misalnya Français */}
|
|
1154
|
+
{getLocaleName(localeItem, locale)}
|
|
1155
|
+
</span>
|
|
1156
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1157
|
+
{/* Bahasa dalam Locale saat ini - misalnya Francés dengan locale saat ini disetel ke Locales.SPANISH */}
|
|
1158
|
+
{getLocaleName(localeItem)}
|
|
1159
|
+
</span>
|
|
1160
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1161
|
+
{/* Bahasa dalam Bahasa Inggris - misalnya French */}
|
|
1162
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1163
|
+
</span>
|
|
1164
|
+
</Link>
|
|
1165
|
+
))}
|
|
1166
|
+
</div>
|
|
1167
|
+
</div>
|
|
1168
|
+
);
|
|
1169
|
+
};
|
|
1170
|
+
```
|
|
1171
|
+
|
|
1172
|
+
```jsx fileName="src/components/LanguageSwitcher.msx" codeFormat="commonjs"
|
|
1173
|
+
const {
|
|
1174
|
+
Locales,
|
|
1175
|
+
getHTMLTextDir,
|
|
1176
|
+
getLocaleName,
|
|
1177
|
+
getLocalizedUrl,
|
|
1178
|
+
} = require("intlayer");
|
|
1179
|
+
const { useLocalePageRouter } = require("next-intlayer");
|
|
1180
|
+
const Link = require("next/link");
|
|
1181
|
+
|
|
1182
|
+
const LocaleSwitcher = () => {
|
|
1183
|
+
const { locale, pathWithoutLocale, availableLocales } = useLocalePageRouter();
|
|
1184
|
+
const { setLocaleCookie } = useLocaleCookie();
|
|
1185
|
+
|
|
1186
|
+
return (
|
|
1187
|
+
<select>
|
|
1188
|
+
{availableLocales.map((localeItem) => (
|
|
1189
|
+
<option value={localeItem} key={localeItem}>
|
|
1190
|
+
<Link
|
|
1191
|
+
href={getLocalizedUrl(pathWithoutLocale, localeItem)}
|
|
1192
|
+
hrefLang={localeItem}
|
|
1193
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1194
|
+
onClick={() => setLocaleCookie(localeItem)}
|
|
1195
|
+
>
|
|
1196
|
+
<span>
|
|
1197
|
+
{/* Locale - misal FR */}
|
|
1198
|
+
{localeItem}
|
|
1199
|
+
</span>
|
|
1200
|
+
<span>
|
|
1201
|
+
{/* Bahasa dalam Locale-nya sendiri - misalnya Français */}
|
|
1202
|
+
{getLocaleName(localeItem, locale)}
|
|
1203
|
+
</span>
|
|
1204
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1205
|
+
{/* Bahasa dalam Locale saat ini - misalnya Francés dengan locale saat ini disetel ke Locales.SPANISH */}
|
|
1206
|
+
{getLocaleName(localeItem)}
|
|
1207
|
+
</span>
|
|
1208
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1209
|
+
{/* Bahasa dalam bahasa Inggris - misalnya French */}
|
|
1210
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1211
|
+
</span>
|
|
1212
|
+
</Link>
|
|
1213
|
+
</option>
|
|
1214
|
+
))}
|
|
1215
|
+
</select>
|
|
1216
|
+
);
|
|
1217
|
+
};
|
|
1218
|
+
```
|
|
1219
|
+
|
|
1220
|
+
> Cara alternatif adalah menggunakan fungsi `setLocale` yang disediakan oleh hook `useLocale`. Fungsi ini tidak akan memungkinkan prefetching halaman dan akan memuat ulang halaman.
|
|
1221
|
+
|
|
1222
|
+
> Dalam kasus ini, tanpa pengalihan menggunakan `router.push`, hanya kode sisi server Anda yang akan mengubah locale dari konten.
|
|
1223
|
+
|
|
1224
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
1225
|
+
"use client";
|
|
1226
|
+
|
|
1227
|
+
import { useRouter } from "next/navigation";
|
|
1228
|
+
import { useLocale } from "next-intlayer";
|
|
1229
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1230
|
+
|
|
1231
|
+
// ... Sisa kode
|
|
1232
|
+
|
|
1233
|
+
const router = useRouter();
|
|
1234
|
+
const { setLocale } = useLocale({
|
|
1235
|
+
onLocaleChange: (locale) => {
|
|
1236
|
+
router.push(getLocalizedUrl(pathWithoutLocale, locale));
|
|
1237
|
+
},
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1240
|
+
return (
|
|
1241
|
+
<button onClick={() => setLocale(Locales.FRENCH)}>
|
|
1242
|
+
Ubah ke Bahasa Perancis
|
|
1243
|
+
</button>
|
|
1244
|
+
);
|
|
1245
|
+
```
|
|
1246
|
+
|
|
1247
|
+
> API `useLocalePageRouter` sama dengan `useLocale`. Untuk mempelajari lebih lanjut tentang hook `useLocale`, lihat [dokumentasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/next-intlayer/useLocale.md).
|
|
1248
|
+
|
|
1249
|
+
> Referensi dokumentasi:
|
|
1250
|
+
>
|
|
1251
|
+
> - [hook `getLocaleName`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/intlayer/getLocaleName.md)
|
|
1252
|
+
> - [hook `getLocalizedUrl`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/intlayer/getLocalizedUrl.md)
|
|
1253
|
+
> - [hook `getHTMLTextDir`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/intlayer/getHTMLTextDir.md)
|
|
1254
|
+
> - [atribut `hrefLang`](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
|
|
1255
|
+
> - [`atribut lang`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
|
|
1256
|
+
> - [`atribut dir`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
|
|
1257
|
+
> - [`atribut aria-current`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1258
|
+
|
|
1259
|
+
### (Opsional) Langkah 10: Membuat Komponen Link yang Dilokalkan
|
|
1260
|
+
|
|
1261
|
+
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 Perancis mengklik tautan ke halaman "About", mereka akan diarahkan ke `/fr/about` bukan `/about`.
|
|
1262
|
+
|
|
1263
|
+
Perilaku ini berguna untuk beberapa alasan:
|
|
1264
|
+
|
|
1265
|
+
- **SEO dan Pengalaman Pengguna**: URL yang dilokalkan membantu mesin pencari mengindeks halaman spesifik bahasa dengan benar dan menyediakan konten kepada pengguna dalam bahasa pilihan mereka.
|
|
1266
|
+
- **Konsistensi**: Dengan menggunakan tautan yang dilokalkan di seluruh aplikasi Anda, Anda menjamin bahwa navigasi tetap dalam locale saat ini, mencegah perubahan bahasa yang tidak terduga.
|
|
1267
|
+
- **Pemeliharaan**: Memusatkan logika lokalisasi dalam satu komponen menyederhanakan pengelolaan URL, membuat codebase Anda lebih mudah dipelihara dan dikembangkan seiring pertumbuhan aplikasi Anda.
|
|
1268
|
+
|
|
1269
|
+
Berikut adalah implementasi komponen `Link` yang dilokalkan dalam TypeScript:
|
|
1270
|
+
|
|
1271
|
+
```tsx fileName="src/components/Link.tsx" codeFormat="typescript"
|
|
1272
|
+
"use client";
|
|
1273
|
+
|
|
1274
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1275
|
+
import NextLink, { type LinkProps as NextLinkProps } from "next/link";
|
|
1276
|
+
import { useLocale } from "next-intlayer";
|
|
1277
|
+
import { forwardRef, PropsWithChildren, type ForwardedRef } from "react";
|
|
1278
|
+
|
|
1279
|
+
/**
|
|
1280
|
+
* Fungsi utilitas untuk memeriksa apakah URL yang diberikan adalah eksternal.
|
|
1281
|
+
* Jika URL dimulai dengan http:// atau https://, maka dianggap eksternal.
|
|
1282
|
+
*/
|
|
1283
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1284
|
+
/^https?:\/\//.test(href ?? "");
|
|
1285
|
+
|
|
1286
|
+
/**
|
|
1287
|
+
* Komponen Link kustom yang menyesuaikan atribut href berdasarkan locale saat ini.
|
|
1288
|
+
* Untuk tautan internal, menggunakan `getLocalizedUrl` untuk menambahkan prefix locale pada URL (misalnya, /fr/about).
|
|
1289
|
+
* Ini memastikan navigasi tetap dalam konteks locale yang sama.
|
|
1290
|
+
*/
|
|
1291
|
+
export const Link = forwardRef<
|
|
1292
|
+
HTMLAnchorElement,
|
|
1293
|
+
PropsWithChildren<NextLinkProps>
|
|
1294
|
+
>(({ href, children, ...props }, ref: ForwardedRef<HTMLAnchorElement>) => {
|
|
1295
|
+
const { locale } = useLocale();
|
|
1296
|
+
const isExternalLink = checkIsExternalLink(href.toString());
|
|
1297
|
+
|
|
1298
|
+
// Jika tautan bersifat internal dan href yang valid disediakan, dapatkan URL yang dilokalkan.
|
|
1299
|
+
const hrefI18n: NextLinkProps["href"] =
|
|
1300
|
+
href && !isExternalLink ? getLocalizedUrl(href.toString(), locale) : href;
|
|
1301
|
+
|
|
1302
|
+
return (
|
|
1303
|
+
<NextLink href={hrefI18n} ref={ref} {...props}>
|
|
1304
|
+
{children}
|
|
1305
|
+
</NextLink>
|
|
1306
|
+
);
|
|
1307
|
+
});
|
|
1308
|
+
|
|
1309
|
+
Link.displayName = "Link";
|
|
1310
|
+
```
|
|
1311
|
+
|
|
1312
|
+
```jsx fileName="src/components/Link.mjx" codeFormat="esm"
|
|
1313
|
+
'use client';
|
|
1314
|
+
|
|
1315
|
+
import { getLocalizedUrl } from 'intlayer';
|
|
1316
|
+
import NextLink, { type LinkProps as NextLinkProps } from 'next/link';
|
|
1317
|
+
import { useLocale } from 'next-intlayer';
|
|
1318
|
+
import { forwardRef, PropsWithChildren, type ForwardedRef } from 'react';
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* Fungsi utilitas untuk memeriksa apakah URL yang diberikan bersifat eksternal.
|
|
1322
|
+
* Jika URL dimulai dengan http:// atau https://, maka dianggap eksternal.
|
|
1323
|
+
*/
|
|
1324
|
+
export const checkIsExternalLink = (href) =>
|
|
1325
|
+
/^https?:\/\//.test(href ?? '');
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* Komponen Link kustom yang menyesuaikan atribut href berdasarkan locale saat ini.
|
|
1329
|
+
* Untuk tautan internal, menggunakan `getLocalizedUrl` untuk menambahkan prefix locale pada URL (misalnya, /fr/about).
|
|
1330
|
+
* Ini memastikan navigasi tetap dalam konteks locale yang sama.
|
|
1331
|
+
*/
|
|
1332
|
+
export const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1333
|
+
const { locale } = useLocale();
|
|
1334
|
+
const isExternalLink = checkIsExternalLink(href.toString());
|
|
1335
|
+
|
|
1336
|
+
// Jika tautan bersifat internal dan href yang valid diberikan, dapatkan URL yang sudah dilokalkan.
|
|
1337
|
+
const hrefI18n =
|
|
1338
|
+
href && !isExternalLink ? getLocalizedUrl(href.toString(), locale) : href;
|
|
1339
|
+
|
|
1340
|
+
return (
|
|
1341
|
+
<NextLink href={hrefI18n} ref={ref} {...props}>
|
|
1342
|
+
{children}
|
|
1343
|
+
</NextLink>
|
|
1344
|
+
);
|
|
1345
|
+
});
|
|
1346
|
+
|
|
1347
|
+
Link.displayName = 'Link';
|
|
1348
|
+
```
|
|
1349
|
+
|
|
1350
|
+
```jsx fileName="src/components/Link.csx" codeFormat="commonjs"
|
|
1351
|
+
'use client';
|
|
1352
|
+
|
|
1353
|
+
const { getLocalizedUrl } = require("intlayer");
|
|
1354
|
+
const NextLink = require("next/link");
|
|
1355
|
+
const { useLocale } = require("next-intlayer");
|
|
1356
|
+
const { forwardRef } = require("react");
|
|
1357
|
+
|
|
1358
|
+
/**
|
|
1359
|
+
* Fungsi utilitas untuk memeriksa apakah URL yang diberikan bersifat eksternal.
|
|
1360
|
+
* Jika URL dimulai dengan http:// atau https://, maka dianggap eksternal.
|
|
1361
|
+
*/
|
|
1362
|
+
const checkIsExternalLink = (href) =>
|
|
1363
|
+
/^https?:\/\//.test(href ?? '');
|
|
1364
|
+
|
|
1365
|
+
|
|
1366
|
+
const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1367
|
+
const { locale } = useLocale();
|
|
1368
|
+
const isExternalLink = checkIsExternalLink(href.toString());
|
|
1369
|
+
|
|
1370
|
+
// Jika tautan bersifat internal dan href yang valid disediakan, dapatkan URL yang sudah dilokalkan.
|
|
1371
|
+
const hrefI18n: NextLinkProps['href'] =
|
|
1372
|
+
href && !isExternalLink ? getLocalizedUrl(href.toString(), locale) : href;
|
|
1373
|
+
|
|
1374
|
+
return (
|
|
1375
|
+
<NextLink href={hrefI18n} ref={ref} {...props}>
|
|
1376
|
+
{children}
|
|
1377
|
+
</NextLink>
|
|
1378
|
+
);
|
|
1379
|
+
});
|
|
1380
|
+
|
|
1381
|
+
Link.displayName = 'Link';
|
|
1382
|
+
```
|
|
1383
|
+
|
|
1384
|
+
#### Cara Kerjanya
|
|
1385
|
+
|
|
1386
|
+
- **Mendeteksi Tautan Eksternal**:
|
|
1387
|
+
Fungsi pembantu `checkIsExternalLink` menentukan apakah sebuah URL bersifat eksternal. Tautan eksternal dibiarkan tidak berubah karena tidak memerlukan lokalisasi.
|
|
1388
|
+
|
|
1389
|
+
- **Mengambil Locale Saat Ini**:
|
|
1390
|
+
Hook `useLocale` menyediakan locale saat ini (misalnya, `fr` untuk bahasa Perancis).
|
|
1391
|
+
|
|
1392
|
+
- **Melokalkan URL**:
|
|
1393
|
+
Untuk tautan internal (yaitu, bukan eksternal), `getLocalizedUrl` digunakan untuk secara otomatis menambahkan prefix locale saat ini ke URL. Ini berarti jika pengguna Anda menggunakan bahasa Perancis, melewatkan `/about` sebagai `href` akan mengubahnya menjadi `/fr/about`.
|
|
1394
|
+
|
|
1395
|
+
- **Mengembalikan Link**:
|
|
1396
|
+
Komponen mengembalikan elemen `<a>` dengan URL yang sudah dilokalkan, memastikan navigasi konsisten dengan locale.
|
|
1397
|
+
|
|
1398
|
+
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.
|
|
1399
|
+
|
|
1400
|
+
### (Opsional) Langkah 11: Optimalkan ukuran bundle Anda
|
|
1401
|
+
|
|
1402
|
+
Saat menggunakan `next-intlayer`, kamus disertakan dalam bundle untuk setiap halaman secara default. Untuk mengoptimalkan ukuran bundle, Intlayer menyediakan plugin SWC opsional yang secara cerdas menggantikan panggilan `useIntlayer` menggunakan makro. Ini memastikan kamus hanya disertakan dalam bundle untuk halaman yang benar-benar menggunakannya.
|
|
1403
|
+
|
|
1404
|
+
Untuk mengaktifkan optimasi ini, instal paket `@intlayer/swc`. Setelah terinstal, `next-intlayer` akan secara otomatis mendeteksi dan menggunakan plugin tersebut:
|
|
1405
|
+
|
|
1406
|
+
```bash packageManager="npm"
|
|
1407
|
+
npm install @intlayer/swc --save-dev
|
|
1408
|
+
```
|
|
1409
|
+
|
|
1410
|
+
```bash packageManager="pnpm"
|
|
1411
|
+
pnpm add @intlayer/swc --save-dev
|
|
1412
|
+
```
|
|
1413
|
+
|
|
1414
|
+
```bash packageManager="yarn"
|
|
1415
|
+
yarn add @intlayer/swc --save-dev
|
|
1416
|
+
```
|
|
1417
|
+
|
|
1418
|
+
> Catatan: Optimasi ini hanya tersedia untuk Next.js 13 ke atas.
|
|
1419
|
+
|
|
1420
|
+
> Catatan: Paket ini tidak diinstal secara default karena plugin SWC masih bersifat eksperimental di Next.js. Hal ini mungkin akan berubah di masa depan.
|
|
1421
|
+
|
|
1422
|
+
### Konfigurasi TypeScript
|
|
1423
|
+
|
|
1424
|
+
Intlayer menggunakan module augmentation untuk mendapatkan manfaat dari TypeScript dan membuat codebase Anda lebih kuat.
|
|
1425
|
+
|
|
1426
|
+

|
|
1427
|
+
|
|
1428
|
+

|
|
1429
|
+
|
|
1430
|
+
Pastikan konfigurasi TypeScript Anda menyertakan tipe yang dihasilkan secara otomatis.
|
|
1431
|
+
|
|
1432
|
+
```json5 fileName="tsconfig.json"
|
|
1433
|
+
{
|
|
1434
|
+
// ... Konfigurasi TypeScript Anda yang sudah ada
|
|
1435
|
+
"include": [
|
|
1436
|
+
// ... Konfigurasi TypeScript Anda yang sudah ada
|
|
1437
|
+
".intlayer/**/*.ts", // Sertakan tipe yang dihasilkan otomatis
|
|
1438
|
+
],
|
|
1439
|
+
}
|
|
1440
|
+
```
|
|
1441
|
+
|
|
1442
|
+
### Konfigurasi Git
|
|
1443
|
+
|
|
1444
|
+
Untuk menjaga kebersihan repositori Anda dan menghindari commit file yang dihasilkan, disarankan untuk mengabaikan file yang dibuat oleh Intlayer.
|
|
1445
|
+
|
|
1446
|
+
Tambahkan baris berikut ke file `.gitignore` Anda:
|
|
1447
|
+
|
|
1448
|
+
```plaintext fileName=".gitignore"
|
|
1449
|
+
# Abaikan file yang dihasilkan oleh Intlayer
|
|
1450
|
+
.intlayer
|
|
1451
|
+
```
|
|
1452
|
+
|
|
1453
|
+
### Ekstensi VS Code
|
|
1454
|
+
|
|
1455
|
+
Untuk meningkatkan pengalaman pengembangan Anda dengan Intlayer, Anda dapat menginstal **Ekstensi VS Code Intlayer** resmi.
|
|
1456
|
+
|
|
1457
|
+
[Pasang dari VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
1458
|
+
|
|
1459
|
+
Ekstensi ini menyediakan:
|
|
1460
|
+
|
|
1461
|
+
- **Autocompletion** untuk kunci terjemahan.
|
|
1462
|
+
- **Deteksi kesalahan waktu nyata** untuk terjemahan yang hilang.
|
|
1463
|
+
- **Pratinjau inline** dari konten terjemahan.
|
|
1464
|
+
- **Aksi cepat** untuk dengan mudah membuat dan memperbarui terjemahan.
|
|
1465
|
+
|
|
1466
|
+
Untuk informasi lebih lanjut tentang cara menggunakan ekstensi ini, lihat [dokumentasi Ekstensi VS Code Intlayer](https://intlayer.org/doc/vs-code-extension).
|
|
1467
|
+
|
|
1468
|
+
## Sumber Daya Tambahan
|
|
1469
|
+
|
|
1470
|
+
- **Dokumentasi Intlayer:** [Repositori GitHub](https://github.com/aymericzip/intlayer)
|
|
1471
|
+
- **Panduan Kamus:** [Kamus](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/content_file.md)
|
|
1472
|
+
- **Dokumentasi Konfigurasi:** [Panduan Konfigurasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/configuration.md)
|
|
1473
|
+
|
|
1474
|
+
Dengan mengikuti panduan ini, Anda dapat mengintegrasikan Intlayer secara efektif ke dalam aplikasi Next.js Anda menggunakan Page Router, memungkinkan dukungan internasionalisasi yang kuat dan skalabel untuk proyek web Anda.
|
|
1475
|
+
|
|
1476
|
+
### Melangkah Lebih Jauh
|
|
1477
|
+
|
|
1478
|
+
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).
|