@intlayer/docs 5.8.1-canary.0 → 6.0.0-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/rag_powered_documentation_assistant.md +282 -0
- package/blog/de/rag_powered_documentation_assistant.md +282 -0
- package/blog/en/rag_powered_documentation_assistant.md +289 -0
- package/blog/en-GB/rag_powered_documentation_assistant.md +284 -0
- package/blog/es/rag_powered_documentation_assistant.md +308 -0
- package/blog/fr/rag_powered_documentation_assistant.md +308 -0
- package/blog/hi/rag_powered_documentation_assistant.md +284 -0
- package/blog/it/rag_powered_documentation_assistant.md +284 -0
- package/blog/ja/rag_powered_documentation_assistant.md +284 -0
- package/blog/ko/rag_powered_documentation_assistant.md +283 -0
- package/blog/pt/rag_powered_documentation_assistant.md +284 -0
- package/blog/ru/rag_powered_documentation_assistant.md +284 -0
- package/blog/tr/index.md +69 -0
- package/blog/tr/internationalization_and_SEO.md +273 -0
- package/blog/tr/intlayer_with_i18next.md +162 -0
- package/blog/tr/intlayer_with_next-i18next.md +367 -0
- package/blog/tr/intlayer_with_next-intl.md +392 -0
- package/blog/tr/intlayer_with_react-i18next.md +346 -0
- package/blog/tr/intlayer_with_react-intl.md +345 -0
- package/blog/tr/list_i18n_technologies/CMS/drupal.md +143 -0
- package/blog/tr/list_i18n_technologies/CMS/wix.md +167 -0
- package/blog/tr/list_i18n_technologies/CMS/wordpress.md +188 -0
- package/blog/tr/list_i18n_technologies/frameworks/angular.md +125 -0
- package/blog/tr/list_i18n_technologies/frameworks/flutter.md +150 -0
- package/blog/tr/list_i18n_technologies/frameworks/react-native.md +217 -0
- package/blog/tr/list_i18n_technologies/frameworks/react.md +155 -0
- package/blog/tr/list_i18n_technologies/frameworks/svelte.md +129 -0
- package/blog/tr/list_i18n_technologies/frameworks/vue.md +130 -0
- package/blog/tr/next-i18next_vs_next-intl_vs_intlayer.md +170 -0
- package/blog/tr/rag_powered_documentation_assistant.md +284 -0
- package/blog/tr/react-i18next_vs_react-intl_vs_intlayer.md +162 -0
- package/blog/tr/vue-i18n_vs_intlayer.md +276 -0
- package/blog/tr/what_is_internationalization.md +166 -0
- package/blog/zh/rag_powered_documentation_assistant.md +284 -0
- package/dist/cjs/generated/blog.entry.cjs +212 -0
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/cjs/generated/docs.entry.cjs +660 -132
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/cjs/generated/frequentQuestions.entry.cjs +84 -0
- package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
- package/dist/cjs/generated/legal.entry.cjs +6 -0
- package/dist/cjs/generated/legal.entry.cjs.map +1 -1
- package/dist/esm/generated/blog.entry.mjs +212 -0
- package/dist/esm/generated/blog.entry.mjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +660 -132
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/esm/generated/frequentQuestions.entry.mjs +84 -0
- package/dist/esm/generated/frequentQuestions.entry.mjs.map +1 -1
- package/dist/esm/generated/legal.entry.mjs +6 -0
- package/dist/esm/generated/legal.entry.mjs.map +1 -1
- package/dist/types/generated/blog.entry.d.ts +1 -0
- package/dist/types/generated/blog.entry.d.ts.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +5 -2
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/dist/types/generated/frequentQuestions.entry.d.ts.map +1 -1
- package/dist/types/generated/legal.entry.d.ts.map +1 -1
- package/docs/ar/autoFill.md +41 -40
- package/docs/ar/configuration.md +202 -199
- package/docs/ar/dictionary/content_file.md +1059 -0
- package/docs/ar/intlayer_CMS.md +4 -4
- package/docs/ar/intlayer_with_nestjs.md +271 -0
- package/docs/ar/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/ar/intlayer_with_react_router_v7.md +533 -0
- package/docs/ar/intlayer_with_tanstack.md +465 -299
- package/docs/ar/intlayer_with_vite+preact.md +7 -7
- package/docs/ar/intlayer_with_vite+react.md +7 -7
- package/docs/ar/intlayer_with_vite+vue.md +9 -9
- package/docs/ar/packages/vite-intlayer/index.md +3 -3
- package/docs/ar/readme.md +261 -0
- package/docs/ar/testing.md +199 -0
- package/docs/de/autoFill.md +42 -19
- package/docs/de/configuration.md +155 -147
- package/docs/de/dictionary/content_file.md +1059 -0
- package/docs/de/intlayer_CMS.md +4 -5
- package/docs/de/intlayer_with_nestjs.md +270 -0
- package/docs/de/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/de/intlayer_with_react_router_v7.md +537 -0
- package/docs/de/intlayer_with_tanstack.md +469 -302
- package/docs/de/intlayer_with_vite+preact.md +7 -7
- package/docs/de/intlayer_with_vite+react.md +7 -7
- package/docs/de/intlayer_with_vite+vue.md +9 -9
- package/docs/de/packages/vite-intlayer/index.md +3 -3
- package/docs/de/readme.md +261 -0
- package/docs/de/testing.md +200 -0
- package/docs/en/CI_CD.md +4 -6
- package/docs/en/autoFill.md +25 -5
- package/docs/en/configuration.md +45 -54
- package/docs/en/dictionary/content_file.md +1054 -0
- package/docs/en/intlayer_CMS.md +8 -7
- package/docs/en/intlayer_cli.md +112 -5
- package/docs/en/intlayer_with_nestjs.md +268 -0
- package/docs/en/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/en/intlayer_with_react_router_v7.md +531 -0
- package/docs/en/intlayer_with_tanstack.md +463 -294
- package/docs/en/intlayer_with_vite+preact.md +8 -8
- package/docs/en/intlayer_with_vite+react.md +8 -8
- package/docs/en/intlayer_with_vite+vue.md +8 -8
- package/docs/en/packages/intlayer/getLocalizedUrl.md +102 -25
- package/docs/en/packages/vite-intlayer/index.md +3 -3
- package/docs/en/readme.md +261 -0
- package/docs/en/testing.md +200 -0
- package/docs/en-GB/autoFill.md +29 -6
- package/docs/en-GB/configuration.md +79 -71
- package/docs/en-GB/dictionary/content_file.md +1084 -0
- package/docs/en-GB/intlayer_CMS.md +4 -5
- package/docs/en-GB/intlayer_with_nestjs.md +268 -0
- package/docs/en-GB/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/en-GB/intlayer_with_react_router_v7.md +533 -0
- package/docs/en-GB/intlayer_with_tanstack.md +466 -299
- package/docs/en-GB/intlayer_with_vite+preact.md +7 -7
- package/docs/en-GB/intlayer_with_vite+react.md +7 -7
- package/docs/en-GB/intlayer_with_vite+vue.md +9 -9
- package/docs/en-GB/packages/vite-intlayer/index.md +3 -3
- package/docs/en-GB/readme.md +261 -0
- package/docs/en-GB/testing.md +200 -0
- package/docs/es/autoFill.md +45 -23
- package/docs/es/configuration.md +171 -167
- package/docs/es/dictionary/content_file.md +1088 -0
- package/docs/es/intlayer_CMS.md +4 -5
- package/docs/es/intlayer_with_nestjs.md +268 -0
- package/docs/es/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/es/intlayer_with_react_router_v7.md +533 -0
- package/docs/es/intlayer_with_tanstack.md +469 -280
- package/docs/es/intlayer_with_vite+preact.md +7 -7
- package/docs/es/intlayer_with_vite+react.md +7 -7
- package/docs/es/intlayer_with_vite+vue.md +9 -9
- package/docs/es/packages/vite-intlayer/index.md +3 -3
- package/docs/es/readme.md +261 -0
- package/docs/es/testing.md +200 -0
- package/docs/fr/autoFill.md +47 -24
- package/docs/fr/configuration.md +213 -198
- package/docs/fr/dictionary/content_file.md +1054 -0
- package/docs/fr/intlayer_CMS.md +4 -5
- package/docs/fr/intlayer_with_nestjs.md +268 -0
- package/docs/fr/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/fr/intlayer_with_react_router_v7.md +549 -0
- package/docs/fr/intlayer_with_tanstack.md +465 -279
- package/docs/fr/intlayer_with_vite+preact.md +7 -7
- package/docs/fr/intlayer_with_vite+react.md +7 -7
- package/docs/fr/intlayer_with_vite+vue.md +9 -9
- package/docs/fr/packages/vite-intlayer/index.md +3 -3
- package/docs/fr/readme.md +261 -0
- package/docs/fr/testing.md +200 -0
- package/docs/hi/autoFill.md +47 -25
- package/docs/hi/configuration.md +194 -189
- package/docs/hi/dictionary/content_file.md +1056 -0
- package/docs/hi/intlayer_CMS.md +4 -5
- package/docs/hi/intlayer_with_nestjs.md +269 -0
- package/docs/hi/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/hi/intlayer_with_react_router_v7.md +533 -0
- package/docs/hi/intlayer_with_tanstack.md +467 -282
- package/docs/hi/intlayer_with_vite+preact.md +7 -7
- package/docs/hi/intlayer_with_vite+react.md +7 -7
- package/docs/hi/intlayer_with_vite+vue.md +9 -9
- package/docs/hi/packages/vite-intlayer/index.md +3 -3
- package/docs/hi/readme.md +261 -0
- package/docs/hi/testing.md +200 -0
- package/docs/it/autoFill.md +46 -24
- package/docs/it/configuration.md +169 -161
- package/docs/it/dictionary/content_file.md +1061 -0
- package/docs/it/intlayer_CMS.md +4 -5
- package/docs/it/intlayer_with_nestjs.md +268 -0
- package/docs/it/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/it/intlayer_with_react_router_v7.md +535 -0
- package/docs/it/intlayer_with_tanstack.md +467 -301
- package/docs/it/intlayer_with_vite+preact.md +7 -7
- package/docs/it/intlayer_with_vite+react.md +7 -7
- package/docs/it/intlayer_with_vite+vue.md +9 -9
- package/docs/it/packages/vite-intlayer/index.md +3 -3
- package/docs/it/readme.md +261 -0
- package/docs/it/testing.md +200 -0
- package/docs/ja/autoFill.md +45 -23
- package/docs/ja/configuration.md +243 -204
- package/docs/ja/dictionary/content_file.md +1064 -0
- package/docs/ja/intlayer_CMS.md +4 -5
- package/docs/ja/intlayer_with_nestjs.md +268 -0
- package/docs/ja/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/ja/intlayer_with_react_router_v7.md +534 -0
- package/docs/ja/intlayer_with_tanstack.md +467 -303
- package/docs/ja/intlayer_with_vite+preact.md +7 -7
- package/docs/ja/intlayer_with_vite+react.md +7 -7
- package/docs/ja/intlayer_with_vite+vue.md +9 -9
- package/docs/ja/packages/vite-intlayer/index.md +3 -3
- package/docs/ja/readme.md +263 -0
- package/docs/ja/testing.md +200 -0
- package/docs/ko/autoFill.md +39 -16
- package/docs/ko/configuration.md +217 -197
- package/docs/ko/dictionary/content_file.md +1060 -0
- package/docs/ko/intlayer_CMS.md +4 -5
- package/docs/ko/intlayer_with_nestjs.md +268 -0
- package/docs/ko/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/ko/intlayer_with_react_router_v7.md +540 -0
- package/docs/ko/intlayer_with_tanstack.md +466 -302
- package/docs/ko/intlayer_with_vite+preact.md +7 -7
- package/docs/ko/intlayer_with_vite+react.md +7 -7
- package/docs/ko/intlayer_with_vite+vue.md +9 -9
- package/docs/ko/packages/vite-intlayer/index.md +3 -3
- package/docs/ko/readme.md +261 -0
- package/docs/ko/testing.md +200 -0
- package/docs/pt/autoFill.md +39 -15
- package/docs/pt/configuration.md +165 -147
- package/docs/pt/dictionary/content_file.md +1062 -0
- package/docs/pt/intlayer_CMS.md +4 -5
- package/docs/pt/intlayer_with_nestjs.md +271 -0
- package/docs/pt/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/pt/intlayer_with_react_router_v7.md +535 -0
- package/docs/pt/intlayer_with_tanstack.md +469 -300
- package/docs/pt/intlayer_with_vite+preact.md +7 -7
- package/docs/pt/intlayer_with_vite+react.md +7 -7
- package/docs/pt/intlayer_with_vite+vue.md +9 -9
- package/docs/pt/packages/vite-intlayer/index.md +3 -3
- package/docs/pt/readme.md +261 -0
- package/docs/pt/testing.md +200 -0
- package/docs/ru/autoFill.md +52 -30
- package/docs/ru/configuration.md +164 -117
- package/docs/ru/dictionary/content_file.md +1064 -0
- package/docs/ru/intlayer_CMS.md +4 -4
- package/docs/ru/intlayer_with_nestjs.md +270 -0
- package/docs/ru/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/ru/intlayer_with_react_router_v7.md +534 -0
- package/docs/ru/intlayer_with_tanstack.md +470 -305
- package/docs/ru/intlayer_with_vite+preact.md +7 -7
- package/docs/ru/intlayer_with_vite+react.md +7 -7
- package/docs/ru/intlayer_with_vite+vue.md +9 -9
- package/docs/ru/packages/vite-intlayer/index.md +3 -3
- package/docs/ru/readme.md +261 -0
- package/docs/ru/testing.md +202 -0
- package/docs/tr/CI_CD.md +198 -0
- package/docs/tr/autoFill.md +201 -0
- package/docs/tr/configuration.md +585 -0
- package/docs/tr/dictionary/condition.md +243 -0
- package/docs/tr/dictionary/content_file.md +1055 -0
- package/docs/tr/dictionary/enumeration.md +251 -0
- package/docs/tr/dictionary/file.md +228 -0
- package/docs/tr/dictionary/function_fetching.md +218 -0
- package/docs/tr/dictionary/gender.md +279 -0
- package/docs/tr/dictionary/insertion.md +191 -0
- package/docs/tr/dictionary/markdown.md +385 -0
- package/docs/tr/dictionary/nesting.md +279 -0
- package/docs/tr/dictionary/translation.md +315 -0
- package/docs/tr/formatters.md +618 -0
- package/docs/tr/how_works_intlayer.md +254 -0
- package/docs/tr/index.md +168 -0
- package/docs/tr/interest_of_intlayer.md +288 -0
- package/docs/tr/intlayer_CMS.md +347 -0
- package/docs/tr/intlayer_cli.md +570 -0
- package/docs/tr/intlayer_visual_editor.md +269 -0
- package/docs/tr/intlayer_with_angular.md +694 -0
- package/docs/tr/intlayer_with_create_react_app.md +1218 -0
- package/docs/tr/intlayer_with_express.md +415 -0
- package/docs/tr/intlayer_with_lynx+react.md +511 -0
- package/docs/tr/intlayer_with_nestjs.md +268 -0
- package/docs/tr/intlayer_with_nextjs_14.md +1029 -0
- package/docs/tr/intlayer_with_nextjs_15.md +1506 -0
- package/docs/tr/intlayer_with_nextjs_page_router.md +1484 -0
- package/docs/tr/intlayer_with_nuxt.md +773 -0
- package/docs/tr/intlayer_with_react_native+expo.md +660 -0
- package/docs/tr/intlayer_with_react_router_v7.md +531 -0
- package/docs/tr/intlayer_with_tanstack.md +452 -0
- package/docs/tr/intlayer_with_vite+preact.md +1673 -0
- package/docs/tr/intlayer_with_vite+react.md +1632 -0
- package/docs/tr/intlayer_with_vite+solid.md +288 -0
- package/docs/tr/intlayer_with_vite+svelte.md +288 -0
- package/docs/tr/intlayer_with_vite+vue.md +1042 -0
- package/docs/tr/introduction.md +209 -0
- package/docs/tr/locale_mapper.md +244 -0
- package/docs/tr/mcp_server.md +207 -0
- package/docs/tr/packages/@intlayer/api/index.md +58 -0
- package/docs/tr/packages/@intlayer/chokidar/index.md +57 -0
- package/docs/tr/packages/@intlayer/cli/index.md +47 -0
- package/docs/tr/packages/@intlayer/config/index.md +142 -0
- package/docs/tr/packages/@intlayer/core/index.md +51 -0
- package/docs/tr/packages/@intlayer/design-system/index.md +47 -0
- package/docs/tr/packages/@intlayer/dictionary-entry/index.md +53 -0
- package/docs/tr/packages/@intlayer/editor/index.md +47 -0
- package/docs/tr/packages/@intlayer/editor-react/index.md +47 -0
- package/docs/tr/packages/@intlayer/webpack/index.md +61 -0
- package/docs/tr/packages/angular-intlayer/index.md +59 -0
- package/docs/tr/packages/express-intlayer/index.md +258 -0
- package/docs/tr/packages/express-intlayer/t.md +459 -0
- package/docs/tr/packages/intlayer/getConfiguration.md +151 -0
- package/docs/tr/packages/intlayer/getEnumeration.md +165 -0
- package/docs/tr/packages/intlayer/getHTMLTextDir.md +127 -0
- package/docs/tr/packages/intlayer/getLocaleLang.md +87 -0
- package/docs/tr/packages/intlayer/getLocaleName.md +124 -0
- package/docs/tr/packages/intlayer/getLocalizedUrl.md +324 -0
- package/docs/tr/packages/intlayer/getMultilingualUrls.md +225 -0
- package/docs/tr/packages/intlayer/getPathWithoutLocale.md +81 -0
- package/docs/tr/packages/intlayer/getTranslation.md +196 -0
- package/docs/tr/packages/intlayer/getTranslationContent.md +195 -0
- package/docs/tr/packages/intlayer/index.md +505 -0
- package/docs/tr/packages/intlayer-cli/index.md +71 -0
- package/docs/tr/packages/intlayer-editor/index.md +139 -0
- package/docs/tr/packages/lynx-intlayer/index.md +85 -0
- package/docs/tr/packages/next-intlayer/index.md +154 -0
- package/docs/tr/packages/next-intlayer/t.md +354 -0
- package/docs/tr/packages/next-intlayer/useDictionary.md +270 -0
- package/docs/tr/packages/next-intlayer/useIntlayer.md +265 -0
- package/docs/tr/packages/next-intlayer/useLocale.md +133 -0
- package/docs/tr/packages/nuxt-intlayer/index.md +59 -0
- package/docs/tr/packages/preact-intlayer/index.md +55 -0
- package/docs/tr/packages/react-intlayer/index.md +148 -0
- package/docs/tr/packages/react-intlayer/t.md +304 -0
- package/docs/tr/packages/react-intlayer/useDictionary.md +554 -0
- package/docs/tr/packages/react-intlayer/useI18n.md +478 -0
- package/docs/tr/packages/react-intlayer/useIntlayer.md +253 -0
- package/docs/tr/packages/react-intlayer/useLocale.md +212 -0
- package/docs/tr/packages/react-native-intlayer/index.md +85 -0
- package/docs/tr/packages/react-scripts-intlayer/index.md +82 -0
- package/docs/tr/packages/solid-intlayer/index.md +56 -0
- package/docs/tr/packages/svelte-intlayer/index.md +55 -0
- package/docs/tr/packages/vite-intlayer/index.md +82 -0
- package/docs/tr/packages/vue-intlayer/index.md +59 -0
- package/docs/tr/per_locale_file.md +321 -0
- package/docs/tr/readme.md +261 -0
- package/docs/tr/roadmap.md +338 -0
- package/docs/tr/testing.md +200 -0
- package/docs/tr/vs_code_extension.md +154 -0
- package/docs/zh/autoFill.md +40 -18
- package/docs/zh/configuration.md +245 -226
- package/docs/zh/dictionary/content_file.md +1064 -0
- package/docs/zh/intlayer_CMS.md +4 -5
- package/docs/zh/intlayer_with_nestjs.md +268 -0
- package/docs/zh/intlayer_with_nextjs_page_router.md +1 -1
- package/docs/zh/intlayer_with_react_router_v7.md +535 -0
- package/docs/zh/intlayer_with_tanstack.md +468 -278
- package/docs/zh/intlayer_with_vite+preact.md +7 -7
- package/docs/zh/intlayer_with_vite+react.md +7 -7
- package/docs/zh/intlayer_with_vite+vue.md +7 -7
- package/docs/zh/packages/vite-intlayer/index.md +3 -3
- package/docs/zh/readme.md +261 -0
- package/docs/zh/testing.md +198 -0
- package/frequent_questions/tr/SSR_Next_no_[locale].md +105 -0
- package/frequent_questions/tr/array_as_content_declaration.md +72 -0
- package/frequent_questions/tr/build_dictionaries.md +59 -0
- package/frequent_questions/tr/build_error_CI_CD.md +75 -0
- package/frequent_questions/tr/customized_locale_list.md +65 -0
- package/frequent_questions/tr/domain_routing.md +114 -0
- package/frequent_questions/tr/esbuild_error.md +30 -0
- package/frequent_questions/tr/get_locale_cookie.md +142 -0
- package/frequent_questions/tr/intlayer_command_undefined.md +156 -0
- package/frequent_questions/tr/locale_incorect_in_url.md +74 -0
- package/frequent_questions/tr/static_rendering.md +45 -0
- package/frequent_questions/tr/translated_path_url.md +56 -0
- package/frequent_questions/tr/unknown_command.md +98 -0
- package/legal/tr/privacy_notice.md +83 -0
- package/legal/tr/terms_of_service.md +55 -0
- package/package.json +13 -13
- package/src/generated/blog.entry.ts +212 -0
- package/src/generated/docs.entry.ts +663 -135
- package/src/generated/frequentQuestions.entry.ts +85 -1
- package/src/generated/legal.entry.ts +7 -1
- package/docs/ar/dictionary/content_extention_customization.md +0 -100
- package/docs/ar/dictionary/get_started.md +0 -527
- package/docs/de/dictionary/content_extention_customization.md +0 -100
- package/docs/de/dictionary/get_started.md +0 -531
- package/docs/en/dictionary/content_extention_customization.md +0 -102
- package/docs/en/dictionary/get_started.md +0 -529
- package/docs/en-GB/dictionary/content_extention_customization.md +0 -100
- package/docs/en-GB/dictionary/get_started.md +0 -591
- package/docs/es/dictionary/content_extention_customization.md +0 -100
- package/docs/es/dictionary/get_started.md +0 -527
- package/docs/fr/dictionary/content_extention_customization.md +0 -100
- package/docs/fr/dictionary/get_started.md +0 -527
- package/docs/hi/dictionary/content_extention_customization.md +0 -100
- package/docs/hi/dictionary/get_started.md +0 -527
- package/docs/it/dictionary/content_extention_customization.md +0 -113
- package/docs/it/dictionary/get_started.md +0 -573
- package/docs/ja/dictionary/content_extention_customization.md +0 -113
- package/docs/ja/dictionary/get_started.md +0 -576
- package/docs/ko/dictionary/content_extention_customization.md +0 -100
- package/docs/ko/dictionary/get_started.md +0 -530
- package/docs/pt/dictionary/content_extention_customization.md +0 -100
- package/docs/pt/dictionary/get_started.md +0 -532
- package/docs/ru/dictionary/content_extention_customization.md +0 -100
- package/docs/ru/dictionary/get_started.md +0 -575
- package/docs/zh/dictionary/content_extention_customization.md +0 -117
- package/docs/zh/dictionary/get_started.md +0 -533
|
@@ -0,0 +1,1484 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-09-07
|
|
3
|
+
updatedAt: 2025-09-07
|
|
4
|
+
title: Next.js ve Sayfa Yönlendirici web sitenizi çevirin (i18n)
|
|
5
|
+
description: Next.js Sayfa Yönlendirici kullanarak web sitenizi çok dilli hale getirmeyi öğrenin. Next.js uygulamanızda uluslararasılaştırma (i18n) ve çeviri yapmak için dokümantasyonu takip edin.
|
|
6
|
+
keywords:
|
|
7
|
+
- Uluslararasılaştırma
|
|
8
|
+
- Dokümantasyon
|
|
9
|
+
- Intlayer
|
|
10
|
+
- Sayfa Yönlendirici
|
|
11
|
+
- Next.js
|
|
12
|
+
- JavaScript
|
|
13
|
+
- React
|
|
14
|
+
slugs:
|
|
15
|
+
- doc
|
|
16
|
+
- environment
|
|
17
|
+
- nextjs
|
|
18
|
+
- next-with-Page-Router
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# Intlayer ve Next.js Sayfa Yönlendirici ile uluslararasılaştırma (i18n) başlangıç kılavuzu
|
|
22
|
+
|
|
23
|
+
## Intlayer Nedir?
|
|
24
|
+
|
|
25
|
+
**Intlayer**, modern web uygulamalarında çok dilli desteği basitleştirmek için tasarlanmış yenilikçi, açık kaynaklı bir uluslararasılaştırma (i18n) kütüphanesidir. Geleneksel **Sayfa Yönlendirici** ile **Next.js** framework'ü ile sorunsuz bir şekilde entegre olur.
|
|
26
|
+
|
|
27
|
+
Intlayer ile şunları yapabilirsiniz:
|
|
28
|
+
|
|
29
|
+
- **Çevirileri bildirimsel sözlükler kullanarak kolayca yönetin** bileşen düzeyinde.
|
|
30
|
+
- **Meta verileri, rotaları ve içeriği dinamik olarak yerelleştirin**.
|
|
31
|
+
- **TypeScript desteği sağlayın**, otomatik tamamlama ve hata algılama ile geliştirin.
|
|
32
|
+
- **Gelişmiş özelliklerden yararlanın**, dinamik yerel algılama ve anahtarlama gibi.
|
|
33
|
+
|
|
34
|
+
> Intlayer, Next.js 12, 13, 14 ve 15 ile uyumludur. App Router kullanıyorsanız, [App Router kılavuzuna](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_nextjs_14.md) bakın. Next.js 15 için bu [kılavuza](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_nextjs_15.md) bakın.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Sayfa Yönlendirici Kullanarak Next.js Uygulamasında Intlayer Kurulumu Adım Adım Kılavuzu
|
|
39
|
+
|
|
40
|
+
### Adım 1: Bağımlılıkları Kurma
|
|
41
|
+
|
|
42
|
+
Tercih ettiğiniz paket yöneticisini kullanarak gerekli paketleri kurun:
|
|
43
|
+
|
|
44
|
+
```bash packageManager="npm"
|
|
45
|
+
npm install intlayer next-intlayer
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```bash packageManager="pnpm"
|
|
49
|
+
pnpm add intlayer next-intlayer
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```bash packageManager="yarn"
|
|
53
|
+
yarn add intlayer next-intlayer
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
- **intlayer**
|
|
57
|
+
|
|
58
|
+
Yapılandırma yönetimi, çeviri, [içerik bildirimi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/get_started.md), derleme ve [CLI komutları](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_cli.md) için uluslararasılaştırma araçları sağlayan çekirdek paket.
|
|
59
|
+
|
|
60
|
+
- **next-intlayer**
|
|
61
|
+
|
|
62
|
+
Intlayer'ı Next.js ile entegre eden paket. Next.js için bağlam sağlayıcıları ve kancalar sağlar. Ayrıca, Intlayer'ı [Webpack](https://webpack.js.org/) veya [Turbopack](https://nextjs.org/docs/app/api-reference/turbopack) ile entegre etmek için Next.js eklentisini içerir, ayrıca kullanıcının tercih ettiği yerel ayarı algılamak, çerezleri yönetmek ve URL yönlendirmesini işlemek için middleware içerir.
|
|
63
|
+
|
|
64
|
+
### Adım 2: Projenizi Yapılandırma
|
|
65
|
+
|
|
66
|
+
Uygulamanızın desteklediği dilleri tanımlamak için bir yapılandırma dosyası oluşturun:
|
|
67
|
+
|
|
68
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
69
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
70
|
+
|
|
71
|
+
const config: IntlayerConfig = {
|
|
72
|
+
internationalization: {
|
|
73
|
+
locales: [
|
|
74
|
+
Locales.ENGLISH,
|
|
75
|
+
Locales.FRENCH,
|
|
76
|
+
Locales.SPANISH,
|
|
77
|
+
// Diğer yerel ayarlarınızı buraya ekleyin
|
|
78
|
+
],
|
|
79
|
+
defaultLocale: Locales.ENGLISH,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default config;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
87
|
+
import { Locales } from "intlayer";
|
|
88
|
+
|
|
89
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
90
|
+
const config = {
|
|
91
|
+
internationalization: {
|
|
92
|
+
locales: [
|
|
93
|
+
Locales.ENGLISH,
|
|
94
|
+
Locales.FRENCH,
|
|
95
|
+
Locales.SPANISH,
|
|
96
|
+
// Diğer yerel ayarlarınızı buraya ekleyin
|
|
97
|
+
],
|
|
98
|
+
defaultLocale: Locales.ENGLISH,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export default config;
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
106
|
+
const { Locales } = require("intlayer");
|
|
107
|
+
|
|
108
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
109
|
+
const config = {
|
|
110
|
+
internationalization: {
|
|
111
|
+
locales: [
|
|
112
|
+
Locales.ENGLISH,
|
|
113
|
+
Locales.FRENCH,
|
|
114
|
+
Locales.SPANISH,
|
|
115
|
+
// Diğer yerel ayarlarınızı buraya ekleyin
|
|
116
|
+
],
|
|
117
|
+
defaultLocale: Locales.ENGLISH,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
module.exports = config;
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
> Bu yapılandırma dosyası aracılığıyla, yerelleştirilmiş URL'ler, middleware yönlendirmesi, çerez adları, içerik bildirimlerinizin konumu ve uzantısı, Intlayer günlüklerinin konsolda devre dışı bırakılması ve daha fazlasını ayarlayabilirsiniz. Kullanılabilir parametrelerin tam listesi için [yapılandırma dokümantasyonuna](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/configuration.md) bakın.
|
|
125
|
+
|
|
126
|
+
### Adım 3: Next.js Yapılandırmasında Intlayer'ı Entegre Etme
|
|
127
|
+
|
|
128
|
+
Next.js kurulumunuzu Intlayer ile uyumlu hale getirin:
|
|
129
|
+
|
|
130
|
+
```typescript fileName="next.config.mjs"
|
|
131
|
+
import { withIntlayer } from "next-intlayer/server";
|
|
132
|
+
|
|
133
|
+
/** @type {import('next').NextConfig} */
|
|
134
|
+
const nextConfig = {
|
|
135
|
+
// Mevcut Next.js yapılandırmanız
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export default withIntlayer(nextConfig);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
> `withIntlayer()` Next.js eklentisi, Intlayer'ı Next.js ile entegre etmek için kullanılır. İçerik bildirim dosyalarının oluşturulmasını sağlar ve bunları geliştirme modunda izler. Intlayer ortam değişkenlerini [Webpack](https://webpack.js.org/) veya [Turbopack](https://nextjs.org/docs/app/api-reference/turbopack) ortamlarında tanımlar. Ayrıca, performansı optimize etmek ve sunucu bileşenleriyle uyumluluğu sağlamak için takma adlar sağlar.
|
|
142
|
+
> `withIntlayer()` Next.js eklentisi promise tabanlı bir fonksiyondur.
|
|
143
|
+
|
|
144
|
+
### Adım 4: Yerel Algılama için Middleware Kurulumu
|
|
145
|
+
|
|
146
|
+
Kullanıcının tercih ettiği yerel ayarı otomatik olarak algılamak ve işlemek için middleware kurun:
|
|
147
|
+
|
|
148
|
+
```typescript fileName="src/middleware.ts" codeFormat="typescript"
|
|
149
|
+
export { intlayerMiddleware as middleware } from "next-intlayer/middleware";
|
|
150
|
+
|
|
151
|
+
export const config = {
|
|
152
|
+
matcher:
|
|
153
|
+
"/((?!api|static|assets|robots|sitemap|sw|service-worker|manifest|.*\\..*|_next).*)",
|
|
154
|
+
};
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
```javascript fileName="src/middleware.mjs" codeFormat="esm"
|
|
158
|
+
export { intlayerMiddleware as middleware } from "next-intlayer/middleware";
|
|
159
|
+
|
|
160
|
+
export const config = {
|
|
161
|
+
matcher:
|
|
162
|
+
"/((?!api|static|assets|robots|sitemap|sw|service-worker|manifest|.*\\..*|_next).*)",
|
|
163
|
+
};
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
```javascript fileName="src/middleware.cjs" codeFormat="commonjs"
|
|
167
|
+
const { intlayerMiddleware } = require("next-intlayer/middleware");
|
|
168
|
+
|
|
169
|
+
const config = {
|
|
170
|
+
matcher:
|
|
171
|
+
"/((?!api|static|assets|robots|sitemap|sw|service-worker|manifest|.*\\..*|_next).*)",
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
module.exports = { middleware: intlayerMiddleware, config };
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
> Eşleştirici parametresini uygulamanızın rotalarına uyacak şekilde uyarlayın. Daha fazla detay için [Next.js dokümantasyonunda eşleştiriciyi yapılandırma](https://nextjs.org/docs/app/building-your-application/routing/middleware) bölümüne bakın.
|
|
178
|
+
|
|
179
|
+
### Adım 5: Dinamik Yerel Rotalar Tanımlama
|
|
180
|
+
|
|
181
|
+
Kullanıcının yerel ayarına göre yerelleştirilmiş içerik sunmak için dinamik yönlendirmeyi uygulayın.
|
|
182
|
+
|
|
183
|
+
1. **Yerel Ayar Özel Sayfalar Oluşturma:**
|
|
184
|
+
|
|
185
|
+
Ana sayfa dosyanızı `[locale]` dinamik segmentini içerecek şekilde yeniden adlandırın.
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
mv src/pages/index.tsx src/pages/[locale]/index.tsx
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
2. **Yerelleştirmeyi İşlemek için `_app.tsx`'yi Güncelleme:**
|
|
192
|
+
|
|
193
|
+
`_app.tsx`'nizi Intlayer sağlayıcılarını içerecek şekilde değiştirin.
|
|
194
|
+
|
|
195
|
+
```tsx fileName="src/pages/_app.tsx" codeFormat="typescript"
|
|
196
|
+
import type { FC } from "react";
|
|
197
|
+
import type { AppProps } from "next/app";
|
|
198
|
+
import { IntlayerClientProvider } from "next-intlayer";
|
|
199
|
+
|
|
200
|
+
const App = FC<AppProps>({ Component, pageProps }) => {
|
|
201
|
+
const { locale } = pageProps;
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<IntlayerClientProvider locale={locale}>
|
|
205
|
+
<Component {...pageProps} />
|
|
206
|
+
</IntlayerClientProvider>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export default MyApp;
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
```jsx fileName="src/pages/_app.mjx" codeFormat="esm"
|
|
214
|
+
import { IntlayerClientProvider } from "next-intlayer";
|
|
215
|
+
|
|
216
|
+
const App = ({ Component, pageProps }) => (
|
|
217
|
+
<IntlayerClientProvider locale={locale}>
|
|
218
|
+
<Component {...pageProps} />
|
|
219
|
+
</IntlayerClientProvider>
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
export default App;
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
```jsx fileName="src/pages/_app.csx" codeFormat="commonjs"
|
|
226
|
+
const { IntlayerClientProvider } = require("next-intlayer");
|
|
227
|
+
|
|
228
|
+
const App = ({ Component, pageProps }) => (
|
|
229
|
+
<IntlayerClientProvider locale={locale}>
|
|
230
|
+
<Component {...pageProps} />
|
|
231
|
+
</IntlayerClientProvider>
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
module.exports = App;
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
3. **Yolları ve Özellikleri İşlemek için `getStaticPaths` ve `getStaticProps` Kurulumu:**
|
|
238
|
+
|
|
239
|
+
`[locale]/index.tsx`'nizde farklı yerel ayarları işlemek için yolları ve özellikleri tanımlayın.
|
|
240
|
+
|
|
241
|
+
```tsx fileName="src/pages/[locale]/index.tsx" codeFormat="typescript"
|
|
242
|
+
import type { FC } from "react";
|
|
243
|
+
import type { GetStaticPaths, GetStaticProps } from "next";
|
|
244
|
+
import { type Locales, getConfiguration } from "intlayer";
|
|
245
|
+
|
|
246
|
+
const HomePage: FC = () => <div>{/* İçeriğiniz burada */}</div>;
|
|
247
|
+
|
|
248
|
+
export const getStaticPaths: GetStaticPaths = () => {
|
|
249
|
+
const { internationalization } = getConfiguration();
|
|
250
|
+
const { locales } = internationalization;
|
|
251
|
+
|
|
252
|
+
const paths = locales.map((locale) => ({
|
|
253
|
+
params: { locale },
|
|
254
|
+
}));
|
|
255
|
+
|
|
256
|
+
return { paths, fallback: false };
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
export const getStaticProps: GetStaticProps = ({ params }) => {
|
|
260
|
+
const locale = params?.locale as string;
|
|
261
|
+
|
|
262
|
+
return {
|
|
263
|
+
props: {
|
|
264
|
+
locale,
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
export default HomePage;
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
```jsx fileName="src/pages/[locale]/index.mjx" codeFormat="esm"
|
|
273
|
+
import { getConfiguration } from "intlayer";
|
|
274
|
+
import { ComponentExample } from "@components/ComponentExample";
|
|
275
|
+
|
|
276
|
+
const HomePage = () => <div>{/* İçeriğiniz burada */}</div>;
|
|
277
|
+
|
|
278
|
+
export const getStaticPaths = () => {
|
|
279
|
+
const { internationalization } = getConfiguration();
|
|
280
|
+
const { locales } = internationalization;
|
|
281
|
+
|
|
282
|
+
const paths = locales.map((locale) => ({
|
|
283
|
+
params: { locale },
|
|
284
|
+
}));
|
|
285
|
+
|
|
286
|
+
return { paths, fallback: false };
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
export const getStaticProps = ({ params }) => {
|
|
290
|
+
const locale = params?.locale;
|
|
291
|
+
|
|
292
|
+
return {
|
|
293
|
+
props: {
|
|
294
|
+
locale,
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
```jsx fileName="src/pages/[locale]/index.csx" codeFormat="commonjs"
|
|
301
|
+
const { getConfiguration } = require("intlayer");
|
|
302
|
+
const { ComponentExample } = require("@components/ComponentExample");
|
|
303
|
+
|
|
304
|
+
const HomePage = () => <div>{/* İçeriğiniz burada */}</div>;
|
|
305
|
+
|
|
306
|
+
const getStaticPaths = async () => {
|
|
307
|
+
const { internationalization } = getConfiguration();
|
|
308
|
+
const { locales } = internationalization;
|
|
309
|
+
|
|
310
|
+
const paths = locales.map((locale) => ({
|
|
311
|
+
params: { locale },
|
|
312
|
+
}));
|
|
313
|
+
|
|
314
|
+
return { paths, fallback: false };
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
const getStaticProps = async ({ params }) => {
|
|
318
|
+
const locale = params?.locale;
|
|
319
|
+
|
|
320
|
+
return {
|
|
321
|
+
props: {
|
|
322
|
+
locale,
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
module.exports = {
|
|
328
|
+
getStaticProps,
|
|
329
|
+
getStaticPaths,
|
|
330
|
+
default: HomePage,
|
|
331
|
+
};
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
> `getStaticPaths` ve `getStaticProps`, Next.js Sayfa Yönlendirici'de uygulamanızın tüm yerel ayarlar için gerekli sayfaları önceden oluşturmasını sağlar. Bu yaklaşım, çalışma zamanı hesaplamasını azaltır ve iyileştirilmiş bir kullanıcı deneyimi sağlar. Daha fazla detay için Next.js'in [`getStaticPaths`](https://nextjs.org/docs/pages/building-your-application/data-fetching/get-static-paths) ve [`getStaticProps`](https://nextjs.org/docs/pages/building-your-application/data-fetching/get-static-props) dokümantasyonuna bakın.
|
|
335
|
+
|
|
336
|
+
### Adım 6: İçeriğinizi Bildirin
|
|
337
|
+
|
|
338
|
+
Çevirileri depolamak için içerik bildirimlerinizi oluşturun ve yönetin.
|
|
339
|
+
|
|
340
|
+
```tsx fileName="src/pages/[locale]/home.content.ts" contentDeclarationFormat="typescript"
|
|
341
|
+
import { t, type Dictionary } from "intlayer";
|
|
342
|
+
|
|
343
|
+
const homeContent = {
|
|
344
|
+
key: "home",
|
|
345
|
+
content: {
|
|
346
|
+
title: t({
|
|
347
|
+
en: "Welcome to My Website",
|
|
348
|
+
fr: "Bienvenue sur mon site Web",
|
|
349
|
+
es: "Bienvenido a mi sitio web",
|
|
350
|
+
}),
|
|
351
|
+
description: t({
|
|
352
|
+
en: "Get started by editing this page.",
|
|
353
|
+
fr: "Commencez par éditer cette page.",
|
|
354
|
+
es: "Comience por editar esta página.",
|
|
355
|
+
}),
|
|
356
|
+
},
|
|
357
|
+
} satisfies Dictionary;
|
|
358
|
+
|
|
359
|
+
export default homeContent;
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
```javascript fileName="src/pages/[locale]/home.content.mjs" contentDeclarationFormat="esm"
|
|
363
|
+
import { t } from "intlayer";
|
|
364
|
+
|
|
365
|
+
const homeContent = {
|
|
366
|
+
key: "home",
|
|
367
|
+
content: {
|
|
368
|
+
getStarted: {
|
|
369
|
+
main: t({
|
|
370
|
+
en: "Get started by editing this page.",
|
|
371
|
+
fr: "Commencez par éditer cette page.",
|
|
372
|
+
es: "Comience por editar esta página.",
|
|
373
|
+
}),
|
|
374
|
+
pageLink: "src/app/page.tsx",
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
export default homeContent;
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
```javascript fileName="src/pages/[locale]/home.content.cjs" contentDeclarationFormat="commonjs"
|
|
383
|
+
const { t } = require("intlayer");
|
|
384
|
+
|
|
385
|
+
const homeContent = {
|
|
386
|
+
key: "home",
|
|
387
|
+
content: {
|
|
388
|
+
getStarted: {
|
|
389
|
+
main: t({
|
|
390
|
+
en: "Get started by editing this page.",
|
|
391
|
+
fr: "Commencez par éditer cette page.",
|
|
392
|
+
es: "Comience por editar esta página.",
|
|
393
|
+
}),
|
|
394
|
+
pageLink: "src/app/page.tsx",
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
module.exports = homeContent;
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
```json fileName="src/pages/[locale]/home.content.json" contentDeclarationFormat="json"
|
|
403
|
+
{
|
|
404
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
405
|
+
"key": "home",
|
|
406
|
+
"content": {
|
|
407
|
+
"getStarted": {
|
|
408
|
+
"nodeType": "translation",
|
|
409
|
+
"translation": {
|
|
410
|
+
"en": "Get started by editing this page.",
|
|
411
|
+
"fr": "Commencez par éditer cette page.",
|
|
412
|
+
"es": "Comience por editar esta página."
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
"pageLink": {
|
|
416
|
+
"nodeType": "translation",
|
|
417
|
+
"translation": {
|
|
418
|
+
"en": "src/app/page.tsx",
|
|
419
|
+
"fr": "src/app/page.tsx",
|
|
420
|
+
"es": "src/app/page.tsx"
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
İçerik bildirim hakkında daha fazla bilgi için [içerik bildirim kılavuzuna](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/get_started.md) bakın.
|
|
428
|
+
|
|
429
|
+
### Adım 7: Kodunuzda İçeriği Kullanın
|
|
430
|
+
|
|
431
|
+
Çevirilmiş içerik görüntülemek için uygulamanız boyunca içerik sözlüklerinize erişin.
|
|
432
|
+
|
|
433
|
+
```tsx {2,6} fileName="src/pages/[locale]/index.tsx" codeFormat="typescript"
|
|
434
|
+
import type { FC } from "react";
|
|
435
|
+
import { useIntlayer } from "next-intlayer";
|
|
436
|
+
import { ComponentExample } from "@components/ComponentExample";
|
|
437
|
+
|
|
438
|
+
const HomePage: FC = () => {
|
|
439
|
+
const content = useIntlayer("home");
|
|
440
|
+
|
|
441
|
+
return (
|
|
442
|
+
<div>
|
|
443
|
+
<h1>{content.title}</h1>
|
|
444
|
+
<p>{content.description}</p>
|
|
445
|
+
<ComponentExample />
|
|
446
|
+
{/* Ek bileşenler */}
|
|
447
|
+
</div>
|
|
448
|
+
);
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
// ... getStaticPaths ve getStaticProps dahil geri kalan kod
|
|
452
|
+
|
|
453
|
+
export default HomePage;
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
```jsx {1,5} fileName="src/pages/[locale]/index.mjx" codeFormat="esm"
|
|
457
|
+
import { useIntlayer } from "next-intlayer";
|
|
458
|
+
import { ComponentExample } from "@components/ComponentExample";
|
|
459
|
+
|
|
460
|
+
const HomePage = () => {
|
|
461
|
+
const content = useIntlayer("home");
|
|
462
|
+
|
|
463
|
+
return (
|
|
464
|
+
<div>
|
|
465
|
+
<h1>{content.getStarted.main}</h1>
|
|
466
|
+
<code>{content.getStarted.pageLink}</code>
|
|
467
|
+
|
|
468
|
+
<ComponentExample />
|
|
469
|
+
{/* Ek bileşenler */}
|
|
470
|
+
</div>
|
|
471
|
+
);
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
// ... getStaticPaths ve getStaticProps dahil geri kalan kod
|
|
475
|
+
|
|
476
|
+
export default HomePage;
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
```jsx {1,5} fileName="src/pages/[locale]/index.csx" codeFormat="commonjs"
|
|
480
|
+
const { useIntlayer } = require("next-intlayer");
|
|
481
|
+
const { ComponentExample } = require("@components/ComponentExample");
|
|
482
|
+
|
|
483
|
+
const HomePage = () => {
|
|
484
|
+
const content = useIntlayer("home");
|
|
485
|
+
|
|
486
|
+
return (
|
|
487
|
+
<div>
|
|
488
|
+
<h1>{content.getStarted.main}</h1>
|
|
489
|
+
<code>{content.getStarted.pageLink}</code>
|
|
490
|
+
|
|
491
|
+
<ComponentExample />
|
|
492
|
+
{/* Ek bileşenler */}
|
|
493
|
+
</div>
|
|
494
|
+
);
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
// ... getStaticPaths ve getStaticProps dahil geri kalan kod
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
```tsx fileName="src/components/ComponentExample.tsx" codeFormat="typescript"
|
|
501
|
+
import type { FC } from "react";
|
|
502
|
+
import { useIntlayer } from "next-intlayer";
|
|
503
|
+
|
|
504
|
+
export const ComponentExample: FC = () => {
|
|
505
|
+
const content = useIntlayer("component-example"); // İlgili içerik bildirimi oluşturduğunuzdan emin olun
|
|
506
|
+
|
|
507
|
+
return (
|
|
508
|
+
<div>
|
|
509
|
+
<h2>{content.title}</h2>
|
|
510
|
+
<p>{content.content}</p>
|
|
511
|
+
</div>
|
|
512
|
+
);
|
|
513
|
+
};
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
```jsx fileName="src/components/ComponentExample.mjx" codeFormat="esm"
|
|
517
|
+
import { useIntlayer } from "next-intlayer";
|
|
518
|
+
|
|
519
|
+
const ComponentExample = () => {
|
|
520
|
+
const content = useIntlayer("component-example"); // İlgili içerik bildirimi oluşturduğunuzdan emin olun
|
|
521
|
+
|
|
522
|
+
return (
|
|
523
|
+
<div>
|
|
524
|
+
<h2>{content.title}</h2>
|
|
525
|
+
<p>{content.content}</p>
|
|
526
|
+
</div>
|
|
527
|
+
);
|
|
528
|
+
};
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
```jsx fileName="src/components/ComponentExample.csx" codeFormat="commonjs"
|
|
532
|
+
const { useIntlayer } = require("next-intlayer");
|
|
533
|
+
|
|
534
|
+
const ComponentExample = () => {
|
|
535
|
+
const content = useIntlayer("component-example"); // İlgili içerik bildirimi oluşturduğunuzdan emin olun
|
|
536
|
+
|
|
537
|
+
return (
|
|
538
|
+
<div>
|
|
539
|
+
<h2>{content.title}</h2>
|
|
540
|
+
<p>{content.content}</p>
|
|
541
|
+
</div>
|
|
542
|
+
);
|
|
543
|
+
};
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
> Çevirileri `string` niteliklerinde kullanmak istediğinizde (örneğin `alt`, `title`, `href`, `aria-label`), fonksiyonun değerini şu şekilde çağırın:
|
|
547
|
+
|
|
548
|
+
> ```jsx
|
|
549
|
+
> <img src={content.image.src.value} alt={content.image.value} />
|
|
550
|
+
> ```
|
|
551
|
+
|
|
552
|
+
> `useIntlayer` kancası hakkında daha fazla bilgi edinmek için [dokümantasyona](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/next-intlayer/useIntlayer.md) bakın.
|
|
553
|
+
|
|
554
|
+
### (İsteğe Bağlı) Adım 8: Meta verilerinizin uluslararasılaştırılması
|
|
555
|
+
|
|
556
|
+
Sayfanızın başlığı gibi meta verilerinizi uluslararasılaştırmak istiyorsanız, Next.js Sayfa Yönlendirici tarafından sağlanan `getStaticProps` fonksiyonunu kullanabilirsiniz. İçinde, meta verilerinizi çevirmek için `getIntlayer` fonksiyonundan içeriği alabilirsiniz.
|
|
557
|
+
|
|
558
|
+
```typescript fileName="src/pages/[locale]/metadata.content.ts" contentDeclarationFormat="typescript"
|
|
559
|
+
import { type Dictionary, t } from "intlayer";
|
|
560
|
+
import { type Metadata } from "next";
|
|
561
|
+
|
|
562
|
+
const metadataContent = {
|
|
563
|
+
key: "page-metadata",
|
|
564
|
+
content: {
|
|
565
|
+
title: t({
|
|
566
|
+
en: "Create Next App",
|
|
567
|
+
fr: "Créer une application Next.js",
|
|
568
|
+
es: "Crear una aplicación Next.js",
|
|
569
|
+
}),
|
|
570
|
+
description: t({
|
|
571
|
+
en: "Generated by create next app",
|
|
572
|
+
fr: "Généré par create next app",
|
|
573
|
+
es: "Generado por create next app",
|
|
574
|
+
}),
|
|
575
|
+
},
|
|
576
|
+
} satisfies Dictionary<Metadata>;
|
|
577
|
+
|
|
578
|
+
export default metadataContent;
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
```javascript fileName="src/pages/[locale]/metadata.content.mjs" contentDeclarationFormat="esm"
|
|
582
|
+
import { t } from "intlayer";
|
|
583
|
+
|
|
584
|
+
/** @type {import('intlayer').Dictionary<import('next').Metadata>} */
|
|
585
|
+
const metadataContent = {
|
|
586
|
+
key: "page-metadata",
|
|
587
|
+
content: {
|
|
588
|
+
title: t({
|
|
589
|
+
en: "Create Next App",
|
|
590
|
+
fr: "Créer une application Next.js",
|
|
591
|
+
es: "Crear una aplicación Next.js",
|
|
592
|
+
}),
|
|
593
|
+
description: t({
|
|
594
|
+
en: "Generated by create next app",
|
|
595
|
+
fr: "Généré par create next app",
|
|
596
|
+
es: "Generado por create next app",
|
|
597
|
+
}),
|
|
598
|
+
},
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
export default metadataContent;
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
```javascript fileName="src/pages/[locale]/metadata.content.cjs" codeFormat="commonjs"
|
|
605
|
+
const { t } = require("intlayer");
|
|
606
|
+
|
|
607
|
+
/** @type {import('intlayer').Dictionary<import('next').Metadata>} */
|
|
608
|
+
const metadataContent = {
|
|
609
|
+
key: "page-metadata",
|
|
610
|
+
content: {
|
|
611
|
+
title: t({
|
|
612
|
+
en: "Create Next App",
|
|
613
|
+
fr: "Créer une application Next.js",
|
|
614
|
+
es: "Crear una aplicación Next.js",
|
|
615
|
+
}),
|
|
616
|
+
description: t({
|
|
617
|
+
en: "Generated by create next app",
|
|
618
|
+
fr: "Généré par create next app",
|
|
619
|
+
es: "Generado por create next app",
|
|
620
|
+
}),
|
|
621
|
+
},
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
module.exports = metadataContent;
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
```json fileName="src/pages/[locale]/metadata.content.json" contentDeclarationFormat="json"
|
|
628
|
+
{
|
|
629
|
+
"key": "page-metadata",
|
|
630
|
+
"content": {
|
|
631
|
+
"title": {
|
|
632
|
+
"nodeType": "translation",
|
|
633
|
+
"translation": {
|
|
634
|
+
"en": "Preact logo",
|
|
635
|
+
"fr": "Logo Preact",
|
|
636
|
+
"es": "Logo Preact",
|
|
637
|
+
},
|
|
638
|
+
},
|
|
639
|
+
"description": {
|
|
640
|
+
"nodeType": "translation",
|
|
641
|
+
"translation": {
|
|
642
|
+
"en": "Generated by create next app",
|
|
643
|
+
"fr": "Généré par create next app",
|
|
644
|
+
"es": "Generado por create next app",
|
|
645
|
+
},
|
|
646
|
+
},
|
|
647
|
+
},
|
|
648
|
+
};
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
````tsx fileName="src/pages/[locale]/index.tsx" codeFormat="typescript"
|
|
652
|
+
import { GetStaticPaths, GetStaticProps } from "next";
|
|
653
|
+
import { getIntlayer, getMultilingualUrls } from "intlayer";
|
|
654
|
+
import { useIntlayer } from "next-intlayer";
|
|
655
|
+
import Head from "next/head";
|
|
656
|
+
import type { FC } from "react";
|
|
657
|
+
|
|
658
|
+
interface HomePageProps {
|
|
659
|
+
locale: string;
|
|
660
|
+
metadata: {
|
|
661
|
+
title: string;
|
|
662
|
+
description: string;
|
|
663
|
+
};
|
|
664
|
+
multilingualUrls: Record<string, string>;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
const HomePage: FC<HomePageProps> = ({
|
|
668
|
+
metadata,
|
|
669
|
+
multilingualUrls,
|
|
670
|
+
locale,
|
|
671
|
+
}) => {
|
|
672
|
+
const content = useIntlayer("page");
|
|
673
|
+
|
|
674
|
+
return (
|
|
675
|
+
<div>
|
|
676
|
+
<Head>
|
|
677
|
+
<title>{metadata.title}</title>
|
|
678
|
+
<meta name="description" content={metadata.description} />
|
|
679
|
+
{/* SEO için hreflang etiketleri oluşturun */}
|
|
680
|
+
{Object.entries(multilingualUrls).map(([lang, url]) => (
|
|
681
|
+
<link key={lang} rel="alternate" hrefLang={lang} href={url} />
|
|
682
|
+
))}
|
|
683
|
+
<link rel="canonical" href={multilingualUrls[locale]} />
|
|
684
|
+
</Head>
|
|
685
|
+
|
|
686
|
+
{/* Sayfa içeriği */}
|
|
687
|
+
<main>{/* Sayfa içeriğiniz burada */}</main>
|
|
688
|
+
</div>
|
|
689
|
+
);
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
export const getStaticProps: GetStaticProps<HomePageProps> = async ({
|
|
693
|
+
params,
|
|
694
|
+
}) => {
|
|
695
|
+
const locale = params?.locale as string;
|
|
696
|
+
|
|
697
|
+
const metadata = getIntlayer("page-metadata", locale);
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Her yerel ayar için tüm URL'leri içeren bir nesne oluşturur.
|
|
701
|
+
*
|
|
702
|
+
* Örnek:
|
|
703
|
+
* ```ts
|
|
704
|
+
* getMultilingualUrls('/about');
|
|
705
|
+
*
|
|
706
|
+
* // Döndürür
|
|
707
|
+
* // {
|
|
708
|
+
* // en: '/about',
|
|
709
|
+
* // fr: '/fr/about',
|
|
710
|
+
* // es: '/es/about',
|
|
711
|
+
* // }
|
|
712
|
+
* ```
|
|
713
|
+
*/
|
|
714
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
715
|
+
|
|
716
|
+
return {
|
|
717
|
+
props: {
|
|
718
|
+
locale,
|
|
719
|
+
metadata,
|
|
720
|
+
multilingualUrls,
|
|
721
|
+
},
|
|
722
|
+
};
|
|
723
|
+
};
|
|
724
|
+
|
|
725
|
+
export default HomePage;
|
|
726
|
+
|
|
727
|
+
// ... getStaticPaths dahil geri kalan kod
|
|
728
|
+
````
|
|
729
|
+
|
|
730
|
+
````jsx fileName="src/pages/[locale]/index.mjx" codeFormat="esm"
|
|
731
|
+
import { getIntlayer, getMultilingualUrls } from "intlayer";
|
|
732
|
+
import { useIntlayer } from "next-intlayer";
|
|
733
|
+
import Head from "next/head";
|
|
734
|
+
|
|
735
|
+
const HomePage = ({ metadata, multilingualUrls, locale }) => {
|
|
736
|
+
const content = useIntlayer("page");
|
|
737
|
+
|
|
738
|
+
return (
|
|
739
|
+
<div>
|
|
740
|
+
<Head>
|
|
741
|
+
<title>{metadata.title}</title>
|
|
742
|
+
<meta name="description" content={metadata.description} />
|
|
743
|
+
{/* SEO için hreflang etiketleri oluşturun */}
|
|
744
|
+
{Object.entries(multilingualUrls).map(([lang, url]) => (
|
|
745
|
+
<link key={lang} rel="alternate" hrefLang={lang} href={url} />
|
|
746
|
+
))}
|
|
747
|
+
<link rel="canonical" href={multilingualUrls[locale]} />
|
|
748
|
+
</Head>
|
|
749
|
+
|
|
750
|
+
{/* Sayfa içeriği */}
|
|
751
|
+
<main>{/* Sayfa içeriğiniz burada */}</main>
|
|
752
|
+
</div>
|
|
753
|
+
);
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
export const getStaticProps = async ({ params }) => {
|
|
757
|
+
const locale = params?.locale;
|
|
758
|
+
|
|
759
|
+
const metadata = getIntlayer("page-metadata", locale);
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Her yerel ayar için tüm URL'leri içeren bir nesne oluşturur.
|
|
763
|
+
*
|
|
764
|
+
* Örnek:
|
|
765
|
+
* ```ts
|
|
766
|
+
* getMultilingualUrls('/about');
|
|
767
|
+
*
|
|
768
|
+
* // Döndürür
|
|
769
|
+
* // {
|
|
770
|
+
* // en: '/about',
|
|
771
|
+
* // fr: '/fr/about',
|
|
772
|
+
* // es: '/es/about',
|
|
773
|
+
* // }
|
|
774
|
+
* ```
|
|
775
|
+
*/
|
|
776
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
777
|
+
|
|
778
|
+
return {
|
|
779
|
+
props: {
|
|
780
|
+
locale,
|
|
781
|
+
metadata,
|
|
782
|
+
multilingualUrls,
|
|
783
|
+
},
|
|
784
|
+
};
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
export default HomePage;
|
|
788
|
+
|
|
789
|
+
// ... getStaticPaths dahil geri kalan kod
|
|
790
|
+
````
|
|
791
|
+
|
|
792
|
+
````jsx fileName="src/pages/[locale]/index.csx" codeFormat="commonjs"
|
|
793
|
+
const { getIntlayer, getMultilingualUrls } = require("intlayer");
|
|
794
|
+
const { useIntlayer } = require("next-intlayer");
|
|
795
|
+
const Head = require("next/head");
|
|
796
|
+
|
|
797
|
+
const HomePage = ({ metadata, multilingualUrls, locale }) => {
|
|
798
|
+
const content = useIntlayer("page");
|
|
799
|
+
|
|
800
|
+
return (
|
|
801
|
+
<div>
|
|
802
|
+
<Head>
|
|
803
|
+
<title>{metadata.title}</title>
|
|
804
|
+
<meta name="description" content={metadata.description} />
|
|
805
|
+
{/* SEO için hreflang etiketleri oluşturun */}
|
|
806
|
+
{Object.entries(multilingualUrls).map(([lang, url]) => (
|
|
807
|
+
<link key={lang} rel="alternate" hrefLang={lang} href={url} />
|
|
808
|
+
))}
|
|
809
|
+
<link rel="canonical" href={multilingualUrls[locale]} />
|
|
810
|
+
</Head>
|
|
811
|
+
|
|
812
|
+
{/* Sayfa içeriği */}
|
|
813
|
+
<main>{/* Sayfa içeriğiniz burada */}</main>
|
|
814
|
+
</div>
|
|
815
|
+
);
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
const getStaticProps = async ({ params }) => {
|
|
819
|
+
const locale = params?.locale;
|
|
820
|
+
|
|
821
|
+
const metadata = getIntlayer("page-metadata", locale);
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Her yerel ayar için tüm URL'leri içeren bir nesne oluşturur.
|
|
825
|
+
*
|
|
826
|
+
* Example:
|
|
827
|
+
* ```ts
|
|
828
|
+
* getMultilingualUrls('/about');
|
|
829
|
+
*
|
|
830
|
+
* // Returns
|
|
831
|
+
* // {
|
|
832
|
+
* // en: '/about',
|
|
833
|
+
* // fr: '/fr/about',
|
|
834
|
+
* // es: '/es/about'
|
|
835
|
+
* // }
|
|
836
|
+
* ```
|
|
837
|
+
*/
|
|
838
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
839
|
+
|
|
840
|
+
return {
|
|
841
|
+
props: {
|
|
842
|
+
locale,
|
|
843
|
+
metadata,
|
|
844
|
+
multilingualUrls,
|
|
845
|
+
},
|
|
846
|
+
};
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
module.exports = {
|
|
850
|
+
getStaticProps,
|
|
851
|
+
getStaticPaths,
|
|
852
|
+
default: HomePage,
|
|
853
|
+
};
|
|
854
|
+
|
|
855
|
+
// ... getStaticPaths dahil geri kalan kod
|
|
856
|
+
````
|
|
857
|
+
|
|
858
|
+
> Not: `next-intlayer`'dan içe aktarılan `getIntlayer` fonksiyonu, içeriğinizi görsel düzenleyici ile entegrasyon için `IntlayerNode`'a sarılmış olarak döndürür. Aksine, `intlayer`'dan içe aktarılan `getIntlayer` fonksiyonu içeriğinizi doğrudan ek özellikler olmadan döndürür.
|
|
859
|
+
|
|
860
|
+
Alternatif olarak, meta verilerinizi bildirmek için `getTranslation` fonksiyonunu kullanabilirsiniz. Ancak, içerik bildirim dosyalarını kullanmak, meta verilerinizin çevirisini otomatikleştirmek ve içeriği bir noktada harici hale getirmek için önerilir.
|
|
861
|
+
|
|
862
|
+
```tsx fileName="src/pages/[locale]/index.tsx" codeFormat="typescript"
|
|
863
|
+
import { GetStaticPaths, GetStaticProps } from "next";
|
|
864
|
+
import {
|
|
865
|
+
type IConfigLocales,
|
|
866
|
+
getTranslation,
|
|
867
|
+
getMultilingualUrls,
|
|
868
|
+
} from "intlayer";
|
|
869
|
+
import { useIntlayer } from "next-intlayer";
|
|
870
|
+
import Head from "next/head";
|
|
871
|
+
import type { FC } from "react";
|
|
872
|
+
|
|
873
|
+
interface HomePageProps {
|
|
874
|
+
locale: string;
|
|
875
|
+
metadata: {
|
|
876
|
+
title: string;
|
|
877
|
+
description: string;
|
|
878
|
+
};
|
|
879
|
+
multilingualUrls: Record<string, string>;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
const HomePage: FC<HomePageProps> = ({ metadata, multilingualUrls, locale }) => {
|
|
883
|
+
const content = useIntlayer("page");
|
|
884
|
+
|
|
885
|
+
return (
|
|
886
|
+
<div>
|
|
887
|
+
<Head>
|
|
888
|
+
<title>{metadata.title}</title>
|
|
889
|
+
<meta name="description" content={metadata.description} />
|
|
890
|
+
{/* SEO için hreflang etiketleri oluşturun */}
|
|
891
|
+
{Object.entries(multilingualUrls).map(([lang, url]) => (
|
|
892
|
+
<link
|
|
893
|
+
key={lang}
|
|
894
|
+
rel="alternate"
|
|
895
|
+
hrefLang={lang}
|
|
896
|
+
href={url}
|
|
897
|
+
/>
|
|
898
|
+
))}
|
|
899
|
+
<link rel="canonical" href={multilingualUrls[locale]} />
|
|
900
|
+
</Head>
|
|
901
|
+
|
|
902
|
+
{/* Sayfa içeriği */}
|
|
903
|
+
<main>
|
|
904
|
+
{/* Sayfa içeriğiniz burada */}
|
|
905
|
+
</main>
|
|
906
|
+
</div>
|
|
907
|
+
);
|
|
908
|
+
};
|
|
909
|
+
|
|
910
|
+
export const getStaticProps: GetStaticProps<HomePageProps> = async ({
|
|
911
|
+
params
|
|
912
|
+
}) => {
|
|
913
|
+
const locale = params?.locale as string;
|
|
914
|
+
const t = <T>(content: IConfigLocales<T>) => getTranslation(content, locale);
|
|
915
|
+
|
|
916
|
+
const metadata = {
|
|
917
|
+
title: t<string>({
|
|
918
|
+
en: "My title",
|
|
919
|
+
fr: "Mon titre",
|
|
920
|
+
es: "Mi título",
|
|
921
|
+
}),
|
|
922
|
+
description: t({
|
|
923
|
+
en: "My description",
|
|
924
|
+
fr: "Ma description",
|
|
925
|
+
es: "Mi descripción",
|
|
926
|
+
}),
|
|
927
|
+
};
|
|
928
|
+
|
|
929
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
930
|
+
|
|
931
|
+
return {
|
|
932
|
+
props: {
|
|
933
|
+
locale,
|
|
934
|
+
metadata,
|
|
935
|
+
multilingualUrls,
|
|
936
|
+
},
|
|
937
|
+
};
|
|
938
|
+
};
|
|
939
|
+
|
|
940
|
+
export default HomePage;
|
|
941
|
+
|
|
942
|
+
// ... getStaticPaths dahil geri kalan kod
|
|
943
|
+
```
|
|
944
|
+
|
|
945
|
+
```jsx fileName="src/pages/[locale]/index.mjx" codeFormat="esm"
|
|
946
|
+
import { getTranslation, getMultilingualUrls } from "intlayer";
|
|
947
|
+
import { useIntlayer } from "next-intlayer";
|
|
948
|
+
import Head from "next/head";
|
|
949
|
+
|
|
950
|
+
const HomePage = ({ metadata, multilingualUrls, locale }) => {
|
|
951
|
+
const content = useIntlayer("page");
|
|
952
|
+
|
|
953
|
+
return (
|
|
954
|
+
<div>
|
|
955
|
+
<Head>
|
|
956
|
+
<title>{metadata.title}</title>
|
|
957
|
+
<meta name="description" content={metadata.description} />
|
|
958
|
+
{/* SEO için hreflang etiketleri oluşturun */}
|
|
959
|
+
{Object.entries(multilingualUrls).map(([lang, url]) => (
|
|
960
|
+
<link key={lang} rel="alternate" hrefLang={lang} href={url} />
|
|
961
|
+
))}
|
|
962
|
+
<link rel="canonical" href={multilingualUrls[locale]} />
|
|
963
|
+
</Head>
|
|
964
|
+
|
|
965
|
+
{/* Sayfa içeriği */}
|
|
966
|
+
<main>{/* Sayfa içeriğiniz burada */}</main>
|
|
967
|
+
</div>
|
|
968
|
+
);
|
|
969
|
+
};
|
|
970
|
+
|
|
971
|
+
export const getStaticProps = async ({ params }) => {
|
|
972
|
+
const locale = params?.locale;
|
|
973
|
+
const t = (content) => getTranslation(content, locale);
|
|
974
|
+
|
|
975
|
+
const metadata = {
|
|
976
|
+
title: t({
|
|
977
|
+
en: "My title",
|
|
978
|
+
fr: "Mon titre",
|
|
979
|
+
es: "Mi título",
|
|
980
|
+
}),
|
|
981
|
+
description: t({
|
|
982
|
+
en: "My description",
|
|
983
|
+
fr: "Ma description",
|
|
984
|
+
es: "Mi descripción",
|
|
985
|
+
}),
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
989
|
+
|
|
990
|
+
return {
|
|
991
|
+
props: {
|
|
992
|
+
locale,
|
|
993
|
+
metadata,
|
|
994
|
+
multilingualUrls,
|
|
995
|
+
},
|
|
996
|
+
};
|
|
997
|
+
};
|
|
998
|
+
|
|
999
|
+
export default HomePage;
|
|
1000
|
+
|
|
1001
|
+
// ... getStaticPaths dahil geri kalan kod
|
|
1002
|
+
```
|
|
1003
|
+
|
|
1004
|
+
```jsx fileName="src/pages/[locale]/index.csx" codeFormat="commonjs"
|
|
1005
|
+
const { getTranslation, getMultilingualUrls } = require("intlayer");
|
|
1006
|
+
const { useIntlayer } = require("next-intlayer";
|
|
1007
|
+
const Head = require("next/head";
|
|
1008
|
+
|
|
1009
|
+
const HomePage = ({ metadata, multilingualUrls, locale }) => {
|
|
1010
|
+
const content = useIntlayer("page");
|
|
1011
|
+
|
|
1012
|
+
return (
|
|
1013
|
+
<div>
|
|
1014
|
+
<Head>
|
|
1015
|
+
<title>{metadata.title}</title>
|
|
1016
|
+
<meta name="description" content={metadata.description} />
|
|
1017
|
+
{/* SEO için hreflang etiketleri oluşturun */}
|
|
1018
|
+
{Object.entries(multilingualUrls).map(([lang, url]) => (
|
|
1019
|
+
<link key={lang} rel="alternate" hrefLang={lang} href={url} />
|
|
1020
|
+
))}
|
|
1021
|
+
<link rel="canonical" href={multilingualUrls[locale]} />
|
|
1022
|
+
</Head>
|
|
1023
|
+
|
|
1024
|
+
{/* Sayfa içeriği */}
|
|
1025
|
+
<main>{/* Sayfa içeriğiniz burada */}</main>
|
|
1026
|
+
</div>
|
|
1027
|
+
);
|
|
1028
|
+
};
|
|
1029
|
+
|
|
1030
|
+
const getStaticProps = async ({ params }) => {
|
|
1031
|
+
const locale = params?.locale;
|
|
1032
|
+
|
|
1033
|
+
const t = (content) => getTranslation(content, locale);
|
|
1034
|
+
|
|
1035
|
+
const metadata = {
|
|
1036
|
+
title: t({
|
|
1037
|
+
en: "My title",
|
|
1038
|
+
fr: "Mon titre",
|
|
1039
|
+
es: "Mi título",
|
|
1040
|
+
}),
|
|
1041
|
+
description: t({
|
|
1042
|
+
en: "My description",
|
|
1043
|
+
fr: "Ma description",
|
|
1044
|
+
es: "Mi descripción",
|
|
1045
|
+
}),
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
const multilingualUrls = getMultilingualUrls("/");
|
|
1049
|
+
|
|
1050
|
+
return {
|
|
1051
|
+
props: {
|
|
1052
|
+
locale,
|
|
1053
|
+
metadata,
|
|
1054
|
+
multilingualUrls,
|
|
1055
|
+
},
|
|
1056
|
+
};
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
module.exports = {
|
|
1060
|
+
getStaticProps,
|
|
1061
|
+
getStaticPaths,
|
|
1062
|
+
default: HomePage,
|
|
1063
|
+
};
|
|
1064
|
+
|
|
1065
|
+
// ... getStaticPaths dahil geri kalan kod
|
|
1066
|
+
```
|
|
1067
|
+
|
|
1068
|
+
> Meta veri optimizasyonu hakkında daha fazla bilgi edinmek için resmi [Next.js dokümantasyonuna](https://nextjs.org/docs/pages/building-your-application/optimizing/metadata) bakın.
|
|
1069
|
+
|
|
1070
|
+
### (İsteğe Bağlı) Adım 9: İçeriğinizin dilini değiştirme
|
|
1071
|
+
|
|
1072
|
+
Next.js'te içeriğinizin dilini değiştirmek için, kullanıcıları uygun yerelleştirilmiş sayfaya yönlendirmek için `Link` bileşenini kullanmak önerilen yoldur. `Link` bileşeni, sayfa ön yüklemesini etkinleştirir, bu da tam sayfa yeniden yüklemeden kaçınmaya yardımcı olur.
|
|
1073
|
+
|
|
1074
|
+
```tsx fileName="src/components/LanguageSwitcher.tsx" codeFormat="typescript"
|
|
1075
|
+
import {
|
|
1076
|
+
Locales,
|
|
1077
|
+
getHTMLTextDir,
|
|
1078
|
+
getLocaleName,
|
|
1079
|
+
getLocalizedUrl,
|
|
1080
|
+
} from "intlayer";
|
|
1081
|
+
import { useLocalePageRouter } from "next-intlayer";
|
|
1082
|
+
import { type FC } from "react";
|
|
1083
|
+
import Link from "next/link";
|
|
1084
|
+
|
|
1085
|
+
const LocaleSwitcher: FC = () => {
|
|
1086
|
+
const { locale, pathWithoutLocale, availableLocales } = useLocalePageRouter();
|
|
1087
|
+
const { setLocaleCookie } = useLocaleCookie();
|
|
1088
|
+
|
|
1089
|
+
return (
|
|
1090
|
+
<div>
|
|
1091
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1092
|
+
<div id="localePopover" popover="auto">
|
|
1093
|
+
{availableLocales.map((localeItem) => (
|
|
1094
|
+
<Link
|
|
1095
|
+
href={getLocalizedUrl(pathWithoutLocale, localeItem)}
|
|
1096
|
+
hrefLang={localeItem}
|
|
1097
|
+
key={localeItem}
|
|
1098
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1099
|
+
onClick={() => setLocaleCookie(localeItem)}
|
|
1100
|
+
>
|
|
1101
|
+
<span>
|
|
1102
|
+
{/* Yerel ayar - örn. FR */}
|
|
1103
|
+
{localeItem}
|
|
1104
|
+
</span>
|
|
1105
|
+
<span>
|
|
1106
|
+
{/* Kendi yerel ayarındaki dil - örn. Français */}
|
|
1107
|
+
{getLocaleName(localeItem, locale)}
|
|
1108
|
+
</span>
|
|
1109
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1110
|
+
{/* Geçerli yerel ayar set edildiğinde dil - örn. Locales.SPANISH set edildiğinde Francés */}
|
|
1111
|
+
{getLocaleName(localeItem)}
|
|
1112
|
+
</span>
|
|
1113
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1114
|
+
{/* İngilizce'deki dil - örn. French */}
|
|
1115
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1116
|
+
</span>
|
|
1117
|
+
</Link>
|
|
1118
|
+
))}
|
|
1119
|
+
</div>
|
|
1120
|
+
</div>
|
|
1121
|
+
);
|
|
1122
|
+
};
|
|
1123
|
+
```
|
|
1124
|
+
|
|
1125
|
+
```jsx fileName="src/components/LanguageSwitcher.msx" codeFormat="esm"
|
|
1126
|
+
import {
|
|
1127
|
+
Locales,
|
|
1128
|
+
getHTMLTextDir,
|
|
1129
|
+
getLocaleName,
|
|
1130
|
+
getLocalizedUrl,
|
|
1131
|
+
} from "intlayer";
|
|
1132
|
+
import { useLocalePageRouter } from "next-intlayer";
|
|
1133
|
+
import Link from "next/link";
|
|
1134
|
+
|
|
1135
|
+
const LocaleSwitcher = () => {
|
|
1136
|
+
const { locale, pathWithoutLocale, availableLocales } = useLocalePageRouter();
|
|
1137
|
+
const { setLocaleCookie } = useLocaleCookie();
|
|
1138
|
+
|
|
1139
|
+
return (
|
|
1140
|
+
<div>
|
|
1141
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1142
|
+
<div id="localePopover" popover="auto">
|
|
1143
|
+
{availableLocales.map((localeItem) => (
|
|
1144
|
+
<Link
|
|
1145
|
+
href={getLocalizedUrl(pathWithoutLocale, localeItem)}
|
|
1146
|
+
hrefLang={localeItem}
|
|
1147
|
+
key={localeItem}
|
|
1148
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1149
|
+
onClick={() => setLocaleCookie(localeItem)}
|
|
1150
|
+
>
|
|
1151
|
+
<span>
|
|
1152
|
+
{/* Yerel ayar - örn. FR */}
|
|
1153
|
+
{localeItem}
|
|
1154
|
+
</span>
|
|
1155
|
+
<span>
|
|
1156
|
+
{/* Kendi yerel ayarındaki dil - örn. Français */}
|
|
1157
|
+
{getLocaleName(localeItem, locale)}
|
|
1158
|
+
</span>
|
|
1159
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1160
|
+
{/* Geçerli yerel ayar set edildiğinde dil - örn. Locales.SPANISH set edildiğinde Francés */}
|
|
1161
|
+
{getLocaleName(localeItem)}
|
|
1162
|
+
</span>
|
|
1163
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1164
|
+
{/* İngilizce'deki dil - örn. French */}
|
|
1165
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1166
|
+
</span>
|
|
1167
|
+
</Link>
|
|
1168
|
+
))}
|
|
1169
|
+
</div>
|
|
1170
|
+
</div>
|
|
1171
|
+
);
|
|
1172
|
+
};
|
|
1173
|
+
```
|
|
1174
|
+
|
|
1175
|
+
```jsx fileName="src/components/LanguageSwitcher.msx" codeFormat="commonjs"
|
|
1176
|
+
const {
|
|
1177
|
+
Locales,
|
|
1178
|
+
getHTMLTextDir,
|
|
1179
|
+
getLocaleName,
|
|
1180
|
+
getLocalizedUrl,
|
|
1181
|
+
} = require("intlayer");
|
|
1182
|
+
const { useLocalePageRouter } = require("next-intlayer");
|
|
1183
|
+
const Link = require("next/link");
|
|
1184
|
+
|
|
1185
|
+
const LocaleSwitcher = () => {
|
|
1186
|
+
const { locale, pathWithoutLocale, availableLocales } = useLocalePageRouter();
|
|
1187
|
+
const { setLocaleCookie } = useLocaleCookie();
|
|
1188
|
+
|
|
1189
|
+
return (
|
|
1190
|
+
<select>
|
|
1191
|
+
{availableLocales.map((localeItem) => (
|
|
1192
|
+
<option value={localeItem} key={localeItem}>
|
|
1193
|
+
<Link
|
|
1194
|
+
href={getLocalizedUrl(pathWithoutLocale, localeItem)}
|
|
1195
|
+
hrefLang={localeItem}
|
|
1196
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1197
|
+
onClick={() => setLocaleCookie(localeItem)}
|
|
1198
|
+
>
|
|
1199
|
+
<span>
|
|
1200
|
+
{/* Yerel ayar - örn. FR */}
|
|
1201
|
+
{localeItem}
|
|
1202
|
+
</span>
|
|
1203
|
+
<span>
|
|
1204
|
+
{/* Kendi yerel ayarındaki dil - örn. Français */}
|
|
1205
|
+
{getLocaleName(localeItem, locale)}
|
|
1206
|
+
</span>
|
|
1207
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1208
|
+
{/* Geçerli yerel ayar set edildiğinde dil - örn. Locales.SPANISH set edildiğinde Francés */}
|
|
1209
|
+
{getLocaleName(localeItem)}
|
|
1210
|
+
</span>
|
|
1211
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1212
|
+
{/* İngilizce'deki dil - örn. French */}
|
|
1213
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1214
|
+
</span>
|
|
1215
|
+
</Link>
|
|
1216
|
+
</option>
|
|
1217
|
+
))}
|
|
1218
|
+
</select>
|
|
1219
|
+
);
|
|
1220
|
+
};
|
|
1221
|
+
```
|
|
1222
|
+
|
|
1223
|
+
> Alternatif bir yol, `useLocale` kancası tarafından sağlanan `setLocale` fonksiyonunu kullanmaktır. Bu fonksiyon, sayfa ön yüklemesine izin vermez ve sayfayı yeniden yükler.
|
|
1224
|
+
|
|
1225
|
+
> Bu durumda, `router.push` kullanarak yönlendirme olmadan, sadece sunucu tarafı kodunuz içeriğin yerel ayarını değiştirecektir.
|
|
1226
|
+
|
|
1227
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
1228
|
+
"use client";
|
|
1229
|
+
|
|
1230
|
+
import { useRouter } from "next/navigation";
|
|
1231
|
+
import { useLocale } from "next-intlayer";
|
|
1232
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1233
|
+
|
|
1234
|
+
// ... Geri kalan kod
|
|
1235
|
+
|
|
1236
|
+
const router = useRouter();
|
|
1237
|
+
const { setLocale } = useLocale({
|
|
1238
|
+
onLocaleChange: (locale) => {
|
|
1239
|
+
router.push(getLocalizedUrl(pathWithoutLocale, locale));
|
|
1240
|
+
},
|
|
1241
|
+
});
|
|
1242
|
+
|
|
1243
|
+
return (
|
|
1244
|
+
<button onClick={() => setLocale(Locales.FRENCH)}>Fransızca'ya Geç</button>
|
|
1245
|
+
);
|
|
1246
|
+
```
|
|
1247
|
+
|
|
1248
|
+
> `useLocalePageRouter` API'si `useLocale` ile aynıdır. `useLocale` kancası hakkında daha fazla bilgi edinmek için [dokümantasyona](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/next-intlayer/useLocale.md) bakın.
|
|
1249
|
+
|
|
1250
|
+
> Dokümantasyon referansları:
|
|
1251
|
+
>
|
|
1252
|
+
> - [`getLocaleName` kancası](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/intlayer/getLocaleName.md)
|
|
1253
|
+
> - [`getLocalizedUrl` kancası](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/intlayer/getLocalizedUrl.md)
|
|
1254
|
+
> - [`getHTMLTextDir` kancası](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/intlayer/getHTMLTextDir.md)
|
|
1255
|
+
> - [`hrefLang` özelliği](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
|
|
1256
|
+
> - [`lang` özelliği](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
|
|
1257
|
+
> - [`dir` özelliği](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
|
|
1258
|
+
> - [`aria-current` özelliği](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1259
|
+
|
|
1260
|
+
### (İsteğe Bağlı) Adım 10: Yerelleştirilmiş Bağlantı Bileşeni Oluşturma
|
|
1261
|
+
|
|
1262
|
+
Uygulamanızın navigasyonunun mevcut yerel ayarı saygı göstermesini sağlamak için, özel bir `Link` bileşeni oluşturabilirsiniz. Bu bileşen, dahili URL'leri otomatik olarak mevcut dille önekler, böylece örneğin Fransızca konuşan bir kullanıcı "Hakkında" sayfasına bir bağlantıya tıkladığında, `/fr/hakkinda` yerine `/hakkinda`ya yönlendirilir.
|
|
1263
|
+
|
|
1264
|
+
Bu davranış birkaç nedenden dolayı kullanışlıdır:
|
|
1265
|
+
|
|
1266
|
+
- **SEO ve Kullanıcı Deneyimi**: Yerelleştirilmiş URL'ler, arama motorlarının dil özel sayfalarını doğru şekilde indekslemesine yardımcı olur ve kullanıcılara tercih ettikleri dilde içerik sağlar.
|
|
1267
|
+
- **Tutarlılık**: Uygulamanız boyunca yerelleştirilmiş bir bağlantı kullanarak, navigasyonun mevcut yerel ayar içinde kalmasını garanti edersiniz, beklenmedik dil anahtarlarını önlersiniz.
|
|
1268
|
+
- **Bakım Kolaylığı**: URL yönetim mantığını tek bir bileşende merkezileştirmek, kod tabanınızı yönetmeyi ve uygulamanız büyüdükçe genişletmeyi basitleştirir.
|
|
1269
|
+
|
|
1270
|
+
Aşağıda, TypeScript'te yerelleştirilmiş bir `Link` bileşeninin uygulanması bulunmaktadır:
|
|
1271
|
+
|
|
1272
|
+
```tsx fileName="src/components/Link.tsx" codeFormat="typescript"
|
|
1273
|
+
"use client";
|
|
1274
|
+
|
|
1275
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1276
|
+
import NextLink, { type LinkProps as NextLinkProps } from "next/link";
|
|
1277
|
+
import { useLocale } from "next-intlayer";
|
|
1278
|
+
import { forwardRef, PropsWithChildren, type ForwardedRef } from "react";
|
|
1279
|
+
|
|
1280
|
+
/**
|
|
1281
|
+
* Verilen bir URL'nin harici olup olmadığını kontrol eden yardımcı fonksiyon.
|
|
1282
|
+
* URL http:// veya https:// ile başlıyorsa, harici olarak kabul edilir.
|
|
1283
|
+
*/
|
|
1284
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1285
|
+
/^https?:\/\//.test(href ?? "");
|
|
1286
|
+
|
|
1287
|
+
/**
|
|
1288
|
+
* Href özelliğini mevcut yerel ayar temelinde uyarlayan özel bir Link bileşeni.
|
|
1289
|
+
* Dahili bağlantılar için, `getLocalizedUrl` kullanarak URL'yi yerel ayar ile önekler (örneğin, /fr/hakkinda).
|
|
1290
|
+
* Bu, navigasyonun aynı yerel ayar bağlamında kalmasını sağlar.
|
|
1291
|
+
*/
|
|
1292
|
+
export const Link = forwardRef<
|
|
1293
|
+
HTMLAnchorElement,
|
|
1294
|
+
PropsWithChildren<NextLinkProps>
|
|
1295
|
+
>(({ href, children, ...props }, ref: ForwardedRef<HTMLAnchorElement>) => {
|
|
1296
|
+
const { locale } = useLocale();
|
|
1297
|
+
const isExternalLink = checkIsExternalLink(href.toString());
|
|
1298
|
+
|
|
1299
|
+
// Bağlantı dahili ise ve geçerli bir href sağlanmışsa, yerelleştirilmiş URL'yi alın.
|
|
1300
|
+
const hrefI18n: NextLinkProps["href"] =
|
|
1301
|
+
href && !isExternalLink ? getLocalizedUrl(href.toString(), locale) : href;
|
|
1302
|
+
|
|
1303
|
+
return (
|
|
1304
|
+
<NextLink href={hrefI18n} ref={ref} {...props}>
|
|
1305
|
+
{children}
|
|
1306
|
+
</NextLink>
|
|
1307
|
+
);
|
|
1308
|
+
});
|
|
1309
|
+
|
|
1310
|
+
Link.displayName = "Link";
|
|
1311
|
+
```
|
|
1312
|
+
|
|
1313
|
+
```jsx fileName="src/components/Link.mjx" codeFormat="esm"
|
|
1314
|
+
'use client';
|
|
1315
|
+
|
|
1316
|
+
import { getLocalizedUrl } from 'intlayer';
|
|
1317
|
+
import NextLink, { type LinkProps as NextLinkProps } from 'next/link';
|
|
1318
|
+
import { useLocale } from 'next-intlayer';
|
|
1319
|
+
import { forwardRef, PropsWithChildren, type ForwardedRef } from 'react';
|
|
1320
|
+
|
|
1321
|
+
/**
|
|
1322
|
+
* Verilen bir URL'nin harici olup olmadığını kontrol eden yardımcı fonksiyon.
|
|
1323
|
+
* URL http:// veya https:// ile başlıyorsa, harici olarak kabul edilir.
|
|
1324
|
+
*/
|
|
1325
|
+
export const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? '');
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* Href özelliğini mevcut yerel ayar temelinde uyarlayan özel bir Link bileşeni.
|
|
1329
|
+
* Dahili bağlantılar için, `getLocalizedUrl` kullanarak URL'yi yerel ayar ile önekler (örneğin, /fr/hakkinda).
|
|
1330
|
+
* Bu, navigasyonun aynı yerel ayar bağlamında kalmasını sağlar.
|
|
1331
|
+
*/
|
|
1332
|
+
export const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1333
|
+
const { locale } = useLocale();
|
|
1334
|
+
const isExternalLink = checkIsExternalLink(href.toString());
|
|
1335
|
+
|
|
1336
|
+
// Bağlantı dahili ise ve geçerli bir href sağlanmışsa, yerelleştirilmiş URL'yi alın.
|
|
1337
|
+
const hrefI18n =
|
|
1338
|
+
href && !isExternalLink ? getLocalizedUrl(href.toString(), locale) : href;
|
|
1339
|
+
|
|
1340
|
+
return (
|
|
1341
|
+
<NextLink href={hrefI18n} ref={ref} {...props}>
|
|
1342
|
+
{children}
|
|
1343
|
+
</NextLink>
|
|
1344
|
+
);
|
|
1345
|
+
});
|
|
1346
|
+
|
|
1347
|
+
Link.displayName = 'Link';
|
|
1348
|
+
```
|
|
1349
|
+
|
|
1350
|
+
```jsx fileName="src/components/Link.csx" codeFormat="commonjs"
|
|
1351
|
+
'use client';
|
|
1352
|
+
|
|
1353
|
+
const { getLocalizedUrl } = require("intlayer");
|
|
1354
|
+
const NextLink = require("next/link");
|
|
1355
|
+
const { useLocale } = require("next-intlayer");
|
|
1356
|
+
const { forwardRef } = require("react");
|
|
1357
|
+
|
|
1358
|
+
/**
|
|
1359
|
+
* Verilen bir URL'nin harici olup olmadığını kontrol eden yardımcı fonksiyon.
|
|
1360
|
+
* URL http:// veya https:// ile başlıyorsa, harici olarak kabul edilir.
|
|
1361
|
+
*/
|
|
1362
|
+
const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? '');
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1366
|
+
const { locale } = useLocale();
|
|
1367
|
+
const isExternalLink = checkIsExternalLink(href.toString());
|
|
1368
|
+
|
|
1369
|
+
// Bağlantı dahili ise ve geçerli bir href sağlanmışsa, yerelleştirilmiş URL'yi alın.
|
|
1370
|
+
const hrefI18n: NextLinkProps['href'] =
|
|
1371
|
+
href && !isExternalLink ? getLocalizedUrl(href.toString(), locale) : href;
|
|
1372
|
+
|
|
1373
|
+
return (
|
|
1374
|
+
<NextLink href={hrefI18n} ref={ref} {...props}>
|
|
1375
|
+
{children}
|
|
1376
|
+
</NextLink>
|
|
1377
|
+
);
|
|
1378
|
+
});
|
|
1379
|
+
|
|
1380
|
+
Link.displayName = 'Link';
|
|
1381
|
+
```
|
|
1382
|
+
|
|
1383
|
+
#### Nasıl Çalışır
|
|
1384
|
+
|
|
1385
|
+
- **Harici Bağlantıları Algılama**:
|
|
1386
|
+
Yardımcı fonksiyon `checkIsExternalLink`, bir URL'nin harici olup olmadığını belirler. Harici bağlantılar değişmeden bırakılır çünkü yerelleştirmeye ihtiyaçları yoktur.
|
|
1387
|
+
|
|
1388
|
+
- **Mevcut Yerel Ayarı Alma**:
|
|
1389
|
+
`useLocale` kancası mevcut yerel ayarı sağlar (örneğin, Fransızca için `fr`).
|
|
1390
|
+
|
|
1391
|
+
- **URL'yi Yerelleştirme**:
|
|
1392
|
+
Dahili bağlantılar (yani harici olmayan) için, `getLocalizedUrl` kullanarak URL'yi otomatik olarak mevcut yerel ayar ile önekler. Bu, kullanıcınız Fransızca ise, `/hakkinda` href'ini geçmek onu `/fr/hakkinda`ya dönüştürür.
|
|
1393
|
+
|
|
1394
|
+
- **Bağlantıyı Döndürme**:
|
|
1395
|
+
Bileşen, yerelleştirilmiş URL ile bir `<a>` elementi döndürür, böylece navigasyon yerel ayar ile tutarlı olur.
|
|
1396
|
+
|
|
1397
|
+
Bu `Link` bileşenini uygulamanız boyunca entegre ederek, tutarlı ve dil bilincine sahip bir kullanıcı deneyimi sürdürürsünüzken aynı zamanda gelişmiş SEO ve kullanılabilirlikten de yararlanırsınız.
|
|
1398
|
+
|
|
1399
|
+
### (İsteğe Bağlı) Adım 11: Paket Boyutunuzu Optimize Edin
|
|
1400
|
+
|
|
1401
|
+
`next-intlayer` kullanırken, sözlükler varsayılan olarak her sayfa için pakete dahil edilir. Paket boyutunu optimize etmek için, Intlayer isteğe bağlı bir SWC eklentisi sağlar ki bu, `useIntlayer` çağrılarını akıllıca makrolar kullanarak değiştirir. Bu, sözlüklerin sadece onları gerçekten kullanan sayfalar için paketlere dahil edilmesini sağlar.
|
|
1402
|
+
|
|
1403
|
+
Bu optimizasyonu etkinleştirmek için, `@intlayer/swc` paketini kurun. Kurulduktan sonra, `next-intlayer` eklentiyi otomatik olarak algılayacak ve kullanacaktır:
|
|
1404
|
+
|
|
1405
|
+
```bash packageManager="npm"
|
|
1406
|
+
npm install @intlayer/swc --save-dev
|
|
1407
|
+
```
|
|
1408
|
+
|
|
1409
|
+
```bash packageManager="pnpm"
|
|
1410
|
+
pnpm add @intlayer/swc --save-dev
|
|
1411
|
+
```
|
|
1412
|
+
|
|
1413
|
+
```bash packageManager="yarn"
|
|
1414
|
+
yarn add @intlayer/swc --save-dev
|
|
1415
|
+
```
|
|
1416
|
+
|
|
1417
|
+
> Not: Bu optimizasyon sadece Next.js 13 ve üzeri için kullanılabilir.
|
|
1418
|
+
|
|
1419
|
+
> Not: Bu paket varsayılan olarak kurulmaz çünkü SWC eklentileri Next.js'te hala deneyseldir. Gelecekte değişebilir.
|
|
1420
|
+
|
|
1421
|
+
### TypeScript Yapılandırma
|
|
1422
|
+
|
|
1423
|
+
Intlayer, TypeScript'ten faydalanmak ve kod tabanınızı daha güçlü hale getirmek için modül genişletmesi kullanır.
|
|
1424
|
+
|
|
1425
|
+

|
|
1426
|
+
|
|
1427
|
+

|
|
1428
|
+
|
|
1429
|
+
TypeScript yapılandırmanızın otomatik olarak oluşturulan türleri içerdiğinden emin olun.
|
|
1430
|
+
|
|
1431
|
+
```json5 fileName="tsconfig.json"
|
|
1432
|
+
{
|
|
1433
|
+
// ... Mevcut TypeScript yapılandırmalarınız
|
|
1434
|
+
"include": [
|
|
1435
|
+
// ... Mevcut TypeScript yapılandırmalarınız
|
|
1436
|
+
".intlayer/**/*.ts", // Otomatik olarak oluşturulan türleri dahil edin
|
|
1437
|
+
],
|
|
1438
|
+
}
|
|
1439
|
+
```
|
|
1440
|
+
|
|
1441
|
+
### Git Yapılandırma
|
|
1442
|
+
|
|
1443
|
+
Deponuzu temiz tutmak ve oluşturulan dosyaları göndermemek için, Intlayer tarafından oluşturulan dosyaları yok saymanız önerilir.
|
|
1444
|
+
|
|
1445
|
+
`.gitignore` dosyanıza aşağıdaki satırları ekleyin:
|
|
1446
|
+
|
|
1447
|
+
```plaintext fileName=".gitignore"
|
|
1448
|
+
# Intlayer tarafından oluşturulan dosyaları yok say
|
|
1449
|
+
.intlayer
|
|
1450
|
+
```
|
|
1451
|
+
|
|
1452
|
+
### VS Code Uzantısı
|
|
1453
|
+
|
|
1454
|
+
Intlayer ile geliştirme deneyiminizi geliştirmek için, resmi **Intlayer VS Code Uzantısı**'nı kurabilirsiniz.
|
|
1455
|
+
|
|
1456
|
+
[VS Code Marketplace'ten Kurun](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
1457
|
+
|
|
1458
|
+
Bu uzantı şunları sağlar:
|
|
1459
|
+
|
|
1460
|
+
- **Çeviri anahtarları için otomatik tamamlama**.
|
|
1461
|
+
- **Eksik çeviriler için gerçek zamanlı hata algılama**.
|
|
1462
|
+
- **Çevrilmiş içeriğin satır içi önizlemeleri**.
|
|
1463
|
+
- **Çevirileri kolayca oluşturmak ve güncellemek için hızlı eylemler**.
|
|
1464
|
+
|
|
1465
|
+
Uzantının nasıl kullanılacağı hakkında daha fazla detay için, [Intlayer VS Code Uzantısı dokümantasyonu](https://intlayer.org/doc/vs-code-extension)na bakın.
|
|
1466
|
+
|
|
1467
|
+
## Ek Kaynaklar
|
|
1468
|
+
|
|
1469
|
+
- **Intlayer Dokümantasyonu:** [GitHub Deposu](https://github.com/aymericzip/intlayer)
|
|
1470
|
+
- **Sözlük Kılavuzu:** [Sözlük](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/get_started.md)
|
|
1471
|
+
- **Yapılandırma Dokümantasyonu:** [Yapılandırma Kılavuzu](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/configuration.md)
|
|
1472
|
+
|
|
1473
|
+
Bu kılavuzu takip ederek, Sayfa Yönlendirici kullanarak Next.js uygulamanızda Intlayer'ı etkili bir şekilde entegre edebilir, web projeleriniz için sağlam ve ölçeklenebilir uluslararasılaştırma desteği sağlayabilirsiniz.
|
|
1474
|
+
|
|
1475
|
+
### Daha Fazla Bilgi Edinin
|
|
1476
|
+
|
|
1477
|
+
Daha fazla ilerlemek için, [görsel düzenleyici](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md)yi uygulayabilir veya içeriğinizi [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_CMS.md) kullanarak harici hale getirebilirsiniz.
|
|
1478
|
+
|
|
1479
|
+
## Dokümantasyon Geçmişi
|
|
1480
|
+
|
|
1481
|
+
| Sürüm | Tarih | Değişiklikler |
|
|
1482
|
+
| ------ | ---------- | ----------------------------------------------------------------- |
|
|
1483
|
+
| 5.6.0 | 2025-07-06 | `withIntlayer()` fonksiyonunu promise tabanlı fonksiyona dönüştür |
|
|
1484
|
+
| 5.5.10 | 2025-06-29 | Geçmişi başlat |
|