@intlayer/docs 5.8.1 → 6.0.0-canary.1
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 +12 -12
- 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,1632 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-09-07
|
|
3
|
+
updatedAt: 2025-09-07
|
|
4
|
+
title: Vite + React'ta Intlayer ile Başlarken
|
|
5
|
+
description: Intlayer kullanarak Vite ve React uygulamanıza i18n eklemeyi öğrenin. Bu kılavuzu takip ederek uygulamanızı çok dilli hale getirin.
|
|
6
|
+
keywords:
|
|
7
|
+
- Uluslararasılaştırma
|
|
8
|
+
- Dokümantasyon
|
|
9
|
+
- Intlayer
|
|
10
|
+
- Vite
|
|
11
|
+
- React
|
|
12
|
+
- i18n
|
|
13
|
+
- JavaScript
|
|
14
|
+
slugs:
|
|
15
|
+
- doc
|
|
16
|
+
- environment
|
|
17
|
+
- vite-and-react
|
|
18
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-vite-react-template
|
|
19
|
+
youtubeVideo: https://www.youtube.com/watch?v=dS9L7uJeak4
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# Vite ve React ile Intlayer kullanarak uluslararasılaştırma (i18n) başlangıç kılavuzu
|
|
23
|
+
|
|
24
|
+
<iframe title="Vite ve React için en iyi i18n çözümü? Intlayer'ı keşfedin" class="m-auto aspect-[16/9] w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/dS9L7uJeak4?si=VaKmrYMmXjo3xpk2"/>
|
|
25
|
+
|
|
26
|
+
GitHub'da [Uygulama Şablonu](https://github.com/aymericzip/intlayer-vite-react-template)'na bakın.
|
|
27
|
+
|
|
28
|
+
## Intlayer Nedir?
|
|
29
|
+
|
|
30
|
+
**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.
|
|
31
|
+
|
|
32
|
+
Intlayer ile şunları yapabilirsiniz:
|
|
33
|
+
|
|
34
|
+
- **Bileşen düzeyinde açıklayıcı sözlükler kullanarak çevirileri kolayca yönetin**.
|
|
35
|
+
- **Meta verileri, rotaları ve içeriği dinamik olarak yerelleştirin**.
|
|
36
|
+
- **Otomatik oluşturulan türlerle TypeScript desteği sağlayın**, böylece otomatik tamamlama ve hata algılama iyileşir.
|
|
37
|
+
- **Dinamik yerel ayar algılama ve anahtarlama gibi gelişmiş özelliklerden yararlanın**.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Vite ve React Uygulamasında Intlayer Kurulumu İçin Adım Adım Kılavuz
|
|
42
|
+
|
|
43
|
+
### Adım 1: Bağımlılıkları Kurma
|
|
44
|
+
|
|
45
|
+
Gerekli paketleri npm kullanarak kurun:
|
|
46
|
+
|
|
47
|
+
```bash packageManager="npm"
|
|
48
|
+
npm install intlayer react-intlayer
|
|
49
|
+
npm install vite-intlayer --save-dev
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```bash packageManager="pnpm"
|
|
53
|
+
pnpm add intlayer react-intlayer
|
|
54
|
+
pnpm add vite-intlayer --save-dev
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```bash packageManager="yarn"
|
|
58
|
+
yarn add intlayer react-intlayer
|
|
59
|
+
yarn add vite-intlayer --save-dev
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- **intlayer**
|
|
63
|
+
|
|
64
|
+
Yapılandırma yönetimi, çeviri, [içerik bildirimi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/get_started.md), dönüştürme 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.
|
|
65
|
+
|
|
66
|
+
- **react-intlayer**
|
|
67
|
+
React uygulamasıyla Intlayer'ı entegre eden paket. React uluslararasılaştırması için bağlam sağlayıcıları ve kancalar sağlar.
|
|
68
|
+
|
|
69
|
+
- **vite-intlayer**
|
|
70
|
+
[Vite bundler](https://vite.dev/guide/why.html#why-bundle-for-production) ile Intlayer'ı entegre etmek için Vite eklentisini ve kullanıcının tercih ettiği yerel ayarı algılamak, çerezleri yönetmek ve URL yönlendirmesi yapmak için middleware'i içerir.
|
|
71
|
+
|
|
72
|
+
### Adım 2: Projenizi Yapılandırma
|
|
73
|
+
|
|
74
|
+
Uygulamanızın dillerini yapılandırmak için bir yapılandırma dosyası oluşturun:
|
|
75
|
+
|
|
76
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
77
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
78
|
+
|
|
79
|
+
const config: IntlayerConfig = {
|
|
80
|
+
internationalization: {
|
|
81
|
+
locales: [
|
|
82
|
+
Locales.ENGLISH,
|
|
83
|
+
Locales.FRENCH,
|
|
84
|
+
Locales.SPANISH,
|
|
85
|
+
// Diğer yerel ayarlarınız
|
|
86
|
+
],
|
|
87
|
+
defaultLocale: Locales.ENGLISH,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export default config;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
95
|
+
import { Locales } from "intlayer";
|
|
96
|
+
|
|
97
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
98
|
+
const config = {
|
|
99
|
+
internationalization: {
|
|
100
|
+
locales: [
|
|
101
|
+
Locales.ENGLISH,
|
|
102
|
+
Locales.FRENCH,
|
|
103
|
+
Locales.SPANISH,
|
|
104
|
+
// Diğer yerel ayarlarınız
|
|
105
|
+
],
|
|
106
|
+
defaultLocale: Locales.ENGLISH,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default config;
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
114
|
+
const { Locales } = require("intlayer");
|
|
115
|
+
|
|
116
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
117
|
+
const config = {
|
|
118
|
+
internationalization: {
|
|
119
|
+
locales: [
|
|
120
|
+
Locales.ENGLISH,
|
|
121
|
+
Locales.FRENCH,
|
|
122
|
+
Locales.SPANISH,
|
|
123
|
+
// Diğer yerel ayarlarınız
|
|
124
|
+
],
|
|
125
|
+
defaultLocale: Locales.ENGLISH,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
module.exports = config;
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
> Bu yapılandırma dosyası aracılığıyla, yerelleştirilmiş URL'leri, middleware yönlendirmesini, çerez adlarını, içerik bildiriminizin konumunu ve uzantısını, Intlayer günlüklerini konsolda devre dışı bırakmayı 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.
|
|
133
|
+
|
|
134
|
+
### Adım 3: Intlayer'ı Vite Yapılandırmanıza Entegre Etme
|
|
135
|
+
|
|
136
|
+
Vite yapılandırmanıza intlayer eklentisini ekleyin.
|
|
137
|
+
|
|
138
|
+
```typescript fileName="vite.config.ts" codeFormat="typescript"
|
|
139
|
+
import { defineConfig } from "vite";
|
|
140
|
+
import react from "@vitejs/plugin-react-swc";
|
|
141
|
+
import { intlayerPlugin } from "vite-intlayer";
|
|
142
|
+
|
|
143
|
+
// https://vitejs.dev/config/
|
|
144
|
+
export default defineConfig({
|
|
145
|
+
plugins: [react(), intlayerPlugin()],
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```javascript fileName="vite.config.mjs" codeFormat="esm"
|
|
150
|
+
import { defineConfig } from "vite";
|
|
151
|
+
import react from "@vitejs/plugin-react-swc";
|
|
152
|
+
import { intlayerPlugin } from "vite-intlayer";
|
|
153
|
+
|
|
154
|
+
// https://vitejs.dev/config/
|
|
155
|
+
export default defineConfig({
|
|
156
|
+
plugins: [react(), intlayerPlugin()],
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```javascript fileName="vite.config.cjs" codeFormat="commonjs"
|
|
161
|
+
const { defineConfig } = require("vite");
|
|
162
|
+
const react = "@vitejs/plugin-react-swc";
|
|
163
|
+
const { intlayerPlugin } = require("vite-intlayer");
|
|
164
|
+
|
|
165
|
+
// https://vitejs.dev/config/
|
|
166
|
+
module.exports = defineConfig({
|
|
167
|
+
plugins: [react(), intlayerPlugin()],
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
> `intlayerPlugin()` Vite eklentisi, Vite ile Intlayer'ı entegre etmek için kullanılır. İçerik bildirimi dosyalarının oluşturulmasını sağlar ve bunları geliştirme modunda izler. Ayrıca Intlayer ortam değişkenlerini Vite uygulaması içinde tanımlar. Ek olarak, performansı optimize etmek için takma adlar sağlar.
|
|
172
|
+
|
|
173
|
+
### Adım 4: İçeriğinizi Bildirin
|
|
174
|
+
|
|
175
|
+
Çevirileri depolamak için içerik bildiriminizi oluşturun ve yönetin:
|
|
176
|
+
|
|
177
|
+
```tsx fileName="src/app.content.tsx" contentDeclarationFormat="typescript"
|
|
178
|
+
import { t, type Dictionary } from "intlayer";
|
|
179
|
+
import type { ReactNode } from "react";
|
|
180
|
+
|
|
181
|
+
const appContent = {
|
|
182
|
+
key: "app",
|
|
183
|
+
content: {
|
|
184
|
+
viteLogo: t({
|
|
185
|
+
en: "Vite logo",
|
|
186
|
+
fr: "Logo Vite",
|
|
187
|
+
es: "Logo Vite",
|
|
188
|
+
}),
|
|
189
|
+
reactLogo: t({
|
|
190
|
+
en: "React logo",
|
|
191
|
+
fr: "Logo React",
|
|
192
|
+
es: "Logo React",
|
|
193
|
+
}),
|
|
194
|
+
|
|
195
|
+
title: "Vite + React",
|
|
196
|
+
|
|
197
|
+
count: t({
|
|
198
|
+
en: "count is ",
|
|
199
|
+
fr: "le compte est ",
|
|
200
|
+
es: "el recuento es ",
|
|
201
|
+
}),
|
|
202
|
+
|
|
203
|
+
edit: t<ReactNode>({
|
|
204
|
+
en: (
|
|
205
|
+
<>
|
|
206
|
+
Edit <code>src/App.tsx</code> and save to test HMR
|
|
207
|
+
</>
|
|
208
|
+
),
|
|
209
|
+
fr: (
|
|
210
|
+
<>
|
|
211
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
212
|
+
</>
|
|
213
|
+
),
|
|
214
|
+
es: (
|
|
215
|
+
<>
|
|
216
|
+
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
217
|
+
</>
|
|
218
|
+
),
|
|
219
|
+
}),
|
|
220
|
+
|
|
221
|
+
readTheDocs: t({
|
|
222
|
+
en: "Click on the Vite and React logos to learn more",
|
|
223
|
+
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
224
|
+
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
225
|
+
}),
|
|
226
|
+
},
|
|
227
|
+
} satisfies Dictionary;
|
|
228
|
+
|
|
229
|
+
export default appContent;
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
```javascript fileName="src/app.content.mjs" contentDeclarationFormat="esm"
|
|
233
|
+
import { t } from "intlayer";
|
|
234
|
+
|
|
235
|
+
/** @type {import('intlayer').Dictionary} */
|
|
236
|
+
const appContent = {
|
|
237
|
+
key: "app",
|
|
238
|
+
content: {
|
|
239
|
+
viteLogo: t({
|
|
240
|
+
en: "Vite logo",
|
|
241
|
+
fr: "Logo Vite",
|
|
242
|
+
es: "Logo Vite",
|
|
243
|
+
}),
|
|
244
|
+
reactLogo: t({
|
|
245
|
+
en: "React logo",
|
|
246
|
+
fr: "Logo React",
|
|
247
|
+
es: "Logo React",
|
|
248
|
+
}),
|
|
249
|
+
|
|
250
|
+
title: "Vite + React",
|
|
251
|
+
|
|
252
|
+
count: t({
|
|
253
|
+
en: "count is ",
|
|
254
|
+
fr: "le compte est ",
|
|
255
|
+
es: "el recuento es ",
|
|
256
|
+
}),
|
|
257
|
+
|
|
258
|
+
edit:
|
|
259
|
+
t <
|
|
260
|
+
ReactNode >
|
|
261
|
+
{
|
|
262
|
+
// React düğümünü içeriğinizde kullanıyorsanız React'i içe aktarmayı unutmayın
|
|
263
|
+
en: (
|
|
264
|
+
<>
|
|
265
|
+
Edit <code>src/App.tsx</code> and save to test HMR
|
|
266
|
+
</>
|
|
267
|
+
),
|
|
268
|
+
fr: (
|
|
269
|
+
<>
|
|
270
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
271
|
+
</>
|
|
272
|
+
),
|
|
273
|
+
es: (
|
|
274
|
+
<>
|
|
275
|
+
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
276
|
+
</>
|
|
277
|
+
),
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
readTheDocs: t({
|
|
281
|
+
en: "Click on the Vite and React logos to learn more",
|
|
282
|
+
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
283
|
+
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
284
|
+
}),
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export default appContent;
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
```javascript fileName="src/app.content.cjs" contentDeclarationFormat="commonjs"
|
|
292
|
+
const { t } = require("intlayer");
|
|
293
|
+
|
|
294
|
+
/** @type {import('intlayer').Dictionary} */
|
|
295
|
+
const appContent = {
|
|
296
|
+
key: "app",
|
|
297
|
+
content: {
|
|
298
|
+
viteLogo: t({
|
|
299
|
+
en: "Vite logo",
|
|
300
|
+
fr: "Logo Vite",
|
|
301
|
+
es: "Logo Vite",
|
|
302
|
+
}),
|
|
303
|
+
reactLogo: t({
|
|
304
|
+
en: "React logo",
|
|
305
|
+
fr: "Logo React",
|
|
306
|
+
es: "Logo React",
|
|
307
|
+
}),
|
|
308
|
+
|
|
309
|
+
title: "Vite + React",
|
|
310
|
+
|
|
311
|
+
count: t({
|
|
312
|
+
en: "count is ",
|
|
313
|
+
fr: "le compte est ",
|
|
314
|
+
es: "el recuento es ",
|
|
315
|
+
}),
|
|
316
|
+
|
|
317
|
+
edit:
|
|
318
|
+
t <
|
|
319
|
+
ReactNode >
|
|
320
|
+
{
|
|
321
|
+
// React düğümünü içeriğinizde kullanıyorsanız React'i içe aktarmayı unutmayın
|
|
322
|
+
en: (
|
|
323
|
+
<>
|
|
324
|
+
Edit <code>src/App.tsx</code> and save to test HMR
|
|
325
|
+
</>
|
|
326
|
+
),
|
|
327
|
+
fr: (
|
|
328
|
+
<>
|
|
329
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour tester HMR
|
|
330
|
+
</>
|
|
331
|
+
),
|
|
332
|
+
es: (
|
|
333
|
+
<>
|
|
334
|
+
Edita <code>src/App.tsx</code> y guarda para probar HMR
|
|
335
|
+
</>
|
|
336
|
+
),
|
|
337
|
+
},
|
|
338
|
+
|
|
339
|
+
readTheDocs: t({
|
|
340
|
+
en: "Click on the Vite and React logos to learn more",
|
|
341
|
+
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
342
|
+
es: "Haga clic en los logotipos de Vite ve React para obtener más bilgi",
|
|
343
|
+
}),
|
|
344
|
+
},
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
module.exports = appContent;
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
```json fileName="src/app.content.json" contentDeclarationFormat="json"
|
|
351
|
+
{
|
|
352
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
353
|
+
"key": "app",
|
|
354
|
+
"content": {
|
|
355
|
+
"viteLogo": {
|
|
356
|
+
"nodeType": "translation",
|
|
357
|
+
"translation": {
|
|
358
|
+
"en": "Vite logo",
|
|
359
|
+
"fr": "Logo Vite",
|
|
360
|
+
"es": "Logo Vite"
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
"reactLogo": {
|
|
364
|
+
"nodeType": "translation",
|
|
365
|
+
"translation": {
|
|
366
|
+
"en": "React logo",
|
|
367
|
+
"fr": "Logo React",
|
|
368
|
+
"es": "Logo React"
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
"title": {
|
|
372
|
+
"nodeType": "translation",
|
|
373
|
+
"translation": {
|
|
374
|
+
"en": "Vite + React",
|
|
375
|
+
"fr": "Vite + React",
|
|
376
|
+
"es": "Vite + React"
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
"count": {
|
|
380
|
+
"nodeType": "translation",
|
|
381
|
+
"translation": {
|
|
382
|
+
"en": "count is ",
|
|
383
|
+
"fr": "le compte est ",
|
|
384
|
+
"es": "el recuento es "
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
"edit": {
|
|
388
|
+
"nodeType": "translation",
|
|
389
|
+
"translation": {
|
|
390
|
+
"en": "Edit src/App.tsx and save to test HMR",
|
|
391
|
+
"fr": "Éditez src/App.tsx et enregistrez pour tester HMR",
|
|
392
|
+
"es": "Edita src/App.tsx y guarda para probar HMR"
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
"readTheDocs": {
|
|
396
|
+
"nodeType": "translation",
|
|
397
|
+
"translation": {
|
|
398
|
+
"en": "Click on the Vite and React logos to learn more",
|
|
399
|
+
"fr": "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
400
|
+
"es": "Haga clic en los logotipos de Vite ve React para obtener más bilgi"
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
> İçerik bildiriminiz uygulamanızın herhangi bir yerine yerleştirilebilir, yeter ki `contentDir` dizinine dahil edilsin (varsayılan olarak `./src`). Ve içerik bildirimi dosya uzantısı ile eşleşsin (varsayılan olarak `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
408
|
+
|
|
409
|
+
> Daha fazla ayrıntı için [içerik bildirimi dokümantasyonuna](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/get_started.md) bakın.
|
|
410
|
+
|
|
411
|
+
> İçerik dosyanız TSX kodu içeriyorsa, `import React from "react";`'ı içerik dosyanıza dahil etmeyi düşünün.
|
|
412
|
+
|
|
413
|
+
### Adım 5: Kodunuzda Intlayer'ı Kullanın
|
|
414
|
+
|
|
415
|
+
Uygulamanız boyunca içerik sözlüklerinize erişin:
|
|
416
|
+
|
|
417
|
+
```tsx {5,9} fileName="src/App.tsx" codeFormat="typescript"
|
|
418
|
+
import { useState, type FC } from "react";
|
|
419
|
+
import reactLogo from "./assets/react.svg";
|
|
420
|
+
import viteLogo from "/vite.svg";
|
|
421
|
+
import "./App.css";
|
|
422
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
423
|
+
|
|
424
|
+
const AppContent: FC = () => {
|
|
425
|
+
const [count, setCount] = useState(0);
|
|
426
|
+
const content = useIntlayer("app");
|
|
427
|
+
|
|
428
|
+
return (
|
|
429
|
+
<>
|
|
430
|
+
<div>
|
|
431
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
432
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
433
|
+
</a>
|
|
434
|
+
<a href="https://react.dev" target="_blank">
|
|
435
|
+
<img
|
|
436
|
+
src={reactLogo}
|
|
437
|
+
className="logo react"
|
|
438
|
+
alt={content.reactLogo.value}
|
|
439
|
+
/>
|
|
440
|
+
</a>
|
|
441
|
+
</div>
|
|
442
|
+
<h1>{content.title}</h1>
|
|
443
|
+
<div className="card">
|
|
444
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
445
|
+
{content.count}
|
|
446
|
+
{count}
|
|
447
|
+
</button>
|
|
448
|
+
<p>{content.edit}</p>
|
|
449
|
+
</div>
|
|
450
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
451
|
+
</>
|
|
452
|
+
);
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
const App: FC = () => (
|
|
456
|
+
<IntlayerProvider>
|
|
457
|
+
<AppContent />
|
|
458
|
+
</IntlayerProvider>
|
|
459
|
+
);
|
|
460
|
+
|
|
461
|
+
export default App;
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
```tsx {5,9} fileName="src/App.msx" codeFormat="esm"
|
|
465
|
+
import { useState } from "react";
|
|
466
|
+
import reactLogo from "./assets/react.svg";
|
|
467
|
+
import viteLogo from "/vite.svg";
|
|
468
|
+
import "./App.css";
|
|
469
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
470
|
+
|
|
471
|
+
const AppContent = () => {
|
|
472
|
+
const [count, setCount] = useState(0);
|
|
473
|
+
const content = useIntlayer("app");
|
|
474
|
+
|
|
475
|
+
return (
|
|
476
|
+
<>
|
|
477
|
+
<div>
|
|
478
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
479
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
480
|
+
</a>
|
|
481
|
+
<a href="https://react.dev" target="_blank">
|
|
482
|
+
<img
|
|
483
|
+
src={reactLogo}
|
|
484
|
+
className="logo react"
|
|
485
|
+
alt={content.reactLogo.value}
|
|
486
|
+
/>
|
|
487
|
+
</a>
|
|
488
|
+
</div>
|
|
489
|
+
<h1>{content.title}</h1>
|
|
490
|
+
<div className="card">
|
|
491
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
492
|
+
{content.count}
|
|
493
|
+
{count}
|
|
494
|
+
</button>
|
|
495
|
+
<p>{content.edit}</p>
|
|
496
|
+
</div>
|
|
497
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
498
|
+
</>
|
|
499
|
+
);
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
const App = () => (
|
|
503
|
+
<IntlayerProvider>
|
|
504
|
+
<AppContent />
|
|
505
|
+
</IntlayerProvider>
|
|
506
|
+
);
|
|
507
|
+
|
|
508
|
+
export default App;
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
```tsx {5,9} fileName="src/App.csx" codeFormat="commonjs"
|
|
512
|
+
const { useState } = require("react");
|
|
513
|
+
const reactLogo = require("./assets/react.svg");
|
|
514
|
+
const viteLogo = require("/vite.svg");
|
|
515
|
+
require("./App.css");
|
|
516
|
+
const { IntlayerProvider, useIntlayer } = require("react-intlayer");
|
|
517
|
+
|
|
518
|
+
const AppContent = () => {
|
|
519
|
+
const [count, setCount] = useState(0);
|
|
520
|
+
const content = useIntlayer("app");
|
|
521
|
+
|
|
522
|
+
return (
|
|
523
|
+
<>
|
|
524
|
+
<div>
|
|
525
|
+
<a href="https://vitejs.dev" target="_blank">
|
|
526
|
+
<img src={viteLogo} className="logo" alt={content.viteLogo.value} />
|
|
527
|
+
</a>
|
|
528
|
+
<a href="https://react.dev" target="_blank">
|
|
529
|
+
<img
|
|
530
|
+
src={reactLogo}
|
|
531
|
+
className="logo react"
|
|
532
|
+
alt={content.reactLogo.value}
|
|
533
|
+
/>
|
|
534
|
+
</a>
|
|
535
|
+
</div>
|
|
536
|
+
<h1>{content.title}</h1>
|
|
537
|
+
<div className="card">
|
|
538
|
+
<button onClick={() => setCount((count) => count + 1)}>
|
|
539
|
+
{content.count}
|
|
540
|
+
{count}
|
|
541
|
+
</button>
|
|
542
|
+
<p>{content.edit}</p>
|
|
543
|
+
</div>
|
|
544
|
+
<p className="read-the-docs">{content.readTheDocs}</p>
|
|
545
|
+
</>
|
|
546
|
+
);
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
const App = () => (
|
|
550
|
+
<IntlayerProvider>
|
|
551
|
+
<AppContent />
|
|
552
|
+
</IntlayerProvider>
|
|
553
|
+
);
|
|
554
|
+
|
|
555
|
+
module.exports = App;
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
> İçeriğinizi bir `string` niteliğinde kullanmak istediğinizde, `alt`, `title`, `href`, `aria-label` vb. gibi, işlevin değerini çağırmanız gerekir:
|
|
559
|
+
|
|
560
|
+
> ```jsx
|
|
561
|
+
> <img src={content.image.src.value} alt={content.image.value} />
|
|
562
|
+
> ```
|
|
563
|
+
|
|
564
|
+
> `useIntlayer` kancası hakkında daha fazla bilgi edinmek için [dokümantasyona](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/react-intlayer/useIntlayer.md) bakın.
|
|
565
|
+
|
|
566
|
+
### (İsteğe Bağlı) Adım 6: İçeriğinizin Dilini Değiştirin
|
|
567
|
+
|
|
568
|
+
İçeriğinizin dilini değiştirmek için `useLocale` kancasından sağlanan `setLocale` işlevini kullanabilirsiniz. Bu işlev uygulamanın yerel ayarını ayarlamanıza ve içeriği buna göre güncellemenize olanak tanır.
|
|
569
|
+
|
|
570
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
571
|
+
import type { FC } from "react";
|
|
572
|
+
import { Locales } from "intlayer";
|
|
573
|
+
import { useLocale } from "react-intlayer";
|
|
574
|
+
|
|
575
|
+
const LocaleSwitcher: FC = () => {
|
|
576
|
+
const { setLocale } = useLocale();
|
|
577
|
+
|
|
578
|
+
return (
|
|
579
|
+
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
580
|
+
Dili İngilizce'ye Değiştir
|
|
581
|
+
</button>
|
|
582
|
+
);
|
|
583
|
+
};
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
```jsx fileName="src/components/LocaleSwitcher.msx" codeFormat="esm"
|
|
587
|
+
import { Locales } from "intlayer";
|
|
588
|
+
import { useLocale } from "react-intlayer";
|
|
589
|
+
|
|
590
|
+
const LocaleSwitcher = () => {
|
|
591
|
+
const { setLocale } = useLocale();
|
|
592
|
+
|
|
593
|
+
return (
|
|
594
|
+
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
595
|
+
Dili İngilizce'ye Değiştir
|
|
596
|
+
</button>
|
|
597
|
+
);
|
|
598
|
+
};
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
```jsx fileName="src/components/LocaleSwitcher.csx" codeFormat="commonjs"
|
|
602
|
+
const { Locales } = require("intlayer");
|
|
603
|
+
const { useLocale } = require("react-intlayer");
|
|
604
|
+
|
|
605
|
+
const LocaleSwitcher = () => {
|
|
606
|
+
const { setLocale } = useLocale();
|
|
607
|
+
|
|
608
|
+
return (
|
|
609
|
+
<button onClick={() => setLocale(Locales.ENGLISH)}>
|
|
610
|
+
Dili İngilizce'ye Değiştir
|
|
611
|
+
</button>
|
|
612
|
+
);
|
|
613
|
+
};
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
> `useLocale` kancası hakkında daha fazla bilgi edinmek için [dokümantasyona](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/react-intlayer/useLocale.md) bakın.
|
|
617
|
+
|
|
618
|
+
### (İsteğe Bağlı) Adım 7: Uygulamanıza Yerelleştirilmiş Yönlendirme Ekleyin
|
|
619
|
+
|
|
620
|
+
Bu adımın amacı, her dil için benzersiz rotalar oluşturmaktır. Bu, SEO ve SEO dostu URL'ler için kullanışlıdır.
|
|
621
|
+
Örnek:
|
|
622
|
+
|
|
623
|
+
```plaintext
|
|
624
|
+
- https://example.com/about
|
|
625
|
+
- https://example.com/es/about
|
|
626
|
+
- https://example.com/fr/about
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
> Varsayılan olarak, rotalar varsayılan yerel ayar için öneklenmez. Varsayılan yerel ayarı öneklemek istiyorsanız, yapılandırmanızda `middleware.prefixDefault` seçeneğini `true` olarak ayarlayabilirsiniz. Daha fazla bilgi için [yapılandırma dokümantasyonuna](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/configuration.md) bakın.
|
|
630
|
+
|
|
631
|
+
Uygulamanıza yerelleştirilmiş yönlendirme eklemek için, uygulamanızın rotalarını saran ve yerel ayar tabanlı yönlendirmeyi yöneten bir `LocaleRouter` bileşeni oluşturabilirsiniz. [React Router](https://reactrouter.com/home) kullanarak bir örnek aşağıda verilmiştir:
|
|
632
|
+
|
|
633
|
+
```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
|
|
634
|
+
// Gerekli bağımlılıkları ve işlevleri içe aktar
|
|
635
|
+
import { type Locales, configuration, getPathWithoutLocale } from "intlayer"; // Intlayer'dan yardımcı işlevler ve türler
|
|
636
|
+
import type { FC, PropsWithChildren } from "react"; // React türleri işlevsel bileşenler ve props için
|
|
637
|
+
import { IntlayerProvider } from "react-intlayer"; // Uluslararasılaştırma bağlam sağlayıcısı
|
|
638
|
+
import {
|
|
639
|
+
BrowserRouter,
|
|
640
|
+
Routes,
|
|
641
|
+
Route,
|
|
642
|
+
Navigate,
|
|
643
|
+
useLocation,
|
|
644
|
+
} from "react-router-dom"; // Navigasyonu yönetmek için yönlendirici bileşenleri
|
|
645
|
+
|
|
646
|
+
// Intlayer'dan yapılandırmayı çıkar
|
|
647
|
+
const { internationalization, middleware } = configuration;
|
|
648
|
+
const { locales, defaultLocale } = internationalization;
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Yerelleştirme ve uygun yerel ayar bağlamıyla çocukları saran bir bileşen.
|
|
652
|
+
* URL tabanlı yerel ayar algılama ve doğrulama yönetir.
|
|
653
|
+
*/
|
|
654
|
+
const AppLocalized: FC<PropsWithChildren<{ locale: Locales }>> = ({
|
|
655
|
+
children,
|
|
656
|
+
locale,
|
|
657
|
+
}) => {
|
|
658
|
+
const { pathname, search } = useLocation(); // Geçerli URL yolunu al
|
|
659
|
+
|
|
660
|
+
// Sağlanmadıysa varsayılan yerel ayara geri dön
|
|
661
|
+
const currentLocale = locale ?? defaultLocale;
|
|
662
|
+
|
|
663
|
+
// Temel bir yol oluşturmak için yoldan yerel ayar önekini kaldır
|
|
664
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
665
|
+
pathname // Geçerli URL yolu
|
|
666
|
+
);
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* middleware.prefixDefault true ise, varsayılan yerel ayar her zaman öneklenmelidir.
|
|
670
|
+
*/
|
|
671
|
+
if (middleware.prefixDefault) {
|
|
672
|
+
// Yerel ayarı doğrula
|
|
673
|
+
if (!locale || !locales.includes(locale)) {
|
|
674
|
+
// Güncellenmiş yol ile varsayılan yerel ayara yönlendir
|
|
675
|
+
return (
|
|
676
|
+
<Navigate
|
|
677
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
678
|
+
replace // Geçerli geçmiş girişini yenisiyle değiştir
|
|
679
|
+
/>
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// Geçerli yerel ayarı ayarlayarak çocukları IntlayerProvider ile sar
|
|
684
|
+
return (
|
|
685
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
686
|
+
);
|
|
687
|
+
} else {
|
|
688
|
+
/**
|
|
689
|
+
* middleware.prefixDefault false olduğunda, varsayılan yerel ayar öneklenmez.
|
|
690
|
+
* Geçerli yerel ayar geçerli olduğundan ve varsayılan yerel ayar olmadığından emin ol.
|
|
691
|
+
*/
|
|
692
|
+
if (
|
|
693
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
694
|
+
!locales
|
|
695
|
+
.filter(
|
|
696
|
+
(locale) => locale.toString() !== defaultLocale.toString() // Varsayılan yerel ayarı hariç tut
|
|
697
|
+
)
|
|
698
|
+
.includes(currentLocale) // Geçerli yerel ayar geçerli yerel ayarlar listesinde mi kontrol et
|
|
699
|
+
) {
|
|
700
|
+
// Yerel ayar öneki olmadan yola yönlendir
|
|
701
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// Geçerli yerel ayarı ayarlayarak çocukları IntlayerProvider ile sar
|
|
705
|
+
return (
|
|
706
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Yerel ayar özel rotaları ayarlayan bir yönlendirici bileşen.
|
|
713
|
+
* React Router kullanarak navigasyonu yönetir ve yerelleştirilmiş bileşenleri işler.
|
|
714
|
+
*/
|
|
715
|
+
export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
|
|
716
|
+
<BrowserRouter>
|
|
717
|
+
<Routes>
|
|
718
|
+
{locales
|
|
719
|
+
.filter(
|
|
720
|
+
(locale) => middleware.prefixDefault || locale !== defaultLocale
|
|
721
|
+
)
|
|
722
|
+
.map((locale) => (
|
|
723
|
+
<Route
|
|
724
|
+
// Yerel ayarı yakalayan rota deseni (örneğin, /en/, /fr/) ve sonraki tüm yolları eşleştir
|
|
725
|
+
path={`/${locale}/*`}
|
|
726
|
+
key={locale}
|
|
727
|
+
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // Yerel ayar yönetimiyle çocukları sar
|
|
728
|
+
/>
|
|
729
|
+
))}
|
|
730
|
+
|
|
731
|
+
{
|
|
732
|
+
// Varsayılan yerel ayar öneki devre dışı bırakılmışsa, kök yolda çocukları doğrudan işle
|
|
733
|
+
!middleware.prefixDefault && (
|
|
734
|
+
<Route
|
|
735
|
+
path="*"
|
|
736
|
+
element={
|
|
737
|
+
<AppLocalized locale={defaultLocale}>{children}</AppLocalized>
|
|
738
|
+
} // Yerel ayar yönetimiyle çocukları sar
|
|
739
|
+
/>
|
|
740
|
+
)
|
|
741
|
+
}
|
|
742
|
+
</Routes>
|
|
743
|
+
</BrowserRouter>
|
|
744
|
+
);
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
```jsx fileName="src/components/LocaleRouter.mjx" codeFormat="esm"
|
|
748
|
+
// Gerekli bağımlılıkları ve işlevleri içe aktar
|
|
749
|
+
import { configuration, getPathWithoutLocale } from "intlayer"; // Intlayer'dan yardımcı işlevler ve türler
|
|
750
|
+
// Intlayer'dan yardımcı işlevler ve türler
|
|
751
|
+
import { IntlayerProvider } from "react-intlayer"; // Uluslararasılaştırma bağlam sağlayıcısı
|
|
752
|
+
import {
|
|
753
|
+
BrowserRouter,
|
|
754
|
+
Routes,
|
|
755
|
+
Route,
|
|
756
|
+
Navigate,
|
|
757
|
+
useLocation,
|
|
758
|
+
} from "react-router-dom"; // Navigasyonu yönetmek için yönlendirici bileşenleri
|
|
759
|
+
|
|
760
|
+
// Intlayer'dan yapılandırmayı çıkar
|
|
761
|
+
const { internationalization, middleware } = configuration;
|
|
762
|
+
const { locales, defaultLocale } = internationalization;
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Yerelleştirme ve uygun yerel ayar bağlamıyla çocukları saran bir bileşen.
|
|
766
|
+
* URL tabanlı yerel ayar algılama ve doğrulama yönetir.
|
|
767
|
+
*/
|
|
768
|
+
const AppLocalized = ({ children, locale }) => {
|
|
769
|
+
const { pathname, search } = useLocation(); // Geçerli URL yolunu al
|
|
770
|
+
|
|
771
|
+
// Sağlanmadıysa varsayılan yerel ayara geri dön
|
|
772
|
+
const currentLocale = locale ?? defaultLocale;
|
|
773
|
+
|
|
774
|
+
// Temel bir yol oluşturmak için yoldan yerel ayar önekini kaldır
|
|
775
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
776
|
+
pathname // Geçerli URL yolu
|
|
777
|
+
);
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* middleware.prefixDefault true ise, varsayılan yerel ayar her zaman öneklenmelidir.
|
|
781
|
+
*/
|
|
782
|
+
if (middleware.prefixDefault) {
|
|
783
|
+
// Yerel ayarı doğrula
|
|
784
|
+
if (!locale || !locales.includes(locale)) {
|
|
785
|
+
// Güncellenmiş yol ile varsayılan yerel ayara yönlendir
|
|
786
|
+
return (
|
|
787
|
+
<Navigate
|
|
788
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
789
|
+
replace // Geçerli geçmiş girişini yenisiyle değiştir
|
|
790
|
+
/>
|
|
791
|
+
);
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
// Geçerli yerel ayarı ayarlayarak çocukları IntlayerProvider ile sar
|
|
795
|
+
return (
|
|
796
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
797
|
+
);
|
|
798
|
+
} else {
|
|
799
|
+
/**
|
|
800
|
+
* middleware.prefixDefault false olduğunda, varsayılan yerel ayar öneklenmez.
|
|
801
|
+
* Geçerli yerel ayar geçerli olduğundan ve varsayılan yerel ayar olmadığından emin ol.
|
|
802
|
+
*/
|
|
803
|
+
if (
|
|
804
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
805
|
+
!locales
|
|
806
|
+
.filter(
|
|
807
|
+
(locale) => locale.toString() !== defaultLocale.toString() // Varsayılan yerel ayarı hariç tut
|
|
808
|
+
)
|
|
809
|
+
.includes(currentLocale) // Geçerli yerel ayar geçerli yerel ayarlar listesinde mi kontrol et
|
|
810
|
+
) {
|
|
811
|
+
// Yerel ayar öneki olmadan yola yönlendir
|
|
812
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// Geçerli yerel ayarı ayarlayarak çocukları IntlayerProvider ile sar
|
|
816
|
+
return (
|
|
817
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Yerel ayar özel rotaları ayarlayan bir yönlendirici bileşen.
|
|
824
|
+
* React Router kullanarak navigasyonu yönetir ve yerelleştirilmiş bileşenleri işler.
|
|
825
|
+
*/
|
|
826
|
+
export const LocaleRouter = ({ children }) => (
|
|
827
|
+
<BrowserRouter>
|
|
828
|
+
<Routes>
|
|
829
|
+
{locales
|
|
830
|
+
.filter(
|
|
831
|
+
(locale) => middleware.prefixDefault || locale !== defaultLocale
|
|
832
|
+
)
|
|
833
|
+
.map((locale) => (
|
|
834
|
+
<Route
|
|
835
|
+
// Yerel ayarı yakalayan rota deseni (örneğin, /en/, /fr/) ve sonraki tüm yolları eşleştir
|
|
836
|
+
path={`/${locale}/*`}
|
|
837
|
+
key={locale}
|
|
838
|
+
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // Yerel ayar yönetimiyle çocukları sar
|
|
839
|
+
/>
|
|
840
|
+
))}
|
|
841
|
+
|
|
842
|
+
{
|
|
843
|
+
// Varsayılan yerel ayar öneki devre dışı bırakılmışsa, kök yolda çocukları doğrudan işle
|
|
844
|
+
!middleware.prefixDefault && (
|
|
845
|
+
<Route
|
|
846
|
+
path="*"
|
|
847
|
+
element={
|
|
848
|
+
<AppLocalized locale={defaultLocale}>{children}</AppLocalized>
|
|
849
|
+
} // Yerel ayar yönetimiyle çocukları sar
|
|
850
|
+
/>
|
|
851
|
+
)
|
|
852
|
+
}
|
|
853
|
+
</Routes>
|
|
854
|
+
</BrowserRouter>
|
|
855
|
+
);
|
|
856
|
+
```
|
|
857
|
+
|
|
858
|
+
```jsx fileName="src/components/LocaleRouter.cjx" codeFormat="commonjs"
|
|
859
|
+
// Gerekli bağımlılıkları ve işlevleri içe aktar
|
|
860
|
+
const { configuration, getPathWithoutLocale } = require("intlayer"); // Intlayer'dan yardımcı işlevler ve türler
|
|
861
|
+
const { IntlayerProvider, useLocale } = require("react-intlayer"); // Uluslararasılaştırma bağlam sağlayıcısı
|
|
862
|
+
const {
|
|
863
|
+
BrowserRouter,
|
|
864
|
+
Routes,
|
|
865
|
+
Route,
|
|
866
|
+
Navigate,
|
|
867
|
+
useLocation,
|
|
868
|
+
} = require("react-router-dom"); // Navigasyonu yönetmek için yönlendirici bileşenleri
|
|
869
|
+
|
|
870
|
+
// Intlayer'dan yapılandırmayı çıkar
|
|
871
|
+
const { internationalization, middleware } = configuration;
|
|
872
|
+
const { locales, defaultLocale } = internationalization;
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Yerelleştirme ve uygun yerel ayar bağlamıyla çocukları saran bir bileşen.
|
|
876
|
+
* URL tabanlı yerel ayar algılama ve doğrulama yönetir.
|
|
877
|
+
*/
|
|
878
|
+
const AppLocalized = ({ children, locale }) => {
|
|
879
|
+
const { pathname, search } = useLocation(); // Geçerli URL yolunu al
|
|
880
|
+
|
|
881
|
+
// Sağlanmadıysa varsayılan yerel ayara geri dön
|
|
882
|
+
const currentLocale = locale ?? defaultLocale;
|
|
883
|
+
|
|
884
|
+
// Temel bir yol oluşturmak için yoldan yerel ayar önekini kaldır
|
|
885
|
+
const pathWithoutLocale = getPathWithoutLocale(
|
|
886
|
+
pathname // Geçerli URL yolu
|
|
887
|
+
);
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* middleware.prefixDefault true ise, varsayılan yerel ayar her zaman öneklenmelidir.
|
|
891
|
+
*/
|
|
892
|
+
if (middleware.prefixDefault) {
|
|
893
|
+
// Yerel ayarı doğrula
|
|
894
|
+
if (!locale || !locales.includes(locale)) {
|
|
895
|
+
// Güncellenmiş yol ile varsayılan yerel ayara yönlendir
|
|
896
|
+
return (
|
|
897
|
+
<Navigate
|
|
898
|
+
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
899
|
+
replace // Geçerli geçmiş girişini yenisiyle değiştir
|
|
900
|
+
/>
|
|
901
|
+
);
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
// Geçerli yerel ayarı ayarlayarak çocukları IntlayerProvider ile sar
|
|
905
|
+
return (
|
|
906
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
907
|
+
);
|
|
908
|
+
} else {
|
|
909
|
+
/**
|
|
910
|
+
* middleware.prefixDefault false olduğunda, varsayılan yerel ayar öneklenmez.
|
|
911
|
+
* Geçerli yerel ayar geçerli olduğundan ve varsayılan yerel ayar olmadığından emin ol.
|
|
912
|
+
*/
|
|
913
|
+
if (
|
|
914
|
+
currentLocale.toString() !== defaultLocale.toString() &&
|
|
915
|
+
!locales
|
|
916
|
+
.filter(
|
|
917
|
+
(locale) => locale.toString() !== defaultLocale.toString() // Varsayılan yerel ayarı hariç tut
|
|
918
|
+
)
|
|
919
|
+
.includes(currentLocale) // Geçerli yerel ayar geçerli yerel ayarlar listesinde mi kontrol et
|
|
920
|
+
) {
|
|
921
|
+
// Yerel ayar öneki olmadan yola yönlendir
|
|
922
|
+
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
// Geçerli yerel ayarı ayarlayarak çocukları IntlayerProvider ile sar
|
|
926
|
+
return (
|
|
927
|
+
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
928
|
+
);
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
* Yerel ayar özel rotaları ayarlayan bir yönlendirici bileşen.
|
|
934
|
+
* React Router kullanarak navigasyonu yönetir ve yerelleştirilmiş bileşenleri işler.
|
|
935
|
+
*/
|
|
936
|
+
const LocaleRouter = ({ children }) => (
|
|
937
|
+
<BrowserRouter>
|
|
938
|
+
<Routes>
|
|
939
|
+
{locales
|
|
940
|
+
.filter(
|
|
941
|
+
(locale) => middleware.prefixDefault || locale !== defaultLocale
|
|
942
|
+
)
|
|
943
|
+
.map((locale) => (
|
|
944
|
+
<Route
|
|
945
|
+
// Yerel ayarı yakalayan rota deseni (örneğin, /en/, /fr/) ve sonraki tüm yolları eşleştir
|
|
946
|
+
path={`/${locale}/*`}
|
|
947
|
+
key={locale}
|
|
948
|
+
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // Yerel ayar yönetimiyle çocukları sar
|
|
949
|
+
/>
|
|
950
|
+
))}
|
|
951
|
+
|
|
952
|
+
{
|
|
953
|
+
// Varsayılan yerel ayar öneki devre dışı bırakılmışsa, kök yolda çocukları doğrudan işle
|
|
954
|
+
!middleware.prefixDefault && (
|
|
955
|
+
<Route
|
|
956
|
+
path="*"
|
|
957
|
+
element={
|
|
958
|
+
<AppLocalized locale={defaultLocale}>{children}</AppLocalized>
|
|
959
|
+
} // Yerel ayar yönetimiyle çocukları sar
|
|
960
|
+
/>
|
|
961
|
+
)
|
|
962
|
+
}
|
|
963
|
+
</Routes>
|
|
964
|
+
</BrowserRouter>
|
|
965
|
+
);
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
Ardından, `LocaleRouter` bileşenini uygulamanızda kullanabilirsiniz:
|
|
969
|
+
|
|
970
|
+
```tsx fileName="src/App.tsx" codeFormat="typescript"
|
|
971
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
972
|
+
import type { FC } from "react";
|
|
973
|
+
|
|
974
|
+
// ... AppContent bileşeniniz
|
|
975
|
+
|
|
976
|
+
const App: FC = () => (
|
|
977
|
+
<LocaleRouter>
|
|
978
|
+
<AppContent />
|
|
979
|
+
</LocaleRouter>
|
|
980
|
+
);
|
|
981
|
+
```
|
|
982
|
+
|
|
983
|
+
```jsx fileName="src/App.mjx" codeFormat="esm"
|
|
984
|
+
import { LocaleRouter } from "./components/LocaleRouter";
|
|
985
|
+
|
|
986
|
+
// ... AppContent bileşeniniz
|
|
987
|
+
|
|
988
|
+
const App = () => (
|
|
989
|
+
<LocaleRouter>
|
|
990
|
+
<AppContent />
|
|
991
|
+
</LocaleRouter>
|
|
992
|
+
);
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
```jsx fileName="src/App.cjx" codeFormat="commonjs"
|
|
996
|
+
const { LocaleRouter } = require("./components/LocaleRouter");
|
|
997
|
+
|
|
998
|
+
// ... AppContent bileşeniniz
|
|
999
|
+
|
|
1000
|
+
const App = () => (
|
|
1001
|
+
<LocaleRouter>
|
|
1002
|
+
<AppContent />
|
|
1003
|
+
</LocaleRouter>
|
|
1004
|
+
);
|
|
1005
|
+
```
|
|
1006
|
+
|
|
1007
|
+
Paralel olarak, uygulamanıza sunucu tarafı yönlendirme eklemek için `intlayerMiddlewarePlugin`'i de kullanabilirsiniz. Bu eklenti, URL'ye göre geçerli yerel ayarı otomatik olarak algılar ve uygun yerel ayar çerezini ayarlar. Hiç yerel ayar belirtilmezse, eklenti kullanıcının tarayıcı dil tercihlerine göre en uygun yerel ayarı belirler. Hiç yerel ayar algılanmazsa, varsayılan yerel ayara yönlendirir.
|
|
1008
|
+
|
|
1009
|
+
> Not: Üretimde `intlayerMiddlewarePlugin`'i kullanmak için `vite-intlayer` paketini `devDependencies`'den `dependencies`'e taşımalısınız.
|
|
1010
|
+
|
|
1011
|
+
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
1012
|
+
import { defineConfig } from "vite";
|
|
1013
|
+
import react from "@vitejs/plugin-react-swc";
|
|
1014
|
+
import { intlayerPlugin, intlayerMiddlewarePlugin } from "vite-intlayer";
|
|
1015
|
+
|
|
1016
|
+
// https://vitejs.dev/config/
|
|
1017
|
+
export default defineConfig({
|
|
1018
|
+
plugins: [react(), intlayerPlugin(), intlayerMiddlewarePlugin()],
|
|
1019
|
+
});
|
|
1020
|
+
```
|
|
1021
|
+
|
|
1022
|
+
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
1023
|
+
import { defineConfig } from "vite";
|
|
1024
|
+
import react from "@vitejs/plugin-react-swc";
|
|
1025
|
+
import { intlayerPlugin, intlayerMiddlewarePlugin } from "vite-intlayer";
|
|
1026
|
+
|
|
1027
|
+
// https://vitejs.dev/config/
|
|
1028
|
+
export default defineConfig({
|
|
1029
|
+
plugins: [react(), intlayerPlugin(), intlayerMiddlewarePlugin()],
|
|
1030
|
+
});
|
|
1031
|
+
```
|
|
1032
|
+
|
|
1033
|
+
```javascript {3,7} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
1034
|
+
const { defineConfig } = require("vite");
|
|
1035
|
+
const react = "@vitejs/plugin-react-swc";
|
|
1036
|
+
const { intlayerPlugin, intlayerMiddlewarePlugin } = require("vite-intlayer");
|
|
1037
|
+
|
|
1038
|
+
// https://vitejs.dev/config/
|
|
1039
|
+
module.exports = defineConfig({
|
|
1040
|
+
plugins: [react(), intlayerPlugin(), intlayerMiddlewarePlugin()],
|
|
1041
|
+
});
|
|
1042
|
+
```
|
|
1043
|
+
|
|
1044
|
+
### (İsteğe Bağlı) Adım 8: Yerel ayar değiştiğinde URL'yi değiştirin
|
|
1045
|
+
|
|
1046
|
+
Yerel ayar değiştiğinde URL'yi değiştirmek için `useLocale` kancasından sağlanan `onLocaleChange` prop'unu kullanabilirsiniz. Paralel olarak, URL yolunu güncellemek için `useLocation` ve `useNavigate` kancalarını `react-router-dom`'dan kullanabilirsiniz.
|
|
1047
|
+
|
|
1048
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
1049
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
1050
|
+
import {
|
|
1051
|
+
Locales,
|
|
1052
|
+
getHTMLTextDir,
|
|
1053
|
+
getLocaleName,
|
|
1054
|
+
getLocalizedUrl,
|
|
1055
|
+
} from "intlayer";
|
|
1056
|
+
import { useLocale } from "react-intlayer";
|
|
1057
|
+
import { type FC } from "react";
|
|
1058
|
+
|
|
1059
|
+
const LocaleSwitcher: FC = () => {
|
|
1060
|
+
const { pathname, search } = useLocation(); // Geçerli URL yolunu al. Örnek: /fr/about?foo=bar
|
|
1061
|
+
const navigate = useNavigate();
|
|
1062
|
+
|
|
1063
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1064
|
+
onLocaleChange: (locale) => {
|
|
1065
|
+
// Güncellenmiş yerel ayar ile URL'yi oluştur
|
|
1066
|
+
// Örnek: /es/about?foo=bar
|
|
1067
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
1068
|
+
|
|
1069
|
+
// URL yolunu güncelle
|
|
1070
|
+
navigate(pathWithLocale);
|
|
1071
|
+
},
|
|
1072
|
+
});
|
|
1073
|
+
|
|
1074
|
+
return (
|
|
1075
|
+
<div>
|
|
1076
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1077
|
+
<div id="localePopover" popover="auto">
|
|
1078
|
+
{availableLocales.map((localeItem) => (
|
|
1079
|
+
<a
|
|
1080
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
1081
|
+
hrefLang={localeItem}
|
|
1082
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1083
|
+
onClick={(e) => {
|
|
1084
|
+
e.preventDefault();
|
|
1085
|
+
setLocale(localeItem);
|
|
1086
|
+
}}
|
|
1087
|
+
key={localeItem}
|
|
1088
|
+
>
|
|
1089
|
+
<span>
|
|
1090
|
+
{/* Yerel ayar - örn. FR */}
|
|
1091
|
+
{localeItem}
|
|
1092
|
+
</span>
|
|
1093
|
+
<span>
|
|
1094
|
+
{/* Kendi yerel ayarındaki dil - örn. Français */}
|
|
1095
|
+
{getLocaleName(localeItem, locale)}
|
|
1096
|
+
</span>
|
|
1097
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1098
|
+
{/* Geçerli yerel ayar set edildiğinde İspanyolca olarak Fransızca - örn. Francés */}
|
|
1099
|
+
{getLocaleName(localeItem)}
|
|
1100
|
+
</span>
|
|
1101
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1102
|
+
{/* İngilizce olarak dil - örn. French */}
|
|
1103
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1104
|
+
</span>
|
|
1105
|
+
</a>
|
|
1106
|
+
))}
|
|
1107
|
+
</div>
|
|
1108
|
+
</div>
|
|
1109
|
+
);
|
|
1110
|
+
};
|
|
1111
|
+
```
|
|
1112
|
+
|
|
1113
|
+
```jsx fileName="src/components/LocaleSwitcher.msx" codeFormat="esm"
|
|
1114
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
1115
|
+
import {
|
|
1116
|
+
Locales,
|
|
1117
|
+
getHTMLTextDir,
|
|
1118
|
+
getLocaleName,
|
|
1119
|
+
getLocalizedUrl,
|
|
1120
|
+
} from "intlayer";
|
|
1121
|
+
import { useLocale } from "react-intlayer";
|
|
1122
|
+
|
|
1123
|
+
const LocaleSwitcher = () => {
|
|
1124
|
+
const { pathname, search } = useLocation(); // Geçerli URL yolunu al. Örnek: /fr/about?foo=bar
|
|
1125
|
+
const navigate = useNavigate();
|
|
1126
|
+
|
|
1127
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1128
|
+
onLocaleChange: (locale) => {
|
|
1129
|
+
// Güncellenmiş yerel ayar ile URL'yi oluştur
|
|
1130
|
+
// Örnek: /es/about?foo=bar
|
|
1131
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
1132
|
+
|
|
1133
|
+
// URL yolunu güncelle
|
|
1134
|
+
navigate(pathWithLocale);
|
|
1135
|
+
},
|
|
1136
|
+
});
|
|
1137
|
+
|
|
1138
|
+
return (
|
|
1139
|
+
<div>
|
|
1140
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1141
|
+
<div id="localePopover" popover="auto">
|
|
1142
|
+
{availableLocales.map((localeItem) => (
|
|
1143
|
+
<a
|
|
1144
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
1145
|
+
hrefLang={localeItem}
|
|
1146
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1147
|
+
onClick={(e) => {
|
|
1148
|
+
e.preventDefault();
|
|
1149
|
+
setLocale(localeItem);
|
|
1150
|
+
}}
|
|
1151
|
+
key={localeItem}
|
|
1152
|
+
>
|
|
1153
|
+
<span>
|
|
1154
|
+
{/* Yerel ayar - örn. FR */}
|
|
1155
|
+
{localeItem}
|
|
1156
|
+
</span>
|
|
1157
|
+
<span>
|
|
1158
|
+
{/* Kendi yerel ayarındaki dil - örn. Français */}
|
|
1159
|
+
{getLocaleName(localeItem, locale)}
|
|
1160
|
+
</span>
|
|
1161
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1162
|
+
{/* Geçerli yerel ayar set edildiğinde İspanyolca olarak Fransızca - örn. Francés */}
|
|
1163
|
+
{getLocaleName(localeItem)}
|
|
1164
|
+
</span>
|
|
1165
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1166
|
+
{/* İngilizce olarak dil - örn. French */}
|
|
1167
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1168
|
+
</span>
|
|
1169
|
+
</a>
|
|
1170
|
+
))}
|
|
1171
|
+
</div>
|
|
1172
|
+
</div>
|
|
1173
|
+
);
|
|
1174
|
+
};
|
|
1175
|
+
```
|
|
1176
|
+
|
|
1177
|
+
```jsx fileName="src/components/LocaleSwitcher.csx" codeFormat="commonjs"
|
|
1178
|
+
const { useLocation, useNavigate } = require("react-router-dom");
|
|
1179
|
+
const {
|
|
1180
|
+
Locales,
|
|
1181
|
+
getHTMLTextDir,
|
|
1182
|
+
getLocaleName,
|
|
1183
|
+
getLocalizedUrl,
|
|
1184
|
+
} = require("intlayer");
|
|
1185
|
+
const { useLocale } = require("react-intlayer");
|
|
1186
|
+
|
|
1187
|
+
const LocaleSwitcher = () => {
|
|
1188
|
+
const { pathname, search } = useLocation(); // Geçerli URL yolunu al. Örnek: /fr/about?foo=bar
|
|
1189
|
+
const navigate = useNavigate();
|
|
1190
|
+
|
|
1191
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
1192
|
+
onLocaleChange: (locale) => {
|
|
1193
|
+
// Güncellenmiş yerel ayar ile URL'yi oluştur
|
|
1194
|
+
// Örnek: /es/about?foo=bar
|
|
1195
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
1196
|
+
|
|
1197
|
+
// URL yolunu güncelle
|
|
1198
|
+
navigate(pathWithLocale);
|
|
1199
|
+
},
|
|
1200
|
+
});
|
|
1201
|
+
|
|
1202
|
+
return (
|
|
1203
|
+
<div>
|
|
1204
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
1205
|
+
<div id="localePopover" popover="auto">
|
|
1206
|
+
{availableLocales.map((localeItem) => (
|
|
1207
|
+
<a
|
|
1208
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
1209
|
+
hrefLang={localeItem}
|
|
1210
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
1211
|
+
onClick={(e) => {
|
|
1212
|
+
e.preventDefault();
|
|
1213
|
+
setLocale(localeItem);
|
|
1214
|
+
}}
|
|
1215
|
+
key={localeItem}
|
|
1216
|
+
>
|
|
1217
|
+
<span>
|
|
1218
|
+
{/* Yerel ayar - örn. FR */}
|
|
1219
|
+
{localeItem}
|
|
1220
|
+
</span>
|
|
1221
|
+
<span>
|
|
1222
|
+
{/* Kendi yerel ayarındaki dil - örn. Français */}
|
|
1223
|
+
{getLocaleName(localeItem, locale)}
|
|
1224
|
+
</span>
|
|
1225
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1226
|
+
{/* Geçerli yerel ayar set edildiğinde İspanyolca olarak Fransızca - örn. Francés */}
|
|
1227
|
+
{getLocaleName(localeItem)}
|
|
1228
|
+
</span>
|
|
1229
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1230
|
+
{/* İngilizce olarak dil - örn. French */}
|
|
1231
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1232
|
+
</span>
|
|
1233
|
+
</a>
|
|
1234
|
+
))}
|
|
1235
|
+
</div>
|
|
1236
|
+
</div>
|
|
1237
|
+
);
|
|
1238
|
+
};
|
|
1239
|
+
```
|
|
1240
|
+
|
|
1241
|
+
> Dokümantasyon referansları:
|
|
1242
|
+
>
|
|
1243
|
+
> - [`useLocale` kancası](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/react-intlayer/useLocale.md)
|
|
1244
|
+
> - [`getLocaleName` kancası](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/intlayer/getLocaleName.md)
|
|
1245
|
+
> - [`getLocalizedUrl` kancası](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/intlayer/getLocalizedUrl.md)
|
|
1246
|
+
> - [`getHTMLTextDir` kancası](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/packages/intlayer/getHTMLTextDir.md)
|
|
1247
|
+
> - [`hrefLang` niteliği](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
|
|
1248
|
+
> - [`lang` niteliği](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
|
|
1249
|
+
> - [`dir` niteliği](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
|
|
1250
|
+
> - [`aria-current` niteliği](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
1251
|
+
|
|
1252
|
+
Aşağıda **güncellenmiş Adım 9** açıklamalar ve iyileştirilmiş kod örnekleriyle eklenmiştir:
|
|
1253
|
+
|
|
1254
|
+
---
|
|
1255
|
+
|
|
1256
|
+
### (İsteğe Bağlı) Adım 9: HTML Dil ve Yön Niteliklerini Değiştirin
|
|
1257
|
+
|
|
1258
|
+
Uygulamanız birden fazla dili desteklediğinde, geçerli yerel ayar ile eşleşmesi için `<html>` etiketinin `lang` ve `dir` niteliklerini güncellemek önemlidir. Bunu yapmak şunları sağlar:
|
|
1259
|
+
|
|
1260
|
+
- **Erişilebilirlik**: Ekran okuyucular ve yardımcı teknolojiler, içeriği doğru şekilde telaffuz etmek ve yorumlamak için doğru `lang` niteliğine güvenir.
|
|
1261
|
+
- **Metin İşleme**: `dir` (yön) niteliği, metnin doğru sırada işlenmesini sağlar (örneğin, İngilizce için soldan sağa, Arapça veya İbranice için sağdan sola), okunabilirlik için gereklidir.
|
|
1262
|
+
- **SEO**: Arama motorları, sayfanızın dilini belirlemek için `lang` niteliğini kullanır, arama sonuçlarında doğru yerelleştirilmiş içeriği sunmaya yardımcı olur.
|
|
1263
|
+
|
|
1264
|
+
Yerel ayar değiştiğinde bu nitelikleri dinamik olarak güncellemek, tüm desteklenen diller için tutarlı ve erişilebilir bir deneyim sağlar.
|
|
1265
|
+
|
|
1266
|
+
#### Kancayı Uygulama
|
|
1267
|
+
|
|
1268
|
+
Geçerli yerel ayara göre HTML niteliklerini yöneten özel bir kanca oluşturun. Kanca yerel ayar değişikliklerini dinler ve nitelikleri buna göre günceller:
|
|
1269
|
+
|
|
1270
|
+
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
|
|
1271
|
+
import { useEffect } from "react";
|
|
1272
|
+
import { useLocale } from "react-intlayer";
|
|
1273
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* Geçerli yerel ayara göre HTML <html> etiketinin `lang` ve `dir` niteliklerini günceller.
|
|
1277
|
+
* - `lang`: Tarayıcılara ve arama motorlarına sayfanın dilini bildirir.
|
|
1278
|
+
* - `dir`: Geçerli yerel ayara göre doğru okuma sırasını (örneğin, İngilizce için 'ltr', Arapça için 'rtl') sağlar.
|
|
1279
|
+
*
|
|
1280
|
+
* Bu dinamik güncelleme, uygun metin işleme, erişilebilirlik ve SEO için gereklidir.
|
|
1281
|
+
*/
|
|
1282
|
+
export const useI18nHTMLAttributes = () => {
|
|
1283
|
+
const { locale } = useLocale();
|
|
1284
|
+
|
|
1285
|
+
useEffect(() => {
|
|
1286
|
+
// Geçerli yerel ayara dil niteliğini ayarla
|
|
1287
|
+
document.documentElement.lang = locale;
|
|
1288
|
+
|
|
1289
|
+
// Geçerli yerel ayara göre metin yönünü ayarla
|
|
1290
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1291
|
+
}, [locale]);
|
|
1292
|
+
};
|
|
1293
|
+
```
|
|
1294
|
+
|
|
1295
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.msx" codeFormat="esm"
|
|
1296
|
+
import { useEffect } from "react";
|
|
1297
|
+
import { useLocale } from "react-intlayer";
|
|
1298
|
+
import { getHTMLTextDir } from "intlayer";
|
|
1299
|
+
|
|
1300
|
+
/**
|
|
1301
|
+
* Geçerli yerel ayara göre HTML <html> etiketinin `lang` ve `dir` niteliklerini günceller.
|
|
1302
|
+
* - `lang`: Tarayıcılara ve arama motorlarına sayfanın dilini bildirir.
|
|
1303
|
+
* - `dir`: Geçerli yerel ayara göre doğru okuma sırasını (örneğin, İngilizce için 'ltr', Arapça için 'rtl') sağlar.
|
|
1304
|
+
*
|
|
1305
|
+
* Bu dinamik güncelleme, uygun metin işleme, erişilebilirlik ve SEO için gereklidir.
|
|
1306
|
+
*/
|
|
1307
|
+
export const useI18nHTMLAttributes = () => {
|
|
1308
|
+
const { locale } = useLocale();
|
|
1309
|
+
|
|
1310
|
+
useEffect(() => {
|
|
1311
|
+
// Geçerli yerel ayara dil niteliğini ayarla
|
|
1312
|
+
document.documentElement.lang = locale;
|
|
1313
|
+
|
|
1314
|
+
// Geçerli yerel ayara göre metin yönünü ayarla
|
|
1315
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1316
|
+
}, [locale]);
|
|
1317
|
+
};
|
|
1318
|
+
```
|
|
1319
|
+
|
|
1320
|
+
```jsx fileName="src/hooks/useI18nHTMLAttributes.csx" codeFormat="commonjs"
|
|
1321
|
+
const { useEffect } = require("react");
|
|
1322
|
+
const { useLocale } = require("react-intlayer";
|
|
1323
|
+
const { getHTMLTextDir } = require("intlayer");
|
|
1324
|
+
|
|
1325
|
+
/**
|
|
1326
|
+
* Geçerli yerel ayara göre HTML <html> etiketinin `lang` ve `dir` niteliklerini günceller.
|
|
1327
|
+
* - `lang`: Tarayıcılara ve arama motorlarına sayfanın dilini bildirir.
|
|
1328
|
+
* - `dir`: Geçerli yerel ayara göre doğru okuma sırasını (örneğin, İngilizce için 'ltr', Arapça için 'rtl') sağlar.
|
|
1329
|
+
*
|
|
1330
|
+
* Bu dinamik güncelleme, uygun metin işleme, erişilebilirlik ve SEO için gereklidir.
|
|
1331
|
+
*/
|
|
1332
|
+
const useI18nHTMLAttributes = () => {
|
|
1333
|
+
const { locale } = useLocale();
|
|
1334
|
+
|
|
1335
|
+
useEffect(() => {
|
|
1336
|
+
// Geçerli yerel ayara dil niteliğini ayarla
|
|
1337
|
+
document.documentElement.lang = locale;
|
|
1338
|
+
|
|
1339
|
+
// Geçerli yerel ayara göre metin yönünü ayarla
|
|
1340
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
1341
|
+
}, [locale]);
|
|
1342
|
+
};
|
|
1343
|
+
|
|
1344
|
+
module.exports = { useI18nHTMLAttributes };
|
|
1345
|
+
```
|
|
1346
|
+
|
|
1347
|
+
#### Uygulamanızda Kancayı Kullanma
|
|
1348
|
+
|
|
1349
|
+
Yerel ayar değiştiğinde HTML niteliklerinin güncellenmesi için kancayı ana bileşeninizde entegre edin:
|
|
1350
|
+
|
|
1351
|
+
```tsx fileName="src/App.tsx" codeFormat="typescript"
|
|
1352
|
+
import type { FC } from "react";
|
|
1353
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
1354
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1355
|
+
import "./App.css";
|
|
1356
|
+
|
|
1357
|
+
const AppContent: FC = () => {
|
|
1358
|
+
// Kancayı kullanarak yerel ayara göre <html> etiketinin lang ve dir niteliklerini güncelle
|
|
1359
|
+
useI18nHTMLAttributes();
|
|
1360
|
+
|
|
1361
|
+
// ... Rest of your component
|
|
1362
|
+
};
|
|
1363
|
+
|
|
1364
|
+
const App: FC = () => (
|
|
1365
|
+
<IntlayerProvider>
|
|
1366
|
+
<AppContent />
|
|
1367
|
+
</IntlayerProvider>
|
|
1368
|
+
);
|
|
1369
|
+
|
|
1370
|
+
export default App;
|
|
1371
|
+
```
|
|
1372
|
+
|
|
1373
|
+
```jsx fileName="src/App.msx" codeFormat="esm"
|
|
1374
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
1375
|
+
import { useI18nHTMLAttributes } from "./hooks/useI18nHTMLAttributes";
|
|
1376
|
+
import "./App.css";
|
|
1377
|
+
|
|
1378
|
+
const AppContent = () => {
|
|
1379
|
+
// Kancayı kullanarak yerel ayara göre <html> etiketinin lang ve dir niteliklerini güncelle
|
|
1380
|
+
useI18nHTMLAttributes();
|
|
1381
|
+
|
|
1382
|
+
// ... Rest of your component
|
|
1383
|
+
};
|
|
1384
|
+
|
|
1385
|
+
const App = () => (
|
|
1386
|
+
<IntlayerProvider>
|
|
1387
|
+
<AppContent />
|
|
1388
|
+
</IntlayerProvider>
|
|
1389
|
+
);
|
|
1390
|
+
|
|
1391
|
+
export default App;
|
|
1392
|
+
```
|
|
1393
|
+
|
|
1394
|
+
```jsx fileName="src/App.csx" codeFormat="commonjs"
|
|
1395
|
+
const { FC } = require("react");
|
|
1396
|
+
const { IntlayerProvider, useIntlayer } = require("react-intlayer");
|
|
1397
|
+
const { useI18nHTMLAttributes } = require("./hooks/useI18nHTMLAttributes");
|
|
1398
|
+
require("./App.css");
|
|
1399
|
+
|
|
1400
|
+
const AppContent = () => {
|
|
1401
|
+
// Kancayı kullanarak yerel ayara göre <html> etiketinin lang ve dir niteliklerini güncelle
|
|
1402
|
+
useI18nHTMLAttributes();
|
|
1403
|
+
|
|
1404
|
+
// ... Rest of your component
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1407
|
+
const App = () => (
|
|
1408
|
+
<IntlayerProvider>
|
|
1409
|
+
<AppContent />
|
|
1410
|
+
</IntlayerProvider>
|
|
1411
|
+
);
|
|
1412
|
+
|
|
1413
|
+
module.exports = App;
|
|
1414
|
+
```
|
|
1415
|
+
|
|
1416
|
+
Bu değişiklikleri uygulayarak uygulamanız şunları sağlayacak:
|
|
1417
|
+
|
|
1418
|
+
- **Dil** (`lang`) niteliği, SEO ve tarayıcı davranışı için geçerli yerel ayarı doğru şekilde yansıtacak.
|
|
1419
|
+
- **Metin yönü** (`dir`) niteliği, farklı okuma sıralarına sahip diller için okunabilirliği ve kullanılabilirliği geliştirecek.
|
|
1420
|
+
- Daha **erişilebilir** bir deneyim sağlayacak, çünkü yardımcı teknolojiler bu niteliklere optimum şekilde çalışmak için güvenir.
|
|
1421
|
+
|
|
1422
|
+
### (İsteğe Bağlı) Adım 10: Yerelleştirilmiş Bağlantı Bileşeni Oluşturun
|
|
1423
|
+
|
|
1424
|
+
Uygulamanızın navigasyonu geçerli yerel ayarı saygı gösterdiğinden emin olmak için özel bir `Link` bileşeni oluşturabilirsiniz. Bu bileşen dahili URL'leri otomatik olarak geçerli dille önekler, böylece. Örneğin, bir Fransızca konuşan kullanıcı "Hakkında" sayfasına giden bir bağlantıya tıkladığında, `/about` yerine `/fr/about`'a yönlendirilir.
|
|
1425
|
+
|
|
1426
|
+
Bu davranış çeşitli nedenlerle kullanışlıdır:
|
|
1427
|
+
|
|
1428
|
+
- **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 sunar.
|
|
1429
|
+
- **Tutarlılık**: Uygulamanız boyunca yerelleştirilmiş bir bağlantı kullanarak, navigasyonun aynı yerel ayar bağlamında kalmasını garanti edersiniz, beklenmedik dil anahtarlarını önlersiniz.
|
|
1430
|
+
- **Bakım Kolaylığı**: URL mantığını tek bir bileşende merkezileştirmek, yönetimini basitleştirir, uygulamanız büyüdükçe kod tabanınızı daha kolay yönetilebilir hale getirir.
|
|
1431
|
+
|
|
1432
|
+
Aşağıda TypeScript'te yerelleştirilmiş bir `Link` bileşeninin uygulanması verilmiştir:
|
|
1433
|
+
|
|
1434
|
+
```tsx fileName="src/components/Link.tsx" codeFormat="typescript"
|
|
1435
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1436
|
+
import {
|
|
1437
|
+
forwardRef,
|
|
1438
|
+
type DetailedHTMLProps,
|
|
1439
|
+
type AnchorHTMLAttributes,
|
|
1440
|
+
} from "react";
|
|
1441
|
+
import { useLocale } from "react-intlayer";
|
|
1442
|
+
|
|
1443
|
+
export interface LinkProps
|
|
1444
|
+
extends DetailedHTMLProps<
|
|
1445
|
+
AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
1446
|
+
HTMLAnchorElement
|
|
1447
|
+
> {}
|
|
1448
|
+
|
|
1449
|
+
/**
|
|
1450
|
+
* Verilen URL'nin harici olup olmadığını belirleyen yardımcı işlev.
|
|
1451
|
+
* URL http:// veya https:// ile başlıyorsa harici olarak kabul edilir.
|
|
1452
|
+
*/
|
|
1453
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1454
|
+
/^https?:\/\//.test(href ?? "");
|
|
1455
|
+
|
|
1456
|
+
/**
|
|
1457
|
+
* Geçerli yerel ayara göre href niteliğini uyarlayan özel bir Link bileşeni.
|
|
1458
|
+
* Dahili bağlantılar için `getLocalizedUrl` kullanarak URL'yi yerel ayar ile önekler (örneğin, /fr/about).
|
|
1459
|
+
* Bu, navigasyonun aynı yerel ayar bağlamında kalmasını sağlar.
|
|
1460
|
+
*/
|
|
1461
|
+
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
1462
|
+
({ href, children, ...props }, ref) => {
|
|
1463
|
+
const { locale } = useLocale();
|
|
1464
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1465
|
+
|
|
1466
|
+
// Dahili bağlantıysa ve geçerli bir href sağlanmışsa, yerelleştirilmiş URL'yi al.
|
|
1467
|
+
const hrefI18n =
|
|
1468
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1469
|
+
|
|
1470
|
+
return (
|
|
1471
|
+
<a href={hrefI18n} ref={ref} {...props}>
|
|
1472
|
+
{children}
|
|
1473
|
+
</a>
|
|
1474
|
+
);
|
|
1475
|
+
}
|
|
1476
|
+
);
|
|
1477
|
+
|
|
1478
|
+
Link.displayName = "Link";
|
|
1479
|
+
```
|
|
1480
|
+
|
|
1481
|
+
```jsx fileName="src/components/Link.mjx" codeFormat="esm"
|
|
1482
|
+
import { getLocalizedUrl } from "intlayer";
|
|
1483
|
+
import { useLocale } from "react-intlayer";
|
|
1484
|
+
import { forwardRef } from "react";
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* Verilen URL'nin harici olup olmadığını belirleyen yardımcı işlev.
|
|
1488
|
+
* URL http:// veya https:// ile başlıyorsa harici olarak kabul edilir.
|
|
1489
|
+
*/
|
|
1490
|
+
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1491
|
+
/^https?:\/\//.test(href ?? "");
|
|
1492
|
+
|
|
1493
|
+
/**
|
|
1494
|
+
* Geçerli yerel ayara göre href niteliğini uyarlayan özel bir Link bileşeni.
|
|
1495
|
+
* Dahili bağlantılar için `getLocalizedUrl` kullanarak URL'yi yerel ayar ile önekler (örneğin, /fr/about).
|
|
1496
|
+
* Bu, navigasyonun aynı yerel ayar bağlamında kalmasını sağlar.
|
|
1497
|
+
*/
|
|
1498
|
+
export const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1499
|
+
const { locale } = useLocale();
|
|
1500
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1501
|
+
|
|
1502
|
+
// Dahili bağlantıysa ve geçerli bir href sağlanmışsa, yerelleştirilmiş URL'yi al.
|
|
1503
|
+
const hrefI18n =
|
|
1504
|
+
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1505
|
+
|
|
1506
|
+
return (
|
|
1507
|
+
<a href={hrefI18n} ref={ref} {...props}>
|
|
1508
|
+
{children}
|
|
1509
|
+
</a>
|
|
1510
|
+
);
|
|
1511
|
+
});
|
|
1512
|
+
|
|
1513
|
+
Link.displayName = "Link";
|
|
1514
|
+
```
|
|
1515
|
+
|
|
1516
|
+
```jsx fileName="src/components/Link.csx" codeFormat="commonjs"
|
|
1517
|
+
const { getLocalizedUrl } = require("intlayer");
|
|
1518
|
+
const { useLocale } = require("react-intlayer");
|
|
1519
|
+
const { forwardRef } = require("react");
|
|
1520
|
+
|
|
1521
|
+
/**
|
|
1522
|
+
* Verilen URL'nin harici olup olmadığını belirleyen yardımcı işlev.
|
|
1523
|
+
* URL http:// veya https:// ile başlıyorsa harici olarak kabul edilir.
|
|
1524
|
+
*/
|
|
1525
|
+
const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
1526
|
+
|
|
1527
|
+
/**
|
|
1528
|
+
* Geçerli yerel ayara göre href niteliğini uyarlayan özel bir Link bileşeni.
|
|
1529
|
+
* Dahili bağlantılar için `getLocalizedUrl` kullanarak URL'yi yerel ayar ile önekler (örneğin, /fr/about).
|
|
1530
|
+
* Bu, navigasyonun aynı yerel ayar bağlamında kalmasını sağlar.
|
|
1531
|
+
*/
|
|
1532
|
+
const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1533
|
+
const { locale } = useLocale();
|
|
1534
|
+
const isExternalLink = checkIsExternalLink(href);
|
|
1535
|
+
|
|
1536
|
+
// Dahili bağlantıysa ve geçerli bir href sağlanmışsa, yerelleştirilmiş URL'yi al.
|
|
1537
|
+
const localizedHref = isExternalLink ? href : getLocalizedUrl(href, locale);
|
|
1538
|
+
|
|
1539
|
+
return (
|
|
1540
|
+
<a
|
|
1541
|
+
href={localizedHref}
|
|
1542
|
+
ref={ref}
|
|
1543
|
+
{...props}
|
|
1544
|
+
aria-current={isExternalLink ? "external" : undefined}
|
|
1545
|
+
>
|
|
1546
|
+
{children}
|
|
1547
|
+
</a>
|
|
1548
|
+
);
|
|
1549
|
+
});
|
|
1550
|
+
|
|
1551
|
+
Link.displayName = "Link";
|
|
1552
|
+
```
|
|
1553
|
+
|
|
1554
|
+
#### Nasıl Çalışır
|
|
1555
|
+
|
|
1556
|
+
- **Harici Bağlantıları Algılama**:
|
|
1557
|
+
Yardımcı işlev `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.
|
|
1558
|
+
|
|
1559
|
+
- **Geçerli Yerel Ayarı Alma**:
|
|
1560
|
+
`useLocale` kancası geçerli yerel ayarı sağlar (örneğin, `fr` Fransızca için).
|
|
1561
|
+
|
|
1562
|
+
- **URL'yi Yerelleştirme**:
|
|
1563
|
+
Dahili bağlantılar için (yani harici olmayan), `getLocalizedUrl`, URL'yi geçerli yerel ayar ile otomatik olarak önekler. Bu, `href` olarak `/about` geçildiğinde, kullanıcının Fransızca'da olduğu durumda `/fr/about`'a dönüştürülmesi anlamına gelir.
|
|
1564
|
+
|
|
1565
|
+
- **Bağlantıyı Döndürme**:
|
|
1566
|
+
Bileşen, yerelleştirilmiş URL ile bir `<a>` etiketi döndürür, böylece navigasyon yerel ayar ile tutarlı kalır.
|
|
1567
|
+
|
|
1568
|
+
Bu `Link` bileşenini uygulamanız boyunca entegre ederek, dil farkındalığı olan tutarlı bir kullanıcı deneyimi sağlar ve aynı zamanda iyileştirilmiş SEO ve kullanılabilirlik avantajlarından yararlanırsınız.
|
|
1569
|
+
|
|
1570
|
+
### TypeScript Yapılandırın
|
|
1571
|
+
|
|
1572
|
+
Intlayer, modül genişletmesi kullanarak TypeScript avantajlarından yararlanır.
|
|
1573
|
+
|
|
1574
|
+

|
|
1575
|
+
|
|
1576
|
+

|
|
1577
|
+
|
|
1578
|
+
Otomatik oluşturulan türleri TypeScript yapılandırmanıza dahil edin.
|
|
1579
|
+
|
|
1580
|
+
```json5 fileName="tsconfig.json"
|
|
1581
|
+
{
|
|
1582
|
+
// ... Mevcut TypeScript yapılandırmalarınız
|
|
1583
|
+
"include": [
|
|
1584
|
+
// ... Mevcut TypeScript yapılandırmalarınız
|
|
1585
|
+
".intlayer/**/*.ts", // Otomatik oluşturulan türleri dahil et
|
|
1586
|
+
],
|
|
1587
|
+
}
|
|
1588
|
+
```
|
|
1589
|
+
|
|
1590
|
+
### Git Yapılandırması
|
|
1591
|
+
|
|
1592
|
+
Intlayer tarafından oluşturulan dosyaları Git deponuza kaydetmekten kaçınmak için bunları yok saymanız önerilir. Bu, bunları Git deponuza kaydetmekten kaçınmanıza olanak tanır.
|
|
1593
|
+
|
|
1594
|
+
Bunu yapmak için `.gitignore` dosyanıza aşağıdaki talimatları ekleyin:
|
|
1595
|
+
|
|
1596
|
+
```plaintext
|
|
1597
|
+
# Intlayer tarafından oluşturulan dosyaları yok say
|
|
1598
|
+
.intlayer
|
|
1599
|
+
```
|
|
1600
|
+
|
|
1601
|
+
### VS Code Uzantısı
|
|
1602
|
+
|
|
1603
|
+
Intlayer ile geliştirme deneyiminizi iyileştirmek için resmi **Intlayer VS Code Uzantısı**'nı kurun.
|
|
1604
|
+
|
|
1605
|
+
[VS Code Marketplace'ten yükleyin](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
1606
|
+
|
|
1607
|
+
Bu uzantı şunları sağlar:
|
|
1608
|
+
|
|
1609
|
+
- **Çeviri anahtarları için otomatik tamamlama**.
|
|
1610
|
+
- **Eksik çeviriler için gerçek zamanlı hata algılama**.
|
|
1611
|
+
- **Çevrilmiş içeriğin satır içi önizlemeleri**.
|
|
1612
|
+
- **Çevirileri kolayca oluşturmak ve güncellemek için hızlı eylemler**.
|
|
1613
|
+
|
|
1614
|
+
Uzantıyı kullanma hakkında daha fazla ayrıntı için [Intlayer VS Code Uzantısı dokümantasyonuna](https://intlayer.org/doc/vs-code-extension) bakın.
|
|
1615
|
+
|
|
1616
|
+
---
|
|
1617
|
+
|
|
1618
|
+
### Daha Fazla İlerle
|
|
1619
|
+
|
|
1620
|
+
Daha fazla ilerlemek için [görsel düzenleyici](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md) veya içeriğinizi [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_CMS.md) kullanarak dışa aktarmayı uygulayabilirsiniz.
|
|
1621
|
+
|
|
1622
|
+
---
|
|
1623
|
+
|
|
1624
|
+
## Dokümantasyon Geçmişi
|
|
1625
|
+
|
|
1626
|
+
| Sürüm | Tarih | Değişiklikler |
|
|
1627
|
+
| ------ | ---------- | ----------------- |
|
|
1628
|
+
| 5.5.10 | 2025-06-29 | Geçmiş başlatıldı |
|
|
1629
|
+
|
|
1630
|
+
```
|
|
1631
|
+
|
|
1632
|
+
```
|