@intlayer/docs 7.0.6 → 7.0.8-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blog/ar/i18n_using_next-i18next.md +1068 -0
- package/blog/ar/i18n_using_next-intl.md +768 -0
- package/blog/ar/intlayer_with_react-intl.md +0 -4
- package/blog/ar/next-i18next_vs_next-intl_vs_intlayer.md +5 -4
- package/blog/de/i18n_using_next-i18next.md +1107 -0
- package/blog/de/i18n_using_next-intl.md +760 -0
- package/blog/de/intlayer_with_react-intl.md +0 -4
- package/blog/de/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/en/i18n_using_next-i18next.md +1073 -0
- package/blog/en/i18n_using_next-intl.md +757 -0
- package/blog/en/intlayer_with_i18next.md +71 -8
- package/blog/en/intlayer_with_next-i18next.md +71 -8
- package/blog/en/intlayer_with_next-intl.md +71 -8
- package/blog/en/intlayer_with_react-i18next.md +69 -8
- package/blog/en/intlayer_with_react-intl.md +68 -9
- package/blog/en/intlayer_with_vue-i18n.md +68 -7
- package/blog/en/react-i18next_vs_react-intl_vs_intlayer.md +2 -0
- package/blog/en/vue-i18n_vs_intlayer.md +2 -0
- package/blog/en-GB/i18n_using_next-i18next.md +1074 -0
- package/blog/en-GB/i18n_using_next-intl.md +757 -0
- package/blog/en-GB/intlayer_with_i18next.md +15 -6
- package/blog/en-GB/intlayer_with_next-i18next.md +16 -6
- package/blog/en-GB/intlayer_with_next-intl.md +16 -6
- package/blog/en-GB/intlayer_with_react-i18next.md +16 -7
- package/blog/en-GB/intlayer_with_react-intl.md +14 -9
- package/blog/en-GB/intlayer_with_vue-i18n.md +16 -7
- package/blog/en-GB/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/en-GB/react-i18next_vs_react-intl_vs_intlayer.md +2 -0
- package/blog/en-GB/vue-i18n_vs_intlayer.md +2 -0
- package/blog/es/i18n_using_next-i18next.md +1066 -0
- package/blog/es/i18n_using_next-intl.md +757 -0
- package/blog/es/intlayer_with_react-intl.md +0 -4
- package/blog/es/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/fr/i18n_using_next-i18next.md +1078 -0
- package/blog/fr/i18n_using_next-intl.md +759 -0
- package/blog/fr/intlayer_with_react-intl.md +0 -4
- package/blog/fr/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/hi/i18n_using_next-i18next.md +1068 -0
- package/blog/hi/i18n_using_next-intl.md +758 -0
- package/blog/hi/intlayer_with_react-intl.md +0 -4
- package/blog/hi/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/id/i18n_using_next-i18next.md +1078 -0
- package/blog/id/i18n_using_next-intl.md +757 -0
- package/blog/id/index.md +69 -0
- package/blog/id/internationalization_and_SEO.md +364 -0
- package/blog/id/intlayer_with_react-intl.md +0 -4
- package/blog/id/list_i18n_technologies/CMS/drupal.md +143 -0
- package/blog/id/list_i18n_technologies/CMS/wix.md +167 -0
- package/blog/id/list_i18n_technologies/CMS/wordpress.md +188 -0
- package/blog/id/list_i18n_technologies/frameworks/angular.md +125 -0
- package/blog/id/list_i18n_technologies/frameworks/flutter.md +150 -0
- package/blog/id/list_i18n_technologies/frameworks/react-native.md +217 -0
- package/blog/id/list_i18n_technologies/frameworks/react.md +155 -0
- package/blog/id/list_i18n_technologies/frameworks/svelte.md +131 -0
- package/blog/id/list_i18n_technologies/frameworks/vue.md +130 -0
- package/blog/id/next-i18next_vs_next-intl_vs_intlayer.md +1500 -0
- package/blog/id/nextjs-multilingual-seo-comparison.md +361 -0
- package/blog/id/rag_powered_documentation_assistant.md +288 -0
- package/blog/id/react-i18next_vs_react-intl_vs_intlayer.md +164 -0
- package/blog/id/vue-i18n_vs_intlayer.md +278 -0
- package/blog/id/what_is_internationalization.md +166 -0
- package/blog/it/i18n_using_next-i18next.md +1078 -0
- package/blog/it/i18n_using_next-intl.md +758 -0
- package/blog/it/intlayer_with_react-intl.md +0 -4
- package/blog/it/react-i18next_vs_react-intl_vs_intlayer.md +4 -0
- package/blog/it/vue-i18n_vs_intlayer.md +2 -0
- package/blog/ja/i18n_using_next-i18next.md +1078 -0
- package/blog/ja/i18n_using_next-intl.md +758 -0
- package/blog/ja/intlayer_with_react-intl.md +0 -4
- package/blog/ja/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/ko/i18n_using_next-i18next.md +1075 -0
- package/blog/ko/i18n_using_next-intl.md +759 -0
- package/blog/ko/intlayer_with_react-intl.md +0 -4
- package/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/pl/i18n_using_next-i18next.md +1078 -0
- package/blog/pl/i18n_using_next-intl.md +758 -0
- package/blog/pl/index.md +69 -0
- package/blog/pl/internationalization_and_SEO.md +363 -0
- package/blog/pl/intlayer_with_react-intl.md +0 -4
- package/blog/pl/list_i18n_technologies/CMS/drupal.md +143 -0
- package/blog/pl/list_i18n_technologies/CMS/wix.md +167 -0
- package/blog/pl/list_i18n_technologies/CMS/wordpress.md +196 -0
- package/blog/pl/list_i18n_technologies/frameworks/angular.md +125 -0
- package/blog/pl/list_i18n_technologies/frameworks/flutter.md +151 -0
- package/blog/pl/list_i18n_technologies/frameworks/react-native.md +217 -0
- package/blog/pl/list_i18n_technologies/frameworks/react.md +155 -0
- package/blog/pl/list_i18n_technologies/frameworks/svelte.md +131 -0
- package/blog/pl/list_i18n_technologies/frameworks/vue.md +130 -0
- package/blog/pl/next-i18next_vs_next-intl_vs_intlayer.md +1501 -0
- package/blog/pl/nextjs-multilingual-seo-comparison.md +362 -0
- package/blog/pl/rag_powered_documentation_assistant.md +288 -0
- package/blog/pl/react-i18next_vs_react-intl_vs_intlayer.md +164 -0
- package/blog/pl/vue-i18n_vs_intlayer.md +278 -0
- package/blog/pl/what_is_internationalization.md +167 -0
- package/blog/pt/i18n_using_next-i18next.md +1067 -0
- package/blog/pt/i18n_using_next-intl.md +760 -0
- package/blog/pt/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/ru/i18n_using_next-i18next.md +1106 -0
- package/blog/ru/i18n_using_next-intl.md +759 -0
- package/blog/ru/intlayer_with_react-intl.md +0 -4
- package/blog/ru/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/tr/i18n_using_next-i18next.md +1078 -0
- package/blog/tr/i18n_using_next-intl.md +760 -0
- package/blog/tr/intlayer_with_react-intl.md +0 -4
- package/blog/tr/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/tr/react-i18next_vs_react-intl_vs_intlayer.md +2 -0
- package/blog/tr/vue-i18n_vs_intlayer.md +2 -0
- package/blog/vi/i18n_using_next-i18next.md +1080 -0
- package/blog/vi/i18n_using_next-intl.md +758 -0
- package/blog/vi/index.md +69 -0
- package/blog/vi/internationalization_and_SEO.md +363 -0
- package/blog/vi/intlayer_with_react-intl.md +0 -4
- package/blog/vi/list_i18n_technologies/CMS/drupal.md +143 -0
- package/blog/vi/list_i18n_technologies/CMS/wix.md +167 -0
- package/blog/vi/list_i18n_technologies/CMS/wordpress.md +188 -0
- package/blog/vi/list_i18n_technologies/frameworks/angular.md +125 -0
- package/blog/vi/list_i18n_technologies/frameworks/flutter.md +150 -0
- package/blog/vi/list_i18n_technologies/frameworks/react-native.md +217 -0
- package/blog/vi/list_i18n_technologies/frameworks/react.md +155 -0
- package/blog/vi/list_i18n_technologies/frameworks/svelte.md +131 -0
- package/blog/vi/list_i18n_technologies/frameworks/vue.md +130 -0
- package/blog/vi/next-i18next_vs_next-intl_vs_intlayer.md +1520 -0
- package/blog/vi/nextjs-multilingual-seo-comparison.md +362 -0
- package/blog/vi/rag_powered_documentation_assistant.md +288 -0
- package/blog/vi/react-i18next_vs_react-intl_vs_intlayer.md +164 -0
- package/blog/vi/vue-i18n_vs_intlayer.md +278 -0
- package/blog/vi/what_is_internationalization.md +168 -0
- package/blog/zh/i18n_using_next-i18next.md +1105 -0
- package/blog/zh/i18n_using_next-intl.md +758 -0
- package/blog/zh/intlayer_with_react-intl.md +0 -4
- package/blog/zh/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/zh/react-i18next_vs_react-intl_vs_intlayer.md +2 -0
- package/dist/cjs/common.cjs +0 -4
- package/dist/cjs/common.cjs.map +1 -1
- package/dist/cjs/generated/blog.entry.cjs +38 -6
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/cjs/generated/docs.entry.cjs +0 -6
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/cjs/generated/frequentQuestions.entry.cjs +0 -6
- package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
- package/dist/cjs/generated/legal.entry.cjs +0 -6
- package/dist/cjs/generated/legal.entry.cjs.map +1 -1
- package/dist/esm/generated/blog.entry.mjs +38 -0
- package/dist/esm/generated/blog.entry.mjs.map +1 -1
- package/dist/types/generated/blog.entry.d.ts +2 -0
- package/dist/types/generated/blog.entry.d.ts.map +1 -1
- package/docs/ar/component_i18n.md +1 -1
- package/docs/ar/configuration.md +6 -0
- package/docs/ar/intlayer_cli.md +8 -3
- package/docs/ar/intlayer_with_next-i18next.md +619 -0
- package/docs/ar/intlayer_with_next-intl.md +446 -0
- package/docs/ar/intlayer_with_nextjs_16.md +21 -0
- package/docs/ar/intlayer_with_tanstack.md +4 -0
- package/docs/ar/intlayer_with_vite+react.md +4 -0
- package/docs/de/component_i18n.md +1 -1
- package/docs/de/configuration.md +6 -0
- package/docs/de/intlayer_cli.md +8 -3
- package/docs/de/intlayer_with_next-i18next.md +627 -0
- package/docs/de/intlayer_with_next-intl.md +451 -0
- package/docs/de/intlayer_with_nextjs_16.md +21 -0
- package/docs/de/intlayer_with_tanstack.md +4 -0
- package/docs/de/intlayer_with_vite+react.md +4 -0
- package/docs/en/component_i18n.md +1 -1
- package/docs/en/intlayer_cli.md +8 -1
- package/docs/en/intlayer_with_astro.md +10 -2
- package/docs/en/intlayer_with_create_react_app.md +8 -0
- package/docs/en/intlayer_with_lynx+react.md +8 -0
- package/docs/en/intlayer_with_nestjs.md +10 -0
- package/docs/en/intlayer_with_nextjs_14.md +10 -2
- package/docs/en/intlayer_with_nextjs_15.md +21 -4
- package/docs/en/intlayer_with_nextjs_16.md +17 -0
- package/docs/en/intlayer_with_nuxt.md +8 -0
- package/docs/en/intlayer_with_react_native+expo.md +10 -2
- package/docs/en/intlayer_with_react_router_v7.md +8 -0
- package/docs/en/intlayer_with_tanstack.md +10 -0
- package/docs/en/intlayer_with_vite+preact.md +10 -2
- package/docs/en/intlayer_with_vite+react.md +21 -4
- package/docs/en/intlayer_with_vite+vue.md +10 -2
- package/docs/en-GB/component_i18n.md +1 -1
- package/docs/en-GB/configuration.md +6 -0
- package/docs/en-GB/intlayer_cli.md +8 -3
- package/docs/en-GB/intlayer_with_angular.md +4 -4
- package/docs/en-GB/intlayer_with_express.md +4 -4
- package/docs/en-GB/intlayer_with_lynx+react.md +12 -12
- package/{blog/en/_intlayer_with_next-i18next.md → docs/en-GB/intlayer_with_next-i18next.md} +241 -42
- package/{blog/en/_intlayer_with_next-intl.md → docs/en-GB/intlayer_with_next-intl.md} +144 -29
- package/docs/en-GB/intlayer_with_nextjs_16.md +21 -0
- package/docs/en-GB/intlayer_with_tanstack.md +5 -1
- package/docs/en-GB/intlayer_with_vite+react.md +4 -0
- package/docs/en-GB/packages/next-intlayer/t.md +2 -2
- package/docs/es/component_i18n.md +1 -1
- package/docs/es/configuration.md +6 -0
- package/docs/es/intlayer_cli.md +8 -3
- package/docs/es/intlayer_with_next-i18next.md +628 -0
- package/docs/es/intlayer_with_next-intl.md +446 -0
- package/docs/es/intlayer_with_nextjs_16.md +21 -0
- package/docs/es/intlayer_with_tanstack.md +4 -0
- package/docs/es/intlayer_with_vite+react.md +4 -0
- package/docs/fr/configuration.md +6 -0
- package/docs/fr/intlayer_cli.md +8 -3
- package/docs/fr/intlayer_with_next-i18next.md +628 -0
- package/docs/fr/intlayer_with_next-intl.md +446 -0
- package/docs/fr/intlayer_with_nextjs_16.md +23 -2
- package/docs/fr/intlayer_with_tanstack.md +4 -0
- package/docs/fr/intlayer_with_vite+react.md +4 -0
- package/docs/hi/component_i18n.md +1 -1
- package/docs/hi/configuration.md +6 -0
- package/docs/hi/intlayer_cli.md +8 -0
- package/docs/hi/intlayer_with_next-i18next.md +628 -0
- package/docs/hi/intlayer_with_next-intl.md +446 -0
- package/docs/hi/intlayer_with_nextjs_16.md +21 -0
- package/docs/hi/intlayer_with_tanstack.md +4 -0
- package/docs/hi/intlayer_with_vite+react.md +4 -0
- package/docs/id/CI_CD.md +198 -0
- package/docs/id/autoFill.md +284 -0
- package/docs/id/component_i18n.md +186 -0
- package/docs/id/configuration.md +710 -0
- package/docs/id/dictionary/condition.md +231 -0
- package/docs/id/dictionary/content_file.md +1092 -0
- package/docs/id/dictionary/enumeration.md +245 -0
- package/docs/id/dictionary/file.md +237 -0
- package/docs/id/dictionary/function_fetching.md +214 -0
- package/docs/id/dictionary/gender.md +273 -0
- package/docs/id/dictionary/insertion.md +192 -0
- package/docs/id/dictionary/markdown.md +381 -0
- package/docs/id/dictionary/nesting.md +273 -0
- package/docs/id/dictionary/translation.md +310 -0
- package/docs/id/formatters.md +596 -0
- package/docs/id/how_works_intlayer.md +256 -0
- package/docs/id/index.md +176 -0
- package/docs/id/interest_of_intlayer.md +293 -0
- package/docs/id/intlayer_CMS.md +549 -0
- package/docs/id/intlayer_cli.md +850 -0
- package/docs/id/intlayer_visual_editor.md +288 -0
- package/docs/id/intlayer_with_angular.md +694 -0
- package/docs/id/intlayer_with_astro.md +252 -0
- package/docs/id/intlayer_with_create_react_app.md +1233 -0
- package/docs/id/intlayer_with_express.md +411 -0
- package/docs/id/intlayer_with_lynx+react.md +518 -0
- package/docs/id/intlayer_with_nestjs.md +272 -0
- package/docs/id/intlayer_with_next-i18next.md +628 -0
- package/docs/id/intlayer_with_next-intl.md +446 -0
- package/docs/id/intlayer_with_nextjs_14.md +1617 -0
- package/docs/id/intlayer_with_nextjs_15.md +1698 -0
- package/docs/id/intlayer_with_nextjs_16.md +21 -0
- package/docs/id/intlayer_with_nextjs_page_router.md +1478 -0
- package/docs/id/intlayer_with_nuxt.md +808 -0
- package/docs/id/intlayer_with_react_native+expo.md +699 -0
- package/docs/id/intlayer_with_react_router_v7.md +496 -0
- package/docs/id/intlayer_with_tanstack.md +564 -0
- package/docs/id/intlayer_with_vite+preact.md +1737 -0
- package/docs/id/intlayer_with_vite+react.md +1413 -0
- package/docs/id/intlayer_with_vite+solid.md +289 -0
- package/docs/id/intlayer_with_vite+svelte.md +289 -0
- package/docs/id/intlayer_with_vite+vue.md +1088 -0
- package/docs/id/introduction.md +218 -0
- package/docs/id/locale_mapper.md +242 -0
- package/docs/id/mcp_server.md +211 -0
- package/docs/id/packages/express-intlayer/t.md +458 -0
- package/docs/id/packages/intlayer/getConfiguration.md +145 -0
- package/docs/id/packages/intlayer/getEnumeration.md +159 -0
- package/docs/id/packages/intlayer/getHTMLTextDir.md +122 -0
- package/docs/id/packages/intlayer/getLocaleLang.md +81 -0
- package/docs/id/packages/intlayer/getLocaleName.md +119 -0
- package/docs/id/packages/intlayer/getLocalizedUrl.md +309 -0
- package/docs/id/packages/intlayer/getMultilingualUrls.md +223 -0
- package/docs/id/packages/intlayer/getPathWithoutLocale.md +75 -0
- package/docs/id/packages/intlayer/getTranslation.md +190 -0
- package/docs/id/packages/intlayer/getTranslationContent.md +188 -0
- package/docs/id/packages/next-intlayer/t.md +352 -0
- package/docs/id/packages/next-intlayer/useDictionary.md +271 -0
- package/docs/id/packages/next-intlayer/useIntlayer.md +264 -0
- package/docs/id/packages/next-intlayer/useLocale.md +166 -0
- package/docs/id/packages/react-intlayer/t.md +303 -0
- package/docs/id/packages/react-intlayer/useDictionary.md +287 -0
- package/docs/id/packages/react-intlayer/useI18n.md +267 -0
- package/docs/id/packages/react-intlayer/useIntlayer.md +254 -0
- package/docs/id/packages/react-intlayer/useLocale.md +210 -0
- package/docs/id/per_locale_file.md +323 -0
- package/docs/id/readme.md +261 -0
- package/docs/id/releases/v6.md +305 -0
- package/docs/id/roadmap.md +362 -0
- package/docs/id/testing.md +202 -0
- package/docs/id/vs_code_extension.md +126 -0
- package/docs/it/component_i18n.md +1 -1
- package/docs/it/configuration.md +6 -0
- package/docs/it/intlayer_cli.md +8 -3
- package/docs/it/intlayer_with_next-i18next.md +628 -0
- package/docs/it/intlayer_with_next-intl.md +446 -0
- package/docs/it/intlayer_with_nextjs_16.md +21 -0
- package/docs/it/intlayer_with_tanstack.md +4 -0
- package/docs/it/intlayer_with_vite+react.md +4 -0
- package/docs/ja/component_i18n.md +1 -1
- package/docs/ja/configuration.md +6 -0
- package/docs/ja/intlayer_cli.md +8 -3
- package/docs/ja/intlayer_with_next-i18next.md +627 -0
- package/docs/ja/intlayer_with_next-intl.md +446 -0
- package/docs/ja/intlayer_with_nextjs_16.md +21 -0
- package/docs/ja/intlayer_with_tanstack.md +4 -0
- package/docs/ja/intlayer_with_vite+react.md +4 -0
- package/docs/ko/configuration.md +6 -0
- package/docs/ko/intlayer_cli.md +8 -3
- package/docs/ko/intlayer_with_next-i18next.md +627 -0
- package/docs/ko/intlayer_with_next-intl.md +446 -0
- package/docs/ko/intlayer_with_nextjs_16.md +21 -0
- package/docs/ko/intlayer_with_tanstack.md +4 -0
- package/docs/ko/intlayer_with_vite+react.md +4 -0
- package/docs/pl/CI_CD.md +198 -0
- package/docs/pl/autoFill.md +284 -0
- package/docs/pl/component_i18n.md +186 -0
- package/docs/pl/configuration.md +710 -0
- package/docs/pl/dictionary/condition.md +232 -0
- package/docs/pl/dictionary/content_file.md +1130 -0
- package/docs/pl/dictionary/enumeration.md +245 -0
- package/docs/pl/dictionary/file.md +234 -0
- package/docs/pl/dictionary/function_fetching.md +214 -0
- package/docs/pl/dictionary/gender.md +276 -0
- package/docs/pl/dictionary/insertion.md +188 -0
- package/docs/pl/dictionary/markdown.md +408 -0
- package/docs/pl/dictionary/nesting.md +273 -0
- package/docs/pl/dictionary/translation.md +310 -0
- package/docs/pl/formatters.md +596 -0
- package/docs/pl/how_works_intlayer.md +256 -0
- package/docs/pl/index.md +176 -0
- package/docs/pl/interest_of_intlayer.md +291 -0
- package/docs/pl/intlayer_CMS.md +549 -0
- package/docs/pl/intlayer_cli.md +857 -0
- package/docs/pl/intlayer_visual_editor.md +288 -0
- package/docs/pl/intlayer_with_angular.md +690 -0
- package/docs/pl/intlayer_with_astro.md +280 -0
- package/docs/pl/intlayer_with_create_react_app.md +1235 -0
- package/docs/pl/intlayer_with_express.md +411 -0
- package/docs/pl/intlayer_with_lynx+react.md +518 -0
- package/docs/pl/intlayer_with_nestjs.md +272 -0
- package/docs/pl/intlayer_with_next-i18next.md +628 -0
- package/docs/pl/intlayer_with_next-intl.md +446 -0
- package/docs/pl/intlayer_with_nextjs_14.md +1594 -0
- package/docs/pl/intlayer_with_nextjs_15.md +1701 -0
- package/docs/pl/intlayer_with_nextjs_16.md +21 -0
- package/docs/pl/intlayer_with_nextjs_page_router.md +1513 -0
- package/docs/pl/intlayer_with_nuxt.md +885 -0
- package/docs/pl/intlayer_with_react_native+expo.md +698 -0
- package/docs/pl/intlayer_with_react_router_v7.md +503 -0
- package/docs/pl/intlayer_with_tanstack.md +562 -0
- package/docs/pl/intlayer_with_vite+preact.md +1736 -0
- package/docs/pl/intlayer_with_vite+react.md +1438 -0
- package/docs/pl/intlayer_with_vite+solid.md +290 -0
- package/docs/pl/intlayer_with_vite+svelte.md +289 -0
- package/docs/pl/intlayer_with_vite+vue.md +1116 -0
- package/docs/pl/introduction.md +209 -0
- package/docs/pl/locale_mapper.md +242 -0
- package/docs/pl/mcp_server.md +211 -0
- package/docs/pl/packages/express-intlayer/t.md +458 -0
- package/docs/pl/packages/intlayer/getConfiguration.md +146 -0
- package/docs/pl/packages/intlayer/getEnumeration.md +160 -0
- package/docs/pl/packages/intlayer/getHTMLTextDir.md +121 -0
- package/docs/pl/packages/intlayer/getLocaleLang.md +81 -0
- package/docs/pl/packages/intlayer/getLocaleName.md +118 -0
- package/docs/pl/packages/intlayer/getLocalizedUrl.md +300 -0
- package/docs/pl/packages/intlayer/getMultilingualUrls.md +221 -0
- package/docs/pl/packages/intlayer/getPathWithoutLocale.md +75 -0
- package/docs/pl/packages/intlayer/getTranslation.md +190 -0
- package/docs/pl/packages/intlayer/getTranslationContent.md +189 -0
- package/docs/pl/packages/next-intlayer/t.md +353 -0
- package/docs/pl/packages/next-intlayer/useDictionary.md +270 -0
- package/docs/pl/packages/next-intlayer/useIntlayer.md +263 -0
- package/docs/pl/packages/next-intlayer/useLocale.md +166 -0
- package/docs/pl/packages/react-intlayer/t.md +303 -0
- package/docs/pl/packages/react-intlayer/useDictionary.md +289 -0
- package/docs/pl/packages/react-intlayer/useI18n.md +249 -0
- package/docs/pl/packages/react-intlayer/useIntlayer.md +256 -0
- package/docs/pl/packages/react-intlayer/useLocale.md +210 -0
- package/docs/pl/per_locale_file.md +321 -0
- package/docs/pl/readme.md +261 -0
- package/docs/pl/releases/v6.md +305 -0
- package/docs/pl/roadmap.md +362 -0
- package/docs/pl/testing.md +202 -0
- package/docs/pl/vs_code_extension.md +126 -0
- package/docs/pt/component_i18n.md +1 -1
- package/docs/pt/configuration.md +6 -0
- package/docs/pt/intlayer_cli.md +8 -3
- package/docs/pt/intlayer_with_next-i18next.md +627 -0
- package/docs/pt/intlayer_with_next-intl.md +446 -0
- package/docs/pt/intlayer_with_nextjs_16.md +21 -0
- package/docs/pt/intlayer_with_tanstack.md +4 -0
- package/docs/pt/intlayer_with_vite+react.md +4 -0
- package/docs/ru/component_i18n.md +1 -1
- package/docs/ru/configuration.md +6 -0
- package/docs/ru/intlayer_cli.md +301 -22
- package/docs/ru/intlayer_with_next-i18next.md +629 -0
- package/docs/ru/intlayer_with_next-intl.md +448 -0
- package/docs/ru/intlayer_with_nextjs_16.md +21 -0
- package/docs/ru/intlayer_with_tanstack.md +4 -0
- package/docs/ru/intlayer_with_vite+react.md +4 -0
- package/docs/tr/component_i18n.md +1 -1
- package/docs/tr/configuration.md +6 -0
- package/docs/tr/intlayer_cli.md +8 -0
- package/docs/tr/intlayer_with_next-i18next.md +627 -0
- package/docs/tr/intlayer_with_next-intl.md +446 -0
- package/docs/tr/intlayer_with_nextjs_16.md +21 -0
- package/docs/tr/intlayer_with_tanstack.md +4 -0
- package/docs/tr/intlayer_with_vite+react.md +4 -0
- package/docs/vi/CI_CD.md +198 -0
- package/docs/vi/autoFill.md +284 -0
- package/docs/vi/component_i18n.md +186 -0
- package/docs/vi/configuration.md +710 -0
- package/docs/vi/dictionary/condition.md +237 -0
- package/docs/vi/dictionary/content_file.md +1115 -0
- package/docs/vi/dictionary/enumeration.md +255 -0
- package/docs/vi/dictionary/file.md +234 -0
- package/docs/vi/dictionary/function_fetching.md +212 -0
- package/docs/vi/dictionary/gender.md +275 -0
- package/docs/vi/dictionary/insertion.md +191 -0
- package/docs/vi/dictionary/markdown.md +381 -0
- package/docs/vi/dictionary/nesting.md +273 -0
- package/docs/vi/dictionary/translation.md +309 -0
- package/docs/vi/formatters.md +595 -0
- package/docs/vi/how_works_intlayer.md +256 -0
- package/docs/vi/index.md +174 -0
- package/docs/vi/interest_of_intlayer.md +292 -0
- package/docs/vi/intlayer_CMS.md +549 -0
- package/docs/vi/intlayer_cli.md +850 -0
- package/docs/vi/intlayer_visual_editor.md +288 -0
- package/docs/vi/intlayer_with_angular.md +692 -0
- package/docs/vi/intlayer_with_astro.md +252 -0
- package/docs/vi/intlayer_with_create_react_app.md +1230 -0
- package/docs/vi/intlayer_with_express.md +409 -0
- package/docs/vi/intlayer_with_lynx+react.md +520 -0
- package/docs/vi/intlayer_with_nestjs.md +272 -0
- package/docs/vi/intlayer_with_next-i18next.md +628 -0
- package/docs/vi/intlayer_with_next-intl.md +446 -0
- package/docs/vi/intlayer_with_nextjs_14.md +1584 -0
- package/docs/vi/intlayer_with_nextjs_15.md +1738 -0
- package/docs/vi/intlayer_with_nextjs_16.md +21 -0
- package/docs/vi/intlayer_with_nextjs_page_router.md +1504 -0
- package/docs/vi/intlayer_with_nuxt.md +821 -0
- package/docs/vi/intlayer_with_react_native+expo.md +700 -0
- package/docs/vi/intlayer_with_react_router_v7.md +498 -0
- package/docs/vi/intlayer_with_tanstack.md +562 -0
- package/docs/vi/intlayer_with_vite+preact.md +1722 -0
- package/docs/vi/intlayer_with_vite+react.md +1407 -0
- package/docs/vi/intlayer_with_vite+solid.md +287 -0
- package/docs/vi/intlayer_with_vite+svelte.md +289 -0
- package/docs/vi/intlayer_with_vite+vue.md +1071 -0
- package/docs/vi/introduction.md +215 -0
- package/docs/vi/locale_mapper.md +242 -0
- package/docs/vi/mcp_server.md +211 -0
- package/docs/vi/packages/express-intlayer/t.md +457 -0
- package/docs/vi/packages/intlayer/getConfiguration.md +145 -0
- package/docs/vi/packages/intlayer/getEnumeration.md +162 -0
- package/docs/vi/packages/intlayer/getHTMLTextDir.md +121 -0
- package/docs/vi/packages/intlayer/getLocaleLang.md +81 -0
- package/docs/vi/packages/intlayer/getLocaleName.md +129 -0
- package/docs/vi/packages/intlayer/getLocalizedUrl.md +309 -0
- package/docs/vi/packages/intlayer/getMultilingualUrls.md +221 -0
- package/docs/vi/packages/intlayer/getPathWithoutLocale.md +75 -0
- package/docs/vi/packages/intlayer/getTranslation.md +201 -0
- package/docs/vi/packages/intlayer/getTranslationContent.md +188 -0
- package/docs/vi/packages/next-intlayer/t.md +352 -0
- package/docs/vi/packages/next-intlayer/useDictionary.md +273 -0
- package/docs/vi/packages/next-intlayer/useIntlayer.md +264 -0
- package/docs/vi/packages/next-intlayer/useLocale.md +166 -0
- package/docs/vi/packages/react-intlayer/t.md +304 -0
- package/docs/vi/packages/react-intlayer/useDictionary.md +288 -0
- package/docs/vi/packages/react-intlayer/useI18n.md +295 -0
- package/docs/vi/packages/react-intlayer/useIntlayer.md +256 -0
- package/docs/vi/packages/react-intlayer/useLocale.md +210 -0
- package/docs/vi/per_locale_file.md +326 -0
- package/docs/vi/readme.md +261 -0
- package/docs/vi/releases/v6.md +305 -0
- package/docs/vi/roadmap.md +346 -0
- package/docs/vi/testing.md +202 -0
- package/docs/vi/vs_code_extension.md +126 -0
- package/docs/zh/configuration.md +6 -0
- package/docs/zh/intlayer_cli.md +8 -3
- package/docs/zh/intlayer_with_next-i18next.md +628 -0
- package/docs/zh/intlayer_with_next-intl.md +448 -0
- package/docs/zh/intlayer_with_nextjs_16.md +21 -0
- package/docs/zh/intlayer_with_tanstack.md +4 -0
- package/docs/zh/intlayer_with_vite+react.md +4 -0
- package/frequent_questions/ar/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/ar/array_as_content_declaration.md +1 -2
- package/frequent_questions/ar/build_dictionaries.md +1 -2
- package/frequent_questions/ar/build_error_CI_CD.md +1 -2
- package/frequent_questions/ar/bun_set_up.md +1 -2
- package/frequent_questions/ar/customized_locale_list.md +1 -2
- package/frequent_questions/ar/domain_routing.md +1 -2
- package/frequent_questions/ar/esbuild_error.md +1 -2
- package/frequent_questions/ar/get_locale_cookie.md +1 -2
- package/frequent_questions/ar/intlayer_command_undefined.md +1 -2
- package/frequent_questions/ar/locale_incorect_in_url.md +1 -2
- package/frequent_questions/ar/static_rendering.md +1 -3
- package/frequent_questions/ar/translated_path_url.md +1 -2
- package/frequent_questions/ar/unknown_command.md +1 -2
- package/frequent_questions/de/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/de/array_as_content_declaration.md +1 -2
- package/frequent_questions/de/build_dictionaries.md +1 -2
- package/frequent_questions/de/build_error_CI_CD.md +1 -2
- package/frequent_questions/de/bun_set_up.md +1 -2
- package/frequent_questions/de/customized_locale_list.md +1 -2
- package/frequent_questions/de/domain_routing.md +1 -2
- package/frequent_questions/de/esbuild_error.md +1 -2
- package/frequent_questions/de/get_locale_cookie.md +1 -2
- package/frequent_questions/de/intlayer_command_undefined.md +1 -2
- package/frequent_questions/de/locale_incorect_in_url.md +1 -2
- package/frequent_questions/de/static_rendering.md +1 -3
- package/frequent_questions/de/translated_path_url.md +1 -2
- package/frequent_questions/de/unknown_command.md +1 -2
- package/frequent_questions/en/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/en/array_as_content_declaration.md +1 -2
- package/frequent_questions/en/build_dictionaries.md +1 -2
- package/frequent_questions/en/build_error_CI_CD.md +1 -2
- package/frequent_questions/en/bun_set_up.md +1 -2
- package/frequent_questions/en/customized_locale_list.md +1 -2
- package/frequent_questions/en/domain_routing.md +1 -2
- package/frequent_questions/en/esbuild_error.md +1 -2
- package/frequent_questions/en/get_locale_cookie.md +1 -2
- package/frequent_questions/en/intlayer_command_undefined.md +1 -2
- package/frequent_questions/en/locale_incorect_in_url.md +1 -2
- package/frequent_questions/en/static_rendering.md +1 -3
- package/frequent_questions/en/translated_path_url.md +1 -2
- package/frequent_questions/en/unknown_command.md +1 -2
- package/frequent_questions/en-GB/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/en-GB/array_as_content_declaration.md +1 -2
- package/frequent_questions/en-GB/build_dictionaries.md +1 -2
- package/frequent_questions/en-GB/build_error_CI_CD.md +1 -2
- package/frequent_questions/en-GB/bun_set_up.md +1 -2
- package/frequent_questions/en-GB/customized_locale_list.md +1 -2
- package/frequent_questions/en-GB/domain_routing.md +1 -2
- package/frequent_questions/en-GB/esbuild_error.md +1 -2
- package/frequent_questions/en-GB/get_locale_cookie.md +1 -2
- package/frequent_questions/en-GB/intlayer_command_undefined.md +1 -2
- package/frequent_questions/en-GB/locale_incorect_in_url.md +1 -2
- package/frequent_questions/en-GB/static_rendering.md +1 -3
- package/frequent_questions/en-GB/translated_path_url.md +1 -2
- package/frequent_questions/en-GB/unknown_command.md +1 -2
- package/frequent_questions/es/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/es/array_as_content_declaration.md +1 -2
- package/frequent_questions/es/build_dictionaries.md +1 -2
- package/frequent_questions/es/build_error_CI_CD.md +1 -2
- package/frequent_questions/es/bun_set_up.md +1 -2
- package/frequent_questions/es/customized_locale_list.md +1 -2
- package/frequent_questions/es/domain_routing.md +1 -2
- package/frequent_questions/es/esbuild_error.md +1 -2
- package/frequent_questions/es/get_locale_cookie.md +1 -2
- package/frequent_questions/es/intlayer_command_undefined.md +1 -2
- package/frequent_questions/es/locale_incorect_in_url.md +1 -2
- package/frequent_questions/es/static_rendering.md +1 -3
- package/frequent_questions/es/translated_path_url.md +1 -2
- package/frequent_questions/es/unknown_command.md +1 -2
- package/frequent_questions/fr/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/fr/array_as_content_declaration.md +1 -2
- package/frequent_questions/fr/build_dictionaries.md +1 -2
- package/frequent_questions/fr/build_error_CI_CD.md +1 -2
- package/frequent_questions/fr/bun_set_up.md +1 -2
- package/frequent_questions/fr/customized_locale_list.md +1 -2
- package/frequent_questions/fr/domain_routing.md +1 -2
- package/frequent_questions/fr/esbuild_error.md +1 -2
- package/frequent_questions/fr/get_locale_cookie.md +1 -2
- package/frequent_questions/fr/intlayer_command_undefined.md +1 -2
- package/frequent_questions/fr/locale_incorect_in_url.md +1 -2
- package/frequent_questions/fr/static_rendering.md +1 -3
- package/frequent_questions/fr/translated_path_url.md +1 -2
- package/frequent_questions/fr/unknown_command.md +1 -2
- package/frequent_questions/hi/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/hi/array_as_content_declaration.md +1 -2
- package/frequent_questions/hi/build_dictionaries.md +1 -2
- package/frequent_questions/hi/build_error_CI_CD.md +1 -2
- package/frequent_questions/hi/bun_set_up.md +1 -2
- package/frequent_questions/hi/customized_locale_list.md +1 -2
- package/frequent_questions/hi/domain_routing.md +1 -2
- package/frequent_questions/hi/esbuild_error.md +1 -2
- package/frequent_questions/hi/get_locale_cookie.md +1 -2
- package/frequent_questions/hi/intlayer_command_undefined.md +1 -2
- package/frequent_questions/hi/locale_incorect_in_url.md +1 -2
- package/frequent_questions/hi/static_rendering.md +1 -3
- package/frequent_questions/hi/translated_path_url.md +1 -2
- package/frequent_questions/hi/unknown_command.md +1 -2
- package/frequent_questions/id/SSR_Next_no_[locale].md +104 -0
- package/frequent_questions/id/array_as_content_declaration.md +71 -0
- package/frequent_questions/id/build_dictionaries.md +58 -0
- package/frequent_questions/id/build_error_CI_CD.md +74 -0
- package/frequent_questions/id/bun_set_up.md +53 -0
- package/frequent_questions/id/customized_locale_list.md +64 -0
- package/frequent_questions/id/domain_routing.md +113 -0
- package/frequent_questions/id/esbuild_error.md +29 -0
- package/frequent_questions/id/get_locale_cookie.md +142 -0
- package/frequent_questions/id/intlayer_command_undefined.md +155 -0
- package/frequent_questions/id/locale_incorect_in_url.md +73 -0
- package/frequent_questions/id/static_rendering.md +44 -0
- package/frequent_questions/id/translated_path_url.md +55 -0
- package/frequent_questions/id/unknown_command.md +97 -0
- package/frequent_questions/it/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/it/array_as_content_declaration.md +1 -2
- package/frequent_questions/it/build_dictionaries.md +1 -2
- package/frequent_questions/it/build_error_CI_CD.md +1 -2
- package/frequent_questions/it/bun_set_up.md +1 -2
- package/frequent_questions/it/customized_locale_list.md +1 -2
- package/frequent_questions/it/domain_routing.md +1 -2
- package/frequent_questions/it/esbuild_error.md +1 -2
- package/frequent_questions/it/get_locale_cookie.md +1 -2
- package/frequent_questions/it/intlayer_command_undefined.md +1 -2
- package/frequent_questions/it/locale_incorect_in_url.md +1 -2
- package/frequent_questions/it/static_rendering.md +1 -3
- package/frequent_questions/it/translated_path_url.md +1 -2
- package/frequent_questions/it/unknown_command.md +1 -2
- package/frequent_questions/ja/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/ja/array_as_content_declaration.md +1 -2
- package/frequent_questions/ja/build_dictionaries.md +1 -2
- package/frequent_questions/ja/build_error_CI_CD.md +1 -2
- package/frequent_questions/ja/bun_set_up.md +1 -2
- package/frequent_questions/ja/customized_locale_list.md +1 -2
- package/frequent_questions/ja/domain_routing.md +1 -2
- package/frequent_questions/ja/esbuild_error.md +1 -2
- package/frequent_questions/ja/get_locale_cookie.md +1 -2
- package/frequent_questions/ja/intlayer_command_undefined.md +1 -2
- package/frequent_questions/ja/locale_incorect_in_url.md +1 -2
- package/frequent_questions/ja/static_rendering.md +1 -3
- package/frequent_questions/ja/translated_path_url.md +1 -2
- package/frequent_questions/ja/unknown_command.md +1 -2
- package/frequent_questions/ko/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/ko/array_as_content_declaration.md +1 -2
- package/frequent_questions/ko/build_dictionaries.md +1 -2
- package/frequent_questions/ko/build_error_CI_CD.md +1 -2
- package/frequent_questions/ko/bun_set_up.md +1 -2
- package/frequent_questions/ko/customized_locale_list.md +1 -2
- package/frequent_questions/ko/domain_routing.md +1 -2
- package/frequent_questions/ko/esbuild_error.md +1 -2
- package/frequent_questions/ko/get_locale_cookie.md +1 -2
- package/frequent_questions/ko/intlayer_command_undefined.md +1 -2
- package/frequent_questions/ko/locale_incorect_in_url.md +1 -2
- package/frequent_questions/ko/static_rendering.md +1 -3
- package/frequent_questions/ko/translated_path_url.md +1 -2
- package/frequent_questions/ko/unknown_command.md +1 -2
- package/frequent_questions/pl/SSR_Next_no_[locale].md +104 -0
- package/frequent_questions/pl/array_as_content_declaration.md +71 -0
- package/frequent_questions/pl/build_dictionaries.md +58 -0
- package/frequent_questions/pl/build_error_CI_CD.md +74 -0
- package/frequent_questions/pl/bun_set_up.md +54 -0
- package/frequent_questions/pl/customized_locale_list.md +64 -0
- package/frequent_questions/pl/domain_routing.md +113 -0
- package/frequent_questions/pl/esbuild_error.md +29 -0
- package/frequent_questions/pl/get_locale_cookie.md +142 -0
- package/frequent_questions/pl/intlayer_command_undefined.md +155 -0
- package/frequent_questions/pl/locale_incorect_in_url.md +73 -0
- package/frequent_questions/pl/static_rendering.md +44 -0
- package/frequent_questions/pl/translated_path_url.md +55 -0
- package/frequent_questions/pl/unknown_command.md +97 -0
- package/frequent_questions/pt/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/pt/array_as_content_declaration.md +1 -2
- package/frequent_questions/pt/build_dictionaries.md +1 -2
- package/frequent_questions/pt/build_error_CI_CD.md +1 -2
- package/frequent_questions/pt/bun_set_up.md +1 -2
- package/frequent_questions/pt/customized_locale_list.md +1 -2
- package/frequent_questions/pt/domain_routing.md +1 -2
- package/frequent_questions/pt/esbuild_error.md +1 -2
- package/frequent_questions/pt/get_locale_cookie.md +1 -2
- package/frequent_questions/pt/intlayer_command_undefined.md +1 -2
- package/frequent_questions/pt/locale_incorect_in_url.md +1 -2
- package/frequent_questions/pt/static_rendering.md +1 -3
- package/frequent_questions/pt/translated_path_url.md +1 -2
- package/frequent_questions/pt/unknown_command.md +1 -2
- package/frequent_questions/ru/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/ru/array_as_content_declaration.md +1 -2
- package/frequent_questions/ru/build_dictionaries.md +1 -2
- package/frequent_questions/ru/build_error_CI_CD.md +1 -2
- package/frequent_questions/ru/bun_set_up.md +1 -2
- package/frequent_questions/ru/customized_locale_list.md +1 -2
- package/frequent_questions/ru/domain_routing.md +1 -2
- package/frequent_questions/ru/esbuild_error.md +1 -2
- package/frequent_questions/ru/get_locale_cookie.md +1 -2
- package/frequent_questions/ru/intlayer_command_undefined.md +1 -2
- package/frequent_questions/ru/locale_incorect_in_url.md +1 -2
- package/frequent_questions/ru/static_rendering.md +1 -2
- package/frequent_questions/ru/translated_path_url.md +1 -2
- package/frequent_questions/ru/unknown_command.md +1 -2
- package/frequent_questions/tr/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/tr/array_as_content_declaration.md +1 -2
- package/frequent_questions/tr/build_dictionaries.md +1 -2
- package/frequent_questions/tr/build_error_CI_CD.md +1 -2
- package/frequent_questions/tr/bun_set_up.md +1 -2
- package/frequent_questions/tr/customized_locale_list.md +1 -2
- package/frequent_questions/tr/domain_routing.md +1 -2
- package/frequent_questions/tr/esbuild_error.md +1 -2
- package/frequent_questions/tr/get_locale_cookie.md +1 -2
- package/frequent_questions/tr/intlayer_command_undefined.md +1 -2
- package/frequent_questions/tr/locale_incorect_in_url.md +1 -2
- package/frequent_questions/tr/static_rendering.md +1 -2
- package/frequent_questions/tr/translated_path_url.md +1 -2
- package/frequent_questions/tr/unknown_command.md +1 -2
- package/frequent_questions/vi/SSR_Next_no_[locale].md +106 -0
- package/frequent_questions/vi/array_as_content_declaration.md +71 -0
- package/frequent_questions/vi/build_dictionaries.md +58 -0
- package/frequent_questions/vi/build_error_CI_CD.md +74 -0
- package/frequent_questions/vi/bun_set_up.md +53 -0
- package/frequent_questions/vi/customized_locale_list.md +64 -0
- package/frequent_questions/vi/domain_routing.md +113 -0
- package/frequent_questions/vi/esbuild_error.md +29 -0
- package/frequent_questions/vi/get_locale_cookie.md +142 -0
- package/frequent_questions/vi/intlayer_command_undefined.md +155 -0
- package/frequent_questions/vi/locale_incorect_in_url.md +73 -0
- package/frequent_questions/vi/static_rendering.md +44 -0
- package/frequent_questions/vi/translated_path_url.md +55 -0
- package/frequent_questions/vi/unknown_command.md +97 -0
- package/frequent_questions/zh/SSR_Next_no_[locale].md +1 -2
- package/frequent_questions/zh/array_as_content_declaration.md +1 -2
- package/frequent_questions/zh/build_dictionaries.md +1 -2
- package/frequent_questions/zh/build_error_CI_CD.md +1 -2
- package/frequent_questions/zh/bun_set_up.md +1 -2
- package/frequent_questions/zh/customized_locale_list.md +1 -2
- package/frequent_questions/zh/domain_routing.md +1 -2
- package/frequent_questions/zh/esbuild_error.md +1 -2
- package/frequent_questions/zh/get_locale_cookie.md +1 -2
- package/frequent_questions/zh/intlayer_command_undefined.md +1 -2
- package/frequent_questions/zh/locale_incorect_in_url.md +1 -2
- package/frequent_questions/zh/static_rendering.md +1 -3
- package/frequent_questions/zh/translated_path_url.md +1 -2
- package/frequent_questions/zh/unknown_command.md +1 -2
- package/legal/id/privacy_notice.md +83 -0
- package/legal/id/terms_of_service.md +55 -0
- package/legal/pl/privacy_notice.md +83 -0
- package/legal/pl/terms_of_service.md +55 -0
- package/legal/vi/privacy_notice.md +83 -0
- package/legal/vi/terms_of_service.md +55 -0
- package/package.json +19 -18
- package/src/generated/blog.entry.ts +38 -0
|
@@ -0,0 +1,1617 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2024-12-06
|
|
3
|
+
updatedAt: 2025-09-22
|
|
4
|
+
title: Cara Menerjemahkan Next.js 14 dan App Router Anda – Panduan i18n 2025
|
|
5
|
+
description: Temukan cara membuat situs web Next.js 14 App Router Anda menjadi multibahasa. Ikuti dokumentasi untuk melakukan internasionalisasi (i18n) dan menerjemahkannya.
|
|
6
|
+
keywords:
|
|
7
|
+
- Internasionalisasi
|
|
8
|
+
- Dokumentasi
|
|
9
|
+
- Intlayer
|
|
10
|
+
- Next.js 14
|
|
11
|
+
- JavaScript
|
|
12
|
+
- React
|
|
13
|
+
slugs:
|
|
14
|
+
- doc
|
|
15
|
+
- environment
|
|
16
|
+
- nextjs
|
|
17
|
+
- 14
|
|
18
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-next-14-template
|
|
19
|
+
history:
|
|
20
|
+
- version: 7.0.6
|
|
21
|
+
- version: 6.2.0
|
|
22
|
+
date: 2025-10-09
|
|
23
|
+
changes: Menambahkan dokumentasi untuk hook `useLocale` dengan opsi `onLocaleChange`
|
|
24
|
+
- version: 5.6.6
|
|
25
|
+
date: 2025-10-02
|
|
26
|
+
changes: Menambahkan dokumentasi untuk fungsi `getLocale` pada server actions
|
|
27
|
+
- version: 5.6.2
|
|
28
|
+
date: 2025-09-22
|
|
29
|
+
changes: Menambahkan dokumentasi untuk helper `multipleMiddlewares`
|
|
30
|
+
- version: 5.6.0
|
|
31
|
+
date: 2025-07-06
|
|
32
|
+
changes: Mengubah fungsi `withIntlayer()` menjadi fungsi berbasis promise
|
|
33
|
+
- version: 5.5.10
|
|
34
|
+
date: 2025-06-29
|
|
35
|
+
changes: Inisialisasi riwayat
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
# Menerjemahkan situs web Next.js 14 dan App Router Anda menggunakan Intlayer | Internasionalisasi (i18n)
|
|
39
|
+
|
|
40
|
+
## Daftar Isi
|
|
41
|
+
|
|
42
|
+
<TOC/>
|
|
43
|
+
|
|
44
|
+
## Apa itu Intlayer?
|
|
45
|
+
|
|
46
|
+
**Intlayer** adalah perpustakaan internasionalisasi (i18n) open-source yang inovatif yang dirancang untuk menyederhanakan dukungan multibahasa dalam aplikasi web modern. Intlayer terintegrasi dengan mulus dengan kerangka kerja terbaru **Next.js 14**, termasuk **App Router** yang kuat. Ini dioptimalkan untuk bekerja dengan **Server Components** untuk rendering yang efisien dan sepenuhnya kompatibel dengan [**Turbopack**](https://nextjs.org/docs/architecture/turbopack) (dari Next.js >= 15).
|
|
47
|
+
|
|
48
|
+
Dengan Intlayer, Anda dapat:
|
|
49
|
+
|
|
50
|
+
- **Mengelola terjemahan dengan mudah** menggunakan kamus deklaratif di tingkat komponen.
|
|
51
|
+
- **Melokalisasi metadata**, rute, dan konten secara dinamis.
|
|
52
|
+
- **Mengakses terjemahan di komponen sisi klien dan sisi server**.
|
|
53
|
+
- **Memastikan dukungan TypeScript** dengan tipe yang dihasilkan secara otomatis, meningkatkan autocompletion dan deteksi kesalahan.
|
|
54
|
+
- **Manfaatkan fitur canggih**, seperti deteksi dan pengalihan locale secara dinamis.
|
|
55
|
+
|
|
56
|
+
> Intlayer kompatibel dengan Next.js 12, 13, 14, dan 15. Jika Anda menggunakan Next.js Page Router, Anda dapat merujuk ke [panduan ini](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_with_nextjs_page_router.md). Untuk Next.js 15 dengan atau tanpa turbopack, lihat [panduan ini](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_with_nextjs_15.md).
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Panduan Langkah demi Langkah untuk Mengatur Intlayer dalam Aplikasi Next.js
|
|
61
|
+
|
|
62
|
+
<iframe
|
|
63
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-next-14-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
64
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
65
|
+
title="Demo CodeSandbox - Cara Menginternasionalisasi aplikasi Anda menggunakan Intlayer"
|
|
66
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
67
|
+
loading="lazy"
|
|
68
|
+
/>
|
|
69
|
+
|
|
70
|
+
Lihat [Template Aplikasi](https://github.com/aymericzip/intlayer-next-14-template) di GitHub.
|
|
71
|
+
|
|
72
|
+
### Langkah 1: Instalasi Dependensi
|
|
73
|
+
|
|
74
|
+
Pasang paket yang diperlukan menggunakan npm:
|
|
75
|
+
|
|
76
|
+
```bash packageManager="npm"
|
|
77
|
+
npm install intlayer next-intlayer
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```bash packageManager="pnpm"
|
|
81
|
+
pnpm add intlayer next-intlayer
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```bash packageManager="yarn"
|
|
85
|
+
yarn add intlayer next-intlayer
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
- **intlayer**
|
|
89
|
+
|
|
90
|
+
- **intlayer**
|
|
91
|
+
|
|
92
|
+
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).
|
|
93
|
+
|
|
94
|
+
- **next-intlayer**
|
|
95
|
+
|
|
96
|
+
Paket yang mengintegrasikan Intlayer dengan Next.js. Paket ini menyediakan context providers dan hooks 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.
|
|
97
|
+
|
|
98
|
+
### Langkah 2: Konfigurasikan Proyek Anda
|
|
99
|
+
|
|
100
|
+
Buat file konfigurasi untuk mengatur bahasa aplikasi Anda:
|
|
101
|
+
|
|
102
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
103
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
104
|
+
|
|
105
|
+
const config: IntlayerConfig = {
|
|
106
|
+
internationalization: {
|
|
107
|
+
locales: [
|
|
108
|
+
Locales.ENGLISH,
|
|
109
|
+
Locales.FRENCH,
|
|
110
|
+
Locales.SPANISH,
|
|
111
|
+
// Bahasa lain milik Anda
|
|
112
|
+
],
|
|
113
|
+
defaultLocale: Locales.ENGLISH,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export default config;
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
121
|
+
import { Locales } from "intlayer";
|
|
122
|
+
|
|
123
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
124
|
+
const config = {
|
|
125
|
+
internationalization: {
|
|
126
|
+
locales: [
|
|
127
|
+
Locales.ENGLISH,
|
|
128
|
+
Locales.FRENCH,
|
|
129
|
+
Locales.SPANISH,
|
|
130
|
+
// Bahasa lain milik Anda
|
|
131
|
+
],
|
|
132
|
+
defaultLocale: Locales.ENGLISH,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export default config;
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
140
|
+
const { Locales } = require("intlayer");
|
|
141
|
+
|
|
142
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
143
|
+
const config = {
|
|
144
|
+
internationalization: {
|
|
145
|
+
locales: [
|
|
146
|
+
Locales.ENGLISH,
|
|
147
|
+
Locales.FRENCH,
|
|
148
|
+
Locales.SPANISH,
|
|
149
|
+
// Bahasa lain milik Anda
|
|
150
|
+
],
|
|
151
|
+
defaultLocale: Locales.ENGLISH,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
module.exports = config;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
> 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).
|
|
159
|
+
|
|
160
|
+
### Langkah 3: Integrasikan Intlayer dalam Konfigurasi Next.js Anda
|
|
161
|
+
|
|
162
|
+
Konfigurasikan setup Next.js Anda untuk menggunakan Intlayer:
|
|
163
|
+
|
|
164
|
+
```typescript fileName="next.config.mjs"
|
|
165
|
+
import { withIntlayer } from "next-intlayer/server";
|
|
166
|
+
|
|
167
|
+
/** @type {import('next').NextConfig} */
|
|
168
|
+
const nextConfig = {};
|
|
169
|
+
|
|
170
|
+
export default withIntlayer(nextConfig);
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
> 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. Ia 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.
|
|
174
|
+
|
|
175
|
+
> Fungsi `withIntlayer()` adalah fungsi promise. Jika Anda ingin menggunakannya bersama plugin lain, Anda dapat menggunakan await. Contoh:
|
|
176
|
+
>
|
|
177
|
+
> ```tsx
|
|
178
|
+
> const nextConfig = await withIntlayer(nextConfig);
|
|
179
|
+
> const nextConfigWithOtherPlugins = withOtherPlugins(nextConfig);
|
|
180
|
+
>
|
|
181
|
+
> export default nextConfigWithOtherPlugins;
|
|
182
|
+
> ```
|
|
183
|
+
|
|
184
|
+
### Langkah 4: Konfigurasikan Middleware untuk Deteksi Locale
|
|
185
|
+
|
|
186
|
+
Siapkan middleware untuk mendeteksi locale yang diinginkan pengguna:
|
|
187
|
+
|
|
188
|
+
```typescript fileName="src/middleware.ts" codeFormat="typescript"
|
|
189
|
+
export { intlayerMiddleware as middleware } from "next-intlayer/middleware";
|
|
190
|
+
|
|
191
|
+
export const config = {
|
|
192
|
+
matcher:
|
|
193
|
+
"/((?!api|static|assets|robots|sitemap|sw|service-worker|manifest|.*\\..*|_next).*)",
|
|
194
|
+
};
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
```javascript fileName="src/middleware.mjs" codeFormat="esm"
|
|
198
|
+
export { intlayerMiddleware as middleware } from "next-intlayer/middleware";
|
|
199
|
+
|
|
200
|
+
export const config = {
|
|
201
|
+
matcher:
|
|
202
|
+
"/((?!api|static|assets|robots|sitemap|sw|service-worker|manifest|.*\\..*|_next).*)",
|
|
203
|
+
};
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
```javascript fileName="src/middleware.cjs" codeFormat="commonjs"
|
|
207
|
+
const { intlayerMiddleware } = require("next-intlayer/middleware");
|
|
208
|
+
|
|
209
|
+
const config = {
|
|
210
|
+
matcher:
|
|
211
|
+
"/((?!api|static|assets|robots|sitemap|sw|service-worker|manifest|.*\\..*|_next).*)",
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
module.exports = { middleware: intlayerMiddleware, config };
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
> `intlayerMiddleware` digunakan untuk mendeteksi locale yang diinginkan pengguna dan mengarahkan mereka ke URL yang sesuai seperti yang ditentukan dalam [konfigurasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/configuration.md). Selain itu, ini memungkinkan penyimpanan locale yang diinginkan pengguna dalam cookie.
|
|
218
|
+
|
|
219
|
+
> Sesuaikan parameter `matcher` agar sesuai dengan rute aplikasi Anda. Untuk detail lebih lanjut, lihat [dokumentasi Next.js tentang konfigurasi matcher](https://nextjs.org/docs/app/building-your-application/routing/middleware).
|
|
220
|
+
|
|
221
|
+
> Jika Anda perlu menggabungkan beberapa middleware bersama-sama (misalnya, `intlayerMiddleware` dengan autentikasi atau middleware kustom), Intlayer sekarang menyediakan helper yang disebut `multipleMiddlewares`.
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import {
|
|
225
|
+
multipleMiddlewares,
|
|
226
|
+
intlayerMiddleware,
|
|
227
|
+
} from "next-intlayer/middleware";
|
|
228
|
+
import { customMiddleware } from "@utils/customMiddleware";
|
|
229
|
+
|
|
230
|
+
export const middleware = multipleMiddlewares([
|
|
231
|
+
intlayerMiddleware,
|
|
232
|
+
customMiddleware,
|
|
233
|
+
]);
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Langkah 5: Definisikan Rute Locale Dinamis
|
|
237
|
+
|
|
238
|
+
Hapus semua isi dari `RootLayout` dan ganti dengan kode berikut:
|
|
239
|
+
|
|
240
|
+
```tsx fileName="src/app/layout.tsx" codeFormat="typescript"
|
|
241
|
+
import type { PropsWithChildren, FC } from "react";
|
|
242
|
+
import "./globals.css";
|
|
243
|
+
|
|
244
|
+
const RootLayout: FC<PropsWithChildren> = ({ children }) => (
|
|
245
|
+
// Anda masih dapat membungkus children dengan provider lain, seperti `next-themes`, `react-query`, `framer-motion`, dll.
|
|
246
|
+
<>{children}</>
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
export default RootLayout;
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
```jsx fileName="src/app/layout.mjx" codeFormat="esm"
|
|
253
|
+
import "./globals.css";
|
|
254
|
+
|
|
255
|
+
const RootLayout = ({ children }) => (
|
|
256
|
+
// Anda masih dapat membungkus children dengan provider lain, seperti `next-themes`, `react-query`, `framer-motion`, dll.
|
|
257
|
+
<>{children}</>
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
export default RootLayout;
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
```jsx fileName="src/app/layout.csx" codeFormat="commonjs"
|
|
264
|
+
require("./globals.css");
|
|
265
|
+
|
|
266
|
+
const RootLayout = ({ children }) => (
|
|
267
|
+
// Anda masih dapat membungkus children dengan provider lain, seperti `next-themes`, `react-query`, `framer-motion`, dll.
|
|
268
|
+
<>{children}</>
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
module.exports = {
|
|
272
|
+
default: RootLayout,
|
|
273
|
+
generateStaticParams,
|
|
274
|
+
};
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
> Membiarkan komponen `RootLayout` kosong memungkinkan untuk mengatur atribut [`lang`](https://developer.mozilla.org/fr/docs/Web/HTML/Global_attributes/lang) dan [`dir`](https://developer.mozilla.org/fr/docs/Web/HTML/Global_attributes/dir) pada tag `<html>`.
|
|
278
|
+
|
|
279
|
+
Untuk mengimplementasikan routing dinamis, sediakan path untuk locale dengan menambahkan layout baru di direktori `[locale]` Anda:
|
|
280
|
+
|
|
281
|
+
```tsx fileName="src/app/[locale]/layout.tsx" codeFormat="typescript"
|
|
282
|
+
import type { Next14LayoutIntlayer } from "next-intlayer";
|
|
283
|
+
import { Inter } from "next/font/google";
|
|
284
|
+
import { getHTMLTextDir } from "intlayer";
|
|
285
|
+
|
|
286
|
+
const inter = Inter({ subsets: ["latin"] });
|
|
287
|
+
|
|
288
|
+
const LocaleLayout: Next14LayoutIntlayer = ({
|
|
289
|
+
children,
|
|
290
|
+
params: { locale },
|
|
291
|
+
}) => (
|
|
292
|
+
<html lang={locale} dir={getHTMLTextDir(locale)}>
|
|
293
|
+
<body className={inter.className}>{children}</body>
|
|
294
|
+
</html>
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
export default LocaleLayout;
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
```jsx fileName="src/app/[locale]/layout.mjx" codeFormat="esm"
|
|
301
|
+
import { Inter } from "next/font/google";
|
|
302
|
+
import { getHTMLTextDir } from "intlayer";
|
|
303
|
+
|
|
304
|
+
const inter = Inter({ subsets: ["latin"] });
|
|
305
|
+
|
|
306
|
+
const LocaleLayout = ({ children, params: { locale } }) => (
|
|
307
|
+
<html lang={locale} dir={getHTMLTextDir(locale)}>
|
|
308
|
+
<body className={inter.className}>{children}</body>
|
|
309
|
+
</html>
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
export default LocaleLayout;
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
```jsx fileName="src/app/[locale]/layout.csx" codeFormat="commonjs"
|
|
316
|
+
const { Inter } = require("next/font/google");
|
|
317
|
+
const { getHTMLTextDir } = require("intlayer");
|
|
318
|
+
|
|
319
|
+
const inter = Inter({ subsets: ["latin"] });
|
|
320
|
+
|
|
321
|
+
const LocaleLayout = ({ children, params: { locale } }) => (
|
|
322
|
+
<html lang={locale} dir={getHTMLTextDir(locale)}>
|
|
323
|
+
<body className={inter.className}>{children}</body>
|
|
324
|
+
</html>
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
module.exports = LocaleLayout;
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
> Segmen path `[locale]` digunakan untuk menentukan locale. Contoh: `/en-US/about` akan merujuk ke `en-US` dan `/fr/about` ke `fr`.
|
|
331
|
+
|
|
332
|
+
> Pada tahap ini, Anda akan menemui error: `Error: Missing <html> and <body> tags in the root layout.`. Ini adalah hal yang diharapkan karena file `/app/page.tsx` tidak lagi digunakan dan dapat dihapus. Sebagai gantinya, segmen path `[locale]` akan mengaktifkan halaman `/app/[locale]/page.tsx`. Akibatnya, halaman akan dapat diakses melalui path seperti `/en`, `/fr`, `/es` di browser Anda. Untuk mengatur locale default sebagai halaman root, lihat pengaturan `middleware` pada langkah 4.
|
|
333
|
+
|
|
334
|
+
Kemudian, implementasikan fungsi `generateStaticParams` di Layout aplikasi Anda.
|
|
335
|
+
|
|
336
|
+
```tsx {1} fileName="src/app/[locale]/layout.tsx" codeFormat="typescript"
|
|
337
|
+
export { generateStaticParams } from "next-intlayer"; // Baris untuk disisipkan
|
|
338
|
+
|
|
339
|
+
const LocaleLayout: Next14LayoutIntlayer = ({
|
|
340
|
+
children,
|
|
341
|
+
params: { locale },
|
|
342
|
+
}) => {
|
|
343
|
+
/*... Sisa kode*/
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
export default LocaleLayout;
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
```jsx {1} fileName="src/app/[locale]/layout.mjx" codeFormat="esm"
|
|
350
|
+
export { generateStaticParams } from "next-intlayer"; // Baris untuk disisipkan
|
|
351
|
+
|
|
352
|
+
const LocaleLayout = ({ children, params: { locale } }) => {
|
|
353
|
+
/*... Sisa kode*/
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
export default LocaleLayout;
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
```jsx {1,7} fileName="src/app/[locale]/layout.csx" codeFormat="commonjs"
|
|
360
|
+
const { generateStaticParams } = require("next-intlayer"); // Baris untuk disisipkan
|
|
361
|
+
|
|
362
|
+
const LocaleLayout = ({ children, params: { locale } }) => {
|
|
363
|
+
/*... Sisa kode*/
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
module.exports = LocaleLayout;
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
> `generateStaticParams` memastikan bahwa aplikasi Anda membangun terlebih dahulu halaman-halaman yang diperlukan untuk semua locale, mengurangi komputasi saat runtime dan meningkatkan pengalaman pengguna. Untuk detail lebih lanjut, lihat [dokumentasi Next.js tentang generateStaticParams](https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic-rendering#generate-static-params).
|
|
370
|
+
|
|
371
|
+
### Langkah 6: Deklarasikan Konten Anda
|
|
372
|
+
|
|
373
|
+
Buat dan kelola deklarasi konten Anda untuk menyimpan terjemahan:
|
|
374
|
+
|
|
375
|
+
```typescript fileName="src/app/[locale]/page.content.ts" contentDeclarationFormat="typescript"
|
|
376
|
+
import { t, type Dictionary } from "intlayer";
|
|
377
|
+
|
|
378
|
+
const pageContent = {
|
|
379
|
+
key: "page",
|
|
380
|
+
content: {
|
|
381
|
+
getStarted: {
|
|
382
|
+
main: t({
|
|
383
|
+
en: "Mulai dengan mengedit",
|
|
384
|
+
fr: "Commencez par éditer",
|
|
385
|
+
es: "Comience por editar",
|
|
386
|
+
}),
|
|
387
|
+
pageLink: "src/app/page.tsx",
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
} satisfies Dictionary;
|
|
391
|
+
|
|
392
|
+
export default pageContent;
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
```javascript fileName="src/app/[locale]/page.content.mjs" contentDeclarationFormat="esm"
|
|
396
|
+
import { t } from "intlayer";
|
|
397
|
+
|
|
398
|
+
/** @type {import('intlayer').Dictionary} */
|
|
399
|
+
const pageContent = {
|
|
400
|
+
key: "page",
|
|
401
|
+
content: {
|
|
402
|
+
getStarted: {
|
|
403
|
+
main: t({
|
|
404
|
+
en: "Mulai dengan mengedit",
|
|
405
|
+
fr: "Commencez par éditer",
|
|
406
|
+
es: "Comience por editar",
|
|
407
|
+
}),
|
|
408
|
+
pageLink: "src/app/page.tsx",
|
|
409
|
+
},
|
|
410
|
+
},
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
export default pageContent;
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
```javascript fileName="src/app/[locale]/page.content.cjs" contentDeclarationFormat="commonjs"
|
|
417
|
+
const { t } = require("intlayer");
|
|
418
|
+
|
|
419
|
+
/** @type {import('intlayer').Dictionary} */
|
|
420
|
+
const pageContent = {
|
|
421
|
+
key: "page",
|
|
422
|
+
content: {
|
|
423
|
+
getStarted: {
|
|
424
|
+
main: t({
|
|
425
|
+
en: "Mulai dengan mengedit",
|
|
426
|
+
fr: "Commencez par éditer",
|
|
427
|
+
es: "Comience por editar",
|
|
428
|
+
}),
|
|
429
|
+
pageLink: "src/app/page.tsx",
|
|
430
|
+
},
|
|
431
|
+
},
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
module.exports = pageContent;
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
```json fileName="src/app/[locale]/page.content.json" contentDeclarationFormat="json"
|
|
438
|
+
{
|
|
439
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
440
|
+
"key": "page",
|
|
441
|
+
"content": {
|
|
442
|
+
"getStarted": {
|
|
443
|
+
"nodeType": "translation",
|
|
444
|
+
"translation": {
|
|
445
|
+
"en": "Mulai dengan mengedit",
|
|
446
|
+
"fr": "Commencez par éditer",
|
|
447
|
+
"es": "Comience por editar"
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
"pageLink": {
|
|
451
|
+
"nodeType": "translation",
|
|
452
|
+
"translation": {
|
|
453
|
+
"en": "src/app/page.tsx",
|
|
454
|
+
"fr": "src/app/page.tsx",
|
|
455
|
+
"es": "src/app/page.tsx"
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
> Deklarasi konten Anda dapat didefinisikan di mana saja dalam aplikasi Anda selama sudah dimasukkan ke dalam direktori `contentDir` (secara default, `./src`). Dan sesuai dengan ekstensi file deklarasi konten (secara default, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
463
|
+
|
|
464
|
+
> Untuk detail lebih lanjut, lihat [dokumentasi deklarasi konten](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/content_file.md).
|
|
465
|
+
|
|
466
|
+
### Langkah 7: Gunakan Konten dalam Kode Anda
|
|
467
|
+
|
|
468
|
+
Akses kamus konten Anda di seluruh aplikasi Anda:
|
|
469
|
+
|
|
470
|
+
```tsx fileName="src/app/[locale]/page.tsx" codeFormat="typescript"
|
|
471
|
+
import { ClientComponentExample } from "@components/ClientComponentExample";
|
|
472
|
+
import { ServerComponentExample } from "@components/ServerComponentExample";
|
|
473
|
+
import { type Next14PageIntlayer, IntlayerClientProvider } from "next-intlayer";
|
|
474
|
+
import { IntlayerServerProvider, useIntlayer } from "next-intlayer/server";
|
|
475
|
+
|
|
476
|
+
const Page: Next14PageIntlayer = ({ params: { locale } }) => {
|
|
477
|
+
const content = useIntlayer("page", locale);
|
|
478
|
+
|
|
479
|
+
return (
|
|
480
|
+
<>
|
|
481
|
+
<p>
|
|
482
|
+
{content.getStarted.main}
|
|
483
|
+
<code>{content.getStarted.pageLink}</code>
|
|
484
|
+
</p>
|
|
485
|
+
|
|
486
|
+
<IntlayerServerProvider locale={locale}>
|
|
487
|
+
<IntlayerClientProvider locale={locale}>
|
|
488
|
+
<ServerComponentExample />
|
|
489
|
+
<ClientComponentExample />
|
|
490
|
+
</IntlayerClientProvider>
|
|
491
|
+
</IntlayerServerProvider>
|
|
492
|
+
</>
|
|
493
|
+
);
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
export default Page;
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
```jsx fileName="src/app/[locale]/page.mjx" codeFormat="esm"
|
|
500
|
+
import { ClientComponentExample } from "@components/ClientComponentExample";
|
|
501
|
+
import { ServerComponentExample } from "@components/ServerComponentExample";
|
|
502
|
+
import { IntlayerClientProvider } from "next-intlayer";
|
|
503
|
+
import { IntlayerServerProvider, useIntlayer } from "next-intlayer/server";
|
|
504
|
+
|
|
505
|
+
const Page = ({ params: { locale } }) => {
|
|
506
|
+
const content = useIntlayer("page", locale);
|
|
507
|
+
|
|
508
|
+
return (
|
|
509
|
+
<>
|
|
510
|
+
<p>
|
|
511
|
+
{content.getStarted.main}
|
|
512
|
+
<code>{content.getStarted.pageLink}</code>
|
|
513
|
+
</p>
|
|
514
|
+
|
|
515
|
+
<IntlayerClientProvider locale={locale}>
|
|
516
|
+
<IntlayerServerProvider locale={locale}>
|
|
517
|
+
<ClientComponentExample />
|
|
518
|
+
<ServerComponentExample />
|
|
519
|
+
</IntlayerServerProvider>
|
|
520
|
+
</IntlayerClientProvider>
|
|
521
|
+
</>
|
|
522
|
+
);
|
|
523
|
+
};
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
```jsx fileName="src/app/[locale]/page.csx" codeFormat="commonjs"
|
|
527
|
+
const { IntlayerClientProvider } = require("next-intlayer");
|
|
528
|
+
const { IntlayerServerProvider, useIntlayer } = require("next-intlayer/server");
|
|
529
|
+
|
|
530
|
+
const Page = ({ params: { locale } }) => {
|
|
531
|
+
const content = useIntlayer("page", locale);
|
|
532
|
+
|
|
533
|
+
return (
|
|
534
|
+
<>
|
|
535
|
+
<p>
|
|
536
|
+
{content.getStarted.main}
|
|
537
|
+
<code>{content.getStarted.pageLink}</code>
|
|
538
|
+
</p>
|
|
539
|
+
|
|
540
|
+
<IntlayerClientProvider locale={locale}>
|
|
541
|
+
<IntlayerServerProvider locale={locale}>
|
|
542
|
+
<ClientComponentExample />
|
|
543
|
+
<ServerComponentExample />
|
|
544
|
+
</IntlayerServerProvider>
|
|
545
|
+
</IntlayerClientProvider>
|
|
546
|
+
</>
|
|
547
|
+
);
|
|
548
|
+
};
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
- **`IntlayerClientProvider`** digunakan untuk menyediakan locale ke komponen sisi klien. Ini dapat ditempatkan di komponen induk mana pun, termasuk layout. Namun, menempatkannya di layout direkomendasikan karena Next.js berbagi kode layout di seluruh halaman, sehingga menjadi lebih efisien. Dengan menggunakan `IntlayerClientProvider` di layout, Anda menghindari inisialisasi ulang untuk setiap halaman, meningkatkan performa dan menjaga konteks lokalisasi yang konsisten di seluruh aplikasi Anda.
|
|
552
|
+
- **`IntlayerServerProvider`** digunakan untuk menyediakan locale ke anak server. Ini tidak dapat disetel di layout.
|
|
553
|
+
|
|
554
|
+
> Layout dan halaman tidak dapat berbagi konteks server yang sama karena sistem konteks server didasarkan pada penyimpanan data per permintaan (melalui mekanisme [cache React](https://react.dev/reference/react/cache)), yang menyebabkan setiap "konteks" dibuat ulang untuk segmen aplikasi yang berbeda. Menempatkan provider di layout bersama akan merusak isolasi ini, mencegah propagasi nilai konteks server yang benar ke komponen server Anda.
|
|
555
|
+
|
|
556
|
+
> Layout dan halaman tidak dapat berbagi konteks server yang sama karena sistem konteks server didasarkan pada penyimpanan data per permintaan (melalui mekanisme [cache React](https://react.dev/reference/react/cache)), yang menyebabkan setiap “konteks” dibuat ulang untuk segmen aplikasi yang berbeda. Menempatkan provider di layout bersama akan memecah isolasi ini, sehingga mencegah propagasi nilai konteks server yang benar ke komponen server Anda.
|
|
557
|
+
|
|
558
|
+
```tsx {4,7} fileName="src/components/ClientComponentExample.tsx" codeFormat="typescript"
|
|
559
|
+
"use client";
|
|
560
|
+
|
|
561
|
+
import type { FC } from "react";
|
|
562
|
+
import { useIntlayer } from "next-intlayer";
|
|
563
|
+
|
|
564
|
+
const ClientComponentExample: FC = () => {
|
|
565
|
+
const content = useIntlayer("client-component-example"); // Membuat deklarasi konten terkait
|
|
566
|
+
|
|
567
|
+
return (
|
|
568
|
+
<div>
|
|
569
|
+
<h2>{content.title}</h2>
|
|
570
|
+
<p>{content.content}</p>
|
|
571
|
+
</div>
|
|
572
|
+
);
|
|
573
|
+
};
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
```jsx {3,6} fileName="src/components/ClientComponentExample.mjx" codeFormat="esm"
|
|
577
|
+
"use client";
|
|
578
|
+
|
|
579
|
+
import { useIntlayer } from "next-intlayer";
|
|
580
|
+
|
|
581
|
+
const ClientComponentExample = () => {
|
|
582
|
+
const content = useIntlayer("client-component-example"); // Membuat deklarasi konten terkait
|
|
583
|
+
|
|
584
|
+
return (
|
|
585
|
+
<div>
|
|
586
|
+
<h2>{content.title}</h2>
|
|
587
|
+
<p>{content.content}</p>
|
|
588
|
+
</div>
|
|
589
|
+
);
|
|
590
|
+
};
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
```jsx {3,6} fileName="src/components/ClientComponentExample.csx" codeFormat="commonjs"
|
|
594
|
+
"use client";
|
|
595
|
+
|
|
596
|
+
const { useIntlayer } = require("next-intlayer");
|
|
597
|
+
|
|
598
|
+
const ClientComponentExample = () => {
|
|
599
|
+
const content = useIntlayer("client-component-example"); // Membuat deklarasi konten terkait
|
|
600
|
+
|
|
601
|
+
return (
|
|
602
|
+
<div>
|
|
603
|
+
<h2>{content.title}</h2>
|
|
604
|
+
<p>{content.content}</p>
|
|
605
|
+
</div>
|
|
606
|
+
);
|
|
607
|
+
};
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
```tsx {2} fileName="src/components/ServerComponentExample.tsx" codeFormat="typescript"
|
|
611
|
+
import type { FC } from "react";
|
|
612
|
+
import { useIntlayer } from "next-intlayer/server";
|
|
613
|
+
|
|
614
|
+
const ServerComponentExample: FC = () => {
|
|
615
|
+
const content = useIntlayer("server-component-example"); // Membuat deklarasi konten terkait
|
|
616
|
+
|
|
617
|
+
return (
|
|
618
|
+
<div>
|
|
619
|
+
<h2>{content.title}</h2>
|
|
620
|
+
<p>{content.content}</p>
|
|
621
|
+
</div>
|
|
622
|
+
);
|
|
623
|
+
};
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
```jsx {1} fileName="src/components/ServerComponentExample.mjx" codeFormat="esm"
|
|
627
|
+
import { useIntlayer } from "next-intlayer/server";
|
|
628
|
+
|
|
629
|
+
const ServerComponentExample = () => {
|
|
630
|
+
const content = useIntlayer("server-component-example"); // Membuat deklarasi konten terkait
|
|
631
|
+
|
|
632
|
+
return (
|
|
633
|
+
<div>
|
|
634
|
+
<h2>{content.title}</h2>
|
|
635
|
+
<p>{content.content}</p>
|
|
636
|
+
</div>
|
|
637
|
+
);
|
|
638
|
+
};
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
```jsx {1} fileName="src/components/ServerComponentExample.csx" codeFormat="commonjs"
|
|
642
|
+
const { useIntlayer } = require("next-intlayer/server");
|
|
643
|
+
|
|
644
|
+
const ServerComponentExample = () => {
|
|
645
|
+
const content = useIntlayer("server-component-example"); // Buat deklarasi konten terkait
|
|
646
|
+
|
|
647
|
+
return (
|
|
648
|
+
<div>
|
|
649
|
+
<h2>{content.title}</h2>
|
|
650
|
+
<p>{content.content}</p>
|
|
651
|
+
</div>
|
|
652
|
+
);
|
|
653
|
+
};
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
> Jika Anda ingin menggunakan konten Anda dalam atribut `string`, seperti `alt`, `title`, `href`, `aria-label`, dll., Anda harus memanggil nilai dari fungsi tersebut, seperti:
|
|
657
|
+
|
|
658
|
+
> ```jsx
|
|
659
|
+
> <img src={content.image.src.value} alt={content.image.value} />
|
|
660
|
+
> ```
|
|
661
|
+
|
|
662
|
+
> Untuk mempelajari lebih lanjut tentang hook `useIntlayer`, lihat [dokumentasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/next-intlayer/useIntlayer.md).
|
|
663
|
+
|
|
664
|
+
### (Opsional) Langkah 8: Internasionalisasi metadata Anda
|
|
665
|
+
|
|
666
|
+
Jika Anda ingin menginternasionalisasi metadata Anda, seperti judul halaman Anda, Anda dapat menggunakan fungsi `generateMetadata` yang disediakan oleh Next.js. Di dalamnya, Anda dapat mengambil konten dari fungsi `getIntlayer` untuk menerjemahkan metadata Anda.
|
|
667
|
+
|
|
668
|
+
```typescript fileName="src/app/[locale]/metadata.content.ts" contentDeclarationFormat="typescript"
|
|
669
|
+
import { type Dictionary, t } from "intlayer";
|
|
670
|
+
import { Metadata } from "next";
|
|
671
|
+
|
|
672
|
+
const metadataContent = {
|
|
673
|
+
key: "page-metadata",
|
|
674
|
+
content: {
|
|
675
|
+
title: t({
|
|
676
|
+
en: "Create Next App",
|
|
677
|
+
fr: "Créer une application Next.js",
|
|
678
|
+
es: "Crear una aplicación Next.js",
|
|
679
|
+
}),
|
|
680
|
+
description: t({
|
|
681
|
+
en: "Generated by create next app",
|
|
682
|
+
fr: "Généré par create next app",
|
|
683
|
+
es: "Generado por create next app",
|
|
684
|
+
}),
|
|
685
|
+
},
|
|
686
|
+
} satisfies Dictionary<Metadata>;
|
|
687
|
+
|
|
688
|
+
export default metadataContent;
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
```javascript fileName="src/app/[locale]/metadata.content.mjs" contentDeclarationFormat="esm"
|
|
692
|
+
import { t } from "intlayer";
|
|
693
|
+
|
|
694
|
+
/** @type {import('intlayer').Dictionary<import('next').Metadata>} */
|
|
695
|
+
const metadataContent = {
|
|
696
|
+
key: "page-metadata",
|
|
697
|
+
content: {
|
|
698
|
+
title: t({
|
|
699
|
+
en: "Create Next App",
|
|
700
|
+
fr: "Créer une application Next.js",
|
|
701
|
+
es: "Crear una aplicación Next.js",
|
|
702
|
+
}),
|
|
703
|
+
description: t({
|
|
704
|
+
en: "Dihasilkan oleh create next app",
|
|
705
|
+
fr: "Généré par create next app",
|
|
706
|
+
es: "Generado por create next app",
|
|
707
|
+
}),
|
|
708
|
+
},
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
export default metadataContent;
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
```javascript fileName="src/app/[locale]/metadata.content.cjs" contentDeclarationFormat="commonjs"
|
|
715
|
+
const { t } = require("intlayer");
|
|
716
|
+
|
|
717
|
+
/** @type {import('intlayer').Dictionary<import('next').Metadata>} */
|
|
718
|
+
const metadataContent = {
|
|
719
|
+
key: "page-metadata",
|
|
720
|
+
content: {
|
|
721
|
+
title: t({
|
|
722
|
+
en: "Create Next App",
|
|
723
|
+
fr: "Créer une application Next.js",
|
|
724
|
+
es: "Crear una aplicación Next.js",
|
|
725
|
+
}),
|
|
726
|
+
description: t({
|
|
727
|
+
en: "Dihasilkan oleh create next app",
|
|
728
|
+
fr: "Généré par create next app",
|
|
729
|
+
es: "Generado por create next app",
|
|
730
|
+
}),
|
|
731
|
+
},
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
module.exports = metadataContent;
|
|
735
|
+
fr: "Généré par create next app",
|
|
736
|
+
es: "Generado por create next app",
|
|
737
|
+
}),
|
|
738
|
+
},
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
export default metadataContent;
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
```javascript fileName="src/app/[locale]/metadata.content.cjs" contentDeclarationFormat="commonjs"
|
|
745
|
+
const { t } = require("intlayer");
|
|
746
|
+
|
|
747
|
+
/** @type {import('intlayer').Dictionary<import('next').Metadata>} */
|
|
748
|
+
const metadataContent = {
|
|
749
|
+
key: "page-metadata",
|
|
750
|
+
content: {
|
|
751
|
+
title: t({
|
|
752
|
+
en: "Create Next App",
|
|
753
|
+
fr: "Créer une application Next.js",
|
|
754
|
+
es: "Crear una aplicación Next.js",
|
|
755
|
+
}),
|
|
756
|
+
description: t({
|
|
757
|
+
en: "Generated by create next app",
|
|
758
|
+
id: "Dihasilkan oleh create next app",
|
|
759
|
+
fr: "Généré par create next app",
|
|
760
|
+
es: "Generado por create next app",
|
|
761
|
+
}),
|
|
762
|
+
},
|
|
763
|
+
};
|
|
764
|
+
|
|
765
|
+
module.exports = metadataContent;
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
```json fileName="src/app/[locale]/metadata.content.json" contentDeclarationFormat="json"
|
|
769
|
+
{
|
|
770
|
+
"key": "page-metadata",
|
|
771
|
+
"content": {
|
|
772
|
+
"title": {
|
|
773
|
+
"nodeType": "translation",
|
|
774
|
+
"translation": {
|
|
775
|
+
"en": "Preact logo",
|
|
776
|
+
"fr": "Logo Preact",
|
|
777
|
+
"es": "Logo Preact",
|
|
778
|
+
"id": "Logo Preact"
|
|
779
|
+
},
|
|
780
|
+
},
|
|
781
|
+
"description": {
|
|
782
|
+
"nodeType": "translation",
|
|
783
|
+
"translation": {
|
|
784
|
+
"en": "Generated by create next app",
|
|
785
|
+
"fr": "Généré par create next app",
|
|
786
|
+
"es": "Generado por create next app",
|
|
787
|
+
"id": "Dihasilkan oleh create next app"
|
|
788
|
+
},
|
|
789
|
+
},
|
|
790
|
+
},
|
|
791
|
+
};
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
````typescript fileName="src/app/[locale]/layout.tsx or src/app/[locale]/page.tsx" codeFormat="typescript"
|
|
795
|
+
import { getIntlayer, getMultilingualUrls } from "intlayer";
|
|
796
|
+
import type { Metadata } from "next";
|
|
797
|
+
import type { LocalParams } from "next-intlayer";
|
|
798
|
+
|
|
799
|
+
export const generateMetadata = ({
|
|
800
|
+
params: { locale },
|
|
801
|
+
}: LocalParams): Metadata => {
|
|
802
|
+
const metadata = getIntlayer("page-metadata", locale);
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Menghasilkan objek yang berisi semua url untuk setiap locale.
|
|
806
|
+
*
|
|
807
|
+
* Contoh:
|
|
808
|
+
* ```ts
|
|
809
|
+
* getMultilingualUrls('/about');
|
|
810
|
+
*
|
|
811
|
+
* // Mengembalikan
|
|
812
|
+
* // {
|
|
813
|
+
* // en: '/about',
|
|
814
|
+
* // fr: '/fr/about',
|
|
815
|
+
* // es: '/es/about',
|
|
816
|
+
* // }
|
|
817
|
+
* ```
|
|
818
|
+
*/
|
|
819
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
820
|
+
const localizedUrl =
|
|
821
|
+
multilingualUrls[locale as keyof typeof multilingualUrls];
|
|
822
|
+
|
|
823
|
+
return {
|
|
824
|
+
...metadata,
|
|
825
|
+
alternates: {
|
|
826
|
+
canonical: localizedUrl,
|
|
827
|
+
languages: { ...multilingualUrls, "x-default": "/" },
|
|
828
|
+
},
|
|
829
|
+
openGraph: {
|
|
830
|
+
url: localizedUrl,
|
|
831
|
+
},
|
|
832
|
+
};
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
// ... Sisa kode
|
|
836
|
+
````
|
|
837
|
+
|
|
838
|
+
````javascript fileName="src/app/[locale]/layout.mjs or src/app/[locale]/page.mjs" codeFormat="esm"
|
|
839
|
+
import { getIntlayer, getMultilingualUrls } from "intlayer";
|
|
840
|
+
|
|
841
|
+
export const generateMetadata = ({ params: { locale } }) => {
|
|
842
|
+
const metadata = getIntlayer("page-metadata", locale);
|
|
843
|
+
|
|
844
|
+
/**
|
|
845
|
+
* Menghasilkan objek yang berisi semua url untuk setiap locale.
|
|
846
|
+
*
|
|
847
|
+
* Contoh:
|
|
848
|
+
* ```ts
|
|
849
|
+
* getMultilingualUrls('/about');
|
|
850
|
+
*
|
|
851
|
+
* // Mengembalikan
|
|
852
|
+
* // {
|
|
853
|
+
* // en: '/about',
|
|
854
|
+
* // fr: '/fr/about',
|
|
855
|
+
* // es: '/es/about'
|
|
856
|
+
* // }
|
|
857
|
+
* ```
|
|
858
|
+
*/
|
|
859
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
860
|
+
const localizedUrl = multilingualUrls[locale];
|
|
861
|
+
|
|
862
|
+
return {
|
|
863
|
+
...metadata,
|
|
864
|
+
alternates: {
|
|
865
|
+
canonical: localizedUrl,
|
|
866
|
+
languages: { ...multilingualUrls, "x-default": "/" },
|
|
867
|
+
},
|
|
868
|
+
openGraph: {
|
|
869
|
+
url: localizedUrl,
|
|
870
|
+
},
|
|
871
|
+
};
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
// ... Sisa kode
|
|
875
|
+
````
|
|
876
|
+
|
|
877
|
+
````javascript fileName="src/app/[locale]/layout.cjs or src/app/[locale]/page.cjs" codeFormat="commonjs"
|
|
878
|
+
const { getIntlayer, getMultilingualUrls } = require("intlayer");
|
|
879
|
+
|
|
880
|
+
const generateMetadata = ({ params: { locale } }) => {
|
|
881
|
+
const metadata = getIntlayer("page-metadata", locale);
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Menghasilkan objek yang berisi semua url untuk setiap locale.
|
|
885
|
+
*
|
|
886
|
+
* Contoh:
|
|
887
|
+
* ```ts
|
|
888
|
+
* getMultilingualUrls('/about');
|
|
889
|
+
*
|
|
890
|
+
* // Mengembalikan
|
|
891
|
+
* // {
|
|
892
|
+
* // en: '/about',
|
|
893
|
+
* // fr: '/fr/about',
|
|
894
|
+
* * es: '/es/about'
|
|
895
|
+
* // }
|
|
896
|
+
* ```
|
|
897
|
+
*/
|
|
898
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
899
|
+
const localizedUrl = multilingualUrls[locale];
|
|
900
|
+
|
|
901
|
+
return {
|
|
902
|
+
...metadata,
|
|
903
|
+
alternates: {
|
|
904
|
+
canonical: localizedUrl,
|
|
905
|
+
languages: { ...multilingualUrls, "x-default": "/" },
|
|
906
|
+
},
|
|
907
|
+
openGraph: {
|
|
908
|
+
url: localizedUrl,
|
|
909
|
+
},
|
|
910
|
+
};
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
module.exports = { generateMetadata };
|
|
914
|
+
|
|
915
|
+
// ... Sisa kode
|
|
916
|
+
````
|
|
917
|
+
|
|
918
|
+
> Perhatikan bahwa fungsi `getIntlayer` yang diimpor dari `next-intlayer` mengembalikan konten Anda yang dibungkus dalam sebuah `IntlayerNode`, memungkinkan integrasi dengan editor visual. Sebaliknya, fungsi `getIntlayer` yang diimpor dari `intlayer` mengembalikan konten Anda secara langsung tanpa properti tambahan.
|
|
919
|
+
|
|
920
|
+
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 saat.
|
|
921
|
+
|
|
922
|
+
```typescript fileName="src/app/[locale]/layout.tsx or src/app/[locale]/page.tsx" codeFormat="typescript"
|
|
923
|
+
import {
|
|
924
|
+
type IConfigLocales,
|
|
925
|
+
getTranslation,
|
|
926
|
+
getMultilingualUrls,
|
|
927
|
+
} from "intlayer";
|
|
928
|
+
import type { Metadata } from "next";
|
|
929
|
+
import type { LocalParams } from "next-intlayer";
|
|
930
|
+
|
|
931
|
+
export const generateMetadata = ({
|
|
932
|
+
params: { locale },
|
|
933
|
+
}: LocalParams): Metadata => {
|
|
934
|
+
const t = <T>(content: IConfigLocales<T>) => getTranslation(content, locale);
|
|
935
|
+
|
|
936
|
+
return {
|
|
937
|
+
title: t<string>({
|
|
938
|
+
en: "My title",
|
|
939
|
+
fr: "Mon titre",
|
|
940
|
+
es: "Mi título",
|
|
941
|
+
}),
|
|
942
|
+
description: t({
|
|
943
|
+
en: "My description",
|
|
944
|
+
fr: "Ma description",
|
|
945
|
+
es: "Mi descripción",
|
|
946
|
+
}),
|
|
947
|
+
};
|
|
948
|
+
};
|
|
949
|
+
|
|
950
|
+
// ... Sisa kode
|
|
951
|
+
```
|
|
952
|
+
|
|
953
|
+
```javascript fileName="src/app/[locale]/layout.mjs or src/app/[locale]/page.mjs" codeFormat="esm"
|
|
954
|
+
import { getTranslation, getMultilingualUrls } from "intlayer";
|
|
955
|
+
|
|
956
|
+
export const generateMetadata = ({ params: { locale } }) => {
|
|
957
|
+
const t = (content) => getTranslation(content, locale);
|
|
958
|
+
|
|
959
|
+
return {
|
|
960
|
+
title: t({
|
|
961
|
+
en: "My title",
|
|
962
|
+
fr: "Mon titre",
|
|
963
|
+
es: "Mi título",
|
|
964
|
+
}),
|
|
965
|
+
description: t({
|
|
966
|
+
en: "My description",
|
|
967
|
+
fr: "Ma description",
|
|
968
|
+
es: "Mi descripción",
|
|
969
|
+
}),
|
|
970
|
+
};
|
|
971
|
+
};
|
|
972
|
+
|
|
973
|
+
// ... Sisa kode
|
|
974
|
+
```
|
|
975
|
+
|
|
976
|
+
```javascript fileName="src/app/[locale]/layout.cjs or src/app/[locale]/page.cjs" codeFormat="commonjs"
|
|
977
|
+
const { getTranslation, getMultilingualUrls } = require("intlayer");
|
|
978
|
+
|
|
979
|
+
const generateMetadata = ({ params: { locale } }) => {
|
|
980
|
+
const t = (content) => getTranslation(content, locale);
|
|
981
|
+
|
|
982
|
+
return {
|
|
983
|
+
title: t({
|
|
984
|
+
en: "My title",
|
|
985
|
+
fr: "Mon titre",
|
|
986
|
+
es: "Mi título",
|
|
987
|
+
}),
|
|
988
|
+
description: t({
|
|
989
|
+
en: "My description",
|
|
990
|
+
fr: "Ma description",
|
|
991
|
+
es: "Mi descripción",
|
|
992
|
+
}),
|
|
993
|
+
};
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
module.exports = { generateMetadata };
|
|
997
|
+
|
|
998
|
+
// ... Sisa kode
|
|
999
|
+
```
|
|
1000
|
+
|
|
1001
|
+
> Pelajari lebih lanjut tentang optimasi metadata [di dokumentasi resmi Next.js](https://nextjs.org/docs/app/building-your-application/optimizing/metadata).
|
|
1002
|
+
|
|
1003
|
+
### (Opsional) Langkah 9: Internasionalisasi sitemap.xml dan robots.txt Anda
|
|
1004
|
+
|
|
1005
|
+
Untuk menginternasionalkan `sitemap.xml` dan `robots.txt` Anda, Anda dapat menggunakan fungsi `getMultilingualUrls` yang disediakan oleh Intlayer. Fungsi ini memungkinkan Anda untuk menghasilkan URL multibahasa untuk sitemap Anda.
|
|
1006
|
+
|
|
1007
|
+
```tsx fileName="src/app/sitemap.ts" codeFormat="typescript"
|
|
1008
|
+
import { getMultilingualUrls } from "intlayer";
|
|
1009
|
+
import type { MetadataRoute } from "next";
|
|
1010
|
+
|
|
1011
|
+
const sitemap = (): MetadataRoute.Sitemap => [
|
|
1012
|
+
{
|
|
1013
|
+
url: "https://example.com",
|
|
1014
|
+
alternates: {
|
|
1015
|
+
languages: {
|
|
1016
|
+
...getMultilingualUrls("https://example.com"),
|
|
1017
|
+
"x-default": "https://example.com",
|
|
1018
|
+
},
|
|
1019
|
+
},
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
url: "https://example.com/login",
|
|
1023
|
+
alternates: {
|
|
1024
|
+
languages: {
|
|
1025
|
+
...getMultilingualUrls("https://example.com/login"),
|
|
1026
|
+
"x-default": "https://example.com/login",
|
|
1027
|
+
},
|
|
1028
|
+
},
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
url: "https://example.com/register",
|
|
1032
|
+
alternates: {
|
|
1033
|
+
languages: {
|
|
1034
|
+
...getMultilingualUrls("https://example.com/register"),
|
|
1035
|
+
"x-default": "https://example.com/register",
|
|
1036
|
+
},
|
|
1037
|
+
},
|
|
1038
|
+
},
|
|
1039
|
+
];
|
|
1040
|
+
|
|
1041
|
+
export default sitemap;
|
|
1042
|
+
```
|
|
1043
|
+
|
|
1044
|
+
```jsx fileName="src/app/sitemap.mjx" codeFormat="esm"
|
|
1045
|
+
import { getMultilingualUrls } from "intlayer";
|
|
1046
|
+
|
|
1047
|
+
const sitemap = () => [
|
|
1048
|
+
{
|
|
1049
|
+
url: "https://example.com",
|
|
1050
|
+
alternates: {
|
|
1051
|
+
languages: {
|
|
1052
|
+
...getMultilingualUrls("https://example.com"),
|
|
1053
|
+
"x-default": "https://example.com",
|
|
1054
|
+
},
|
|
1055
|
+
},
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
url: "https://example.com/login",
|
|
1059
|
+
alternates: {
|
|
1060
|
+
languages: {
|
|
1061
|
+
...getMultilingualUrls("https://example.com/login"),
|
|
1062
|
+
"x-default": "https://example.com/login",
|
|
1063
|
+
},
|
|
1064
|
+
},
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
url: "https://example.com/register",
|
|
1068
|
+
alternates: {
|
|
1069
|
+
languages: {
|
|
1070
|
+
...getMultilingualUrls("https://example.com/register"),
|
|
1071
|
+
"x-default": "https://example.com/register",
|
|
1072
|
+
},
|
|
1073
|
+
},
|
|
1074
|
+
},
|
|
1075
|
+
];
|
|
1076
|
+
|
|
1077
|
+
export default sitemap;
|
|
1078
|
+
```
|
|
1079
|
+
|
|
1080
|
+
```jsx fileName="src/app/sitemap.csx" codeFormat="commonjs"
|
|
1081
|
+
const { getMultilingualUrls } = require("intlayer");
|
|
1082
|
+
|
|
1083
|
+
const sitemap = () => [
|
|
1084
|
+
{
|
|
1085
|
+
url: "https://example.com",
|
|
1086
|
+
alternates: {
|
|
1087
|
+
languages: {
|
|
1088
|
+
...getMultilingualUrls("https://example.com"),
|
|
1089
|
+
"x-default": "https://example.com",
|
|
1090
|
+
},
|
|
1091
|
+
},
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
url: "https://example.com/login",
|
|
1095
|
+
alternates: {
|
|
1096
|
+
languages: {
|
|
1097
|
+
...getMultilingualUrls("https://example.com/login"),
|
|
1098
|
+
"x-default": "https://example.com/login",
|
|
1099
|
+
},
|
|
1100
|
+
},
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
url: "https://example.com/register",
|
|
1104
|
+
alternates: {
|
|
1105
|
+
languages: {
|
|
1106
|
+
...getMultilingualUrls("https://example.com/register"),
|
|
1107
|
+
"x-default": "https://example.com/register",
|
|
1108
|
+
},
|
|
1109
|
+
},
|
|
1110
|
+
},
|
|
1111
|
+
];
|
|
1112
|
+
|
|
1113
|
+
module.exports = sitemap;
|
|
1114
|
+
```
|
|
1115
|
+
|
|
1116
|
+
```tsx fileName="src/app/robots.ts" codeFormat="typescript"
|
|
1117
|
+
import type { MetadataRoute } from "next";
|
|
1118
|
+
import { getMultilingualUrls } from "intlayer";
|
|
1119
|
+
|
|
1120
|
+
const getAllMultilingualUrls = (urls: string[]) =>
|
|
1121
|
+
urls.flatMap((url) => Object.values(getMultilingualUrls(url)) as string[]);
|
|
1122
|
+
|
|
1123
|
+
// Mendefinisikan aturan robots.txt untuk mengizinkan akses ke root dan melarang akses ke halaman login dan register dalam semua bahasa
|
|
1124
|
+
const robots = (): MetadataRoute.Robots => ({
|
|
1125
|
+
rules: {
|
|
1126
|
+
userAgent: "*",
|
|
1127
|
+
allow: ["/"],
|
|
1128
|
+
disallow: getAllMultilingualUrls(["/login", "/register"]),
|
|
1129
|
+
},
|
|
1130
|
+
host: "https://example.com",
|
|
1131
|
+
sitemap: `https://example.com/sitemap.xml`,
|
|
1132
|
+
});
|
|
1133
|
+
|
|
1134
|
+
export default robots;
|
|
1135
|
+
|
|
1136
|
+
export default robots;
|
|
1137
|
+
```
|
|
1138
|
+
|
|
1139
|
+
```jsx fileName="src/app/robots.mjx" codeFormat="esm"
|
|
1140
|
+
import { getMultilingualUrls } from "intlayer";
|
|
1141
|
+
|
|
1142
|
+
const getAllMultilingualUrls = (urls) =>
|
|
1143
|
+
urls.flatMap((url) => Object.values(getMultilingualUrls(url)));
|
|
1144
|
+
|
|
1145
|
+
const robots = () => ({
|
|
1146
|
+
rules: {
|
|
1147
|
+
userAgent: "*",
|
|
1148
|
+
allow: ["/"],
|
|
1149
|
+
disallow: getAllMultilingualUrls(["/login", "/register"]),
|
|
1150
|
+
},
|
|
1151
|
+
host: "https://example.com",
|
|
1152
|
+
sitemap: `https://example.com/sitemap.xml`,
|
|
1153
|
+
});
|
|
1154
|
+
|
|
1155
|
+
export default robots;
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
```jsx fileName="src/app/robots.csx" codeFormat="commonjs"
|
|
1159
|
+
const { getMultilingualUrls } = require("intlayer");
|
|
1160
|
+
|
|
1161
|
+
const getAllMultilingualUrls = (urls) =>
|
|
1162
|
+
urls.flatMap((url) => Object.values(getMultilingualUrls(url)));
|
|
1163
|
+
|
|
1164
|
+
const robots = () => ({
|
|
1165
|
+
rules: {
|
|
1166
|
+
userAgent: "*",
|
|
1167
|
+
allow: ["/"],
|
|
1168
|
+
disallow: getAllMultilingualUrls(["/login", "/register"]),
|
|
1169
|
+
},
|
|
1170
|
+
host: "https://example.com",
|
|
1171
|
+
sitemap: `https://example.com/sitemap.xml`,
|
|
1172
|
+
});
|
|
1173
|
+
|
|
1174
|
+
module.exports = robots;
|
|
1175
|
+
```
|
|
1176
|
+
|
|
1177
|
+
> Pelajari lebih lanjut tentang optimasi sitemap [di dokumentasi resmi Next.js](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap). Pelajari lebih lanjut tentang optimasi robots.txt [di dokumentasi resmi Next.js](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/robots).
|
|
1178
|
+
|
|
1179
|
+
### (Opsional) Langkah 10: Ubah bahasa konten Anda
|
|
1180
|
+
|
|
1181
|
+
Untuk mengubah bahasa konten Anda di Next.js, cara yang direkomendasikan adalah menggunakan komponen `Link` untuk mengarahkan pengguna ke halaman yang sesuai dengan lokal yang diinginkan. Komponen `Link` memungkinkan prefetching halaman, yang membantu menghindari pemuatan ulang halaman secara penuh.
|
|
1182
|
+
|
|
1183
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
1184
|
+
"use client";
|
|
1185
|
+
|
|
1186
|
+
import {
|
|
1187
|
+
Locales,
|
|
1188
|
+
getHTMLTextDir,
|
|
1189
|
+
getLocaleName,
|
|
1190
|
+
getLocalizedUrl,
|
|
1191
|
+
} from "intlayer";
|
|
1192
|
+
import { useLocale } from "next-intlayer";
|
|
1193
|
+
import { type FC } from "react";
|
|
1194
|
+
import Link from "next/link";
|
|
1195
|
+
|
|
1196
|
+
const LocaleSwitcher: FC = () => {
|
|
1197
|
+
const { locale, pathWithoutLocale, availableLocales, setLocale } =
|
|
1198
|
+
useLocale();
|
|
1199
|
+
|
|
1200
|
+
return (
|
|
1201
|
+
<div>
|
|
1202
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1203
|
+
<div id="localePopover" popover="auto">
|
|
1204
|
+
{availableLocales.map((localeItem) => (
|
|
1205
|
+
<Link
|
|
1206
|
+
href={getLocalizedUrl(pathWithoutLocale, localeItem)}
|
|
1207
|
+
hrefLang={localeItem}
|
|
1208
|
+
key={localeItem}
|
|
1209
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1210
|
+
onClick={() => setLocale(localeItem)}
|
|
1211
|
+
replace // Akan memastikan bahwa tombol "kembali" pada browser akan mengarahkan ke halaman sebelumnya
|
|
1212
|
+
>
|
|
1213
|
+
<span>
|
|
1214
|
+
{/* Locale - misalnya FR */}
|
|
1215
|
+
{localeItem}
|
|
1216
|
+
</span>
|
|
1217
|
+
<span>
|
|
1218
|
+
{/* Bahasa dalam Locale-nya sendiri - misalnya Français */}
|
|
1219
|
+
{getLocaleName(localeItem, locale)}
|
|
1220
|
+
</span>
|
|
1221
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1222
|
+
{/* Bahasa dalam Locale saat ini - misalnya Francés dengan locale saat ini disetel ke Locales.SPANISH */}
|
|
1223
|
+
{getLocaleName(localeItem)}
|
|
1224
|
+
</span>
|
|
1225
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1226
|
+
{/* Bahasa dalam Bahasa Inggris - misalnya French */}
|
|
1227
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1228
|
+
</span>
|
|
1229
|
+
</Link>
|
|
1230
|
+
))}
|
|
1231
|
+
</div>
|
|
1232
|
+
</div>
|
|
1233
|
+
);
|
|
1234
|
+
};
|
|
1235
|
+
```
|
|
1236
|
+
|
|
1237
|
+
```jsx fileName="src/components/LocaleSwitcher.msx" codeFormat="esm"
|
|
1238
|
+
"use client";
|
|
1239
|
+
|
|
1240
|
+
import {
|
|
1241
|
+
Locales,
|
|
1242
|
+
getHTMLTextDir,
|
|
1243
|
+
getLocaleName,
|
|
1244
|
+
getLocalizedUrl,
|
|
1245
|
+
} from "intlayer";
|
|
1246
|
+
import { useLocale } from "next-intlayer";
|
|
1247
|
+
import Link from "next/link";
|
|
1248
|
+
|
|
1249
|
+
const LocaleSwitcher = () => {
|
|
1250
|
+
const { locale, pathWithoutLocale, availableLocales, setLocale } =
|
|
1251
|
+
useLocale();
|
|
1252
|
+
|
|
1253
|
+
return (
|
|
1254
|
+
<div>
|
|
1255
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1256
|
+
<div id="localePopover" popover="auto">
|
|
1257
|
+
{availableLocales.map((localeItem) => (
|
|
1258
|
+
<Link
|
|
1259
|
+
href={getLocalizedUrl(pathWithoutLocale, localeItem)}
|
|
1260
|
+
hrefLang={localeItem}
|
|
1261
|
+
key={localeItem}
|
|
1262
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1263
|
+
onClick={() => setLocale(localeItem)}
|
|
1264
|
+
replace // Akan memastikan bahwa tombol "kembali" pada browser akan mengarahkan ke halaman sebelumnya
|
|
1265
|
+
>
|
|
1266
|
+
<span>
|
|
1267
|
+
{/* Lokal - misalnya FR */}
|
|
1268
|
+
{localeItem}
|
|
1269
|
+
</span>
|
|
1270
|
+
<span>
|
|
1271
|
+
{/* Bahasa dalam Locale-nya sendiri - misalnya Français */}
|
|
1272
|
+
{getLocaleName(localeItem, locale)}
|
|
1273
|
+
</span>
|
|
1274
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1275
|
+
{/* Bahasa dalam Locale saat ini - misalnya Francés dengan locale saat ini disetel ke Locales.SPANISH */}
|
|
1276
|
+
{getLocaleName(localeItem)}
|
|
1277
|
+
</span>
|
|
1278
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1279
|
+
{/* Bahasa dalam Bahasa Inggris - misalnya French */}
|
|
1280
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1281
|
+
</span>
|
|
1282
|
+
</Link>
|
|
1283
|
+
))}
|
|
1284
|
+
</div>
|
|
1285
|
+
</div>
|
|
1286
|
+
);
|
|
1287
|
+
};
|
|
1288
|
+
```
|
|
1289
|
+
|
|
1290
|
+
```jsx fileName="src/components/LocaleSwitcher.csx" codeFormat="commonjs"
|
|
1291
|
+
"use client";
|
|
1292
|
+
|
|
1293
|
+
const {
|
|
1294
|
+
Locales,
|
|
1295
|
+
getHTMLTextDir,
|
|
1296
|
+
getLocaleName,
|
|
1297
|
+
getLocalizedUrl,
|
|
1298
|
+
} = require("intlayer");
|
|
1299
|
+
const { useLocale } = require("next-intlayer");
|
|
1300
|
+
const Link = require("next/link");
|
|
1301
|
+
|
|
1302
|
+
const LocaleSwitcher = () => {
|
|
1303
|
+
const { locale, pathWithoutLocale, availableLocales, setLocale } =
|
|
1304
|
+
useLocale();
|
|
1305
|
+
|
|
1306
|
+
return (
|
|
1307
|
+
<div>
|
|
1308
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1309
|
+
<div id="localePopover" popover="auto">
|
|
1310
|
+
{availableLocales.map((localeItem) => (
|
|
1311
|
+
<Link
|
|
1312
|
+
href={getLocalizedUrl(pathWithoutLocale, localeItem)}
|
|
1313
|
+
hrefLang={localeItem}
|
|
1314
|
+
key={localeItem}
|
|
1315
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1316
|
+
onClick={() => setLocale(localeItem)}
|
|
1317
|
+
replace // Akan memastikan bahwa tombol "kembali" di browser akan mengarahkan ke halaman sebelumnya
|
|
1318
|
+
>
|
|
1319
|
+
<span>
|
|
1320
|
+
{/* Lokalisasi - misalnya FR */}
|
|
1321
|
+
{localeItem}
|
|
1322
|
+
</span>
|
|
1323
|
+
<span>
|
|
1324
|
+
{/* Bahasa dalam Lokalisasi sendiri - misalnya Français */}
|
|
1325
|
+
{getLocaleName(localeItem, locale)}
|
|
1326
|
+
</span>
|
|
1327
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1328
|
+
{/* Bahasa dalam Lokalisasi saat ini - misalnya Francés dengan lokalisasi saat ini disetel ke Locales.SPANISH */}
|
|
1329
|
+
{getLocaleName(localeItem)}
|
|
1330
|
+
</span>
|
|
1331
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1332
|
+
{/* Bahasa dalam Bahasa Inggris - misalnya French */}
|
|
1333
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1334
|
+
</span>
|
|
1335
|
+
</Link>
|
|
1336
|
+
))}
|
|
1337
|
+
</div>
|
|
1338
|
+
</div>
|
|
1339
|
+
);
|
|
1340
|
+
};
|
|
1341
|
+
```
|
|
1342
|
+
|
|
1343
|
+
> Cara alternatif adalah menggunakan fungsi `setLocale` yang disediakan oleh hook `useLocale`. Fungsi ini tidak akan memungkinkan prefetching halaman. Lihat dokumentasi [`useLocale` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/next-intlayer/useLocale.md) untuk detail lebih lanjut.
|
|
1344
|
+
|
|
1345
|
+
> Anda juga dapat mengatur fungsi pada opsi `onLocaleChange` untuk memicu fungsi kustom saat locale berubah.
|
|
1346
|
+
|
|
1347
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx"
|
|
1348
|
+
"use client";
|
|
1349
|
+
|
|
1350
|
+
import { useRouter } from "next/navigation";
|
|
1351
|
+
import { useLocale } from "next-intlayer";
|
|
1352
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1353
|
+
|
|
1354
|
+
// ... Sisa kode
|
|
1355
|
+
|
|
1356
|
+
const router = useRouter();
|
|
1357
|
+
const { setLocale } = useLocale({
|
|
1358
|
+
onLocaleChange: (locale) => {
|
|
1359
|
+
router.push(getLocalizedUrl(pathWithoutLocale, locale));
|
|
1360
|
+
},
|
|
1361
|
+
});
|
|
1362
|
+
|
|
1363
|
+
return (
|
|
1364
|
+
<button onClick={() => setLocale(Locales.FRENCH)}>
|
|
1365
|
+
Ganti ke Bahasa Perancis
|
|
1366
|
+
</button>
|
|
1367
|
+
);
|
|
1368
|
+
```
|
|
1369
|
+
|
|
1370
|
+
> Referensi dokumentasi:
|
|
1371
|
+
>
|
|
1372
|
+
> - [`useLocale` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/next-intlayer/useLocale.md)
|
|
1373
|
+
> - [`getLocaleName` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/intlayer/getLocaleName.md)
|
|
1374
|
+
> - [`getLocalizedUrl` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/intlayer/getLocalizedUrl.md)
|
|
1375
|
+
> - [`getHTMLTextDir` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/intlayer/getHTMLTextDir.md)
|
|
1376
|
+
> - [`hrefLang` attribute](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
|
|
1377
|
+
> - [`atribut lang`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
|
|
1378
|
+
> - [`atribut dir`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
|
|
1379
|
+
> - [`atribut aria-current`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1380
|
+
|
|
1381
|
+
### (Opsional) Langkah 11: Membuat Komponen Link yang Dilokalisasi
|
|
1382
|
+
|
|
1383
|
+
Untuk memastikan navigasi aplikasi Anda menghormati locale saat ini, Anda dapat membuat komponen `Link` kustom. Komponen ini secara otomatis menambahkan prefix bahasa saat ini pada URL internal, sehingga misalnya, ketika pengguna berbahasa Prancis mengklik tautan ke halaman "About", mereka diarahkan ke `/fr/about` bukan `/about`.
|
|
1384
|
+
|
|
1385
|
+
Perilaku ini berguna untuk beberapa alasan:
|
|
1386
|
+
|
|
1387
|
+
- **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.
|
|
1388
|
+
- **Konsistensi**: Dengan menggunakan tautan yang dilokalkan di seluruh aplikasi Anda, Anda menjamin bahwa navigasi tetap dalam locale saat ini, mencegah perubahan bahasa yang tidak diinginkan.
|
|
1389
|
+
- **Pemeliharaan**: Memusatkan logika lokalisasi dalam satu komponen menyederhanakan pengelolaan URL, membuat codebase Anda lebih mudah dipelihara dan dikembangkan seiring pertumbuhan aplikasi Anda.
|
|
1390
|
+
|
|
1391
|
+
Berikut adalah implementasi komponen `Link` yang dilokalkan dalam TypeScript:
|
|
1392
|
+
|
|
1393
|
+
```tsx fileName="src/components/Link.tsx" codeFormat="typescript"
|
|
1394
|
+
"use client";
|
|
1395
|
+
|
|
1396
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1397
|
+
import NextLink, { type LinkProps as NextLinkProps } from "next/link";
|
|
1398
|
+
import { useLocale } from "next-intlayer";
|
|
1399
|
+
import { forwardRef, PropsWithChildren, type ForwardedRef } from "react";
|
|
1400
|
+
|
|
1401
|
+
/**
|
|
1402
|
+
* Fungsi utilitas untuk memeriksa apakah URL yang diberikan adalah eksternal.
|
|
1403
|
+
* Jika URL dimulai dengan http:// atau https://, maka dianggap eksternal.
|
|
1404
|
+
*/
|
|
1405
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1406
|
+
/^https?:\/\//.test(href ?? "");
|
|
1407
|
+
|
|
1408
|
+
/**
|
|
1409
|
+
* Komponen Link kustom yang menyesuaikan atribut href berdasarkan locale saat ini.
|
|
1410
|
+
* Untuk tautan internal, menggunakan `getLocalizedUrl` untuk menambahkan prefix locale pada URL (misalnya, /fr/about).
|
|
1411
|
+
* Ini memastikan navigasi tetap dalam konteks locale yang sama.
|
|
1412
|
+
*/
|
|
1413
|
+
export const Link = forwardRef<
|
|
1414
|
+
HTMLAnchorElement,
|
|
1415
|
+
PropsWithChildren<NextLinkProps>
|
|
1416
|
+
>(({ href, children, ...props }, ref: ForwardedRef<HTMLAnchorElement>) => {
|
|
1417
|
+
const { locale } = useLocale();
|
|
1418
|
+
const isExternalLink = checkIsExternalLink(href.toString());
|
|
1419
|
+
|
|
1420
|
+
// Jika tautan bersifat internal dan href yang valid diberikan, dapatkan URL yang sudah dilokalkan.
|
|
1421
|
+
const hrefI18n: NextLinkProps["href"] =
|
|
1422
|
+
href && !isExternalLink ? getLocalizedUrl(href.toString(), locale) : href;
|
|
1423
|
+
|
|
1424
|
+
return (
|
|
1425
|
+
<NextLink href={hrefI18n} ref={ref} {...props}>
|
|
1426
|
+
{children}
|
|
1427
|
+
</NextLink>
|
|
1428
|
+
);
|
|
1429
|
+
});
|
|
1430
|
+
|
|
1431
|
+
Link.displayName = "Link";
|
|
1432
|
+
```
|
|
1433
|
+
|
|
1434
|
+
```jsx fileName="src/components/Link.mjx" codeFormat="esm"
|
|
1435
|
+
'use client';
|
|
1436
|
+
|
|
1437
|
+
import { getLocalizedUrl } from 'intlayer';
|
|
1438
|
+
import NextLink, { type LinkProps as NextLinkProps } from 'next/link';
|
|
1439
|
+
import { useLocale } from 'next-intlayer';
|
|
1440
|
+
import { forwardRef, PropsWithChildren, type ForwardedRef } from 'react';
|
|
1441
|
+
|
|
1442
|
+
/**
|
|
1443
|
+
* Fungsi utilitas untuk memeriksa apakah sebuah URL merupakan link eksternal.
|
|
1444
|
+
* Jika URL dimulai dengan http:// atau https://, maka dianggap sebagai link eksternal.
|
|
1445
|
+
*/
|
|
1446
|
+
export const checkIsExternalLink = (href) =>
|
|
1447
|
+
/^https?:\/\//.test(href ?? '');
|
|
1448
|
+
|
|
1449
|
+
/**
|
|
1450
|
+
* Komponen Link kustom yang menyesuaikan atribut href berdasarkan locale saat ini.
|
|
1451
|
+
* Untuk link internal, menggunakan `getLocalizedUrl` untuk menambahkan prefix locale pada URL (misalnya, /fr/about).
|
|
1452
|
+
* Ini memastikan navigasi tetap dalam konteks locale yang sama.
|
|
1453
|
+
*/
|
|
1454
|
+
export const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1455
|
+
const { locale } = useLocale();
|
|
1456
|
+
const isExternalLink = checkIsExternalLink(href.toString());
|
|
1457
|
+
|
|
1458
|
+
// Jika tautan bersifat internal dan href yang valid diberikan, dapatkan URL yang sudah dilokalkan.
|
|
1459
|
+
const hrefI18n =
|
|
1460
|
+
href && !isExternalLink ? getLocalizedUrl(href.toString(), locale) : href;
|
|
1461
|
+
|
|
1462
|
+
return (
|
|
1463
|
+
<NextLink href={hrefI18n} ref={ref} {...props}>
|
|
1464
|
+
{children}
|
|
1465
|
+
</NextLink>
|
|
1466
|
+
);
|
|
1467
|
+
});
|
|
1468
|
+
|
|
1469
|
+
Link.displayName = 'Link';
|
|
1470
|
+
```
|
|
1471
|
+
|
|
1472
|
+
```jsx fileName="src/components/Link.csx" codeFormat="commonjs"
|
|
1473
|
+
'use client';
|
|
1474
|
+
|
|
1475
|
+
const { getLocalizedUrl } = require("intlayer");
|
|
1476
|
+
const NextLink = require("next/link");
|
|
1477
|
+
const { useLocale } = require("next-intlayer");
|
|
1478
|
+
const { forwardRef } = require("react");
|
|
1479
|
+
|
|
1480
|
+
/**
|
|
1481
|
+
* Fungsi utilitas untuk memeriksa apakah URL yang diberikan bersifat eksternal.
|
|
1482
|
+
* Jika URL diawali dengan http:// atau https://, maka dianggap eksternal.
|
|
1483
|
+
*/
|
|
1484
|
+
const checkIsExternalLink = (href) =>
|
|
1485
|
+
/^https?:\/\//.test(href ?? '');
|
|
1486
|
+
|
|
1487
|
+
|
|
1488
|
+
const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1489
|
+
const { locale } = useLocale();
|
|
1490
|
+
const isExternalLink = checkIsExternalLink(href.toString());
|
|
1491
|
+
|
|
1492
|
+
// Jika tautan bersifat internal dan href yang valid diberikan, dapatkan URL yang sudah dilokalkan.
|
|
1493
|
+
const hrefI18n: NextLinkProps['href'] =
|
|
1494
|
+
href && !isExternalLink ? getLocalizedUrl(href.toString(), locale) : href;
|
|
1495
|
+
|
|
1496
|
+
return (
|
|
1497
|
+
<NextLink href={hrefI18n} ref={ref} {...props}>
|
|
1498
|
+
{children}
|
|
1499
|
+
</NextLink>
|
|
1500
|
+
);
|
|
1501
|
+
});
|
|
1502
|
+
|
|
1503
|
+
Link.displayName = 'Link';
|
|
1504
|
+
```
|
|
1505
|
+
|
|
1506
|
+
#### Cara Kerjanya
|
|
1507
|
+
|
|
1508
|
+
- **Mendeteksi Tautan Eksternal**:
|
|
1509
|
+
Fungsi pembantu `checkIsExternalLink` menentukan apakah sebuah URL bersifat eksternal. Tautan eksternal dibiarkan tidak berubah karena tidak memerlukan lokalisasi.
|
|
1510
|
+
|
|
1511
|
+
- **Mengambil Locale Saat Ini**:
|
|
1512
|
+
- **Melokalisasi URL**:
|
|
1513
|
+
Untuk tautan internal (yaitu, bukan tautan eksternal), `getLocalizedUrl` digunakan untuk secara otomatis menambahkan prefiks URL dengan locale saat ini. Ini berarti jika pengguna Anda menggunakan bahasa Prancis, melewatkan `/about` sebagai `href` akan mengubahnya menjadi `/fr/about`.
|
|
1514
|
+
|
|
1515
|
+
- **Mengembalikan Link**:
|
|
1516
|
+
Komponen mengembalikan elemen `<a>` dengan URL yang sudah dilokalisasi, memastikan navigasi konsisten dengan locale.
|
|
1517
|
+
|
|
1518
|
+
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.
|
|
1519
|
+
|
|
1520
|
+
### (Opsional) Langkah 12: Mendapatkan locale saat ini dalam Server Actions
|
|
1521
|
+
|
|
1522
|
+
Jika Anda membutuhkan locale aktif di dalam Server Action (misalnya, untuk melokalkan email atau menjalankan logika yang sadar locale), panggil `getLocale` dari `next-intlayer/server`:
|
|
1523
|
+
|
|
1524
|
+
```tsx fileName="src/app/actions/getLocale.ts" codeFormat="typescript"
|
|
1525
|
+
"use server";
|
|
1526
|
+
|
|
1527
|
+
import { getLocale } from "next-intlayer/server";
|
|
1528
|
+
|
|
1529
|
+
export const myServerAction = async () => {
|
|
1530
|
+
const locale = await getLocale();
|
|
1531
|
+
|
|
1532
|
+
// Lakukan sesuatu dengan locale
|
|
1533
|
+
};
|
|
1534
|
+
```
|
|
1535
|
+
|
|
1536
|
+
> Fungsi `getLocale` mengikuti strategi bertingkat untuk menentukan locale pengguna:
|
|
1537
|
+
>
|
|
1538
|
+
> 1. Pertama, memeriksa header permintaan untuk nilai locale yang mungkin telah diatur oleh middleware
|
|
1539
|
+
> 2. Jika tidak ditemukan locale di header, mencari locale yang disimpan di cookie
|
|
1540
|
+
> 3. Jika tidak ditemukan cookie, mencoba mendeteksi bahasa yang dipilih pengguna dari pengaturan browser mereka
|
|
1541
|
+
> 4. Sebagai upaya terakhir, ia akan kembali ke locale default yang dikonfigurasi dalam aplikasi
|
|
1542
|
+
>
|
|
1543
|
+
> Ini memastikan locale yang paling sesuai dipilih berdasarkan konteks yang tersedia.
|
|
1544
|
+
|
|
1545
|
+
### (Opsional) Langkah 13: Optimalkan ukuran bundle Anda
|
|
1546
|
+
|
|
1547
|
+
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.
|
|
1548
|
+
|
|
1549
|
+
Untuk mengaktifkan optimasi ini, instal paket `@intlayer/swc`. Setelah terinstal, `next-intlayer` akan secara otomatis mendeteksi dan menggunakan plugin tersebut:
|
|
1550
|
+
|
|
1551
|
+
```bash packageManager="npm"
|
|
1552
|
+
npm install @intlayer/swc --save-dev
|
|
1553
|
+
```
|
|
1554
|
+
|
|
1555
|
+
```bash packageManager="pnpm"
|
|
1556
|
+
pnpm add @intlayer/swc --save-dev
|
|
1557
|
+
```
|
|
1558
|
+
|
|
1559
|
+
```bash packageManager="yarn"
|
|
1560
|
+
yarn add @intlayer/swc --save-dev
|
|
1561
|
+
```
|
|
1562
|
+
|
|
1563
|
+
> Catatan: Optimasi ini hanya tersedia untuk Next.js 13 ke atas.
|
|
1564
|
+
|
|
1565
|
+
> Catatan: Paket ini tidak diinstal secara default karena plugin SWC masih bersifat eksperimental di Next.js. Hal ini mungkin berubah di masa depan.
|
|
1566
|
+
|
|
1567
|
+
> Catatan: Jika Anda mengatur opsi sebagai `importMode: 'dynamic'` atau `importMode: 'live'`, maka akan bergantung pada Suspense, sehingga Anda harus membungkus pemanggilan `useIntlayer` Anda dalam batas `Suspense`. Itu berarti, Anda tidak dapat menggunakan `useIntlayer` secara langsung di tingkat atas komponen Halaman / Layout Anda.
|
|
1568
|
+
|
|
1569
|
+
### Konfigurasi TypeScript
|
|
1570
|
+
|
|
1571
|
+
Intlayer menggunakan augmentasi modul untuk mendapatkan manfaat dari TypeScript dan membuat codebase Anda lebih kuat.
|
|
1572
|
+
|
|
1573
|
+

|
|
1574
|
+
|
|
1575
|
+

|
|
1576
|
+
|
|
1577
|
+
Pastikan konfigurasi TypeScript Anda menyertakan tipe yang dihasilkan secara otomatis.
|
|
1578
|
+
|
|
1579
|
+
```json5 fileName="tsconfig.json"
|
|
1580
|
+
{
|
|
1581
|
+
// ... Konfigurasi TypeScript Anda yang sudah ada
|
|
1582
|
+
"include": [
|
|
1583
|
+
// ... Konfigurasi TypeScript Anda yang sudah ada
|
|
1584
|
+
".intlayer/**/*.ts", // Sertakan tipe yang dihasilkan secara otomatis
|
|
1585
|
+
],
|
|
1586
|
+
}
|
|
1587
|
+
```
|
|
1588
|
+
|
|
1589
|
+
### Konfigurasi Git
|
|
1590
|
+
|
|
1591
|
+
Disarankan untuk mengabaikan file yang dihasilkan oleh Intlayer. Ini memungkinkan Anda untuk menghindari meng-commit file tersebut ke repositori Git Anda.
|
|
1592
|
+
|
|
1593
|
+
Untuk melakukan ini, Anda dapat menambahkan instruksi berikut ke file `.gitignore` Anda:
|
|
1594
|
+
|
|
1595
|
+
```plaintext fileName=".gitignore"
|
|
1596
|
+
# Abaikan file yang dihasilkan oleh Intlayer
|
|
1597
|
+
.intlayer
|
|
1598
|
+
```
|
|
1599
|
+
|
|
1600
|
+
### Ekstensi VS Code
|
|
1601
|
+
|
|
1602
|
+
Untuk meningkatkan pengalaman pengembangan Anda dengan Intlayer, Anda dapat menginstal **Ekstensi VS Code Intlayer** resmi.
|
|
1603
|
+
|
|
1604
|
+
[Pasang dari VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
1605
|
+
|
|
1606
|
+
Ekstensi ini menyediakan:
|
|
1607
|
+
|
|
1608
|
+
- **Autocompletion** untuk kunci terjemahan.
|
|
1609
|
+
- **Deteksi kesalahan waktu nyata** untuk terjemahan yang hilang.
|
|
1610
|
+
- **Pratinjau inline** dari konten terjemahan.
|
|
1611
|
+
- **Tindakan cepat** untuk dengan mudah membuat dan memperbarui terjemahan.
|
|
1612
|
+
|
|
1613
|
+
Untuk detail lebih lanjut tentang cara menggunakan ekstensi ini, lihat [dokumentasi Ekstensi VS Code Intlayer](https://intlayer.org/doc/vs-code-extension).
|
|
1614
|
+
|
|
1615
|
+
### Melangkah Lebih Jauh
|
|
1616
|
+
|
|
1617
|
+
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).
|