@intlayer/docs 5.5.11 → 5.6.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/intlayer_with_next-intl.md +0 -1
- package/blog/ar/list_i18n_technologies/CMS/wordpress.md +1 -1
- package/blog/ar/list_i18n_technologies/frameworks/angular.md +1 -1
- package/blog/ar/list_i18n_technologies/frameworks/flutter.md +1 -1
- package/blog/ar/list_i18n_technologies/frameworks/react-native.md +1 -1
- package/blog/ar/list_i18n_technologies/frameworks/react.md +1 -1
- package/blog/ar/list_i18n_technologies/frameworks/svelte.md +1 -1
- package/blog/ar/list_i18n_technologies/frameworks/vue.md +1 -1
- package/blog/ar/what_is_internationalization.md +2 -2
- package/blog/de/intlayer_with_next-intl.md +0 -1
- package/blog/de/list_i18n_technologies/CMS/wordpress.md +1 -1
- package/blog/de/list_i18n_technologies/frameworks/angular.md +1 -1
- package/blog/de/list_i18n_technologies/frameworks/flutter.md +1 -1
- package/blog/de/list_i18n_technologies/frameworks/react-native.md +1 -1
- package/blog/de/list_i18n_technologies/frameworks/react.md +1 -1
- package/blog/de/list_i18n_technologies/frameworks/svelte.md +1 -1
- package/blog/de/list_i18n_technologies/frameworks/vue.md +1 -1
- package/blog/de/what_is_internationalization.md +2 -2
- package/blog/en/intlayer_with_next-intl.md +0 -1
- package/blog/en/list_i18n_technologies/CMS/wordpress.md +1 -1
- package/blog/en/list_i18n_technologies/frameworks/angular.md +1 -1
- package/blog/en/list_i18n_technologies/frameworks/flutter.md +1 -1
- package/blog/en/list_i18n_technologies/frameworks/react-native.md +1 -1
- package/blog/en/list_i18n_technologies/frameworks/react.md +1 -1
- package/blog/en/list_i18n_technologies/frameworks/svelte.md +1 -1
- package/blog/en/list_i18n_technologies/frameworks/vue.md +1 -1
- package/blog/en/what_is_internationalization.md +2 -2
- package/blog/en-GB/intlayer_with_next-intl.md +0 -1
- package/blog/en-GB/list_i18n_technologies/CMS/wordpress.md +1 -1
- package/blog/en-GB/list_i18n_technologies/frameworks/angular.md +1 -1
- package/blog/en-GB/list_i18n_technologies/frameworks/flutter.md +1 -1
- package/blog/en-GB/list_i18n_technologies/frameworks/react-native.md +1 -1
- package/blog/en-GB/list_i18n_technologies/frameworks/svelte.md +1 -1
- package/blog/en-GB/list_i18n_technologies/frameworks/vue.md +1 -1
- package/blog/en-GB/what_is_internationalization.md +2 -2
- package/blog/es/intlayer_with_next-intl.md +0 -1
- package/blog/es/list_i18n_technologies/CMS/wordpress.md +1 -1
- package/blog/es/list_i18n_technologies/frameworks/angular.md +1 -1
- package/blog/es/list_i18n_technologies/frameworks/flutter.md +1 -1
- package/blog/es/list_i18n_technologies/frameworks/react-native.md +1 -1
- package/blog/es/list_i18n_technologies/frameworks/react.md +1 -1
- package/blog/es/list_i18n_technologies/frameworks/svelte.md +1 -1
- package/blog/es/list_i18n_technologies/frameworks/vue.md +1 -1
- package/blog/es/what_is_internationalization.md +2 -2
- package/blog/fr/intlayer_with_next-intl.md +0 -1
- package/blog/fr/list_i18n_technologies/CMS/wordpress.md +1 -1
- package/blog/fr/list_i18n_technologies/frameworks/angular.md +1 -1
- package/blog/fr/list_i18n_technologies/frameworks/flutter.md +1 -1
- package/blog/fr/list_i18n_technologies/frameworks/react-native.md +1 -1
- package/blog/fr/list_i18n_technologies/frameworks/react.md +1 -1
- package/blog/fr/list_i18n_technologies/frameworks/svelte.md +1 -1
- package/blog/fr/list_i18n_technologies/frameworks/vue.md +1 -1
- package/blog/fr/what_is_internationalization.md +2 -2
- package/blog/hi/list_i18n_technologies/CMS/wordpress.md +1 -1
- package/blog/hi/list_i18n_technologies/frameworks/angular.md +1 -1
- package/blog/hi/list_i18n_technologies/frameworks/flutter.md +1 -1
- package/blog/hi/list_i18n_technologies/frameworks/react-native.md +1 -1
- package/blog/hi/list_i18n_technologies/frameworks/react.md +1 -1
- package/blog/hi/list_i18n_technologies/frameworks/svelte.md +1 -1
- package/blog/hi/list_i18n_technologies/frameworks/vue.md +1 -1
- package/blog/hi/what_is_internationalization.md +2 -2
- package/blog/it/intlayer_with_next-intl.md +0 -1
- package/blog/it/list_i18n_technologies/CMS/wordpress.md +1 -1
- package/blog/it/list_i18n_technologies/frameworks/angular.md +1 -1
- package/blog/it/list_i18n_technologies/frameworks/react-native.md +1 -1
- package/blog/it/list_i18n_technologies/frameworks/react.md +1 -1
- package/blog/it/list_i18n_technologies/frameworks/svelte.md +1 -1
- package/blog/it/list_i18n_technologies/frameworks/vue.md +1 -1
- package/blog/it/what_is_internationalization.md +2 -2
- package/blog/ja/intlayer_with_next-intl.md +0 -1
- package/blog/ja/list_i18n_technologies/CMS/wordpress.md +1 -1
- package/blog/ja/list_i18n_technologies/frameworks/angular.md +1 -1
- package/blog/ja/list_i18n_technologies/frameworks/flutter.md +1 -1
- package/blog/ja/list_i18n_technologies/frameworks/react-native.md +1 -1
- package/blog/ja/list_i18n_technologies/frameworks/react.md +1 -1
- package/blog/ja/list_i18n_technologies/frameworks/svelte.md +1 -1
- package/blog/ja/list_i18n_technologies/frameworks/vue.md +1 -1
- package/blog/ja/what_is_internationalization.md +2 -2
- package/blog/ko/intlayer_with_next-intl.md +0 -1
- package/blog/ko/list_i18n_technologies/CMS/wordpress.md +1 -1
- package/blog/ko/list_i18n_technologies/frameworks/angular.md +1 -1
- package/blog/ko/list_i18n_technologies/frameworks/react-native.md +1 -1
- package/blog/ko/list_i18n_technologies/frameworks/react.md +1 -1
- package/blog/ko/list_i18n_technologies/frameworks/vue.md +1 -1
- package/blog/pt/intlayer_with_next-intl.md +0 -1
- package/blog/pt/list_i18n_technologies/CMS/wordpress.md +1 -1
- package/blog/pt/list_i18n_technologies/frameworks/angular.md +1 -1
- package/blog/pt/list_i18n_technologies/frameworks/flutter.md +1 -1
- package/blog/pt/list_i18n_technologies/frameworks/react-native.md +1 -1
- package/blog/pt/list_i18n_technologies/frameworks/react.md +1 -1
- package/blog/pt/list_i18n_technologies/frameworks/svelte.md +1 -1
- package/blog/pt/list_i18n_technologies/frameworks/vue.md +1 -1
- package/blog/pt/what_is_internationalization.md +2 -2
- package/blog/ru/intlayer_with_next-intl.md +0 -1
- package/blog/ru/list_i18n_technologies/CMS/wordpress.md +1 -1
- package/blog/ru/list_i18n_technologies/frameworks/angular.md +1 -1
- package/blog/ru/list_i18n_technologies/frameworks/flutter.md +1 -1
- package/blog/ru/list_i18n_technologies/frameworks/react-native.md +1 -1
- package/blog/ru/list_i18n_technologies/frameworks/react.md +1 -1
- package/blog/ru/list_i18n_technologies/frameworks/svelte.md +1 -1
- package/blog/ru/list_i18n_technologies/frameworks/vue.md +1 -1
- package/blog/ru/what_is_internationalization.md +2 -2
- package/blog/zh/intlayer_with_next-intl.md +0 -1
- package/blog/zh/list_i18n_technologies/CMS/wordpress.md +1 -1
- package/blog/zh/list_i18n_technologies/frameworks/angular.md +1 -1
- package/blog/zh/list_i18n_technologies/frameworks/flutter.md +1 -1
- package/blog/zh/list_i18n_technologies/frameworks/react-native.md +1 -1
- package/blog/zh/list_i18n_technologies/frameworks/react.md +1 -1
- package/blog/zh/list_i18n_technologies/frameworks/svelte.md +1 -1
- package/blog/zh/list_i18n_technologies/frameworks/vue.md +1 -1
- package/blog/zh/what_is_internationalization.md +2 -2
- package/dist/cjs/blog.cjs +2 -2
- package/dist/cjs/blog.cjs.map +1 -1
- package/dist/cjs/common.cjs +17 -6
- package/dist/cjs/common.cjs.map +1 -1
- package/dist/cjs/doc.cjs +2 -2
- package/dist/cjs/doc.cjs.map +1 -1
- package/dist/cjs/frequentQuestions.cjs +2 -2
- package/dist/cjs/frequentQuestions.cjs.map +1 -1
- package/dist/cjs/generated/blog.entry.cjs +1152 -252
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/cjs/generated/docs.entry.cjs +3778 -1124
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/cjs/generated/frequentQuestions.entry.cjs +794 -161
- package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
- package/dist/cjs/generated/legal.entry.cjs +32 -31
- package/dist/cjs/generated/legal.entry.cjs.map +1 -1
- package/dist/cjs/legal.cjs +2 -2
- package/dist/cjs/legal.cjs.map +1 -1
- package/dist/esm/blog.mjs +2 -2
- package/dist/esm/blog.mjs.map +1 -1
- package/dist/esm/common.mjs +17 -6
- package/dist/esm/common.mjs.map +1 -1
- package/dist/esm/doc.mjs +2 -2
- package/dist/esm/doc.mjs.map +1 -1
- package/dist/esm/frequentQuestions.mjs +2 -2
- package/dist/esm/frequentQuestions.mjs.map +1 -1
- package/dist/esm/generated/blog.entry.mjs +1151 -252
- package/dist/esm/generated/blog.entry.mjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +3777 -1124
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/esm/generated/frequentQuestions.entry.mjs +793 -161
- package/dist/esm/generated/frequentQuestions.entry.mjs.map +1 -1
- package/dist/esm/generated/legal.entry.mjs +31 -31
- package/dist/esm/generated/legal.entry.mjs.map +1 -1
- package/dist/esm/legal.mjs +2 -2
- package/dist/esm/legal.mjs.map +1 -1
- package/dist/types/blog.d.ts +2 -2
- package/dist/types/blog.d.ts.map +1 -1
- package/dist/types/common.d.ts +5 -2
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/doc.d.ts +2 -2
- package/dist/types/doc.d.ts.map +1 -1
- package/dist/types/frequentQuestions.d.ts +2 -2
- package/dist/types/frequentQuestions.d.ts.map +1 -1
- package/dist/types/generated/blog.entry.d.ts.map +1 -1
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/dist/types/generated/frequentQuestions.entry.d.ts +1 -0
- package/dist/types/generated/frequentQuestions.entry.d.ts.map +1 -1
- package/dist/types/generated/legal.entry.d.ts.map +1 -1
- package/dist/types/legal.d.ts +2 -2
- package/dist/types/legal.d.ts.map +1 -1
- package/docs/ar/intlayer_CMS.md +1 -0
- package/docs/ar/intlayer_cli.md +292 -177
- package/docs/ar/intlayer_visual_editor.md +1 -0
- package/docs/ar/intlayer_with_angular.md +1 -0
- package/docs/ar/intlayer_with_create_react_app.md +1 -0
- package/docs/ar/intlayer_with_lynx+react.md +1 -0
- package/docs/ar/intlayer_with_nextjs_14.md +1 -0
- package/docs/ar/intlayer_with_nextjs_15.md +3 -1
- package/docs/ar/intlayer_with_nuxt.md +1 -0
- package/docs/ar/intlayer_with_react_native+expo.md +1 -0
- package/docs/ar/intlayer_with_vite+preact.md +4 -3
- package/docs/ar/intlayer_with_vite+react.md +108 -112
- package/docs/ar/intlayer_with_vite+solid.md +4 -3
- package/docs/ar/intlayer_with_vite+svelte.md +4 -3
- package/docs/ar/intlayer_with_vite+vue.md +5 -4
- package/docs/ar/mcp_server.md +126 -92
- package/docs/de/intlayer_CMS.md +1 -0
- package/docs/de/intlayer_cli.md +291 -171
- package/docs/de/intlayer_visual_editor.md +1 -0
- package/docs/de/intlayer_with_angular.md +1 -0
- package/docs/de/intlayer_with_create_react_app.md +1 -0
- package/docs/de/intlayer_with_lynx+react.md +1 -0
- package/docs/de/intlayer_with_nextjs_14.md +1 -0
- package/docs/de/intlayer_with_nextjs_15.md +3 -1
- package/docs/de/intlayer_with_nuxt.md +1 -0
- package/docs/de/intlayer_with_react_native+expo.md +1 -0
- package/docs/de/intlayer_with_vite+preact.md +4 -3
- package/docs/de/intlayer_with_vite+react.md +128 -146
- package/docs/de/intlayer_with_vite+solid.md +4 -3
- package/docs/de/intlayer_with_vite+svelte.md +4 -3
- package/docs/de/intlayer_with_vite+vue.md +5 -4
- package/docs/de/mcp_server.md +116 -112
- package/docs/en/CI_CD.md +3 -1
- package/docs/en/autoFill.md +3 -1
- package/docs/en/configuration.md +7 -3
- package/docs/en/dictionary/condition.md +3 -1
- package/docs/en/dictionary/content_extention_customization.md +3 -1
- package/docs/en/dictionary/enumeration.md +3 -1
- package/docs/en/dictionary/file.md +3 -1
- package/docs/en/dictionary/function_fetching.md +3 -1
- package/docs/en/dictionary/get_started.md +3 -1
- package/docs/en/dictionary/insertion.md +3 -1
- package/docs/en/dictionary/markdown.md +3 -1
- package/docs/en/dictionary/nesting.md +3 -1
- package/docs/en/dictionary/translation.md +3 -1
- package/docs/en/how_works_intlayer.md +3 -1
- package/docs/en/index.md +3 -1
- package/docs/en/interest_of_intlayer.md +3 -1
- package/docs/en/intlayer_CMS.md +4 -1
- package/docs/en/intlayer_cli.md +246 -136
- package/docs/en/intlayer_visual_editor.md +4 -1
- package/docs/en/intlayer_with_angular.md +4 -1
- package/docs/en/intlayer_with_create_react_app.md +4 -1
- package/docs/en/intlayer_with_express.md +3 -1
- package/docs/en/intlayer_with_lynx+react.md +4 -1
- package/docs/en/intlayer_with_nextjs_14.md +7 -1
- package/docs/en/intlayer_with_nextjs_15.md +8 -2
- package/docs/en/intlayer_with_nextjs_page_router.md +5 -1
- package/docs/en/intlayer_with_nuxt.md +4 -1
- package/docs/en/intlayer_with_react_native+expo.md +4 -1
- package/docs/en/intlayer_with_vite+preact.md +9 -4
- package/docs/en/intlayer_with_vite+react.md +18 -10
- package/docs/en/intlayer_with_vite+solid.md +7 -4
- package/docs/en/intlayer_with_vite+svelte.md +7 -4
- package/docs/en/intlayer_with_vite+vue.md +10 -5
- package/docs/en/introduction.md +3 -1
- package/docs/en/mcp_server.md +114 -80
- package/docs/en/packages/@intlayer/api/index.md +3 -1
- package/docs/en/packages/@intlayer/chokidar/index.md +3 -1
- package/docs/en/packages/@intlayer/cli/index.md +3 -1
- package/docs/en/packages/@intlayer/config/index.md +3 -1
- package/docs/en/packages/@intlayer/core/index.md +3 -1
- package/docs/en/packages/@intlayer/design-system/index.md +3 -1
- package/docs/en/packages/@intlayer/dictionary-entry/index.md +3 -1
- package/docs/en/packages/@intlayer/editor/index.md +3 -1
- package/docs/en/packages/@intlayer/editor-react/index.md +3 -1
- package/docs/en/packages/@intlayer/webpack/index.md +3 -1
- package/docs/en/packages/angular-intlayer/index.md +3 -1
- package/docs/en/packages/express-intlayer/index.md +3 -1
- package/docs/en/packages/express-intlayer/t.md +3 -1
- package/docs/en/packages/intlayer/getConfiguration.md +3 -1
- package/docs/en/packages/intlayer/getEnumeration.md +3 -1
- package/docs/en/packages/intlayer/getHTMLTextDir.md +3 -1
- package/docs/en/packages/intlayer/getLocaleLang.md +3 -1
- package/docs/en/packages/intlayer/getLocaleName.md +3 -1
- package/docs/en/packages/intlayer/getLocalizedUrl.md +3 -1
- package/docs/en/packages/intlayer/getMultilingualUrls.md +3 -1
- package/docs/en/packages/intlayer/getPathWithoutLocale.md +3 -1
- package/docs/en/packages/intlayer/getTranslation.md +3 -1
- package/docs/en/packages/intlayer/getTranslationContent.md +3 -1
- package/docs/en/packages/intlayer/index.md +3 -1
- package/docs/en/packages/intlayer-cli/index.md +3 -1
- package/docs/en/packages/intlayer-editor/index.md +3 -1
- package/docs/en/packages/lynx-intlayer/index.md +3 -1
- package/docs/en/packages/next-intlayer/index.md +3 -1
- package/docs/en/packages/next-intlayer/t.md +3 -1
- package/docs/en/packages/next-intlayer/useDictionary.md +3 -1
- package/docs/en/packages/next-intlayer/useIntlayer.md +3 -1
- package/docs/en/packages/next-intlayer/useIntlayerAsync.md +3 -1
- package/docs/en/packages/next-intlayer/useLocale.md +3 -1
- package/docs/en/packages/nuxt-intlayer/index.md +3 -1
- package/docs/en/packages/preact-intlayer/index.md +3 -1
- package/docs/en/packages/react-intlayer/index.md +3 -1
- package/docs/en/packages/react-intlayer/t.md +3 -1
- package/docs/en/packages/react-intlayer/useDictionary.md +3 -1
- package/docs/en/packages/react-intlayer/useIntlayer.md +3 -1
- package/docs/en/packages/react-intlayer/useIntlayerAsync.md +3 -1
- package/docs/en/packages/react-intlayer/useLocale.md +3 -1
- package/docs/en/packages/react-native-intlayer/index.md +3 -1
- package/docs/en/packages/react-scripts-intlayer/index.md +3 -1
- package/docs/en/packages/solid-intlayer/index.md +3 -1
- package/docs/en/packages/svelte-intlayer/index.md +3 -1
- package/docs/en/packages/vite-intlayer/index.md +3 -1
- package/docs/en/packages/vue-intlayer/index.md +3 -1
- package/docs/en/per_locale_file.md +3 -1
- package/docs/en/roadmap.md +5 -2
- package/docs/en/vs_code_extension.md +3 -1
- package/docs/en-GB/intlayer_CMS.md +1 -0
- package/docs/en-GB/intlayer_cli.md +257 -138
- package/docs/en-GB/intlayer_visual_editor.md +1 -0
- package/docs/en-GB/intlayer_with_angular.md +1 -0
- package/docs/en-GB/intlayer_with_create_react_app.md +1 -0
- package/docs/en-GB/intlayer_with_lynx+react.md +1 -0
- package/docs/en-GB/intlayer_with_nextjs_14.md +1 -0
- package/docs/en-GB/intlayer_with_nextjs_15.md +3 -1
- package/docs/en-GB/intlayer_with_nuxt.md +1 -0
- package/docs/en-GB/intlayer_with_react_native+expo.md +1 -0
- package/docs/en-GB/intlayer_with_vite+preact.md +4 -3
- package/docs/en-GB/intlayer_with_vite+react.md +71 -87
- package/docs/en-GB/intlayer_with_vite+solid.md +4 -3
- package/docs/en-GB/intlayer_with_vite+svelte.md +4 -3
- package/docs/en-GB/intlayer_with_vite+vue.md +5 -4
- package/docs/en-GB/mcp_server.md +116 -82
- package/docs/es/intlayer_CMS.md +1 -0
- package/docs/es/intlayer_cli.md +283 -164
- package/docs/es/intlayer_visual_editor.md +1 -0
- package/docs/es/intlayer_with_angular.md +1 -0
- package/docs/es/intlayer_with_create_react_app.md +1 -0
- package/docs/es/intlayer_with_lynx+react.md +1 -0
- package/docs/es/intlayer_with_nextjs_14.md +1 -0
- package/docs/es/intlayer_with_nextjs_15.md +3 -1
- package/docs/es/intlayer_with_nuxt.md +1 -0
- package/docs/es/intlayer_with_react_native+expo.md +1 -0
- package/docs/es/intlayer_with_vite+preact.md +4 -3
- package/docs/es/intlayer_with_vite+react.md +98 -98
- package/docs/es/intlayer_with_vite+solid.md +4 -3
- package/docs/es/intlayer_with_vite+svelte.md +4 -3
- package/docs/es/intlayer_with_vite+vue.md +5 -4
- package/docs/es/mcp_server.md +120 -86
- package/docs/es/vs_code_extension.md +1 -0
- package/docs/fr/intlayer_CMS.md +1 -0
- package/docs/fr/intlayer_cli.md +280 -184
- package/docs/fr/intlayer_visual_editor.md +1 -0
- package/docs/fr/intlayer_with_angular.md +1 -0
- package/docs/fr/intlayer_with_create_react_app.md +1 -0
- package/docs/fr/intlayer_with_lynx+react.md +1 -0
- package/docs/fr/intlayer_with_nextjs_14.md +1 -0
- package/docs/fr/intlayer_with_nextjs_15.md +3 -1
- package/docs/fr/intlayer_with_nuxt.md +1 -0
- package/docs/fr/intlayer_with_react_native+expo.md +1 -0
- package/docs/fr/intlayer_with_vite+preact.md +5 -4
- package/docs/fr/intlayer_with_vite+react.md +80 -69
- package/docs/fr/intlayer_with_vite+solid.md +4 -3
- package/docs/fr/intlayer_with_vite+svelte.md +4 -3
- package/docs/fr/intlayer_with_vite+vue.md +5 -4
- package/docs/fr/mcp_server.md +121 -87
- package/docs/hi/intlayer_CMS.md +1 -0
- package/docs/hi/intlayer_cli.md +295 -174
- package/docs/hi/intlayer_visual_editor.md +1 -0
- package/docs/hi/intlayer_with_angular.md +1 -0
- package/docs/hi/intlayer_with_create_react_app.md +1 -0
- package/docs/hi/intlayer_with_lynx+react.md +1 -0
- package/docs/hi/intlayer_with_nextjs_14.md +1 -0
- package/docs/hi/intlayer_with_nextjs_15.md +3 -1
- package/docs/hi/intlayer_with_nuxt.md +1 -0
- package/docs/hi/intlayer_with_react_native+expo.md +1 -0
- package/docs/hi/intlayer_with_vite+preact.md +4 -3
- package/docs/hi/intlayer_with_vite+react.md +114 -111
- package/docs/hi/intlayer_with_vite+solid.md +4 -3
- package/docs/hi/intlayer_with_vite+svelte.md +4 -3
- package/docs/hi/intlayer_with_vite+vue.md +5 -4
- package/docs/hi/mcp_server.md +118 -84
- package/docs/it/intlayer_CMS.md +1 -0
- package/docs/it/intlayer_cli.md +282 -167
- package/docs/it/intlayer_visual_editor.md +1 -0
- package/docs/it/intlayer_with_angular.md +1 -0
- package/docs/it/intlayer_with_create_react_app.md +1 -0
- package/docs/it/intlayer_with_lynx+react.md +1 -0
- package/docs/it/intlayer_with_nextjs_14.md +1 -0
- package/docs/it/intlayer_with_nextjs_15.md +3 -1
- package/docs/it/intlayer_with_nuxt.md +1 -0
- package/docs/it/intlayer_with_react_native+expo.md +1 -0
- package/docs/it/intlayer_with_vite+preact.md +4 -3
- package/docs/it/intlayer_with_vite+react.md +163 -116
- package/docs/it/intlayer_with_vite+solid.md +4 -3
- package/docs/it/intlayer_with_vite+svelte.md +4 -3
- package/docs/it/intlayer_with_vite+vue.md +4 -4
- package/docs/it/mcp_server.md +120 -86
- package/docs/ja/intlayer_CMS.md +1 -0
- package/docs/ja/intlayer_cli.md +285 -168
- package/docs/ja/intlayer_visual_editor.md +1 -0
- package/docs/ja/intlayer_with_angular.md +1 -0
- package/docs/ja/intlayer_with_create_react_app.md +1 -0
- package/docs/ja/intlayer_with_lynx+react.md +1 -0
- package/docs/ja/intlayer_with_nextjs_14.md +1 -0
- package/docs/ja/intlayer_with_nextjs_15.md +3 -1
- package/docs/ja/intlayer_with_nuxt.md +1 -0
- package/docs/ja/intlayer_with_react_native+expo.md +1 -0
- package/docs/ja/intlayer_with_vite+preact.md +4 -3
- package/docs/ja/intlayer_with_vite+react.md +160 -222
- package/docs/ja/intlayer_with_vite+solid.md +4 -3
- package/docs/ja/intlayer_with_vite+svelte.md +4 -3
- package/docs/ja/intlayer_with_vite+vue.md +5 -4
- package/docs/ja/mcp_server.md +121 -85
- package/docs/ko/intlayer_CMS.md +1 -0
- package/docs/ko/intlayer_cli.md +291 -175
- package/docs/ko/intlayer_visual_editor.md +1 -0
- package/docs/ko/intlayer_with_angular.md +1 -0
- package/docs/ko/intlayer_with_create_react_app.md +1 -0
- package/docs/ko/intlayer_with_lynx+react.md +1 -0
- package/docs/ko/intlayer_with_nextjs_14.md +1 -0
- package/docs/ko/intlayer_with_nextjs_15.md +3 -1
- package/docs/ko/intlayer_with_nuxt.md +1 -0
- package/docs/ko/intlayer_with_react_native+expo.md +1 -0
- package/docs/ko/intlayer_with_vite+preact.md +4 -3
- package/docs/ko/intlayer_with_vite+react.md +123 -152
- package/docs/ko/intlayer_with_vite+solid.md +4 -3
- package/docs/ko/intlayer_with_vite+svelte.md +4 -3
- package/docs/ko/intlayer_with_vite+vue.md +5 -4
- package/docs/ko/mcp_server.md +117 -83
- package/docs/ko/packages/intlayer/getLocalizedUrl.md +1 -23
- package/docs/pt/intlayer_CMS.md +1 -0
- package/docs/pt/intlayer_cli.md +274 -154
- package/docs/pt/intlayer_visual_editor.md +1 -0
- package/docs/pt/intlayer_with_angular.md +1 -0
- package/docs/pt/intlayer_with_create_react_app.md +1 -0
- package/docs/pt/intlayer_with_lynx+react.md +1 -0
- package/docs/pt/intlayer_with_nextjs_14.md +1 -0
- package/docs/pt/intlayer_with_nextjs_15.md +3 -1
- package/docs/pt/intlayer_with_nuxt.md +1 -0
- package/docs/pt/intlayer_with_react_native+expo.md +1 -0
- package/docs/pt/intlayer_with_vite+preact.md +4 -3
- package/docs/pt/intlayer_with_vite+react.md +117 -136
- package/docs/pt/intlayer_with_vite+solid.md +4 -3
- package/docs/pt/intlayer_with_vite+svelte.md +4 -3
- package/docs/pt/intlayer_with_vite+vue.md +4 -4
- package/docs/pt/mcp_server.md +121 -87
- package/docs/ru/intlayer_CMS.md +1 -0
- package/docs/ru/intlayer_cli.md +287 -170
- package/docs/ru/intlayer_visual_editor.md +1 -0
- package/docs/ru/intlayer_with_angular.md +1 -0
- package/docs/ru/intlayer_with_create_react_app.md +1 -0
- package/docs/ru/intlayer_with_lynx+react.md +1 -0
- package/docs/ru/intlayer_with_nextjs_14.md +1 -0
- package/docs/ru/intlayer_with_nextjs_15.md +3 -1
- package/docs/ru/intlayer_with_nuxt.md +1 -0
- package/docs/ru/intlayer_with_react_native+expo.md +1 -0
- package/docs/ru/intlayer_with_vite+preact.md +4 -3
- package/docs/ru/intlayer_with_vite+react.md +105 -87
- package/docs/ru/intlayer_with_vite+solid.md +4 -3
- package/docs/ru/intlayer_with_vite+svelte.md +4 -3
- package/docs/ru/intlayer_with_vite+vue.md +5 -4
- package/docs/ru/mcp_server.md +119 -85
- package/docs/zh/intlayer_CMS.md +1 -0
- package/docs/zh/intlayer_cli.md +275 -155
- package/docs/zh/intlayer_visual_editor.md +1 -0
- package/docs/zh/intlayer_with_angular.md +1 -0
- package/docs/zh/intlayer_with_create_react_app.md +1 -0
- package/docs/zh/intlayer_with_lynx+react.md +1 -0
- package/docs/zh/intlayer_with_nextjs_14.md +1 -0
- package/docs/zh/intlayer_with_nextjs_15.md +3 -1
- package/docs/zh/intlayer_with_nuxt.md +1 -0
- package/docs/zh/intlayer_with_react_native+expo.md +1 -0
- package/docs/zh/intlayer_with_vite+preact.md +4 -3
- package/docs/zh/intlayer_with_vite+react.md +154 -188
- package/docs/zh/intlayer_with_vite+solid.md +4 -3
- package/docs/zh/intlayer_with_vite+svelte.md +4 -3
- package/docs/zh/intlayer_with_vite+vue.md +5 -4
- package/docs/zh/mcp_server.md +119 -86
- package/docs/zh/packages/intlayer/getLocalizedUrl.md +1 -23
- package/frequent_questions/ar/build_error_CI_CD.md +75 -0
- package/frequent_questions/de/build_error_CI_CD.md +75 -0
- package/frequent_questions/en/build_error_CI_CD.md +75 -0
- package/frequent_questions/en-GB/build_error_CI_CD.md +75 -0
- package/frequent_questions/es/build_error_CI_CD.md +75 -0
- package/frequent_questions/fr/build_error_CI_CD.md +75 -0
- package/frequent_questions/hi/build_error_CI_CD.md +75 -0
- package/frequent_questions/it/build_error_CI_CD.md +75 -0
- package/frequent_questions/ja/build_error_CI_CD.md +75 -0
- package/frequent_questions/ja/intlayer_command_undefined.md +3 -3
- package/frequent_questions/ko/build_error_CI_CD.md +75 -0
- package/frequent_questions/ko/intlayer_command_undefined.md +3 -3
- package/frequent_questions/pt/build_error_CI_CD.md +75 -0
- package/frequent_questions/ru/build_error_CI_CD.md +75 -0
- package/frequent_questions/zh/build_error_CI_CD.md +75 -0
- package/frequent_questions/zh/intlayer_command_undefined.md +3 -3
- package/legal/ar/privacy_notice.md +83 -0
- package/legal/ar/terms_of_service.md +55 -0
- package/legal/de/privacy_notice.md +83 -0
- package/legal/de/terms_of_service.md +55 -0
- package/legal/en/privacy_notice.md +83 -0
- package/legal/en/terms_of_service.md +55 -0
- package/legal/en-GB/privacy_notice.md +83 -0
- package/legal/en-GB/terms_of_service.md +55 -0
- package/legal/es/privacy_notice.md +83 -0
- package/legal/es/terms_of_service.md +55 -0
- package/legal/fr/privacy_notice.md +83 -0
- package/legal/fr/terms_of_service.md +55 -0
- package/legal/hi/privacy_notice.md +83 -0
- package/legal/hi/terms_of_service.md +55 -0
- package/legal/it/privacy_notice.md +83 -0
- package/legal/it/terms_of_service.md +55 -0
- package/legal/ja/privacy_notice.md +83 -0
- package/legal/ja/terms_of_service.md +55 -0
- package/legal/ko/privacy_notice.md +83 -0
- package/legal/ko/terms_of_service.md +55 -0
- package/legal/pt/privacy_notice.md +83 -0
- package/legal/pt/terms_of_service.md +55 -0
- package/legal/ru/privacy_notice.md +83 -0
- package/legal/ru/terms_of_service.md +55 -0
- package/legal/zh/privacy_notice.md +83 -0
- package/legal/zh/terms_of_service.md +55 -0
- package/package.json +12 -11
- package/src/blog.ts +6 -4
- package/src/common.ts +25 -7
- package/src/doc.ts +6 -4
- package/src/frequentQuestions.ts +6 -4
- package/src/generated/blog.entry.ts +1177 -280
- package/src/generated/docs.entry.ts +3868 -1217
- package/src/generated/frequentQuestions.entry.ts +808 -178
- package/src/generated/legal.entry.ts +34 -36
- package/src/legal.ts +6 -4
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
---
|
|
2
|
-
createdAt:
|
|
3
|
-
updatedAt:
|
|
4
|
-
title:
|
|
5
|
-
description:
|
|
2
|
+
createdAt: 2024-03-07
|
|
3
|
+
updatedAt: 2024-03-07
|
|
4
|
+
title: Começando com Intlayer em Vite + React
|
|
5
|
+
description: Aprenda como adicionar internacionalização (i18n) à sua aplicação Vite e React usando Intlayer. Siga este guia para tornar seu app multilíngue.
|
|
6
6
|
keywords:
|
|
7
7
|
- Internacionalização
|
|
8
8
|
- Documentação
|
|
9
9
|
- Intlayer
|
|
10
10
|
- Vite
|
|
11
11
|
- React
|
|
12
|
-
-
|
|
12
|
+
- i18n
|
|
13
13
|
- JavaScript
|
|
14
14
|
slugs:
|
|
15
15
|
- doc
|
|
16
16
|
- environment
|
|
17
|
-
-
|
|
18
|
-
|
|
17
|
+
- vite-and-react
|
|
18
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-vite-react-template
|
|
19
|
+
youtubeVideo: https://www.youtube.com/watch?v=dS9L7uJeak4---
|
|
19
20
|
|
|
20
21
|
# Começando a Internacionalizar (i18n) com Intlayer, Vite e React
|
|
21
22
|
|
|
23
|
+
<iframe title="The best i18n solution for Vite and React? Discover Intlayer" 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"/>
|
|
24
|
+
|
|
22
25
|
Veja o [Modelo de Aplicação](https://github.com/aymericzip/intlayer-vite-react-template) no GitHub.
|
|
23
26
|
|
|
24
27
|
## O que é Intlayer?
|
|
@@ -27,10 +30,10 @@ Veja o [Modelo de Aplicação](https://github.com/aymericzip/intlayer-vite-react
|
|
|
27
30
|
|
|
28
31
|
Com o Intlayer, você pode:
|
|
29
32
|
|
|
30
|
-
- **
|
|
31
|
-
- **
|
|
32
|
-
- **
|
|
33
|
-
- **
|
|
33
|
+
- **Gerencie traduções facilmente** usando dicionários declarativos no nível do componente.
|
|
34
|
+
- **Localize dinamicamente metadados**, rotas e conteúdo.
|
|
35
|
+
- **Garanta suporte ao TypeScript** com tipos autogerados, melhorando o autocompletar e a detecção de erros.
|
|
36
|
+
- **Beneficie-se de recursos avançados**, como detecção e troca dinâmica de localidade.
|
|
34
37
|
|
|
35
38
|
---
|
|
36
39
|
|
|
@@ -42,17 +45,17 @@ Instale os pacotes necessários usando npm:
|
|
|
42
45
|
|
|
43
46
|
```bash packageManager="npm"
|
|
44
47
|
npm install intlayer react-intlayer
|
|
45
|
-
npm install --save-dev
|
|
48
|
+
npm install vite-intlayer --save-dev
|
|
46
49
|
```
|
|
47
50
|
|
|
48
51
|
```bash packageManager="pnpm"
|
|
49
52
|
pnpm add intlayer react-intlayer
|
|
50
|
-
pnpm add --save-dev
|
|
53
|
+
pnpm add vite-intlayer --save-dev
|
|
51
54
|
```
|
|
52
55
|
|
|
53
56
|
```bash packageManager="yarn"
|
|
54
57
|
yarn add intlayer react-intlayer
|
|
55
|
-
yarn add --save-dev
|
|
58
|
+
yarn add vite-intlayer --save-dev
|
|
56
59
|
```
|
|
57
60
|
|
|
58
61
|
- **intlayer**
|
|
@@ -63,7 +66,7 @@ yarn add --save-dev vite-intlayer
|
|
|
63
66
|
O pacote que integra o Intlayer com aplicações React. Ele fornece provedores de contexto e hooks para internacionalização em React.
|
|
64
67
|
|
|
65
68
|
- **vite-intlayer**
|
|
66
|
-
Inclui o plugin Vite para integrar o Intlayer com o [empacotador Vite](https://vite.dev/guide/why.html#why-bundle-for-production),
|
|
69
|
+
Inclui o plugin Vite para integrar o Intlayer com o [empacotador Vite](https://vite.dev/guide/why.html#why-bundle-for-production), além de middleware para detectar a localidade preferida do usuário, gerenciar cookies e lidar com redirecionamento de URL.
|
|
67
70
|
|
|
68
71
|
### Passo 2: Configuração do seu projeto
|
|
69
72
|
|
|
@@ -164,7 +167,7 @@ module.exports = defineConfig({
|
|
|
164
167
|
});
|
|
165
168
|
```
|
|
166
169
|
|
|
167
|
-
> O plugin Vite `intlayerPlugin()` é usado para integrar o Intlayer com o Vite. Ele garante a construção dos arquivos de declaração de conteúdo e os monitora no modo de desenvolvimento. Define
|
|
170
|
+
> O plugin Vite `intlayerPlugin()` é usado para integrar o Intlayer com o Vite. Ele garante a construção dos arquivos de declaração de conteúdo e os monitora no modo de desenvolvimento. Define variáveis de ambiente do Intlayer dentro da aplicação Vite. Além disso, fornece aliases para otimizar o desempenho.
|
|
168
171
|
|
|
169
172
|
### Passo 4: Declare Seu Conteúdo
|
|
170
173
|
|
|
@@ -215,7 +218,7 @@ const appContent = {
|
|
|
215
218
|
}),
|
|
216
219
|
|
|
217
220
|
readTheDocs: t({
|
|
218
|
-
en: "
|
|
221
|
+
en: "Clique nos logos do Vite e React para saber mais",
|
|
219
222
|
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
220
223
|
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
221
224
|
}),
|
|
@@ -255,7 +258,7 @@ const appContent = {
|
|
|
255
258
|
t <
|
|
256
259
|
ReactNode >
|
|
257
260
|
{
|
|
258
|
-
// Não se esqueça de importar React se
|
|
261
|
+
// Não se esqueça de importar React se usar um nó React no seu conteúdo
|
|
259
262
|
en: (
|
|
260
263
|
<>
|
|
261
264
|
Edit <code>src/App.tsx</code> e salve para testar HMR
|
|
@@ -274,7 +277,7 @@ const appContent = {
|
|
|
274
277
|
},
|
|
275
278
|
|
|
276
279
|
readTheDocs: t({
|
|
277
|
-
en: "
|
|
280
|
+
en: "Click on the Vite and React logos to learn more",
|
|
278
281
|
fr: "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
279
282
|
es: "Haga clic en los logotipos de Vite y React para obtener más información",
|
|
280
283
|
}),
|
|
@@ -292,13 +295,13 @@ const appContent = {
|
|
|
292
295
|
key: "app",
|
|
293
296
|
content: {
|
|
294
297
|
viteLogo: t({
|
|
295
|
-
pt: "Logo
|
|
298
|
+
pt: "Logo Vite",
|
|
296
299
|
en: "Vite logo",
|
|
297
300
|
fr: "Logo Vite",
|
|
298
301
|
es: "Logo Vite",
|
|
299
302
|
}),
|
|
300
303
|
reactLogo: t({
|
|
301
|
-
pt: "Logo
|
|
304
|
+
pt: "Logo React",
|
|
302
305
|
en: "React logo",
|
|
303
306
|
fr: "Logo React",
|
|
304
307
|
es: "Logo React",
|
|
@@ -360,7 +363,7 @@ module.exports = appContent;
|
|
|
360
363
|
"viteLogo": {
|
|
361
364
|
"nodeType": "translation",
|
|
362
365
|
"translation": {
|
|
363
|
-
"pt": "Logo
|
|
366
|
+
"pt": "Logo Vite",
|
|
364
367
|
"en": "Vite logo",
|
|
365
368
|
"fr": "Logo Vite",
|
|
366
369
|
"es": "Logo Vite"
|
|
@@ -369,43 +372,43 @@ module.exports = appContent;
|
|
|
369
372
|
"reactLogo": {
|
|
370
373
|
"nodeType": "translation",
|
|
371
374
|
"translation": {
|
|
372
|
-
"pt": "Logo React",
|
|
373
375
|
"en": "React logo",
|
|
374
376
|
"fr": "Logo React",
|
|
375
|
-
"es": "Logo React"
|
|
377
|
+
"es": "Logo React",
|
|
378
|
+
"pt": "Logo React"
|
|
376
379
|
}
|
|
377
380
|
},
|
|
378
381
|
"title": {
|
|
379
382
|
"nodeType": "translation",
|
|
380
383
|
"translation": {
|
|
381
|
-
"pt": "Vite + React",
|
|
382
384
|
"en": "Vite + React",
|
|
383
385
|
"fr": "Vite + React",
|
|
384
|
-
"es": "Vite + React"
|
|
386
|
+
"es": "Vite + React",
|
|
387
|
+
"pt": "Vite + React"
|
|
385
388
|
}
|
|
386
389
|
},
|
|
387
390
|
"count": {
|
|
388
391
|
"nodeType": "translation",
|
|
389
392
|
"translation": {
|
|
390
|
-
"pt": "a contagem é ",
|
|
391
393
|
"en": "count is ",
|
|
392
394
|
"fr": "le compte est ",
|
|
393
|
-
"es": "el recuento es "
|
|
395
|
+
"es": "el recuento es ",
|
|
396
|
+
"pt": "a contagem é "
|
|
394
397
|
}
|
|
395
398
|
},
|
|
396
399
|
"edit": {
|
|
397
400
|
"nodeType": "translation",
|
|
398
401
|
"translation": {
|
|
399
|
-
"pt": "Edite src/App.tsx e salve para testar HMR",
|
|
400
402
|
"en": "Edit src/App.tsx and save to test HMR",
|
|
401
403
|
"fr": "Éditez src/App.tsx et enregistrez pour tester HMR",
|
|
402
|
-
"es": "Edita src/App.tsx y guarda para probar HMR"
|
|
404
|
+
"es": "Edita src/App.tsx y guarda para probar HMR",
|
|
405
|
+
"pt": "Edite src/App.tsx e salve para testar HMR"
|
|
403
406
|
}
|
|
404
407
|
},
|
|
405
408
|
"readTheDocs": {
|
|
406
409
|
"nodeType": "translation",
|
|
407
410
|
"translation": {
|
|
408
|
-
"pt": "Clique nos logos do Vite e React para saber mais",
|
|
411
|
+
"pt": "Clique nos logos do Vite e do React para saber mais",
|
|
409
412
|
"en": "Click on the Vite and React logos to learn more",
|
|
410
413
|
"fr": "Cliquez sur les logos Vite et React pour en savoir plus",
|
|
411
414
|
"es": "Haga clic en los logotipos de Vite y React para obtener más información"
|
|
@@ -566,7 +569,7 @@ const App = () => (
|
|
|
566
569
|
module.exports = App;
|
|
567
570
|
```
|
|
568
571
|
|
|
569
|
-
> Se quiser usar seu conteúdo em um atributo `string`, como `alt`, `title`, `href`, `aria-label`, etc., você deve chamar o valor da função, assim:
|
|
572
|
+
> Se você quiser usar seu conteúdo em um atributo do tipo `string`, como `alt`, `title`, `href`, `aria-label`, etc., você deve chamar o valor da função, assim:
|
|
570
573
|
|
|
571
574
|
> ```jsx
|
|
572
575
|
> <img src={content.image.src.value} alt={content.image.value} />
|
|
@@ -594,28 +597,6 @@ const LocaleSwitcher: FC = () => {
|
|
|
594
597
|
};
|
|
595
598
|
```
|
|
596
599
|
|
|
597
|
-
> Para saber mais sobre o hook `useIntlayer`, consulte a [documentação](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/packages/react-intlayer/useIntlayer.md).
|
|
598
|
-
|
|
599
|
-
### (Opcional) Passo 6: Alterar o idioma do seu conteúdo
|
|
600
|
-
|
|
601
|
-
Para alterar o idioma do seu conteúdo, você pode usar a função `setLocale` fornecida pelo hook `useLocale`. Esta função permite definir o locale da aplicação e atualizar o conteúdo de acordo.
|
|
602
|
-
|
|
603
|
-
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat="typescript"
|
|
604
|
-
import type { FC } from "react";
|
|
605
|
-
import { Locales } from "intlayer";
|
|
606
|
-
import { useLocale } from "react-intlayer";
|
|
607
|
-
|
|
608
|
-
const LocaleSwitcher: FC = () => {
|
|
609
|
-
const { setLocale } = useLocale();
|
|
610
|
-
|
|
611
|
-
return (
|
|
612
|
-
<button onClick={() => setLocale(Locales.English)}>
|
|
613
|
-
Alterar idioma para Inglês
|
|
614
|
-
</button>
|
|
615
|
-
);
|
|
616
|
-
};
|
|
617
|
-
```
|
|
618
|
-
|
|
619
600
|
```jsx fileName="src/components/LocaleSwitcher.msx" codeFormat="esm"
|
|
620
601
|
import { Locales } from "intlayer";
|
|
621
602
|
import { useLocale } from "react-intlayer";
|
|
@@ -648,7 +629,7 @@ const LocaleSwitcher = () => {
|
|
|
648
629
|
|
|
649
630
|
> Para saber mais sobre o hook `useLocale`, consulte a [documentação](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/packages/react-intlayer/useLocale.md).
|
|
650
631
|
|
|
651
|
-
### (Opcional) Passo 7: Adicionar
|
|
632
|
+
### (Opcional) Passo 7: Adicionar roteamento localizado à sua aplicação
|
|
652
633
|
|
|
653
634
|
O objetivo deste passo é criar rotas únicas para cada idioma. Isso é útil para SEO e URLs amigáveis para SEO.
|
|
654
635
|
Exemplo:
|
|
@@ -661,7 +642,7 @@ Exemplo:
|
|
|
661
642
|
|
|
662
643
|
> Por padrão, as rotas não são prefixadas para o idioma padrão. Se você quiser prefixar o idioma padrão, pode definir a opção `middleware.prefixDefault` como `true` na sua configuração. Veja a [documentação de configuração](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/configuration.md) para mais informações.
|
|
663
644
|
|
|
664
|
-
Para adicionar roteamento localizado à sua aplicação, você pode criar um componente `LocaleRouter` que envolve as rotas da sua aplicação e gerencia o roteamento baseado no idioma. Aqui está um exemplo usando
|
|
645
|
+
Para adicionar roteamento localizado à sua aplicação, você pode criar um componente `LocaleRouter` que envolve as rotas da sua aplicação e gerencia o roteamento baseado no idioma. Aqui está um exemplo usando [React Router](https://reactrouter.com/home):
|
|
665
646
|
|
|
666
647
|
```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
|
|
667
648
|
// Importando dependências e funções necessárias
|
|
@@ -674,7 +655,7 @@ import {
|
|
|
674
655
|
Route,
|
|
675
656
|
Navigate,
|
|
676
657
|
useLocation,
|
|
677
|
-
} from "react-router-dom"; // Componentes do roteador para
|
|
658
|
+
} from "react-router-dom"; // Componentes do roteador para gerenciar navegação
|
|
678
659
|
|
|
679
660
|
// Desestruturando configuração do Intlayer
|
|
680
661
|
const { internationalization, middleware } = configuration;
|
|
@@ -682,29 +663,29 @@ const { locales, defaultLocale } = internationalization;
|
|
|
682
663
|
|
|
683
664
|
/**
|
|
684
665
|
* Um componente que gerencia a localização e envolve os filhos com o contexto de local apropriado.
|
|
685
|
-
* Ele gerencia a detecção e validação
|
|
666
|
+
* Ele gerencia a detecção e validação da localidade baseada na URL.
|
|
686
667
|
*/
|
|
687
668
|
const AppLocalized: FC<PropsWithChildren<{ locale: Locales }>> = ({
|
|
688
669
|
children,
|
|
689
670
|
locale,
|
|
690
671
|
}) => {
|
|
691
|
-
const { pathname, search } = useLocation(); //
|
|
672
|
+
const { pathname, search } = useLocation(); // Obtém o caminho atual da URL
|
|
692
673
|
|
|
693
|
-
//
|
|
674
|
+
// Determina o idioma atual, usando o padrão caso não seja fornecido
|
|
694
675
|
const currentLocale = locale ?? defaultLocale;
|
|
695
676
|
|
|
696
|
-
//
|
|
677
|
+
// Remove o prefixo do idioma do caminho para construir um caminho base
|
|
697
678
|
const pathWithoutLocale = getPathWithoutLocale(
|
|
698
679
|
pathname // Caminho atual da URL
|
|
699
680
|
);
|
|
700
681
|
|
|
701
682
|
/**
|
|
702
|
-
* Se middleware.prefixDefault for true, o
|
|
683
|
+
* Se middleware.prefixDefault for true, o idioma padrão deve sempre ser prefixado.
|
|
703
684
|
*/
|
|
704
685
|
if (middleware.prefixDefault) {
|
|
705
|
-
//
|
|
686
|
+
// Valida o idioma
|
|
706
687
|
if (!locale || !locales.includes(locale)) {
|
|
707
|
-
//
|
|
688
|
+
// Redireciona para o idioma padrão com o caminho atualizado
|
|
708
689
|
return (
|
|
709
690
|
<Navigate
|
|
710
691
|
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
@@ -713,28 +694,28 @@ const AppLocalized: FC<PropsWithChildren<{ locale: Locales }>> = ({
|
|
|
713
694
|
);
|
|
714
695
|
}
|
|
715
696
|
|
|
716
|
-
// Envolve os filhos com o IntlayerProvider e define
|
|
697
|
+
// Envolve os filhos com o IntlayerProvider e define a localidade atual
|
|
717
698
|
return (
|
|
718
699
|
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
719
700
|
);
|
|
720
701
|
} else {
|
|
721
702
|
/**
|
|
722
|
-
* Quando middleware.prefixDefault é falso,
|
|
723
|
-
*
|
|
703
|
+
* Quando middleware.prefixDefault é falso, a localidade padrão não é prefixada.
|
|
704
|
+
* Assegura que a localidade atual seja válida e não a localidade padrão.
|
|
724
705
|
*/
|
|
725
706
|
if (
|
|
726
707
|
currentLocale.toString() !== defaultLocale.toString() &&
|
|
727
708
|
!locales
|
|
728
709
|
.filter(
|
|
729
|
-
(locale) => locale.toString() !== defaultLocale.toString() // Exclui
|
|
710
|
+
(locale) => locale.toString() !== defaultLocale.toString() // Exclui a localidade padrão
|
|
730
711
|
)
|
|
731
|
-
.includes(currentLocale) // Verifica se o
|
|
712
|
+
.includes(currentLocale) // Verifica se o idioma atual está na lista de idiomas válidos
|
|
732
713
|
) {
|
|
733
|
-
// Redireciona para o caminho sem o prefixo
|
|
714
|
+
// Redireciona para o caminho sem o prefixo do idioma
|
|
734
715
|
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
735
716
|
}
|
|
736
717
|
|
|
737
|
-
// Envolve os filhos com o IntlayerProvider e define o
|
|
718
|
+
// Envolve os filhos com o IntlayerProvider e define o idioma atual
|
|
738
719
|
return (
|
|
739
720
|
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
740
721
|
);
|
|
@@ -742,7 +723,7 @@ const AppLocalized: FC<PropsWithChildren<{ locale: Locales }>> = ({
|
|
|
742
723
|
};
|
|
743
724
|
|
|
744
725
|
/**
|
|
745
|
-
* Um componente de roteador que configura rotas específicas por
|
|
726
|
+
* Um componente de roteador que configura rotas específicas por idioma.
|
|
746
727
|
* Ele usa o React Router para gerenciar a navegação e renderizar componentes localizados.
|
|
747
728
|
*/
|
|
748
729
|
export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
|
|
@@ -754,21 +735,21 @@ export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
|
|
|
754
735
|
)
|
|
755
736
|
.map((locale) => (
|
|
756
737
|
<Route
|
|
757
|
-
// Padrão de rota para capturar
|
|
738
|
+
// Padrão de rota para capturar a localidade (ex.: /en/, /fr/) e corresponder a todos os caminhos subsequentes
|
|
758
739
|
path={`/${locale}/*`}
|
|
759
740
|
key={locale}
|
|
760
|
-
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // Envolve os filhos com o gerenciamento de
|
|
741
|
+
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // Envolve os filhos com o gerenciamento de localidade
|
|
761
742
|
/>
|
|
762
743
|
))}
|
|
763
744
|
|
|
764
745
|
{
|
|
765
|
-
// Se o prefixo
|
|
746
|
+
// Se o prefixo da localidade padrão estiver desativado, renderiza os filhos diretamente na raiz
|
|
766
747
|
!middleware.prefixDefault && (
|
|
767
748
|
<Route
|
|
768
749
|
path="*"
|
|
769
750
|
element={
|
|
770
751
|
<AppLocalized locale={defaultLocale}>{children}</AppLocalized>
|
|
771
|
-
} // Envolve os filhos com o gerenciamento de
|
|
752
|
+
} // Envolve os filhos com o gerenciamento de localidade
|
|
772
753
|
/>
|
|
773
754
|
)
|
|
774
755
|
}
|
|
@@ -796,26 +777,26 @@ const { locales, defaultLocale } = internationalization;
|
|
|
796
777
|
|
|
797
778
|
/**
|
|
798
779
|
* Um componente que gerencia a localização e envolve os filhos com o contexto de local apropriado.
|
|
799
|
-
* Ele gerencia a detecção e validação
|
|
780
|
+
* Ele gerencia a detecção e validação da localidade baseada na URL.
|
|
800
781
|
*/
|
|
801
782
|
const AppLocalized = ({ children, locale }) => {
|
|
802
783
|
const { pathname, search } = useLocation(); // Obtém o caminho atual da URL
|
|
803
784
|
|
|
804
|
-
// Determina
|
|
785
|
+
// Determina a localidade atual, usando a localidade padrão caso não seja fornecida
|
|
805
786
|
const currentLocale = locale ?? defaultLocale;
|
|
806
787
|
|
|
807
|
-
// Remove o prefixo
|
|
788
|
+
// Remove o prefixo da localidade do caminho para construir um caminho base
|
|
808
789
|
const pathWithoutLocale = getPathWithoutLocale(
|
|
809
790
|
pathname // Caminho atual da URL
|
|
810
791
|
);
|
|
811
792
|
|
|
812
793
|
/**
|
|
813
|
-
* Se middleware.prefixDefault for verdadeiro,
|
|
794
|
+
* Se middleware.prefixDefault for verdadeiro, a localidade padrão deve sempre ser prefixada.
|
|
814
795
|
*/
|
|
815
796
|
if (middleware.prefixDefault) {
|
|
816
|
-
// Valida
|
|
797
|
+
// Valida a localidade
|
|
817
798
|
if (!locale || !locales.includes(locale)) {
|
|
818
|
-
// Redireciona para
|
|
799
|
+
// Redireciona para a localidade padrão com o caminho atualizado
|
|
819
800
|
return (
|
|
820
801
|
<Navigate
|
|
821
802
|
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
@@ -824,28 +805,28 @@ const AppLocalized = ({ children, locale }) => {
|
|
|
824
805
|
);
|
|
825
806
|
}
|
|
826
807
|
|
|
827
|
-
// Envolve os filhos com o IntlayerProvider e define
|
|
808
|
+
// Envolve os filhos com o IntlayerProvider e define a localidade atual
|
|
828
809
|
return (
|
|
829
810
|
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
830
811
|
);
|
|
831
812
|
} else {
|
|
832
813
|
/**
|
|
833
|
-
* Quando middleware.prefixDefault é falso,
|
|
834
|
-
*
|
|
814
|
+
* Quando middleware.prefixDefault é falso, a localidade padrão não é prefixada.
|
|
815
|
+
* Garante que a localidade atual seja válida e não a localidade padrão.
|
|
835
816
|
*/
|
|
836
817
|
if (
|
|
837
818
|
currentLocale.toString() !== defaultLocale.toString() &&
|
|
838
819
|
!locales
|
|
839
820
|
.filter(
|
|
840
|
-
(locale) => locale.toString() !== defaultLocale.toString() // Exclui
|
|
821
|
+
(locale) => locale.toString() !== defaultLocale.toString() // Exclui a localidade padrão
|
|
841
822
|
)
|
|
842
|
-
.includes(currentLocale) // Verifica se
|
|
823
|
+
.includes(currentLocale) // Verifica se a localidade atual está na lista de localidades válidas
|
|
843
824
|
) {
|
|
844
|
-
// Redireciona para o caminho sem o prefixo
|
|
825
|
+
// Redireciona para o caminho sem o prefixo da localidade
|
|
845
826
|
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
846
827
|
}
|
|
847
828
|
|
|
848
|
-
// Envolve os filhos com o IntlayerProvider e define
|
|
829
|
+
// Envolve os filhos com o IntlayerProvider e define a localidade atual
|
|
849
830
|
return (
|
|
850
831
|
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
851
832
|
);
|
|
@@ -853,7 +834,7 @@ const AppLocalized = ({ children, locale }) => {
|
|
|
853
834
|
};
|
|
854
835
|
|
|
855
836
|
/**
|
|
856
|
-
* Um componente de roteador que configura rotas específicas por
|
|
837
|
+
* Um componente de roteador que configura rotas específicas por localidade.
|
|
857
838
|
* Ele usa o React Router para gerenciar a navegação e renderizar componentes localizados.
|
|
858
839
|
*/
|
|
859
840
|
export const LocaleRouter = ({ children }) => (
|
|
@@ -865,21 +846,21 @@ export const LocaleRouter = ({ children }) => (
|
|
|
865
846
|
)
|
|
866
847
|
.map((locale) => (
|
|
867
848
|
<Route
|
|
868
|
-
// Padrão de rota para capturar
|
|
849
|
+
// Padrão de rota para capturar a localidade (ex.: /en/, /fr/) e corresponder a todos os caminhos subsequentes
|
|
869
850
|
path={`/${locale}/*`}
|
|
870
851
|
key={locale}
|
|
871
|
-
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // Envolve os filhos com o gerenciamento de
|
|
852
|
+
element={<AppLocalized locale={locale}>{children}</AppLocalized>} // Envolve os filhos com o gerenciamento de localidade
|
|
872
853
|
/>
|
|
873
854
|
))}
|
|
874
855
|
|
|
875
856
|
{
|
|
876
|
-
// Se o prefixo
|
|
857
|
+
// Se o prefixo da localidade padrão estiver desativado, renderiza os filhos diretamente na raiz
|
|
877
858
|
!middleware.prefixDefault && (
|
|
878
859
|
<Route
|
|
879
860
|
path="*"
|
|
880
861
|
element={
|
|
881
862
|
<AppLocalized locale={defaultLocale}>{children}</AppLocalized>
|
|
882
|
-
} // Envolve os filhos com o gerenciamento de
|
|
863
|
+
} // Envolve os filhos com o gerenciamento de localidade
|
|
883
864
|
/>
|
|
884
865
|
)
|
|
885
866
|
}
|
|
@@ -905,27 +886,27 @@ const { internationalization, middleware } = configuration;
|
|
|
905
886
|
const { locales, defaultLocale } = internationalization;
|
|
906
887
|
|
|
907
888
|
/**
|
|
908
|
-
* Um componente que gerencia a localização e envolve os filhos com o contexto de
|
|
909
|
-
* Ele gerencia a detecção e validação
|
|
889
|
+
* Um componente que gerencia a localização e envolve os filhos com o contexto de localidade apropriado.
|
|
890
|
+
* Ele gerencia a detecção e validação da localidade baseada na URL.
|
|
910
891
|
*/
|
|
911
892
|
const AppLocalized = ({ children, locale }) => {
|
|
912
|
-
const { pathname, search } = useLocation(); //
|
|
893
|
+
const { pathname, search } = useLocation(); // Obtém o caminho atual da URL
|
|
913
894
|
|
|
914
|
-
//
|
|
895
|
+
// Determina o locale atual, usando o padrão caso não seja fornecido
|
|
915
896
|
const currentLocale = locale ?? defaultLocale;
|
|
916
897
|
|
|
917
|
-
//
|
|
898
|
+
// Remove o prefixo do locale do caminho para construir um caminho base
|
|
918
899
|
const pathWithoutLocale = getPathWithoutLocale(
|
|
919
900
|
pathname // Caminho atual da URL
|
|
920
901
|
);
|
|
921
902
|
|
|
922
903
|
/**
|
|
923
|
-
* Se middleware.prefixDefault for
|
|
904
|
+
* Se middleware.prefixDefault for true, o locale padrão deve sempre ser prefixado.
|
|
924
905
|
*/
|
|
925
906
|
if (middleware.prefixDefault) {
|
|
926
|
-
//
|
|
907
|
+
// Valida o locale
|
|
927
908
|
if (!locale || !locales.includes(locale)) {
|
|
928
|
-
//
|
|
909
|
+
// Redireciona para o locale padrão com o caminho atualizado
|
|
929
910
|
return (
|
|
930
911
|
<Navigate
|
|
931
912
|
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
@@ -941,7 +922,7 @@ const AppLocalized = ({ children, locale }) => {
|
|
|
941
922
|
} else {
|
|
942
923
|
/**
|
|
943
924
|
* Quando middleware.prefixDefault é falso, o locale padrão não é prefixado.
|
|
944
|
-
*
|
|
925
|
+
* Garante que o locale atual seja válido e não o locale padrão.
|
|
945
926
|
*/
|
|
946
927
|
if (
|
|
947
928
|
currentLocale.toString() !== defaultLocale.toString() &&
|
|
@@ -951,7 +932,7 @@ const AppLocalized = ({ children, locale }) => {
|
|
|
951
932
|
)
|
|
952
933
|
.includes(currentLocale) // Verifica se o locale atual está na lista de locales válidos
|
|
953
934
|
) {
|
|
954
|
-
// Redireciona para o caminho sem prefixo
|
|
935
|
+
// Redireciona para o caminho sem o prefixo do locale
|
|
955
936
|
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
956
937
|
}
|
|
957
938
|
|
|
@@ -983,7 +964,7 @@ const LocaleRouter = ({ children }) => (
|
|
|
983
964
|
))}
|
|
984
965
|
|
|
985
966
|
{
|
|
986
|
-
// Se o prefixo para o locale padrão estiver
|
|
967
|
+
// Se o prefixo para o locale padrão estiver desabilitado, renderiza os filhos diretamente na raiz
|
|
987
968
|
!middleware.prefixDefault && (
|
|
988
969
|
<Route
|
|
989
970
|
path="*"
|
|
@@ -1093,11 +1074,11 @@ const LocaleSwitcher: FC = () => {
|
|
|
1093
1074
|
|
|
1094
1075
|
const { locale, availableLocales, setLocale } = useLocale({
|
|
1095
1076
|
onLocaleChange: (locale) => {
|
|
1096
|
-
//
|
|
1077
|
+
// Construir a URL com o locale atualizado
|
|
1097
1078
|
// Exemplo: /es/about?foo=bar
|
|
1098
1079
|
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
1099
1080
|
|
|
1100
|
-
//
|
|
1081
|
+
// Atualizar o caminho da URL
|
|
1101
1082
|
navigate(pathWithLocale);
|
|
1102
1083
|
},
|
|
1103
1084
|
});
|
|
@@ -1118,19 +1099,19 @@ const LocaleSwitcher: FC = () => {
|
|
|
1118
1099
|
key={localeItem}
|
|
1119
1100
|
>
|
|
1120
1101
|
<span>
|
|
1121
|
-
{/* Local - ex
|
|
1102
|
+
{/* Local - ex: FR */}
|
|
1122
1103
|
{localeItem}
|
|
1123
1104
|
</span>
|
|
1124
1105
|
<span>
|
|
1125
|
-
{/* Idioma na sua própria
|
|
1106
|
+
{/* Idioma na sua própria localidade - ex: Français */}
|
|
1126
1107
|
{getLocaleName(localeItem, locale)}
|
|
1127
1108
|
</span>
|
|
1128
1109
|
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1129
|
-
{/* Idioma na
|
|
1110
|
+
{/* Idioma na localidade atual - ex: Francés com localidade atual definida para Locales.SPANISH */}
|
|
1130
1111
|
{getLocaleName(localeItem)}
|
|
1131
1112
|
</span>
|
|
1132
1113
|
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1133
|
-
{/* Idioma em
|
|
1114
|
+
{/* Idioma em inglês - ex: French */}
|
|
1134
1115
|
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1135
1116
|
</span>
|
|
1136
1117
|
</a>
|
|
@@ -1182,19 +1163,19 @@ const LocaleSwitcher = () => {
|
|
|
1182
1163
|
key={localeItem}
|
|
1183
1164
|
>
|
|
1184
1165
|
<span>
|
|
1185
|
-
{/*
|
|
1166
|
+
{/* Localidade - ex: FR */}
|
|
1186
1167
|
{localeItem}
|
|
1187
1168
|
</span>
|
|
1188
1169
|
<span>
|
|
1189
|
-
{/* Idioma
|
|
1170
|
+
{/* Idioma na sua própria localidade - ex: Français */}
|
|
1190
1171
|
{getLocaleName(localeItem, locale)}
|
|
1191
1172
|
</span>
|
|
1192
1173
|
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1193
|
-
{/* Idioma
|
|
1174
|
+
{/* Idioma no Locale atual - ex. Francés com o locale atual definido para Locales.SPANISH */}
|
|
1194
1175
|
{getLocaleName(localeItem)}
|
|
1195
1176
|
</span>
|
|
1196
1177
|
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
1197
|
-
{/* Idioma em
|
|
1178
|
+
{/* Idioma em inglês - ex. French */}
|
|
1198
1179
|
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
1199
1180
|
</span>
|
|
1200
1181
|
</a>
|
|
@@ -1250,11 +1231,11 @@ const LocaleSwitcher = () => {
|
|
|
1250
1231
|
{localeItem}
|
|
1251
1232
|
</span>
|
|
1252
1233
|
<span>
|
|
1253
|
-
{/*
|
|
1234
|
+
{/* Língua no seu próprio local - ex: Français */}
|
|
1254
1235
|
{getLocaleName(localeItem, locale)}
|
|
1255
1236
|
</span>
|
|
1256
1237
|
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
1257
|
-
{/*
|
|
1238
|
+
{/* Língua no local atual - ex: Francés com local atual definido para Locales.SPANISH */}
|
|
1258
1239
|
{getLocaleName(localeItem)}
|
|
1259
1240
|
</span>
|
|
1260
1241
|
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
@@ -1292,11 +1273,11 @@ Quando sua aplicação suporta múltiplos idiomas, é crucial atualizar os atrib
|
|
|
1292
1273
|
- **Renderização de Texto**: O atributo `dir` (direção) assegura que o texto seja exibido na ordem correta (por exemplo, da esquerda para a direita para inglês, da direita para a esquerda para árabe ou hebraico), o que é essencial para a legibilidade.
|
|
1293
1274
|
- **SEO**: Motores de busca usam o atributo `lang` para determinar o idioma da sua página, ajudando a exibir o conteúdo localizado correto nos resultados de busca.
|
|
1294
1275
|
|
|
1295
|
-
Ao atualizar esses atributos dinamicamente quando o
|
|
1276
|
+
Ao atualizar esses atributos dinamicamente quando o locale muda, você garante uma experiência consistente e acessível para os usuários em todos os idiomas suportados.
|
|
1296
1277
|
|
|
1297
1278
|
#### Implementando o Hook
|
|
1298
1279
|
|
|
1299
|
-
Crie um hook personalizado para gerenciar os atributos do HTML. O hook escuta as mudanças de
|
|
1280
|
+
Crie um hook personalizado para gerenciar os atributos do HTML. O hook escuta as mudanças de locale e atualiza os atributos conforme necessário:
|
|
1300
1281
|
|
|
1301
1282
|
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx" codeFormat="typescript"
|
|
1302
1283
|
import { useEffect } from "react";
|
|
@@ -1304,7 +1285,7 @@ import { useLocale } from "react-intlayer";
|
|
|
1304
1285
|
import { getHTMLTextDir } from "intlayer";
|
|
1305
1286
|
|
|
1306
1287
|
/**
|
|
1307
|
-
* Atualiza os atributos `lang` e `dir` do elemento <html> com base no
|
|
1288
|
+
* Atualiza os atributos `lang` e `dir` do elemento HTML <html> com base no locale atual.
|
|
1308
1289
|
* - `lang`: Informa aos navegadores e motores de busca o idioma da página.
|
|
1309
1290
|
* - `dir`: Garante a ordem correta de leitura (ex: 'ltr' para inglês, 'rtl' para árabe).
|
|
1310
1291
|
*
|
|
@@ -1331,7 +1312,7 @@ import { getHTMLTextDir } from "intlayer";
|
|
|
1331
1312
|
/**
|
|
1332
1313
|
* Atualiza os atributos `lang` e `dir` do elemento HTML <html> com base no locale atual.
|
|
1333
1314
|
* - `lang`: Informa aos navegadores e motores de busca o idioma da página.
|
|
1334
|
-
* - `dir`: Garante a ordem correta
|
|
1315
|
+
* - `dir`: Garante a ordem correta de leitura (ex.: 'ltr' para inglês, 'rtl' para árabe).
|
|
1335
1316
|
*
|
|
1336
1317
|
* Esta atualização dinâmica é essencial para a renderização correta do texto, acessibilidade e SEO.
|
|
1337
1318
|
*/
|
|
@@ -1458,7 +1439,7 @@ Esse comportamento é útil por várias razões:
|
|
|
1458
1439
|
|
|
1459
1440
|
- **SEO e Experiência do Usuário**: URLs localizadas ajudam os motores de busca a indexar corretamente páginas específicas por idioma e fornecem aos usuários conteúdo no idioma de sua preferência.
|
|
1460
1441
|
- **Consistência**: Ao usar um link localizado em toda a sua aplicação, você garante que a navegação permaneça dentro do idioma atual, evitando mudanças inesperadas de idioma.
|
|
1461
|
-
- **
|
|
1442
|
+
- **Manutenção**: Centralizar a lógica de localização em um único componente simplifica o gerenciamento das URLs, tornando seu código mais fácil de manter e expandir conforme sua aplicação cresce.
|
|
1462
1443
|
|
|
1463
1444
|
Abaixo está a implementação de um componente `Link` localizado em TypeScript:
|
|
1464
1445
|
|
|
@@ -1478,15 +1459,15 @@ export interface LinkProps
|
|
|
1478
1459
|
> {}
|
|
1479
1460
|
|
|
1480
1461
|
/**
|
|
1481
|
-
* Função utilitária para verificar se uma URL
|
|
1482
|
-
* Se a URL começar com http:// ou https://,
|
|
1462
|
+
* Função utilitária para verificar se uma URL é externa.
|
|
1463
|
+
* Se a URL começar com http:// ou https://, é considerada externa.
|
|
1483
1464
|
*/
|
|
1484
1465
|
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1485
1466
|
/^https?:\/\//.test(href ?? "");
|
|
1486
1467
|
|
|
1487
1468
|
/**
|
|
1488
1469
|
* Um componente Link personalizado que adapta o atributo href com base na localidade atual.
|
|
1489
|
-
* Para links internos,
|
|
1470
|
+
* Para links internos, ele usa `getLocalizedUrl` para prefixar a URL com a localidade (ex: /fr/about).
|
|
1490
1471
|
* Isso garante que a navegação permaneça dentro do mesmo contexto de localidade.
|
|
1491
1472
|
*/
|
|
1492
1473
|
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
@@ -1494,7 +1475,7 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
1494
1475
|
const { locale } = useLocale();
|
|
1495
1476
|
const isExternalLink = checkIsExternalLink(href);
|
|
1496
1477
|
|
|
1497
|
-
// Se o link for interno e um href válido for fornecido,
|
|
1478
|
+
// Se o link for interno e um href válido for fornecido, obtenha a URL localizada.
|
|
1498
1479
|
const hrefI18n =
|
|
1499
1480
|
href && !isExternalLink ? getLocalizedUrl(href, locale) : href;
|
|
1500
1481
|
|
|
@@ -1515,16 +1496,16 @@ import { useLocale } from "react-intlayer";
|
|
|
1515
1496
|
import { forwardRef } from "react";
|
|
1516
1497
|
|
|
1517
1498
|
/**
|
|
1518
|
-
* Função utilitária para verificar se uma URL é externa.
|
|
1499
|
+
* Função utilitária para verificar se uma URL fornecida é externa.
|
|
1519
1500
|
* Se a URL começar com http:// ou https://, é considerada externa.
|
|
1520
1501
|
*/
|
|
1521
1502
|
export const checkIsExternalLink = (href?: string): boolean =>
|
|
1522
1503
|
/^https?:\/\//.test(href ?? "");
|
|
1523
1504
|
|
|
1524
1505
|
/**
|
|
1525
|
-
* Um componente Link personalizado que adapta o atributo href com base no
|
|
1526
|
-
* Para links internos, usa `getLocalizedUrl` para prefixar a URL com o
|
|
1527
|
-
* Isso garante que a navegação permaneça dentro do mesmo contexto de
|
|
1506
|
+
* Um componente Link personalizado que adapta o atributo href com base no locale atual.
|
|
1507
|
+
* Para links internos, ele usa `getLocalizedUrl` para prefixar a URL com o locale (ex: /fr/about).
|
|
1508
|
+
* Isso garante que a navegação permaneça dentro do mesmo contexto de locale.
|
|
1528
1509
|
*/
|
|
1529
1510
|
export const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
1530
1511
|
const { locale } = useLocale();
|
|
@@ -1557,7 +1538,7 @@ const checkIsExternalLink = (href) => /^https?:\/\//.test(href ?? "");
|
|
|
1557
1538
|
|
|
1558
1539
|
/**
|
|
1559
1540
|
* Um componente Link personalizado que adapta o atributo href com base na localidade atual.
|
|
1560
|
-
* Para links internos,
|
|
1541
|
+
* Para links internos, usa `getLocalizedUrl` para prefixar a URL com a localidade (ex.: /fr/about).
|
|
1561
1542
|
* Isso garante que a navegação permaneça dentro do mesmo contexto de localidade.
|
|
1562
1543
|
*/
|
|
1563
1544
|
const Link = forwardRef(({ href, children, ...props }, ref) => {
|
|
@@ -1585,7 +1566,7 @@ Link.displayName = "Link";
|
|
|
1585
1566
|
#### Como Funciona
|
|
1586
1567
|
|
|
1587
1568
|
- **Detectando Links Externos**:
|
|
1588
|
-
A função auxiliar `checkIsExternalLink` determina se uma URL é externa. Links externos
|
|
1569
|
+
A função auxiliar `checkIsExternalLink` determina se uma URL é externa. Links externos são mantidos inalterados porque não precisam de localização.
|
|
1589
1570
|
|
|
1590
1571
|
- **Recuperando a Localização Atual**:
|
|
1591
1572
|
O hook `useLocale` fornece a localidade atual (por exemplo, `fr` para francês).
|
|
@@ -1600,7 +1581,7 @@ Ao integrar este componente `Link` em toda a sua aplicação, você mantém uma
|
|
|
1600
1581
|
|
|
1601
1582
|
### Configurar TypeScript
|
|
1602
1583
|
|
|
1603
|
-
O Intlayer
|
|
1584
|
+
O Intlayer utiliza a ampliação de módulos para aproveitar os benefícios do TypeScript e tornar sua base de código mais robusta.
|
|
1604
1585
|
|
|
1605
1586
|

|
|
1606
1587
|
|
|
@@ -1629,7 +1610,7 @@ Para isso, você pode adicionar as seguintes instruções ao seu arquivo `.gitig
|
|
|
1629
1610
|
.intlayer
|
|
1630
1611
|
```
|
|
1631
1612
|
|
|
1632
|
-
### Extensão VS Code
|
|
1613
|
+
### Extensão do VS Code
|
|
1633
1614
|
|
|
1634
1615
|
Para melhorar sua experiência de desenvolvimento com o Intlayer, você pode instalar a extensão oficial **Intlayer VS Code Extension**.
|
|
1635
1616
|
|
|
@@ -1646,9 +1627,9 @@ Para mais detalhes sobre como usar a extensão, consulte a [documentação da Ex
|
|
|
1646
1627
|
|
|
1647
1628
|
---
|
|
1648
1629
|
|
|
1649
|
-
###
|
|
1630
|
+
### Avançar Mais
|
|
1650
1631
|
|
|
1651
|
-
Para
|
|
1632
|
+
Para avançar mais, você pode implementar o [editor visual](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_visual_editor.md) ou externalizar seu conteúdo usando o [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_CMS.md).
|
|
1652
1633
|
|
|
1653
1634
|
---
|
|
1654
1635
|
|