@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,1737 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-04-18
|
|
3
|
+
updatedAt: 2025-10-28
|
|
4
|
+
title: Cara menerjemahkan aplikasi Vite dan Preact Anda – panduan i18n 2025
|
|
5
|
+
description: Temukan cara membuat situs web Vite dan Preact Anda menjadi multibahasa. Ikuti dokumentasi untuk melakukan internasionalisasi (i18n) dan menerjemahkannya.
|
|
6
|
+
keywords:
|
|
7
|
+
- Internasionalisasi
|
|
8
|
+
- Dokumentasi
|
|
9
|
+
- Intlayer
|
|
10
|
+
- Vite
|
|
11
|
+
- Preact
|
|
12
|
+
- JavaScript
|
|
13
|
+
slugs:
|
|
14
|
+
- doc
|
|
15
|
+
- environment
|
|
16
|
+
- vite-and-preact
|
|
17
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-vite-preact-template
|
|
18
|
+
history:
|
|
19
|
+
- version: 7.0.0
|
|
20
|
+
date: 2025-10-28
|
|
21
|
+
changes: Memperbarui komponen LocaleRouter untuk menggunakan konfigurasi rute baru
|
|
22
|
+
- version: 5.5.10
|
|
23
|
+
date: 2025-06-29
|
|
24
|
+
changes: Inisialisasi riwayat
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Terjemahkan situs web Vite dan Preact Anda menggunakan Intlayer | Internasionalisasi (i18n)
|
|
28
|
+
|
|
29
|
+
> Paket ini sedang dalam pengembangan. Lihat [issue](https://github.com/aymericzip/intlayer/issues/118) untuk informasi lebih lanjut. Tunjukkan minat Anda pada Intlayer untuk Preact dengan menyukai issue tersebut
|
|
30
|
+
|
|
31
|
+
## Daftar Isi
|
|
32
|
+
|
|
33
|
+
<TOC/>
|
|
34
|
+
|
|
35
|
+
## Apa itu Intlayer?
|
|
36
|
+
|
|
37
|
+
**Intlayer** adalah perpustakaan internasionalisasi (i18n) open-source yang inovatif, dirancang untuk menyederhanakan dukungan multibahasa dalam aplikasi web modern.
|
|
38
|
+
|
|
39
|
+
Dengan Intlayer, Anda dapat:
|
|
40
|
+
|
|
41
|
+
- **Mengelola terjemahan dengan mudah** menggunakan kamus deklaratif di tingkat komponen.
|
|
42
|
+
- **Melokalkan metadata**, rute, dan konten secara dinamis.
|
|
43
|
+
- **Menjamin dukungan TypeScript** dengan tipe yang dihasilkan secara otomatis, meningkatkan autocompletion dan deteksi kesalahan.
|
|
44
|
+
- **Memanfaatkan fitur canggih**, seperti deteksi dan pergantian locale secara dinamis.
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Panduan Langkah demi Langkah untuk Mengatur Intlayer dalam Aplikasi Vite dan Preact
|
|
49
|
+
|
|
50
|
+
<iframe
|
|
51
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-vite-preact-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
52
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
53
|
+
title="Demo CodeSandbox - Cara Menginternasionalisasi aplikasi Anda menggunakan Intlayer"
|
|
54
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
55
|
+
loading="lazy"
|
|
56
|
+
/>
|
|
57
|
+
|
|
58
|
+
Lihat [Template Aplikasi](https://github.com/aymericzip/intlayer-vite-preact-template) di GitHub.
|
|
59
|
+
|
|
60
|
+
### Langkah 1: Instalasi Dependensi
|
|
61
|
+
|
|
62
|
+
Instal paket yang diperlukan menggunakan npm:
|
|
63
|
+
|
|
64
|
+
```bash packageManager="npm"
|
|
65
|
+
npm install intlayer preact-intlayer
|
|
66
|
+
npm install vite-intlayer --save-dev
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```bash packageManager="pnpm"
|
|
70
|
+
pnpm add intlayer preact-intlayer
|
|
71
|
+
pnpm add vite-intlayer --save-dev
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```bash packageManager="yarn"
|
|
75
|
+
yarn add intlayer preact-intlayer
|
|
76
|
+
yarn add vite-intlayer --save-dev
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- **intlayer**
|
|
80
|
+
|
|
81
|
+
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).
|
|
82
|
+
|
|
83
|
+
- **preact-intlayer**
|
|
84
|
+
Paket yang mengintegrasikan Intlayer dengan aplikasi Preact. Ini menyediakan context providers dan hooks untuk internasionalisasi Preact.
|
|
85
|
+
|
|
86
|
+
- **vite-intlayer**
|
|
87
|
+
Termasuk plugin Vite untuk mengintegrasikan Intlayer dengan [Vite bundler](https://vite.dev/guide/why.html#why-bundle-for-production), serta middleware untuk mendeteksi locale yang dipilih pengguna, mengelola cookie, dan menangani pengalihan URL.
|
|
88
|
+
|
|
89
|
+
### Langkah 2: Konfigurasi proyek Anda
|
|
90
|
+
|
|
91
|
+
Buat file konfigurasi untuk mengatur bahasa aplikasi Anda:
|
|
92
|
+
|
|
93
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
94
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
95
|
+
|
|
96
|
+
const config: IntlayerConfig = {
|
|
97
|
+
internationalization: {
|
|
98
|
+
locales: [
|
|
99
|
+
Locales.ENGLISH,
|
|
100
|
+
Locales.FRENCH,
|
|
101
|
+
Locales.SPANISH,
|
|
102
|
+
// Locale lain milik Anda
|
|
103
|
+
],
|
|
104
|
+
defaultLocale: Locales.ENGLISH,
|
|
105
|
+
},
|
|
106
|
+
routing: {
|
|
107
|
+
mode: "prefix-no-default", // Default: prefix semua locale kecuali locale default
|
|
108
|
+
storage: ["cookie", "header"], // Default: simpan locale di cookie dan deteksi dari header
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export default config;
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
116
|
+
import { Locales } from "intlayer";
|
|
117
|
+
|
|
118
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
119
|
+
const config = {
|
|
120
|
+
internationalization: {
|
|
121
|
+
locales: [
|
|
122
|
+
Locales.ENGLISH,
|
|
123
|
+
Locales.FRENCH,
|
|
124
|
+
Locales.SPANISH,
|
|
125
|
+
// Locale lain milik Anda
|
|
126
|
+
],
|
|
127
|
+
defaultLocale: Locales.ENGLISH,
|
|
128
|
+
},
|
|
129
|
+
routing: {
|
|
130
|
+
mode: "prefix-no-default", // Default: prefix semua locale kecuali locale default
|
|
131
|
+
storage: ["cookie", "header"], // Default: simpan locale di cookie dan deteksi dari header
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export default config;
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
139
|
+
const { Locales } = require("intlayer");
|
|
140
|
+
|
|
141
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
142
|
+
const config = {
|
|
143
|
+
internationalization: {
|
|
144
|
+
locales: [
|
|
145
|
+
Locales.ENGLISH,
|
|
146
|
+
Locales.FRENCH,
|
|
147
|
+
Locales.SPANISH,
|
|
148
|
+
// Locale lain milik Anda
|
|
149
|
+
],
|
|
150
|
+
defaultLocale: Locales.ENGLISH,
|
|
151
|
+
},
|
|
152
|
+
routing: {
|
|
153
|
+
mode: "prefix-no-default", // Default: prefix semua locale kecuali locale default
|
|
154
|
+
storage: ["cookie", "header"], // Default: simpan locale di cookie dan deteksi dari header
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
module.exports = config;
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
> Melalui file konfigurasi ini, Anda dapat mengatur URL yang dilokalkan, mode routing, opsi penyimpanan, nama cookie, lokasi dan ekstensi deklarasi konten Anda, menonaktifkan log Intlayer di konsol, dan lainnya. Untuk daftar lengkap parameter yang tersedia, lihat [dokumentasi konfigurasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/configuration.md).
|
|
162
|
+
|
|
163
|
+
### Langkah 3: Integrasikan Intlayer dalam Konfigurasi Vite Anda
|
|
164
|
+
|
|
165
|
+
Tambahkan plugin intlayer ke dalam konfigurasi Anda.
|
|
166
|
+
|
|
167
|
+
```typescript fileName="vite.config.ts" codeFormat="typescript"
|
|
168
|
+
import { defineConfig } from "vite";
|
|
169
|
+
import preact from "@preact/preset-vite";
|
|
170
|
+
import { intlayer } from "vite-intlayer";
|
|
171
|
+
|
|
172
|
+
// https://vitejs.dev/config/
|
|
173
|
+
export default defineConfig({
|
|
174
|
+
plugins: [preact(), intlayer()],
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
```javascript fileName="vite.config.mjs" codeFormat="esm"
|
|
179
|
+
import { defineConfig } from "vite";
|
|
180
|
+
import preact from "@preact/preset-vite";
|
|
181
|
+
import { intlayer } from "vite-intlayer";
|
|
182
|
+
|
|
183
|
+
// https://vitejs.dev/config/
|
|
184
|
+
export default defineConfig({
|
|
185
|
+
plugins: [preact(), intlayer()],
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
```javascript fileName="vite.config.cjs" codeFormat="commonjs"
|
|
190
|
+
const { defineConfig } = require("vite");
|
|
191
|
+
const preact = require("@preact/preset-vite");
|
|
192
|
+
const { intlayer } = require("vite-intlayer");
|
|
193
|
+
|
|
194
|
+
// https://vitejs.dev/config/
|
|
195
|
+
module.exports = defineConfig({
|
|
196
|
+
plugins: [preact(), intlayer()],
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
> Plugin Vite `intlayer()` digunakan untuk mengintegrasikan Intlayer dengan Vite. Plugin ini memastikan pembuatan file deklarasi konten dan memantau file tersebut dalam mode pengembangan. Plugin ini juga mendefinisikan variabel lingkungan Intlayer di dalam aplikasi Vite. Selain itu, plugin ini menyediakan alias untuk mengoptimalkan performa.
|
|
201
|
+
|
|
202
|
+
### Langkah 4: Deklarasikan Konten Anda
|
|
203
|
+
|
|
204
|
+
Buat dan kelola deklarasi konten Anda untuk menyimpan terjemahan:
|
|
205
|
+
|
|
206
|
+
```tsx fileName="src/app.content.tsx" contentDeclarationFormat="typescript"
|
|
207
|
+
import { t, type Dictionary } from "intlayer";
|
|
208
|
+
import type { ComponentChildren } from "preact";
|
|
209
|
+
|
|
210
|
+
const appContent = {
|
|
211
|
+
key: "app",
|
|
212
|
+
content: {
|
|
213
|
+
viteLogo: t({
|
|
214
|
+
en: "Vite logo",
|
|
215
|
+
fr: "Logo Vite",
|
|
216
|
+
es: "Logo Vite",
|
|
217
|
+
}),
|
|
218
|
+
preactLogo: t({
|
|
219
|
+
en: "Preact logo",
|
|
220
|
+
fr: "Logo Preact",
|
|
221
|
+
es: "Logo Preact",
|
|
222
|
+
}),
|
|
223
|
+
|
|
224
|
+
title: "Vite + Preact",
|
|
225
|
+
|
|
226
|
+
count: t({
|
|
227
|
+
en: "count is ",
|
|
228
|
+
fr: "le compte est ",
|
|
229
|
+
es: "el recuento es ",
|
|
230
|
+
}),
|
|
231
|
+
|
|
232
|
+
edit: t<ComponentChildren>({
|
|
233
|
+
en: (
|
|
234
|
+
<>
|
|
235
|
+
Edit <code>src/app.tsx</code> dan simpan untuk menguji HMR
|
|
236
|
+
</>
|
|
237
|
+
),
|
|
238
|
+
fr: (
|
|
239
|
+
<>
|
|
240
|
+
Éditez <code>src/app.tsx</code> et enregistrez pour tester HMR
|
|
241
|
+
</>
|
|
242
|
+
),
|
|
243
|
+
es: (
|
|
244
|
+
<>
|
|
245
|
+
Edita <code>src/app.tsx</code> y guarda para probar HMR
|
|
246
|
+
</>
|
|
247
|
+
),
|
|
248
|
+
}),
|
|
249
|
+
|
|
250
|
+
readTheDocs: t({
|
|
251
|
+
en: "Klik pada logo Vite dan Preact untuk mempelajari lebih lanjut",
|
|
252
|
+
fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
253
|
+
es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
254
|
+
}),
|
|
255
|
+
},
|
|
256
|
+
} satisfies Dictionary;
|
|
257
|
+
|
|
258
|
+
export default appContent;
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
```javascript fileName="src/app.content.mjs" contentDeclarationFormat="esm"
|
|
262
|
+
import { t } from "intlayer";
|
|
263
|
+
// import { h } from 'preact'; // Diperlukan jika Anda menggunakan JSX langsung di .mjs
|
|
264
|
+
|
|
265
|
+
/** @type {import('intlayer').Dictionary} */
|
|
266
|
+
const appContent = {
|
|
267
|
+
key: "app",
|
|
268
|
+
content: {
|
|
269
|
+
viteLogo: t({
|
|
270
|
+
en: "Vite logo",
|
|
271
|
+
fr: "Logo Vite",
|
|
272
|
+
es: "Logo Vite",
|
|
273
|
+
}),
|
|
274
|
+
preactLogo: t({
|
|
275
|
+
en: "Preact logo",
|
|
276
|
+
fr: "Logo Preact",
|
|
277
|
+
es: "Logo Preact",
|
|
278
|
+
}),
|
|
279
|
+
|
|
280
|
+
title: "Vite + Preact",
|
|
281
|
+
|
|
282
|
+
count: t({
|
|
283
|
+
en: "count is ",
|
|
284
|
+
fr: "le compte est ",
|
|
285
|
+
es: "el recuento es ",
|
|
286
|
+
}),
|
|
287
|
+
|
|
288
|
+
edit: t({
|
|
289
|
+
en: "Edit src/app.jsx and save to test HMR",
|
|
290
|
+
fr: "Éditez src/app.jsx et enregistrez pour tester HMR",
|
|
291
|
+
es: "Edita src/app.jsx y guarda para probar HMR",
|
|
292
|
+
}),
|
|
293
|
+
|
|
294
|
+
readTheDocs: t({
|
|
295
|
+
en: "Klik pada logo Vite dan Preact untuk mempelajari lebih lanjut",
|
|
296
|
+
fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
297
|
+
es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
298
|
+
}),
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
export default appContent;
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
```javascript fileName="src/app.content.cjs" contentDeclarationFormat="commonjs"
|
|
306
|
+
const { t } = require("intlayer");
|
|
307
|
+
// const { h } = require('preact'); // Diperlukan jika Anda menggunakan JSX langsung di .cjs
|
|
308
|
+
|
|
309
|
+
/** @type {import('intlayer').Dictionary} */
|
|
310
|
+
const appContent = {
|
|
311
|
+
key: "app",
|
|
312
|
+
content: {
|
|
313
|
+
viteLogo: t({
|
|
314
|
+
en: "Vite logo",
|
|
315
|
+
fr: "Logo Vite",
|
|
316
|
+
es: "Logo Vite",
|
|
317
|
+
}),
|
|
318
|
+
preactLogo: t({
|
|
319
|
+
fr: "Logo Preact",
|
|
320
|
+
es: "Logo Preact",
|
|
321
|
+
}),
|
|
322
|
+
|
|
323
|
+
title: "Vite + Preact",
|
|
324
|
+
|
|
325
|
+
count: t({
|
|
326
|
+
en: "count is ",
|
|
327
|
+
fr: "le compte est ",
|
|
328
|
+
es: "el recuento es ",
|
|
329
|
+
id: "jumlah adalah ",
|
|
330
|
+
}),
|
|
331
|
+
|
|
332
|
+
edit: t({
|
|
333
|
+
en: "Edit src/app.tsx and save to test HMR",
|
|
334
|
+
fr: "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
335
|
+
es: "Edita src/app.tsx y guarda para probar HMR",
|
|
336
|
+
id: "Edit src/app.tsx dan simpan untuk menguji HMR",
|
|
337
|
+
}),
|
|
338
|
+
|
|
339
|
+
readTheDocs: t({
|
|
340
|
+
en: "Click on the Vite and Preact logos to learn more",
|
|
341
|
+
fr: "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
342
|
+
es: "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
343
|
+
id: "Klik pada logo Vite dan Preact untuk mempelajari lebih lanjut",
|
|
344
|
+
}),
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
module.exports = appContent;
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
```json fileName="src/app.content.json" contentDeclarationFormat="json"
|
|
352
|
+
{
|
|
353
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
354
|
+
"key": "app",
|
|
355
|
+
"content": {
|
|
356
|
+
"viteLogo": {
|
|
357
|
+
"nodeType": "translation",
|
|
358
|
+
"translation": {
|
|
359
|
+
"en": "Vite logo",
|
|
360
|
+
"fr": "Logo Vite",
|
|
361
|
+
"es": "Logo Vite",
|
|
362
|
+
"id": "Logo Vite"
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
"preactLogo": {
|
|
366
|
+
"nodeType": "translation",
|
|
367
|
+
"translation": {
|
|
368
|
+
"en": "Preact logo",
|
|
369
|
+
"fr": "Logo Preact",
|
|
370
|
+
"es": "Logo Preact",
|
|
371
|
+
"id": "Logo Preact"
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
"title": {
|
|
375
|
+
"nodeType": "translation",
|
|
376
|
+
"translation": {
|
|
377
|
+
"en": "Vite + Preact",
|
|
378
|
+
"fr": "Vite + Preact",
|
|
379
|
+
"es": "Vite + Preact",
|
|
380
|
+
"id": "Vite + Preact"
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
"count": {
|
|
384
|
+
"nodeType": "translation",
|
|
385
|
+
"translation": {
|
|
386
|
+
"en": "count is ",
|
|
387
|
+
"fr": "le compte est ",
|
|
388
|
+
"es": "el recuento es ",
|
|
389
|
+
"id": "jumlah adalah "
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
"edit": {
|
|
393
|
+
"nodeType": "translation",
|
|
394
|
+
"translation": {
|
|
395
|
+
"en": "Edit src/app.tsx and save to test HMR",
|
|
396
|
+
"fr": "Éditez src/app.tsx et enregistrez pour tester HMR",
|
|
397
|
+
"es": "Edita src/app.tsx y guarda para probar HMR",
|
|
398
|
+
"id": "Edit src/app.tsx dan simpan untuk menguji HMR"
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
"readTheDocs": {
|
|
402
|
+
"nodeType": "translation",
|
|
403
|
+
"translation": {
|
|
404
|
+
"en": "Click on the Vite and Preact logos to learn more",
|
|
405
|
+
"fr": "Cliquez sur les logos Vite et Preact pour en savoir plus",
|
|
406
|
+
"es": "Haga clic en los logotipos de Vite y Preact para obtener más información",
|
|
407
|
+
"id": "Klik pada logo Vite dan Preact untuk mempelajari lebih lanjut"
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
> 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}`).
|
|
415
|
+
|
|
416
|
+
> Untuk detail lebih lanjut, lihat [dokumentasi deklarasi konten](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/content_file.md).
|
|
417
|
+
|
|
418
|
+
> Jika file konten Anda menyertakan kode TSX, Anda mungkin perlu mengimpor `import { h } from "preact";` atau memastikan pragma JSX Anda sudah diatur dengan benar untuk Preact.
|
|
419
|
+
|
|
420
|
+
### Langkah 5: Gunakan Intlayer dalam Kode Anda
|
|
421
|
+
|
|
422
|
+
Akses kamus konten Anda di seluruh aplikasi:
|
|
423
|
+
|
|
424
|
+
```tsx {6,10} fileName="src/app.tsx" codeFormat="typescript"
|
|
425
|
+
import { useState } from "preact/hooks";
|
|
426
|
+
import type { FunctionalComponent } from "preact";
|
|
427
|
+
import preactLogo from "./assets/preact.svg"; // Mengasumsikan Anda memiliki preact.svg
|
|
428
|
+
import viteLogo from "/vite.svg";
|
|
429
|
+
import "./app.css"; // Mengasumsikan file CSS Anda bernama app.css
|
|
430
|
+
import { IntlayerProvider, useIntlayer } from "preact-intlayer";
|
|
431
|
+
|
|
432
|
+
const AppContent: FunctionalComponent = () => {
|
|
433
|
+
const [count, setCount] = useState(0);
|
|
434
|
+
const content = useIntlayer("app");
|
|
435
|
+
|
|
436
|
+
return (
|
|
437
|
+
<>
|
|
438
|
+
<div>
|
|
439
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
440
|
+
<img src={viteLogo} class="logo" alt={content.viteLogo.value} />
|
|
441
|
+
</a>
|
|
442
|
+
<a href="https://preactjs.com" target="_blank">
|
|
443
|
+
<img
|
|
444
|
+
src={preactLogo}
|
|
445
|
+
class="logo preact"
|
|
446
|
+
alt={content.preactLogo.value}
|
|
447
|
+
/>
|
|
448
|
+
</a>
|
|
449
|
+
</div>
|
|
450
|
+
<h1>{content.title}</h1>
|
|
451
|
+
<div class="card">
|
|
452
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
453
|
+
{content.count}
|
|
454
|
+
{count}
|
|
455
|
+
</button>
|
|
456
|
+
<p>{content.edit}</p>
|
|
457
|
+
</div>
|
|
458
|
+
<p class="read-the-docs">{content.readTheDocs}</p>
|
|
459
|
+
</>
|
|
460
|
+
);
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
const App: FunctionalComponent = () => (
|
|
464
|
+
<IntlayerProvider>
|
|
465
|
+
<AppContent />
|
|
466
|
+
</IntlayerProvider>
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
export default App;
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
```jsx {5,9} fileName="src/app.jsx" codeFormat="esm"
|
|
473
|
+
import { useState } from "preact/hooks";
|
|
474
|
+
import preactLogo from "./assets/preact.svg";
|
|
475
|
+
import viteLogo from "/vite.svg";
|
|
476
|
+
import "./app.css";
|
|
477
|
+
import { IntlayerProvider, useIntlayer } from "preact-intlayer";
|
|
478
|
+
|
|
479
|
+
const AppContent = () => {
|
|
480
|
+
const [count, setCount] = useState(0);
|
|
481
|
+
const content = useIntlayer("app");
|
|
482
|
+
|
|
483
|
+
return (
|
|
484
|
+
<>
|
|
485
|
+
<div>
|
|
486
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
487
|
+
<img src={viteLogo} class="logo" alt={content.viteLogo.value} />
|
|
488
|
+
</a>
|
|
489
|
+
<a href="https://preactjs.com" target="_blank">
|
|
490
|
+
<img
|
|
491
|
+
src={preactLogo}
|
|
492
|
+
class="logo preact"
|
|
493
|
+
alt={content.preactLogo.value}
|
|
494
|
+
/>
|
|
495
|
+
</a>
|
|
496
|
+
</div>
|
|
497
|
+
<h1>{content.title}</h1>
|
|
498
|
+
<div class="card">
|
|
499
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
500
|
+
{content.count}
|
|
501
|
+
{count}
|
|
502
|
+
</button>
|
|
503
|
+
<p>{content.edit}</p>
|
|
504
|
+
</div>
|
|
505
|
+
<p class="read-the-docs">{content.readTheDocs}</p>
|
|
506
|
+
</>
|
|
507
|
+
);
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
const App = () => (
|
|
511
|
+
<IntlayerProvider>
|
|
512
|
+
<AppContent />
|
|
513
|
+
</IntlayerProvider>
|
|
514
|
+
);
|
|
515
|
+
|
|
516
|
+
export default App;
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
```jsx {5,9} fileName="src/app.cjsx" codeFormat="commonjs"
|
|
520
|
+
const { useState } = require("preact/hooks");
|
|
521
|
+
const preactLogo = require("./assets/preact.svg");
|
|
522
|
+
const viteLogo = require("/vite.svg");
|
|
523
|
+
require("./app.css");
|
|
524
|
+
const { IntlayerProvider, useIntlayer } = require("preact-intlayer");
|
|
525
|
+
|
|
526
|
+
const AppContent = () => {
|
|
527
|
+
const [count, setCount] = useState(0);
|
|
528
|
+
const content = useIntlayer("app");
|
|
529
|
+
|
|
530
|
+
return (
|
|
531
|
+
<>
|
|
532
|
+
<div>
|
|
533
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
534
|
+
<img src={viteLogo} class="logo" alt={content.viteLogo.value} />
|
|
535
|
+
</a>
|
|
536
|
+
<a href="https://preactjs.com" target="_blank">
|
|
537
|
+
<img
|
|
538
|
+
src={preactLogo}
|
|
539
|
+
class="logo preact"
|
|
540
|
+
alt={content.preactLogo.value}
|
|
541
|
+
/>
|
|
542
|
+
</a>
|
|
543
|
+
</div>
|
|
544
|
+
<h1>{content.title}</h1>
|
|
545
|
+
<div class="card">
|
|
546
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
547
|
+
{content.count}
|
|
548
|
+
{count}
|
|
549
|
+
</button>
|
|
550
|
+
<p>{content.edit}</p>
|
|
551
|
+
</div>
|
|
552
|
+
<p class="read-the-docs">{content.readTheDocs}</p>
|
|
553
|
+
</>
|
|
554
|
+
);
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
const App = () => (
|
|
558
|
+
<IntlayerProvider>
|
|
559
|
+
<AppContent />
|
|
560
|
+
</IntlayerProvider>
|
|
561
|
+
);
|
|
562
|
+
|
|
563
|
+
module.exports = App;
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
> Jika Anda ingin menggunakan konten Anda dalam atribut `string`, seperti `alt`, `title`, `href`, `aria-label`, dll., Anda harus memanggil nilai fungsi tersebut, seperti:
|
|
567
|
+
|
|
568
|
+
> ```jsx
|
|
569
|
+
> <img src={content.image.src.value} alt={content.image.value} />
|
|
570
|
+
> ```
|
|
571
|
+
|
|
572
|
+
> Catatan: Dalam Preact, `className` biasanya ditulis sebagai `class`.
|
|
573
|
+
|
|
574
|
+
> Untuk mempelajari lebih lanjut tentang hook `useIntlayer`, lihat [dokumentasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/react-intlayer/useIntlayer.md) (API-nya serupa untuk `preact-intlayer`).
|
|
575
|
+
|
|
576
|
+
### (Opsional) Langkah 6: Ubah bahasa konten Anda
|
|
577
|
+
|
|
578
|
+
Untuk mengubah bahasa konten Anda, Anda dapat menggunakan fungsi `setLocale` yang disediakan oleh hook `useLocale`. Fungsi ini memungkinkan Anda untuk mengatur locale aplikasi dan memperbarui konten sesuai dengan locale yang dipilih.
|
|
579
|
+
|
|
580
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
581
|
+
import type { FunctionalComponent } from "preact";
|
|
582
|
+
import { Locales } from "intlayer";
|
|
583
|
+
import { useLocale } from "preact-intlayer";
|
|
584
|
+
|
|
585
|
+
const LocaleSwitcher: FunctionalComponent = () => {
|
|
586
|
+
const { setLocale } = useLocale();
|
|
587
|
+
|
|
588
|
+
return (
|
|
589
|
+
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
590
|
+
Ubah Bahasa ke Bahasa Inggris
|
|
591
|
+
</button>
|
|
592
|
+
);
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
export default LocaleSwitcher;
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
```jsx fileName="src/components/LocaleSwitcher.jsx" codeFormat="esm"
|
|
599
|
+
import { Locales } from "intlayer";
|
|
600
|
+
import { useLocale } from "preact-intlayer";
|
|
601
|
+
|
|
602
|
+
const LocaleSwitcher = () => {
|
|
603
|
+
const { setLocale } = useLocale();
|
|
604
|
+
|
|
605
|
+
return (
|
|
606
|
+
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
607
|
+
Ubah Bahasa ke Bahasa Inggris
|
|
608
|
+
</button>
|
|
609
|
+
);
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
export default LocaleSwitcher;
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
```jsx fileName="src/components/LocaleSwitcher.cjsx" codeFormat="commonjs"
|
|
616
|
+
const { Locales } = require("intlayer");
|
|
617
|
+
const { useLocale } = require("preact-intlayer");
|
|
618
|
+
|
|
619
|
+
const LocaleSwitcher = () => {
|
|
620
|
+
const { setLocale } = useLocale();
|
|
621
|
+
|
|
622
|
+
return (
|
|
623
|
+
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
624
|
+
Ubah Bahasa ke Bahasa Inggris
|
|
625
|
+
</button>
|
|
626
|
+
);
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
module.exports = LocaleSwitcher;
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
> Untuk mempelajari lebih lanjut tentang hook `useLocale`, lihat [dokumentasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/react-intlayer/useLocale.md) (API serupa untuk `preact-intlayer`).
|
|
633
|
+
|
|
634
|
+
### (Opsional) Langkah 7: Tambahkan Routing yang Dilokalkan ke aplikasi Anda
|
|
635
|
+
|
|
636
|
+
Tujuan dari langkah ini adalah untuk membuat rute unik untuk setiap bahasa. Ini berguna untuk SEO dan URL yang ramah SEO.
|
|
637
|
+
Contoh:
|
|
638
|
+
|
|
639
|
+
```plaintext
|
|
640
|
+
- https://example.com/about
|
|
641
|
+
- https://example.com/es/about
|
|
642
|
+
- https://example.com/fr/about
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
> Secara default, rute tidak diberi awalan untuk locale default (`routing.mode: "prefix-no-default"`). Jika Anda ingin memberi awalan pada locale default, Anda dapat mengatur opsi `routing.mode` ke `"prefix-all"` dalam konfigurasi Anda. Lihat [dokumentasi konfigurasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/configuration.md) untuk informasi lebih lanjut.
|
|
646
|
+
|
|
647
|
+
Untuk menambahkan routing yang dilokalkan ke aplikasi Anda, Anda dapat membuat komponen `LocaleRouter` yang membungkus rute aplikasi Anda dan menangani routing berbasis locale. Berikut adalah contoh menggunakan [preact-iso](https://github.com/preactjs/preact-iso):
|
|
648
|
+
|
|
649
|
+
Pertama, instal `preact-iso`:
|
|
650
|
+
|
|
651
|
+
```bash packageManager="npm"
|
|
652
|
+
npm install preact-iso
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
```bash packageManager="pnpm"
|
|
656
|
+
pnpm add preact-iso
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
```bash packageManager="yarn"
|
|
660
|
+
yarn add preact-iso
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
|
|
664
|
+
import { configuration, getPathWithoutLocale, type Locale } from "intlayer";
|
|
665
|
+
import type { ComponentChildren, FunctionalComponent } from "preact";
|
|
666
|
+
import { useEffect } from "preact/hooks";
|
|
667
|
+
import { IntlayerProvider } from "preact-intlayer";
|
|
668
|
+
import { LocationProvider, useLocation } from "preact-iso";
|
|
669
|
+
|
|
670
|
+
const { internationalization, routing } = configuration;
|
|
671
|
+
const { locales, defaultLocale } = internationalization;
|
|
672
|
+
|
|
673
|
+
const Navigate: FunctionalComponent<{ to: string; replace?: boolean }> = ({
|
|
674
|
+
to,
|
|
675
|
+
replace,
|
|
676
|
+
}) => {
|
|
677
|
+
const { route } = useLocation();
|
|
678
|
+
useEffect(() => {
|
|
679
|
+
route(to, replace);
|
|
680
|
+
}, [to, replace, route]);
|
|
681
|
+
return null;
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
/**
|
|
686
|
+
* Sebuah komponen yang menangani lokalisasi dan membungkus children dengan konteks locale yang sesuai.
|
|
687
|
+
* Komponen ini mengelola deteksi dan validasi locale berbasis URL.
|
|
688
|
+
*/
|
|
689
|
+
const AppLocalized: FunctionalComponent<{
|
|
690
|
+
children: ComponentChildren;
|
|
691
|
+
locale?: Locale;
|
|
692
|
+
}> = ({ children, locale }) => {
|
|
693
|
+
const { path: pathname, url } = useLocation();
|
|
694
|
+
|
|
695
|
+
if (!url) {
|
|
696
|
+
return null;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
const search = url.substring(pathname.length);
|
|
700
|
+
|
|
701
|
+
// Menentukan locale saat ini, menggunakan default jika tidak disediakan
|
|
702
|
+
const currentLocale = locale ?? defaultLocale;
|
|
703
|
+
|
|
704
|
+
// Menghapus prefix locale dari path untuk membangun path dasar
|
|
705
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
706
|
+
pathname // Path URL saat ini
|
|
707
|
+
);
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Jika routing.mode adalah 'prefix-all', locale default harus selalu diberi prefix.
|
|
711
|
+
*/
|
|
712
|
+
if (routing.mode === "prefix-all") {
|
|
713
|
+
// Validasi locale
|
|
714
|
+
if (!locale || !locales.includes(locale)) {
|
|
715
|
+
// Redirect ke locale default dengan path yang diperbarui
|
|
716
|
+
return (
|
|
717
|
+
<Navigate
|
|
718
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
719
|
+
replace // Ganti entri history saat ini dengan yang baru
|
|
720
|
+
/>
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// Bungkus children dengan IntlayerProvider dan set locale saat ini
|
|
725
|
+
return (
|
|
726
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
727
|
+
);
|
|
728
|
+
} else {
|
|
729
|
+
/**
|
|
730
|
+
* Ketika routing.mode bukan 'prefix-all', locale default tidak diberi prefix.
|
|
731
|
+
* Pastikan locale saat ini valid dan bukan locale default.
|
|
732
|
+
*/
|
|
733
|
+
if (
|
|
734
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
735
|
+
!locales
|
|
736
|
+
.filter(
|
|
737
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Kecualikan locale default
|
|
738
|
+
)
|
|
739
|
+
.includes(currentLocale) // Periksa apakah locale saat ini ada dalam daftar locale yang valid
|
|
740
|
+
) {
|
|
741
|
+
// Redirect ke path tanpa prefix locale
|
|
742
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
// Bungkus children dengan IntlayerProvider dan set locale saat ini
|
|
746
|
+
return (
|
|
747
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
748
|
+
);
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
const RouterContent: FunctionalComponent<{
|
|
753
|
+
children: ComponentChildren;
|
|
754
|
+
}> = ({ children }) => {
|
|
755
|
+
const { path } = useLocation();
|
|
756
|
+
|
|
757
|
+
if (!path) {
|
|
758
|
+
return null;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
const pathLocale = path.split("/")[1] as Locale;
|
|
762
|
+
|
|
763
|
+
const isLocaleRoute = locales
|
|
764
|
+
.filter(
|
|
765
|
+
(locale) => routing.mode === "prefix-all" || locale !== defaultLocale
|
|
766
|
+
)
|
|
767
|
+
.some((locale) => locale.toString() === pathLocale);
|
|
768
|
+
|
|
769
|
+
if (isLocaleRoute) {
|
|
770
|
+
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
return (
|
|
774
|
+
<AppLocalized
|
|
775
|
+
locale={routing.mode !== "prefix-all" ? defaultLocale : undefined}
|
|
776
|
+
>
|
|
777
|
+
{children}
|
|
778
|
+
</AppLocalized>
|
|
779
|
+
);
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* Komponen router yang mengatur rute spesifik locale.
|
|
784
|
+
* Menggunakan preact-iso untuk mengelola navigasi dan merender komponen yang dilokalkan.
|
|
785
|
+
*/
|
|
786
|
+
export const LocaleRouter: FunctionalComponent<{
|
|
787
|
+
children: ComponentChildren;
|
|
788
|
+
}> = ({ children }) => (
|
|
789
|
+
<LocationProvider>
|
|
790
|
+
<RouterContent>{children}</RouterContent>
|
|
791
|
+
</LocationProvider>
|
|
792
|
+
);
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
```jsx fileName="src/components/LocaleRouter.jsx" codeFormat="esm"
|
|
796
|
+
// Mengimpor dependensi dan fungsi yang diperlukan
|
|
797
|
+
import { configuration, getPathWithoutLocale } from "intlayer";
|
|
798
|
+
import { IntlayerProvider } from "preact-intlayer";
|
|
799
|
+
import { LocationProvider, useLocation } from "preact-iso";
|
|
800
|
+
import { useEffect } from "preact/hooks";
|
|
801
|
+
import { h } from "preact"; // Diperlukan untuk JSX
|
|
802
|
+
|
|
803
|
+
// Mendestruktur konfigurasi dari Intlayer
|
|
804
|
+
const { internationalization, routing } = configuration;
|
|
805
|
+
const { locales, defaultLocale } = internationalization;
|
|
806
|
+
|
|
807
|
+
const Navigate = ({ to, replace }) => {
|
|
808
|
+
const { route } = useLocation();
|
|
809
|
+
useEffect(() => {
|
|
810
|
+
route(to, replace);
|
|
811
|
+
}, [to, replace, route]);
|
|
812
|
+
return null;
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
/**
|
|
817
|
+
* Komponen yang menangani lokalisasi dan membungkus children dengan konteks locale yang sesuai.
|
|
818
|
+
* Komponen ini mengelola deteksi dan validasi locale berdasarkan URL.
|
|
819
|
+
*/
|
|
820
|
+
const AppLocalized = ({ children, locale }) => {
|
|
821
|
+
const { path: pathname, url } = useLocation();
|
|
822
|
+
|
|
823
|
+
if (!url) {
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
const search = url.substring(pathname.length);
|
|
828
|
+
|
|
829
|
+
// Menentukan locale saat ini, menggunakan default jika tidak disediakan
|
|
830
|
+
const currentLocale = locale ?? defaultLocale;
|
|
831
|
+
|
|
832
|
+
// Menghapus prefix locale dari path untuk membentuk path dasar
|
|
833
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
834
|
+
pathname // Path URL saat ini
|
|
835
|
+
);
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* Jika routing.mode adalah 'prefix-all', locale default harus selalu diprefix.
|
|
839
|
+
*/
|
|
840
|
+
if (routing.mode === "prefix-all") {
|
|
841
|
+
// Validasi locale
|
|
842
|
+
if (!locale || !locales.includes(locale)) {
|
|
843
|
+
// Alihkan ke locale default dengan path yang diperbarui
|
|
844
|
+
return (
|
|
845
|
+
<Navigate
|
|
846
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
847
|
+
replace // Gantikan entri riwayat saat ini dengan yang baru
|
|
848
|
+
/>
|
|
849
|
+
);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
// Bungkus children dengan IntlayerProvider dan set locale saat ini
|
|
853
|
+
return (
|
|
854
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
855
|
+
);
|
|
856
|
+
} else {
|
|
857
|
+
/**
|
|
858
|
+
* Ketika routing.mode bukan 'prefix-all', locale default tidak diberi prefix.
|
|
859
|
+
* Pastikan locale saat ini valid dan bukan locale default.
|
|
860
|
+
*/
|
|
861
|
+
if (
|
|
862
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
863
|
+
!locales
|
|
864
|
+
.filter(
|
|
865
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Kecualikan locale default
|
|
866
|
+
)
|
|
867
|
+
.includes(currentLocale) // Periksa apakah locale saat ini ada dalam daftar locale yang valid
|
|
868
|
+
) {
|
|
869
|
+
// Redirect ke path tanpa prefix locale
|
|
870
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
// Bungkus children dengan IntlayerProvider dan set locale saat ini
|
|
874
|
+
return (
|
|
875
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
876
|
+
);
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
|
|
880
|
+
const RouterContent = ({ children }) => {
|
|
881
|
+
const { path } = useLocation();
|
|
882
|
+
|
|
883
|
+
if (!path) {
|
|
884
|
+
return null;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
const pathLocale = path.split("/")[1];
|
|
888
|
+
|
|
889
|
+
const isLocaleRoute = locales
|
|
890
|
+
.filter(
|
|
891
|
+
(locale) => routing.mode === "prefix-all" || locale !== defaultLocale
|
|
892
|
+
)
|
|
893
|
+
.some((locale) => locale.toString() === pathLocale);
|
|
894
|
+
|
|
895
|
+
if (isLocaleRoute) {
|
|
896
|
+
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
return (
|
|
900
|
+
<AppLocalized
|
|
901
|
+
locale={routing.mode !== "prefix-all" ? defaultLocale : undefined}
|
|
902
|
+
>
|
|
903
|
+
{children}
|
|
904
|
+
</AppLocalized>
|
|
905
|
+
);
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* Komponen router yang mengatur rute spesifik locale.
|
|
910
|
+
* Menggunakan preact-iso untuk mengelola navigasi dan merender komponen yang dilokalkan.
|
|
911
|
+
*/
|
|
912
|
+
export const LocaleRouter = ({ children }) => (
|
|
913
|
+
<LocationProvider>
|
|
914
|
+
<RouterContent>{children}</RouterContent>
|
|
915
|
+
</LocationProvider>
|
|
916
|
+
);
|
|
917
|
+
```
|
|
918
|
+
|
|
919
|
+
```jsx fileName="src/components/LocaleRouter.cjsx" codeFormat="commonjs"
|
|
920
|
+
// Mengimpor dependensi dan fungsi yang diperlukan
|
|
921
|
+
const { configuration, getPathWithoutLocale } = require("intlayer");
|
|
922
|
+
const { IntlayerProvider } = require("preact-intlayer");
|
|
923
|
+
const { LocationProvider, useLocation } = require("preact-iso");
|
|
924
|
+
const { useEffect } = require("preact/hooks");
|
|
925
|
+
const { h } = require("preact"); // Diperlukan untuk JSX
|
|
926
|
+
|
|
927
|
+
// Mendestrukturisasi konfigurasi dari Intlayer
|
|
928
|
+
const { internationalization, routing } = configuration;
|
|
929
|
+
const { locales, defaultLocale } = internationalization;
|
|
930
|
+
|
|
931
|
+
const Navigate = ({ to, replace }) => {
|
|
932
|
+
const { route } = useLocation();
|
|
933
|
+
useEffect(() => {
|
|
934
|
+
route(to, replace);
|
|
935
|
+
}, [to, replace, route]);
|
|
936
|
+
return null;
|
|
937
|
+
};
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* Komponen yang menangani lokalisasi dan membungkus children dengan konteks locale yang sesuai.
|
|
941
|
+
* Komponen ini mengelola deteksi dan validasi locale berbasis URL.
|
|
942
|
+
*/
|
|
943
|
+
const AppLocalized = ({ children, locale }) => {
|
|
944
|
+
const { path: pathname, url } = useLocation();
|
|
945
|
+
|
|
946
|
+
if (!url) {
|
|
947
|
+
return null;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
const search = url.substring(pathname.length);
|
|
951
|
+
|
|
952
|
+
// Tentukan locale saat ini, kembali ke default jika tidak disediakan
|
|
953
|
+
const currentLocale = locale ?? defaultLocale;
|
|
954
|
+
|
|
955
|
+
// Hapus prefix locale dari path untuk membangun path dasar
|
|
956
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
957
|
+
pathname // Path URL saat ini
|
|
958
|
+
);
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* Jika routing.mode adalah 'prefix-all', locale default harus selalu diprefix.
|
|
962
|
+
*/
|
|
963
|
+
if (routing.mode === "prefix-all") {
|
|
964
|
+
// Validasi locale
|
|
965
|
+
if (!locale || !locales.includes(locale)) {
|
|
966
|
+
// Redirect ke locale default dengan path yang diperbarui
|
|
967
|
+
return (
|
|
968
|
+
<Navigate
|
|
969
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
970
|
+
replace // Gantikan entri history saat ini dengan yang baru
|
|
971
|
+
/>
|
|
972
|
+
);
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
// Bungkus children dengan IntlayerProvider dan set locale saat ini
|
|
976
|
+
return (
|
|
977
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
978
|
+
);
|
|
979
|
+
} else {
|
|
980
|
+
/**
|
|
981
|
+
* Ketika routing.mode bukan 'prefix-all', locale default tidak diberi prefix.
|
|
982
|
+
* Pastikan locale saat ini valid dan bukan locale default.
|
|
983
|
+
*/
|
|
984
|
+
if (
|
|
985
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
986
|
+
!locales
|
|
987
|
+
.filter(
|
|
988
|
+
(loc) => loc.toString() !== defaultLocale.toString() // Kecualikan locale default
|
|
989
|
+
)
|
|
990
|
+
.includes(currentLocale) // Periksa apakah locale saat ini ada dalam daftar locale yang valid
|
|
991
|
+
) {
|
|
992
|
+
// Redirect ke path tanpa prefix locale
|
|
993
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
// Bungkus children dengan IntlayerProvider dan set locale saat ini
|
|
997
|
+
return (
|
|
998
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
const RouterContent = ({ children }) => {
|
|
1004
|
+
const { path } = useLocation();
|
|
1005
|
+
|
|
1006
|
+
if (!path) {
|
|
1007
|
+
return null;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
const pathLocale = path.split("/")[1];
|
|
1011
|
+
|
|
1012
|
+
const isLocaleRoute = locales
|
|
1013
|
+
.filter(
|
|
1014
|
+
(locale) => routing.mode === "prefix-all" || locale !== defaultLocale
|
|
1015
|
+
)
|
|
1016
|
+
.some((locale) => locale.toString() === pathLocale);
|
|
1017
|
+
|
|
1018
|
+
if (isLocaleRoute) {
|
|
1019
|
+
return <AppLocalized locale={pathLocale}>{children}</AppLocalized>;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
return (
|
|
1023
|
+
<AppLocalized
|
|
1024
|
+
locale={routing.mode !== "prefix-all" ? defaultLocale : undefined}
|
|
1025
|
+
>
|
|
1026
|
+
{children}
|
|
1027
|
+
</AppLocalized>
|
|
1028
|
+
);
|
|
1029
|
+
};
|
|
1030
|
+
|
|
1031
|
+
/**
|
|
1032
|
+
* Komponen router yang mengatur rute spesifik locale.
|
|
1033
|
+
* Menggunakan preact-iso untuk mengelola navigasi dan merender komponen yang dilokalkan.
|
|
1034
|
+
*/
|
|
1035
|
+
const LocaleRouter = ({ children }) => (
|
|
1036
|
+
<LocationProvider>
|
|
1037
|
+
<RouterContent>{children}</RouterContent>
|
|
1038
|
+
</LocationProvider>
|
|
1039
|
+
);
|
|
1040
|
+
|
|
1041
|
+
module.exports = { LocaleRouter };
|
|
1042
|
+
```
|
|
1043
|
+
|
|
1044
|
+
Kemudian, Anda dapat menggunakan komponen `LocaleRouter` dalam aplikasi Anda:
|
|
1045
|
+
|
|
1046
|
+
```tsx fileName="src/app.tsx" codeFormat="typescript"
|
|
1047
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
1048
|
+
import type { FunctionalComponent } from "preact";
|
|
1049
|
+
// ... Komponen AppContent Anda (didefinisikan di Langkah 5)
|
|
1050
|
+
|
|
1051
|
+
const App: FunctionalComponent = () => (
|
|
1052
|
+
<LocaleRouter>
|
|
1053
|
+
<AppContent />
|
|
1054
|
+
</LocaleRouter>
|
|
1055
|
+
);
|
|
1056
|
+
|
|
1057
|
+
export default App;
|
|
1058
|
+
```
|
|
1059
|
+
|
|
1060
|
+
```jsx fileName="src/app.jsx" codeFormat="esm"
|
|
1061
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
1062
|
+
// ... Komponen AppContent Anda (didefinisikan di Langkah 5)
|
|
1063
|
+
|
|
1064
|
+
const App = () => (
|
|
1065
|
+
<LocaleRouter>
|
|
1066
|
+
<AppContent />
|
|
1067
|
+
</LocaleRouter>
|
|
1068
|
+
);
|
|
1069
|
+
|
|
1070
|
+
export default App;
|
|
1071
|
+
```
|
|
1072
|
+
|
|
1073
|
+
```jsx fileName="src/app.cjsx" codeFormat="commonjs"
|
|
1074
|
+
const { LocaleRouter } = require("./components/LocaleRouter");
|
|
1075
|
+
// ... Komponen AppContent Anda (didefinisikan di Langkah 5)
|
|
1076
|
+
|
|
1077
|
+
const App = () => (
|
|
1078
|
+
<LocaleRouter>
|
|
1079
|
+
<AppContent />
|
|
1080
|
+
</LocaleRouter>
|
|
1081
|
+
);
|
|
1082
|
+
|
|
1083
|
+
module.exports = App;
|
|
1084
|
+
```
|
|
1085
|
+
|
|
1086
|
+
Secara paralel, Anda juga dapat menggunakan `intlayerMiddleware` untuk menambahkan routing sisi server ke aplikasi Anda. Plugin ini akan secara otomatis mendeteksi locale saat ini berdasarkan URL dan mengatur cookie locale yang sesuai. Jika tidak ada locale yang ditentukan, plugin akan menentukan locale yang paling tepat berdasarkan preferensi bahasa browser pengguna. Jika tidak ada locale yang terdeteksi, maka akan mengarahkan ulang ke locale default.
|
|
1087
|
+
|
|
1088
|
+
> Perlu diperhatikan bahwa untuk menggunakan `intlayerMiddleware` dalam produksi, Anda perlu memindahkan paket `vite-intlayer` dari `devDependencies` ke `dependencies`.
|
|
1089
|
+
|
|
1090
|
+
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
1091
|
+
import { defineConfig } from "vite";
|
|
1092
|
+
import preact from "@preact/preset-vite";
|
|
1093
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
1094
|
+
|
|
1095
|
+
// https://vitejs.dev/config/
|
|
1096
|
+
export default defineConfig({
|
|
1097
|
+
plugins: [preact(), intlayer(), intlayerMiddleware()],
|
|
1098
|
+
});
|
|
1099
|
+
```
|
|
1100
|
+
|
|
1101
|
+
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
1102
|
+
import { defineConfig } from "vite";
|
|
1103
|
+
import preact from "@preact/preset-vite";
|
|
1104
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
1105
|
+
|
|
1106
|
+
// https://vitejs.dev/config/
|
|
1107
|
+
export default defineConfig({
|
|
1108
|
+
plugins: [preact(), intlayer(), intlayerMiddleware()],
|
|
1109
|
+
});
|
|
1110
|
+
```
|
|
1111
|
+
|
|
1112
|
+
```javascript {3,7} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
1113
|
+
const { defineConfig } = require("vite");
|
|
1114
|
+
const preact = require("@preact/preset-vite");
|
|
1115
|
+
const { intlayer, intlayerMiddleware } = require("vite-intlayer");
|
|
1116
|
+
|
|
1117
|
+
// https://vitejs.dev/config/
|
|
1118
|
+
module.exports = defineConfig({
|
|
1119
|
+
plugins: [preact(), intlayer(), intlayerMiddleware()],
|
|
1120
|
+
});
|
|
1121
|
+
```
|
|
1122
|
+
|
|
1123
|
+
### (Opsional) Langkah 8: Ubah URL saat locale berubah
|
|
1124
|
+
|
|
1125
|
+
Untuk mengubah URL saat locale berubah, Anda dapat menggunakan properti `onLocaleChange` yang disediakan oleh hook `useLocale`. Secara paralel, Anda dapat menggunakan `useLocation` dan `route` dari `preact-iso` untuk memperbarui path URL.
|
|
1126
|
+
|
|
1127
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
1128
|
+
import { useLocation, route } from "preact-iso";
|
|
1129
|
+
import {
|
|
1130
|
+
Locales,
|
|
1131
|
+
getHTMLTextDir,
|
|
1132
|
+
getLocaleName,
|
|
1133
|
+
getLocalizedUrl,
|
|
1134
|
+
} from "intlayer";
|
|
1135
|
+
import { useLocale } from "preact-intlayer";
|
|
1136
|
+
import type { FunctionalComponent } from "preact";
|
|
1137
|
+
|
|
1138
|
+
const LocaleSwitcher: FunctionalComponent = () => {
|
|
1139
|
+
const location = useLocation();
|
|
1140
|
+
plugins: [preact(), intlayer(), intlayerMiddleware()],
|
|
1141
|
+
});
|
|
1142
|
+
```
|
|
1143
|
+
|
|
1144
|
+
### (Optional) Step 8: Change the URL when the locale changes
|
|
1145
|
+
|
|
1146
|
+
To change the URL when the locale changes, you can use the `onLocaleChange` prop provided by the `useLocale` hook. In parallel, you can use `useLocation` and `route` from `preact-iso` to update the URL path.
|
|
1147
|
+
|
|
1148
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
1149
|
+
import { useLocation, route } from "preact-iso";
|
|
1150
|
+
import {
|
|
1151
|
+
Locales,
|
|
1152
|
+
getHTMLTextDir,
|
|
1153
|
+
getLocaleName,
|
|
1154
|
+
getLocalizedUrl,
|
|
1155
|
+
} from "intlayer";
|
|
1156
|
+
import { useLocale } from "preact-intlayer";
|
|
1157
|
+
import type { FunctionalComponent } from "preact";
|
|
1158
|
+
|
|
1159
|
+
const LocaleSwitcher: FunctionalComponent = () => {
|
|
1160
|
+
const location = useLocation();
|
|
1161
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1162
|
+
onLocaleChange: (newLocale) => {
|
|
1163
|
+
const currentFullPath = location.url; // preact-iso menyediakan URL lengkap
|
|
1164
|
+
// Membangun URL dengan locale yang diperbarui
|
|
1165
|
+
// Contoh: /es/about?foo=bar
|
|
1166
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1167
|
+
|
|
1168
|
+
// Memperbarui jalur URL
|
|
1169
|
+
route(pathWithLocale, true); // true untuk mengganti
|
|
1170
|
+
},
|
|
1171
|
+
});
|
|
1172
|
+
|
|
1173
|
+
return (
|
|
1174
|
+
<div>
|
|
1175
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1176
|
+
<div id="localePopover" popover="auto">
|
|
1177
|
+
{availableLocales.map((localeItem) => (
|
|
1178
|
+
<a
|
|
1179
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1180
|
+
hreflang={localeItem}
|
|
1181
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1182
|
+
onClick={(e) => {
|
|
1183
|
+
e.preventDefault();
|
|
1184
|
+
setLocale(localeItem);
|
|
1185
|
+
// Navigasi programatik setelah pengaturan locale akan ditangani oleh onLocaleChange
|
|
1186
|
+
}}
|
|
1187
|
+
key={localeItem}
|
|
1188
|
+
>
|
|
1189
|
+
<span>
|
|
1190
|
+
{/* Locale - misalnya FR */}
|
|
1191
|
+
{localeItem}
|
|
1192
|
+
</span>
|
|
1193
|
+
<span>
|
|
1194
|
+
{/* Bahasa dalam Locale-nya sendiri - misalnya Français */}
|
|
1195
|
+
{getLocaleName(localeItem, localeItem)}
|
|
1196
|
+
</span>
|
|
1197
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1198
|
+
{/* Bahasa dalam Locale saat ini - misalnya Francés dengan locale saat ini disetel ke Locales.SPANISH */}
|
|
1199
|
+
{getLocaleName(localeItem, locale)}
|
|
1200
|
+
</span>
|
|
1201
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1202
|
+
{/* Bahasa dalam Bahasa Inggris - misalnya French */}
|
|
1203
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1204
|
+
</span>
|
|
1205
|
+
</a>
|
|
1206
|
+
))}
|
|
1207
|
+
</div>
|
|
1208
|
+
</div>
|
|
1209
|
+
);
|
|
1210
|
+
};
|
|
1211
|
+
|
|
1212
|
+
export default LocaleSwitcher;
|
|
1213
|
+
```
|
|
1214
|
+
|
|
1215
|
+
```jsx fileName="src/components/LocaleSwitcher.jsx" codeFormat="esm"
|
|
1216
|
+
import { useLocation, route } from "preact-iso";
|
|
1217
|
+
import {
|
|
1218
|
+
Locales,
|
|
1219
|
+
getHTMLTextDir,
|
|
1220
|
+
getLocaleName,
|
|
1221
|
+
getLocalizedUrl,
|
|
1222
|
+
} from "intlayer";
|
|
1223
|
+
import { useLocale } from "preact-intlayer";
|
|
1224
|
+
import { h } from "preact"; // Untuk JSX
|
|
1225
|
+
|
|
1226
|
+
const LocaleSwitcher = () => {
|
|
1227
|
+
const location = useLocation();
|
|
1228
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1229
|
+
onLocaleChange: (newLocale) => {
|
|
1230
|
+
const currentFullPath = location.url;
|
|
1231
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1232
|
+
route(pathWithLocale, true);
|
|
1233
|
+
},
|
|
1234
|
+
});
|
|
1235
|
+
|
|
1236
|
+
return (
|
|
1237
|
+
<div>
|
|
1238
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1239
|
+
<div id="localePopover" popover="auto">
|
|
1240
|
+
{availableLocales.map((localeItem) => (
|
|
1241
|
+
<a
|
|
1242
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1243
|
+
hreflang={localeItem}
|
|
1244
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1245
|
+
onClick={(e) => {
|
|
1246
|
+
e.preventDefault();
|
|
1247
|
+
setLocale(localeItem);
|
|
1248
|
+
}}
|
|
1249
|
+
key={localeItem}
|
|
1250
|
+
>
|
|
1251
|
+
<span>{localeItem}</span>
|
|
1252
|
+
<span>{getLocaleName(localeItem, localeItem)}</span>
|
|
1253
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1254
|
+
{getLocaleName(localeItem, locale)}
|
|
1255
|
+
</span>
|
|
1256
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1257
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1258
|
+
</span>
|
|
1259
|
+
</a>
|
|
1260
|
+
))}
|
|
1261
|
+
</div>
|
|
1262
|
+
</div>
|
|
1263
|
+
);
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1266
|
+
export default LocaleSwitcher;
|
|
1267
|
+
```
|
|
1268
|
+
|
|
1269
|
+
```jsx fileName="src/components/LocaleSwitcher.cjsx" codeFormat="commonjs"
|
|
1270
|
+
const { useLocation, route } = require("preact-iso");
|
|
1271
|
+
const {
|
|
1272
|
+
Locales,
|
|
1273
|
+
getHTMLTextDir,
|
|
1274
|
+
getLocaleName,
|
|
1275
|
+
getLocalizedUrl,
|
|
1276
|
+
} = require("intlayer");
|
|
1277
|
+
const { useLocale } = require("preact-intlayer");
|
|
1278
|
+
const { h } = require("preact"); // Untuk JSX
|
|
1279
|
+
|
|
1280
|
+
const LocaleSwitcher = () => {
|
|
1281
|
+
const location = useLocation();
|
|
1282
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1283
|
+
onLocaleChange: (newLocale) => {
|
|
1284
|
+
const currentFullPath = location.url;
|
|
1285
|
+
const pathWithLocale = getLocalizedUrl(currentFullPath, newLocale);
|
|
1286
|
+
route(pathWithLocale, true);
|
|
1287
|
+
},
|
|
1288
|
+
});
|
|
1289
|
+
|
|
1290
|
+
return (
|
|
1291
|
+
<div>
|
|
1292
|
+
<button popovertarget="localePopover">{getLocaleName(locale)}</button>
|
|
1293
|
+
<div id="localePopover" popover="auto">
|
|
1294
|
+
{availableLocales.map((localeItem) => (
|
|
1295
|
+
<a
|
|
1296
|
+
href={getLocalizedUrl(location.url, localeItem)}
|
|
1297
|
+
hreflang={localeItem}
|
|
1298
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1299
|
+
onClick={(e) => {
|
|
1300
|
+
e.preventDefault();
|
|
1301
|
+
setLocale(localeItem);
|
|
1302
|
+
}}
|
|
1303
|
+
key={localeItem}
|
|
1304
|
+
>
|
|
1305
|
+
<span>{localeItem}</span>
|
|
1306
|
+
<span>{getLocaleName(localeItem, localeItem)}</span>
|
|
1307
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1308
|
+
{getLocaleName(localeItem, locale)}
|
|
1309
|
+
</span>
|
|
1310
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1311
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1312
|
+
</span>
|
|
1313
|
+
</a>
|
|
1314
|
+
))}
|
|
1315
|
+
</div>
|
|
1316
|
+
</div>
|
|
1317
|
+
);
|
|
1318
|
+
};
|
|
1319
|
+
|
|
1320
|
+
module.exports = LocaleSwitcher;
|
|
1321
|
+
```
|
|
1322
|
+
|
|
1323
|
+
> Referensi dokumentasi:
|
|
1324
|
+
>
|
|
1325
|
+
> > - [`useLocale` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/react-intlayer/useLocale.md) (API serupa untuk `preact-intlayer`)
|
|
1326
|
+
>
|
|
1327
|
+
> - [`getLocaleName` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/intlayer/getLocaleName.md)
|
|
1328
|
+
> - [`getLocalizedUrl` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/intlayer/getLocalizedUrl.md)
|
|
1329
|
+
> - [`getHTMLTextDir` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/intlayer/getHTMLTextDir.md)
|
|
1330
|
+
> - atribut [`hreflang`](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
|
|
1331
|
+
> - atribut [`lang`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
|
|
1332
|
+
> - atribut [`dir`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
|
|
1333
|
+
> - atribut [`aria-current`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1334
|
+
> - [API Popover](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API) la.org/en-US/docs/Web/HTML/Global_attributes/dir)> - [`atribut aria-current`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)> - [API Popover](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API)
|
|
1335
|
+
|
|
1336
|
+
Berikut adalah **Langkah 9** yang diperbarui dengan penjelasan tambahan dan contoh kode yang disempurnakan:
|
|
1337
|
+
|
|
1338
|
+
---
|
|
1339
|
+
|
|
1340
|
+
### (Opsional) Langkah 9: Mengubah Atribut Bahasa dan Arah pada HTML
|
|
1341
|
+
|
|
1342
|
+
Ketika aplikasi Anda mendukung banyak bahasa, sangat penting untuk memperbarui atribut `lang` dan `dir` pada tag `<html>` agar sesuai dengan locale saat ini. Melakukan hal ini memastikan:
|
|
1343
|
+
|
|
1344
|
+
- **Aksesibilitas**: Pembaca layar dan teknologi bantu bergantung pada atribut `lang` yang benar untuk mengucapkan dan menginterpretasikan konten dengan akurat.
|
|
1345
|
+
- **Perenderan Teks**: Atribut `dir` (arah) memastikan teks ditampilkan dalam urutan yang tepat (misalnya, kiri ke kanan untuk bahasa Inggris, kanan ke kiri untuk bahasa Arab atau Ibrani), yang sangat penting untuk keterbacaan.
|
|
1346
|
+
- **SEO**: Mesin pencari menggunakan atribut `lang` untuk menentukan bahasa halaman Anda, membantu menyajikan konten lokal yang tepat dalam hasil pencarian.
|
|
1347
|
+
|
|
1348
|
+
Dengan memperbarui atribut ini secara dinamis saat locale berubah, Anda menjamin pengalaman yang konsisten dan dapat diakses bagi pengguna di semua bahasa yang didukung.
|
|
1349
|
+
|
|
1350
|
+
#### Mengimplementasikan Hook
|
|
1351
|
+
|
|
1352
|
+
Buat hook kustom untuk mengelola atribut HTML. Hook ini mendengarkan perubahan locale dan memperbarui atribut sesuai:
|
|
1353
|
+
|
|
1354
|
+
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
|
|
1355
|
+
import { useEffect } from "preact/hooks";
|
|
1356
|
+
import { useLocale } from "preact-intlayer";
|
|
1357
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1358
|
+
|
|
1359
|
+
/**
|
|
1360
|
+
* Memperbarui atribut `lang` dan `dir` elemen <html> berdasarkan locale saat ini.
|
|
1361
|
+
* - `lang`: Memberitahu browser dan mesin pencari tentang bahasa halaman.
|
|
1362
|
+
* - `dir`: Memastikan urutan pembacaan yang benar (misalnya, 'ltr' untuk bahasa Inggris, 'rtl' untuk bahasa Arab).
|
|
1363
|
+
*
|
|
1364
|
+
* Pembaruan dinamis ini penting untuk rendering teks yang tepat, aksesibilitas, dan SEO.
|
|
1365
|
+
*/
|
|
1366
|
+
export const useI18nHTMLAttributes = () => {
|
|
1367
|
+
const { locale } = useLocale();
|
|
1368
|
+
|
|
1369
|
+
useEffect(() => {
|
|
1370
|
+
// Perbarui atribut bahasa ke locale saat ini.
|
|
1371
|
+
document.documentElement.lang = locale;
|
|
1372
|
+
|
|
1373
|
+
// Atur arah teks berdasarkan locale saat ini.
|
|
1374
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1375
|
+
}, [locale]);
|
|
1376
|
+
};
|
|
1377
|
+
```
|
|
1378
|
+
|
|
1379
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.jsx" codeFormat="esm"
|
|
1380
|
+
import { useEffect } from "preact/hooks";
|
|
1381
|
+
import { useLocale } from "preact-intlayer";
|
|
1382
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1383
|
+
|
|
1384
|
+
/**
|
|
1385
|
+
* Memperbarui atribut `lang` dan `dir` elemen HTML <html> berdasarkan locale saat ini.
|
|
1386
|
+
*/
|
|
1387
|
+
export const useI18nHTMLAttributes = () => {
|
|
1388
|
+
const { locale } = useLocale();
|
|
1389
|
+
|
|
1390
|
+
useEffect(() => {
|
|
1391
|
+
document.documentElement.lang = locale;
|
|
1392
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1393
|
+
}, [locale]);
|
|
1394
|
+
};
|
|
1395
|
+
```
|
|
1396
|
+
|
|
1397
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.cjsx" codeFormat="commonjs"
|
|
1398
|
+
const { useEffect } = require("preact/hooks");
|
|
1399
|
+
const { useLocale } = require("preact-intlayer");
|
|
1400
|
+
const { getHTMLTextDir } = require("intlayer");
|
|
1401
|
+
|
|
1402
|
+
/**
|
|
1403
|
+
* Memperbarui atribut `lang` dan `dir` elemen HTML <html> berdasarkan locale saat ini.
|
|
1404
|
+
*/
|
|
1405
|
+
const useI18nHTMLAttributes = () => {
|
|
1406
|
+
const { locale } = useLocale();
|
|
1407
|
+
|
|
1408
|
+
useEffect(() => {
|
|
1409
|
+
document.documentElement.lang = locale;
|
|
1410
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1411
|
+
}, [locale]);
|
|
1412
|
+
};
|
|
1413
|
+
|
|
1414
|
+
module.exports = { useI18nHTMLAttributes };
|
|
1415
|
+
```
|
|
1416
|
+
|
|
1417
|
+
#### Menggunakan Hook dalam Aplikasi Anda
|
|
1418
|
+
|
|
1419
|
+
Integrasikan hook ini ke dalam komponen utama Anda sehingga atribut HTML diperbarui setiap kali locale berubah:
|
|
1420
|
+
|
|
1421
|
+
```tsx fileName="src/app.tsx" codeFormat="typescript"
|
|
1422
|
+
import type { FunctionalComponent } from "preact";
|
|
1423
|
+
import { IntlayerProvider } from "preact-intlayer"; // useIntlayer sudah diimpor jika AppContent membutuhkannya
|
|
1424
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1425
|
+
import "./app.css";
|
|
1426
|
+
// Definisi AppContent dari Langkah 5
|
|
1427
|
+
|
|
1428
|
+
const AppWithHooks: FunctionalComponent = () => {
|
|
1429
|
+
// Terapkan hook untuk memperbarui atribut lang dan dir pada tag <html> berdasarkan locale.
|
|
1430
|
+
useI18nHTMLAttributes();
|
|
1431
|
+
|
|
1432
|
+
// Mengasumsikan AppContent adalah komponen tampilan konten utama Anda dari Langkah 5
|
|
1433
|
+
return <AppContent />;
|
|
1434
|
+
};
|
|
1435
|
+
|
|
1436
|
+
const App: FunctionalComponent = () => (
|
|
1437
|
+
<IntlayerProvider>
|
|
1438
|
+
<AppWithHooks />
|
|
1439
|
+
</IntlayerProvider>
|
|
1440
|
+
);
|
|
1441
|
+
|
|
1442
|
+
export default App;
|
|
1443
|
+
```
|
|
1444
|
+
|
|
1445
|
+
```jsx fileName="src/app.jsx" codeFormat="esm"
|
|
1446
|
+
import { IntlayerProvider } from "preact-intlayer";
|
|
1447
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1448
|
+
import "./app.css";
|
|
1449
|
+
// Definisi AppContent dari Langkah 5
|
|
1450
|
+
|
|
1451
|
+
const AppWithHooks = () => {
|
|
1452
|
+
useI18nHTMLAttributes();
|
|
1453
|
+
return <AppContent />;
|
|
1454
|
+
};
|
|
1455
|
+
|
|
1456
|
+
const App = () => (
|
|
1457
|
+
<IntlayerProvider>
|
|
1458
|
+
<AppWithHooks />
|
|
1459
|
+
</IntlayerProvider>
|
|
1460
|
+
);
|
|
1461
|
+
|
|
1462
|
+
export default App;
|
|
1463
|
+
```
|
|
1464
|
+
|
|
1465
|
+
```jsx fileName="src/app.cjsx" codeFormat="commonjs"
|
|
1466
|
+
const { IntlayerProvider } = require("preact-intlayer");
|
|
1467
|
+
const { useI18nHTMLAttributes } = require("./hooks/useI18nHTMLAttributes");
|
|
1468
|
+
require("./app.css");
|
|
1469
|
+
// Definisi AppContent dari Langkah 5
|
|
1470
|
+
|
|
1471
|
+
const AppWithHooks = () => {
|
|
1472
|
+
useI18nHTMLAttributes();
|
|
1473
|
+
return <AppContent />;
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1476
|
+
const App = () => (
|
|
1477
|
+
<IntlayerProvider>
|
|
1478
|
+
<AppWithHooks />
|
|
1479
|
+
</IntlayerProvider>
|
|
1480
|
+
);
|
|
1481
|
+
|
|
1482
|
+
module.exports = App;
|
|
1483
|
+
```
|
|
1484
|
+
|
|
1485
|
+
Dengan menerapkan perubahan ini, aplikasi Anda akan:
|
|
1486
|
+
|
|
1487
|
+
- Memastikan atribut **bahasa** (`lang`) mencerminkan locale saat ini dengan benar, yang penting untuk SEO dan perilaku browser.
|
|
1488
|
+
- Menyesuaikan **arah teks** (`dir`) sesuai dengan locale, meningkatkan keterbacaan dan kegunaan untuk bahasa dengan urutan baca yang berbeda.
|
|
1489
|
+
- Memberikan pengalaman yang lebih **aksesibel**, karena teknologi bantu bergantung pada atribut ini agar berfungsi secara optimal.
|
|
1490
|
+
|
|
1491
|
+
### (Opsional) Langkah 10: Membuat Komponen Link yang Dilokalkan
|
|
1492
|
+
|
|
1493
|
+
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.
|
|
1494
|
+
|
|
1495
|
+
Perilaku ini berguna untuk beberapa alasan:
|
|
1496
|
+
|
|
1497
|
+
- **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.
|
|
1498
|
+
- **Konsistensi**: Dengan menggunakan link yang dilokalkan di seluruh aplikasi Anda, Anda menjamin navigasi tetap berada dalam locale saat ini, mencegah perubahan bahasa yang tidak diinginkan.
|
|
1499
|
+
- **Maintainability**: Memusatkan logika lokalisasi dalam satu komponen mempermudah pengelolaan URL.
|
|
1500
|
+
|
|
1501
|
+
Untuk Preact dengan `preact-iso`, tag `<a>` standar biasanya digunakan untuk navigasi, dan `preact-iso` yang menangani routing. Jika Anda membutuhkan navigasi programatik saat klik (misalnya, untuk melakukan aksi sebelum navigasi), Anda dapat menggunakan fungsi `route` dari `useLocation`. Berikut cara membuat komponen anchor kustom yang melokalisasi URL:
|
|
1502
|
+
|
|
1503
|
+
```tsx fileName="src/components/LocalizedLink.tsx" codeFormat="typescript"
|
|
1504
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1505
|
+
import { useLocale } from "preact-intlayer";
|
|
1506
|
+
import { useLocation, route } from "preact-iso";
|
|
1507
|
+
import type { JSX } from "preact";
|
|
1508
|
+
import { forwardRef } from "preact/compat";
|
|
1509
|
+
|
|
1510
|
+
/**
|
|
1511
|
+
* Props untuk LocalizedLink - mewarisi atribut anchor + beberapa properti ekstra.
|
|
1512
|
+
*/
|
|
1513
|
+
export interface LocalizedLinkProps
|
|
1514
|
+
extends JSX.HTMLAttributes<HTMLAnchorElement> {
|
|
1515
|
+
href: string;
|
|
1516
|
+
replace?: boolean; // Opsional: untuk mengganti state history
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* Fungsi utilitas untuk memeriksa apakah URL adalah link eksternal.
|
|
1521
|
+
*/
|
|
1522
|
+
export function checkIsExternalLink(href?: string): boolean {
|
|
1523
|
+
return /^https?:\/\//.test(href ?? "");
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
/**
|
|
1527
|
+
* Komponen link terlokalisasi. Menyesuaikan href untuk locale saat ini secara otomatis pada link internal.
|
|
1528
|
+
* Routing navigasi sisi-klien dengan preact-iso.
|
|
1529
|
+
*/
|
|
1530
|
+
export const LocalizedLink = forwardRef<HTMLAnchorElement, LocalizedLinkProps>(
|
|
1531
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1532
|
+
const { locale } = useLocale();
|
|
1533
|
+
const location = useLocation();
|
|
1534
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1535
|
+
|
|
1536
|
+
const hrefI18n =
|
|
1537
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1538
|
+
|
|
1539
|
+
const handleClick = (event: JSX.TargetedMouseEvent<HTMLAnchorElement>) => {
|
|
1540
|
+
if (typeof onClick === "function") onClick(event);
|
|
1541
|
+
|
|
1542
|
+
if (
|
|
1543
|
+
!isExternalLink &&
|
|
1544
|
+
href &&
|
|
1545
|
+
event.button === 0 &&
|
|
1546
|
+
!event.metaKey &&
|
|
1547
|
+
!event.ctrlKey &&
|
|
1548
|
+
!event.shiftKey &&
|
|
1549
|
+
!event.altKey &&
|
|
1550
|
+
!props.target
|
|
1551
|
+
) {
|
|
1552
|
+
event.preventDefault();
|
|
1553
|
+
if (location.url !== hrefI18n) {
|
|
1554
|
+
route(hrefI18n, replace);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
};
|
|
1558
|
+
|
|
1559
|
+
return (
|
|
1560
|
+
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1561
|
+
{children}
|
|
1562
|
+
</a>
|
|
1563
|
+
);
|
|
1564
|
+
}
|
|
1565
|
+
);
|
|
1566
|
+
```
|
|
1567
|
+
|
|
1568
|
+
```jsx fileName="src/components/LocalizedLink.jsx" codeFormat="esm"
|
|
1569
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1570
|
+
import { useLocale } from "preact-intlayer";
|
|
1571
|
+
import { useLocation, route } from "preact-iso"; // Impor dari preact-iso
|
|
1572
|
+
import { forwardRef } from "preact/compat";
|
|
1573
|
+
import { h } from "preact"; // Untuk JSX
|
|
1574
|
+
|
|
1575
|
+
export const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1576
|
+
|
|
1577
|
+
export const LocalizedLink = forwardRef(
|
|
1578
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1579
|
+
const { locale } = useLocale();
|
|
1580
|
+
const location = useLocation();
|
|
1581
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1582
|
+
|
|
1583
|
+
const hrefI18n =
|
|
1584
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1585
|
+
|
|
1586
|
+
const handleClick = (event) => {
|
|
1587
|
+
if (onClick) {
|
|
1588
|
+
onClick(event);
|
|
1589
|
+
}
|
|
1590
|
+
if (
|
|
1591
|
+
!isExternalLink &&
|
|
1592
|
+
href &&
|
|
1593
|
+
event.button === 0 &&
|
|
1594
|
+
!event.metaKey &&
|
|
1595
|
+
!event.ctrlKey &&
|
|
1596
|
+
!event.shiftKey &&
|
|
1597
|
+
!event.altKey &&
|
|
1598
|
+
!props.target
|
|
1599
|
+
) {
|
|
1600
|
+
event.preventDefault();
|
|
1601
|
+
if (location.url !== hrefI18n) {
|
|
1602
|
+
route(hrefI18n, replace);
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
};
|
|
1606
|
+
|
|
1607
|
+
return (
|
|
1608
|
+
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1609
|
+
{children}
|
|
1610
|
+
</a>
|
|
1611
|
+
);
|
|
1612
|
+
}
|
|
1613
|
+
);
|
|
1614
|
+
```
|
|
1615
|
+
|
|
1616
|
+
```jsx fileName="src/components/LocalizedLink.cjsx" codeFormat="commonjs"
|
|
1617
|
+
const { getLocalizedUrl } = require("intlayer");
|
|
1618
|
+
const { useLocale } = require("preact-intlayer");
|
|
1619
|
+
const { useLocation, route } = require("preact-iso"); // Impor dari preact-iso
|
|
1620
|
+
const { forwardRef } = require("preact/compat");
|
|
1621
|
+
const { h } = require("preact"); // Untuk JSX
|
|
1622
|
+
|
|
1623
|
+
const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1624
|
+
|
|
1625
|
+
const LocalizedLink = forwardRef(
|
|
1626
|
+
({ href, children, onClick, replace = false, ...props }, ref) => {
|
|
1627
|
+
const { locale } = useLocale();
|
|
1628
|
+
const location = useLocation();
|
|
1629
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1630
|
+
|
|
1631
|
+
const hrefI18n =
|
|
1632
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1633
|
+
|
|
1634
|
+
const handleClick = (event) => {
|
|
1635
|
+
if (onClick) {
|
|
1636
|
+
onClick(event);
|
|
1637
|
+
}
|
|
1638
|
+
if (
|
|
1639
|
+
!isExternalLink &&
|
|
1640
|
+
href &&
|
|
1641
|
+
event.button === 0 &&
|
|
1642
|
+
!event.metaKey &&
|
|
1643
|
+
!event.ctrlKey &&
|
|
1644
|
+
!event.shiftKey &&
|
|
1645
|
+
!event.altKey &&
|
|
1646
|
+
!props.target
|
|
1647
|
+
) {
|
|
1648
|
+
event.preventDefault();
|
|
1649
|
+
if (location.url !== hrefI18n) {
|
|
1650
|
+
route(hrefI18n, replace);
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
};
|
|
1654
|
+
|
|
1655
|
+
return (
|
|
1656
|
+
<a href={hrefI18n} ref={ref} onClick={handleClick} {...props}>
|
|
1657
|
+
{children}
|
|
1658
|
+
</a>
|
|
1659
|
+
);
|
|
1660
|
+
}
|
|
1661
|
+
);
|
|
1662
|
+
|
|
1663
|
+
module.exports = { LocalizedLink, checkIsExternalLink };
|
|
1664
|
+
```
|
|
1665
|
+
|
|
1666
|
+
#### Cara Kerjanya
|
|
1667
|
+
|
|
1668
|
+
- **Mendeteksi Tautan Eksternal**:
|
|
1669
|
+
Fungsi pembantu `checkIsExternalLink` menentukan apakah sebuah URL adalah eksternal. Tautan eksternal dibiarkan tanpa perubahan.
|
|
1670
|
+
- **Mengambil Locale Saat Ini**:
|
|
1671
|
+
Hook `useLocale` menyediakan locale saat ini.
|
|
1672
|
+
- **Melokalkan URL**:
|
|
1673
|
+
Untuk tautan internal, `getLocalizedUrl` menambahkan prefix locale saat ini ke URL.
|
|
1674
|
+
- **Navigasi di Sisi Klien**:
|
|
1675
|
+
Fungsi `handleClick` memeriksa apakah itu tautan internal dan jika navigasi standar harus dicegah. Jika ya, fungsi `route` dari `preact-iso` (yang diperoleh melalui `useLocation` atau diimpor langsung) digunakan untuk melakukan navigasi sisi-klien. Ini memberikan perilaku seperti SPA tanpa memuat ulang halaman secara penuh.
|
|
1676
|
+
- **Mengembalikan Tautan**:
|
|
1677
|
+
Komponen mengembalikan elemen `<a>` dengan URL yang sudah dilokalkan dan penangan klik khusus.
|
|
1678
|
+
|
|
1679
|
+
### Konfigurasi TypeScript
|
|
1680
|
+
|
|
1681
|
+
Intlayer menggunakan augmentasi modul untuk mendapatkan manfaat dari TypeScript dan membuat basis kode Anda lebih kuat.
|
|
1682
|
+
|
|
1683
|
+

|
|
1684
|
+
|
|
1685
|
+

|
|
1686
|
+
|
|
1687
|
+
Pastikan konfigurasi TypeScript Anda menyertakan tipe yang dihasilkan secara otomatis.
|
|
1688
|
+
|
|
1689
|
+
```json5 fileName="tsconfig.json"
|
|
1690
|
+
{
|
|
1691
|
+
// ... Konfigurasi TypeScript Anda yang sudah ada
|
|
1692
|
+
"compilerOptions": {
|
|
1693
|
+
// ...
|
|
1694
|
+
"jsx": "react-jsx",
|
|
1695
|
+
"jsxImportSource": "preact", // Direkomendasikan untuk Preact 10+
|
|
1696
|
+
// ...
|
|
1697
|
+
},
|
|
1698
|
+
"include": [
|
|
1699
|
+
// ... Konfigurasi TypeScript Anda yang sudah ada
|
|
1700
|
+
".intlayer/**/*.ts", // Sertakan tipe yang dihasilkan secara otomatis
|
|
1701
|
+
],
|
|
1702
|
+
}
|
|
1703
|
+
```
|
|
1704
|
+
|
|
1705
|
+
> Pastikan `tsconfig.json` Anda diatur untuk Preact, terutama `jsx` dan `jsxImportSource` atau `jsxFactory`/`jsxFragmentFactory` untuk versi Preact yang lebih lama jika tidak menggunakan default dari `preset-vite`.
|
|
1706
|
+
|
|
1707
|
+
### Konfigurasi Git
|
|
1708
|
+
|
|
1709
|
+
Disarankan untuk mengabaikan file yang dihasilkan oleh Intlayer. Ini memungkinkan Anda menghindari meng-commit file tersebut ke repository Git Anda.
|
|
1710
|
+
|
|
1711
|
+
Untuk melakukan ini, Anda dapat menambahkan instruksi berikut ke file `.gitignore` Anda:
|
|
1712
|
+
|
|
1713
|
+
```plaintext
|
|
1714
|
+
# Abaikan file yang dihasilkan oleh Intlayer
|
|
1715
|
+
.intlayer
|
|
1716
|
+
```
|
|
1717
|
+
|
|
1718
|
+
### Ekstensi VS Code
|
|
1719
|
+
|
|
1720
|
+
Untuk meningkatkan pengalaman pengembangan Anda dengan Intlayer, Anda dapat menginstal **Ekstensi VS Code Intlayer** resmi.
|
|
1721
|
+
|
|
1722
|
+
[Pasang dari VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
1723
|
+
|
|
1724
|
+
Ekstensi ini menyediakan:
|
|
1725
|
+
|
|
1726
|
+
- **Autocompletion** untuk kunci terjemahan.
|
|
1727
|
+
- **Deteksi kesalahan waktu nyata** untuk terjemahan yang hilang.
|
|
1728
|
+
- **Pratinjau inline** dari konten yang diterjemahkan.
|
|
1729
|
+
- **Tindakan cepat** untuk dengan mudah membuat dan memperbarui terjemahan.
|
|
1730
|
+
|
|
1731
|
+
Untuk detail lebih lanjut tentang cara menggunakan ekstensi ini, lihat [dokumentasi Ekstensi VS Code Intlayer](https://intlayer.org/doc/vs-code-extension).
|
|
1732
|
+
|
|
1733
|
+
---
|
|
1734
|
+
|
|
1735
|
+
### Melangkah Lebih Jauh
|
|
1736
|
+
|
|
1737
|
+
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).
|