@intlayer/docs 9.1.3 → 9.3.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/index.md +1 -1
- package/blog/ar/rag_powered_documentation_assistant.md +7 -0
- package/blog/de/index.md +1 -1
- package/blog/de/rag_powered_documentation_assistant.md +6 -0
- package/blog/en/index.md +1 -1
- package/blog/en-GB/index.md +1 -1
- package/blog/en-GB/rag_powered_documentation_assistant.md +6 -0
- package/blog/es/index.md +1 -1
- package/blog/es/rag_powered_documentation_assistant.md +7 -0
- package/blog/fr/i18n_meaning.md +7 -1
- package/blog/fr/index.md +1 -1
- package/blog/fr/list_i18n_technologies/frameworks/angular.md +5 -1
- package/blog/fr/rag_powered_documentation_assistant.md +6 -0
- package/blog/hi/index.md +1 -1
- package/blog/hi/next-i18next_vs_next-intl_vs_intlayer.md +119 -42
- package/blog/hi/rag_powered_documentation_assistant.md +7 -0
- package/blog/id/index.md +1 -1
- package/blog/id/rag_powered_documentation_assistant.md +6 -0
- package/blog/it/index.md +1 -1
- package/blog/it/rag_powered_documentation_assistant.md +6 -0
- package/blog/ja/index.md +1 -1
- package/blog/ja/rag_powered_documentation_assistant.md +7 -0
- package/blog/ko/index.md +1 -1
- package/blog/ko/list_i18n_technologies/frameworks/react.md +7 -7
- package/blog/ko/rag_powered_documentation_assistant.md +6 -0
- package/blog/pl/index.md +1 -1
- package/blog/pl/rag_powered_documentation_assistant.md +6 -0
- package/blog/pt/index.md +1 -1
- package/blog/pt/rag_powered_documentation_assistant.md +6 -0
- package/blog/ru/index.md +1 -1
- package/blog/ru/rag_powered_documentation_assistant.md +7 -0
- package/blog/tr/intlayer_with_react-intl.md +3 -1
- package/blog/tr/next-i18next_vs_next-intl_vs_intlayer.md +175 -42
- package/blog/tr/rag_powered_documentation_assistant.md +6 -0
- package/blog/uk/index.md +1 -1
- package/blog/uk/rag_powered_documentation_assistant.md +6 -0
- package/blog/vi/index.md +1 -1
- package/blog/vi/rag_powered_documentation_assistant.md +6 -0
- package/blog/zh/index.md +1 -1
- package/blog/zh/intlayer_with_i18next.md +87 -28
- package/blog/zh/intlayer_with_next-i18next.md +86 -29
- package/blog/zh/intlayer_with_next-intl.md +88 -28
- package/blog/zh/intlayer_with_react-i18next.md +87 -28
- package/blog/zh/intlayer_with_react-intl.md +88 -27
- package/blog/zh/intlayer_with_vue-i18n.md +117 -8
- package/blog/zh/rag_powered_documentation_assistant.md +6 -0
- package/dist/cjs/common.cjs +24 -1
- package/dist/cjs/common.cjs.map +1 -1
- package/dist/cjs/generated/blog.entry.cjs +58 -31
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/cjs/generated/docs.entry.cjs +265 -218
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/cjs/generated/frequentQuestions.entry.cjs +48 -21
- package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
- package/dist/cjs/generated/legal.entry.cjs +33 -6
- package/dist/cjs/generated/legal.entry.cjs.map +1 -1
- package/dist/esm/common.mjs +24 -1
- package/dist/esm/common.mjs.map +1 -1
- package/dist/esm/generated/blog.entry.mjs +58 -31
- package/dist/esm/generated/blog.entry.mjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +265 -218
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/esm/generated/frequentQuestions.entry.mjs +48 -21
- package/dist/esm/generated/frequentQuestions.entry.mjs.map +1 -1
- package/dist/esm/generated/legal.entry.mjs +33 -6
- package/dist/esm/generated/legal.entry.mjs.map +1 -1
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/generated/blog.entry.d.ts.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -0
- 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/analytics.md +222 -0
- package/docs/ar/autoFill.md +28 -9
- package/docs/ar/bundle_optimization.md +58 -25
- package/docs/ar/configuration.md +25 -8
- package/docs/ar/dictionary/file.md +3 -1
- package/docs/ar/dictionary/nesting.md +47 -30
- package/docs/ar/formatters.md +148 -193
- package/docs/ar/intlayer_CMS.md +152 -0
- package/docs/ar/intlayer_with_angular_21.md +9 -9
- package/docs/ar/intlayer_with_nextjs_14.md +1 -28
- package/docs/ar/intlayer_with_nextjs_15.md +1 -33
- package/docs/ar/intlayer_with_react_router_v7_fs_routes.md +40 -83
- package/docs/ar/intlayer_with_solid_start.md +1078 -0
- package/docs/ar/intlayer_with_vite+vue.md +1 -3
- package/docs/ar/live-sync.md +4 -0
- package/docs/ar/packages/intlayer/getLocalizedUrl.md +26 -24
- package/docs/ar/packages/intlayer/getMultilingualUrls.md +4 -18
- package/docs/ar/packages/react-intlayer/useDictionary.md +4 -21
- package/docs/ar/packages/react-intlayer/useIntlayer.md +2 -2
- package/docs/ar/packages/vite-intlayer/exports.md +15 -0
- package/docs/ar/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/ar/packages/vite-intlayer/intlayerPrune.md +70 -3
- package/docs/ar/releases/v9.md +0 -37
- package/docs/ar/self_hosting.md +46 -49
- package/docs/bn/bundle_optimization.md +58 -25
- package/docs/bn/configuration.md +25 -8
- package/docs/bn/intlayer_with_angular_21.md +9 -9
- package/docs/cs/bundle_optimization.md +58 -25
- package/docs/cs/configuration.md +25 -8
- package/docs/cs/intlayer_with_angular_21.md +9 -9
- package/docs/de/analytics.md +222 -0
- package/docs/de/autoFill.md +28 -9
- package/docs/de/bundle_optimization.md +58 -25
- package/docs/de/configuration.md +25 -8
- package/docs/de/dictionary/file.md +3 -1
- package/docs/de/dictionary/nesting.md +47 -31
- package/docs/de/formatters.md +208 -334
- package/docs/de/intlayer_CMS.md +66 -15
- package/docs/de/intlayer_with_angular_21.md +9 -9
- package/docs/de/intlayer_with_nestjs.md +11 -7
- package/docs/de/intlayer_with_nextjs_14.md +1 -28
- package/docs/de/intlayer_with_nextjs_15.md +1 -33
- package/docs/de/intlayer_with_solid_start.md +1078 -0
- package/docs/de/intlayer_with_vite+vue.md +1 -3
- package/docs/de/live-sync.md +4 -0
- package/docs/de/packages/intlayer/getLocalizedUrl.md +33 -25
- package/docs/de/packages/intlayer/getMultilingualUrls.md +4 -18
- package/docs/de/packages/react-intlayer/useDictionary.md +2 -5
- package/docs/de/packages/vite-intlayer/exports.md +15 -0
- package/docs/de/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/de/packages/vite-intlayer/intlayerPrune.md +77 -4
- package/docs/de/releases/v9.md +0 -15
- package/docs/de/self_hosting.md +46 -50
- package/docs/en/bundle_optimization.md +51 -23
- package/docs/en/cli/doc-review.md +13 -2
- package/docs/en/configuration.md +24 -15
- package/docs/en/intlayer_with_angular_21.md +9 -9
- package/docs/en/intlayer_with_solid_start.md +1091 -0
- package/docs/en/intlayer_with_vite+solid.md +12 -0
- package/docs/en/live-sync.md +4 -0
- package/docs/en-GB/analytics.md +222 -0
- package/docs/en-GB/autoFill.md +26 -7
- package/docs/en-GB/bundle_optimization.md +58 -25
- package/docs/en-GB/configuration.md +25 -8
- package/docs/en-GB/dictionary/file.md +2 -0
- package/docs/en-GB/dictionary/nesting.md +64 -205
- package/docs/en-GB/formatters.md +146 -181
- package/docs/en-GB/intlayer_CMS.md +152 -0
- package/docs/en-GB/intlayer_with_angular_21.md +9 -9
- package/docs/en-GB/intlayer_with_nestjs.md +6 -2
- package/docs/en-GB/intlayer_with_nextjs_14.md +0 -27
- package/docs/en-GB/intlayer_with_nextjs_15.md +1 -33
- package/docs/en-GB/intlayer_with_react_router_v7_fs_routes.md +40 -82
- package/docs/en-GB/intlayer_with_solid_start.md +1078 -0
- package/docs/en-GB/intlayer_with_vite+vue.md +1 -3
- package/docs/en-GB/live-sync.md +4 -0
- package/docs/en-GB/packages/intlayer/getLocalizedUrl.md +30 -22
- package/docs/en-GB/packages/intlayer/getMultilingualUrls.md +16 -48
- package/docs/en-GB/packages/vite-intlayer/exports.md +15 -0
- package/docs/en-GB/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/en-GB/packages/vite-intlayer/intlayerPrune.md +77 -4
- package/docs/en-GB/self_hosting.md +60 -49
- package/docs/es/analytics.md +222 -0
- package/docs/es/autoFill.md +28 -9
- package/docs/es/bundle_optimization.md +58 -25
- package/docs/es/configuration.md +24 -7
- package/docs/es/dictionary/file.md +3 -1
- package/docs/es/dictionary/nesting.md +47 -30
- package/docs/es/formatters.md +114 -168
- package/docs/es/intlayer_CMS.md +35 -10
- package/docs/es/intlayer_with_angular_21.md +9 -9
- package/docs/es/intlayer_with_nextjs_14.md +1 -28
- package/docs/es/intlayer_with_nextjs_15.md +1 -33
- package/docs/es/intlayer_with_solid_start.md +1078 -0
- package/docs/es/live-sync.md +4 -0
- package/docs/es/packages/intlayer/getLocalizedUrl.md +31 -23
- package/docs/es/packages/intlayer/getMultilingualUrls.md +4 -18
- package/docs/es/packages/vite-intlayer/exports.md +15 -0
- package/docs/es/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/es/packages/vite-intlayer/intlayerPrune.md +69 -2
- package/docs/es/releases/v9.md +0 -15
- package/docs/es/self_hosting.md +46 -49
- package/docs/fr/analytics.md +222 -0
- package/docs/fr/autoFill.md +27 -8
- package/docs/fr/bundle_optimization.md +58 -25
- package/docs/fr/configuration.md +25 -8
- package/docs/fr/dictionary/file.md +2 -0
- package/docs/fr/dictionary/nesting.md +37 -184
- package/docs/fr/formatters.md +95 -236
- package/docs/fr/intlayer_CMS.md +66 -15
- package/docs/fr/intlayer_with_angular_21.md +9 -9
- package/docs/fr/intlayer_with_nextjs_14.md +1 -28
- package/docs/fr/intlayer_with_nextjs_15.md +1 -33
- package/docs/fr/intlayer_with_solid_start.md +1078 -0
- package/docs/fr/live-sync.md +4 -0
- package/docs/fr/packages/intlayer/getLocalizedUrl.md +37 -27
- package/docs/fr/packages/intlayer/getMultilingualUrls.md +18 -20
- package/docs/fr/packages/vite-intlayer/exports.md +15 -0
- package/docs/fr/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/fr/packages/vite-intlayer/intlayerPrune.md +77 -4
- package/docs/fr/releases/v9.md +0 -15
- package/docs/fr/self_hosting.md +46 -49
- package/docs/hi/analytics.md +222 -0
- package/docs/hi/autoFill.md +28 -9
- package/docs/hi/bundle_optimization.md +58 -25
- package/docs/hi/configuration.md +25 -8
- package/docs/hi/dictionary/file.md +3 -1
- package/docs/hi/dictionary/nesting.md +47 -30
- package/docs/hi/formatters.md +233 -334
- package/docs/hi/how_works_intlayer.md +3 -1
- package/docs/hi/intlayer_CMS.md +152 -0
- package/docs/hi/intlayer_with_angular_21.md +9 -9
- package/docs/hi/intlayer_with_nestjs.md +11 -7
- package/docs/hi/intlayer_with_nextjs_14.md +1 -28
- package/docs/hi/intlayer_with_nextjs_15.md +1 -33
- package/docs/hi/intlayer_with_react_router_v7_fs_routes.md +40 -83
- package/docs/hi/intlayer_with_solid_start.md +1077 -0
- package/docs/hi/intlayer_with_vite+preact.md +56 -49
- package/docs/hi/intlayer_with_vite+react.md +48 -41
- package/docs/hi/intlayer_with_vite+solid.md +32 -41
- package/docs/hi/intlayer_with_vite+vue.md +49 -44
- package/docs/hi/live-sync.md +4 -0
- package/docs/hi/packages/intlayer/getLocalizedUrl.md +26 -24
- package/docs/hi/packages/intlayer/getMultilingualUrls.md +4 -18
- package/docs/hi/packages/next-intlayer/t.md +33 -1
- package/docs/hi/packages/react-intlayer/useDictionary.md +4 -21
- package/docs/hi/packages/vite-intlayer/exports.md +15 -0
- package/docs/hi/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/hi/packages/vite-intlayer/intlayerPrune.md +78 -5
- package/docs/hi/plugins/sync-json.md +9 -9
- package/docs/hi/releases/v9.md +0 -15
- package/docs/hi/self_hosting.md +38 -51
- package/docs/id/analytics.md +223 -0
- package/docs/id/bundle_optimization.md +58 -25
- package/docs/id/configuration.md +25 -8
- package/docs/id/dictionary/nesting.md +37 -184
- package/docs/id/formatters.md +208 -305
- package/docs/id/intlayer_CMS.md +164 -0
- package/docs/id/intlayer_with_angular_21.md +9 -9
- package/docs/id/intlayer_with_nextjs_14.md +1 -26
- package/docs/id/intlayer_with_react_router_v7_fs_routes.md +70 -63
- package/docs/id/intlayer_with_solid_start.md +1078 -0
- package/docs/id/live-sync.md +4 -0
- package/docs/id/packages/intlayer/getMultilingualUrls.md +4 -18
- package/docs/id/packages/react-intlayer/useIntlayer.md +2 -2
- package/docs/id/packages/vite-intlayer/exports.md +15 -0
- package/docs/id/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/id/packages/vite-intlayer/intlayerPrune.md +78 -5
- package/docs/id/releases/v9.md +12 -0
- package/docs/id/self_hosting.md +61 -50
- package/docs/it/analytics.md +222 -0
- package/docs/it/autoFill.md +27 -8
- package/docs/it/bundle_optimization.md +58 -25
- package/docs/it/configuration.md +25 -8
- package/docs/it/dictionary/file.md +3 -1
- package/docs/it/dictionary/nesting.md +47 -30
- package/docs/it/formatters.md +114 -168
- package/docs/it/intlayer_CMS.md +66 -15
- package/docs/it/intlayer_with_angular_21.md +9 -9
- package/docs/it/intlayer_with_nestjs.md +11 -7
- package/docs/it/intlayer_with_nextjs_14.md +1 -28
- package/docs/it/intlayer_with_nextjs_15.md +1 -33
- package/docs/it/intlayer_with_solid_start.md +1078 -0
- package/docs/it/intlayer_with_vite+vue.md +1 -3
- package/docs/it/live-sync.md +4 -0
- package/docs/it/packages/intlayer/getLocalizedUrl.md +34 -26
- package/docs/it/packages/intlayer/getMultilingualUrls.md +4 -18
- package/docs/it/packages/react-intlayer/useDictionary.md +4 -21
- package/docs/it/packages/vite-intlayer/exports.md +15 -0
- package/docs/it/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/it/packages/vite-intlayer/intlayerPrune.md +77 -4
- package/docs/it/releases/v9.md +0 -15
- package/docs/it/self_hosting.md +60 -49
- package/docs/ja/analytics.md +222 -0
- package/docs/ja/autoFill.md +28 -9
- package/docs/ja/bundle_optimization.md +58 -25
- package/docs/ja/configuration.md +25 -8
- package/docs/ja/dictionary/content_file.md +15 -7
- package/docs/ja/dictionary/file.md +3 -1
- package/docs/ja/dictionary/nesting.md +47 -30
- package/docs/ja/formatters.md +133 -187
- package/docs/ja/intlayer_visual_editor.md +3 -1
- package/docs/ja/intlayer_with_angular_21.md +6 -6
- package/docs/ja/intlayer_with_nestjs.md +2 -12
- package/docs/ja/intlayer_with_nextjs_14.md +1 -28
- package/docs/ja/intlayer_with_nextjs_15.md +1 -33
- package/docs/ja/intlayer_with_react_router_v7.md +456 -20
- package/docs/ja/intlayer_with_solid_start.md +1078 -0
- package/docs/ja/intlayer_with_vite+preact.md +73 -41
- package/docs/ja/intlayer_with_vite+vue.md +1 -3
- package/docs/ja/live-sync.md +4 -0
- package/docs/ja/mcp_server.md +3 -9
- package/docs/ja/packages/intlayer/getLocalizedUrl.md +26 -24
- package/docs/ja/packages/intlayer/getMultilingualUrls.md +3 -17
- package/docs/ja/packages/vite-intlayer/exports.md +15 -0
- package/docs/ja/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/ja/packages/vite-intlayer/intlayerPrune.md +79 -6
- package/docs/ja/releases/v9.md +12 -0
- package/docs/ja/self_hosting.md +46 -50
- package/docs/ko/analytics.md +222 -0
- package/docs/ko/autoFill.md +28 -9
- package/docs/ko/bundle_optimization.md +58 -25
- package/docs/ko/configuration.md +25 -8
- package/docs/ko/dictionary/file.md +3 -1
- package/docs/ko/dictionary/nesting.md +47 -30
- package/docs/ko/formatters.md +133 -187
- package/docs/ko/intlayer_with_angular_21.md +9 -9
- package/docs/ko/intlayer_with_lynx+react.md +133 -39
- package/docs/ko/intlayer_with_nextjs_14.md +1 -28
- package/docs/ko/intlayer_with_nextjs_15.md +1 -33
- package/docs/ko/intlayer_with_react_router_v7_fs_routes.md +40 -188
- package/docs/ko/intlayer_with_solid_start.md +1078 -0
- package/docs/ko/intlayer_with_vite+preact.md +57 -23
- package/docs/ko/intlayer_with_vite+vue.md +1 -3
- package/docs/ko/live-sync.md +4 -0
- package/docs/ko/packages/intlayer/getLocalizedUrl.md +26 -24
- package/docs/ko/packages/intlayer/getMultilingualUrls.md +4 -18
- package/docs/ko/packages/vite-intlayer/exports.md +15 -0
- package/docs/ko/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/ko/packages/vite-intlayer/intlayerPrune.md +79 -6
- package/docs/ko/releases/v9.md +12 -0
- package/docs/ko/self_hosting.md +60 -49
- package/docs/nl/bundle_optimization.md +58 -25
- package/docs/nl/configuration.md +25 -8
- package/docs/nl/intlayer_with_angular_21.md +9 -9
- package/docs/pl/analytics.md +220 -0
- package/docs/pl/bundle_optimization.md +58 -25
- package/docs/pl/configuration.md +25 -8
- package/docs/pl/dictionary/nesting.md +47 -30
- package/docs/pl/formatters.md +208 -305
- package/docs/pl/intlayer_CMS.md +152 -0
- package/docs/pl/intlayer_with_angular_21.md +9 -9
- package/docs/pl/intlayer_with_nextjs_14.md +1 -26
- package/docs/pl/intlayer_with_solid_start.md +1078 -0
- package/docs/pl/live-sync.md +4 -0
- package/docs/pl/packages/intlayer/getMultilingualUrls.md +4 -18
- package/docs/pl/packages/react-intlayer/useDictionary.md +2 -19
- package/docs/pl/packages/vite-intlayer/exports.md +15 -0
- package/docs/pl/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/pl/packages/vite-intlayer/intlayerPrune.md +77 -4
- package/docs/pl/releases/v9.md +0 -15
- package/docs/pl/self_hosting.md +60 -49
- package/docs/pt/analytics.md +222 -0
- package/docs/pt/bundle_optimization.md +58 -24
- package/docs/pt/configuration.md +25 -8
- package/docs/pt/dictionary/file.md +3 -1
- package/docs/pt/dictionary/nesting.md +47 -30
- package/docs/pt/formatters.md +112 -168
- package/docs/pt/intlayer_CMS.md +66 -15
- package/docs/pt/intlayer_with_angular_21.md +9 -9
- package/docs/pt/intlayer_with_astro_lit.md +26 -1
- package/docs/pt/intlayer_with_nextjs_14.md +1 -28
- package/docs/pt/intlayer_with_nextjs_15.md +1 -33
- package/docs/pt/intlayer_with_solid_start.md +1078 -0
- package/docs/pt/intlayer_with_vite+vue.md +1 -3
- package/docs/pt/live-sync.md +4 -0
- package/docs/pt/packages/intlayer/getLocalizedUrl.md +34 -26
- package/docs/pt/packages/intlayer/getMultilingualUrls.md +4 -18
- package/docs/pt/packages/vite-intlayer/exports.md +15 -0
- package/docs/pt/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/pt/packages/vite-intlayer/intlayerPrune.md +78 -6
- package/docs/pt/releases/v9.md +0 -15
- package/docs/pt/self_hosting.md +60 -49
- package/docs/ru/analytics.md +222 -0
- package/docs/ru/autoFill.md +27 -8
- package/docs/ru/bundle_optimization.md +58 -25
- package/docs/ru/configuration.md +25 -8
- package/docs/ru/dictionary/file.md +3 -1
- package/docs/ru/dictionary/nesting.md +64 -205
- package/docs/ru/formatters.md +108 -128
- package/docs/ru/intlayer_with_angular_21.md +9 -9
- package/docs/ru/intlayer_with_nextjs_14.md +1 -28
- package/docs/ru/intlayer_with_nextjs_15.md +1 -33
- package/docs/ru/intlayer_with_solid_start.md +1078 -0
- package/docs/ru/intlayer_with_vite+vue.md +1 -3
- package/docs/ru/live-sync.md +4 -0
- package/docs/ru/packages/intlayer/getLocalizedUrl.md +34 -26
- package/docs/ru/packages/intlayer/getMultilingualUrls.md +4 -18
- package/docs/ru/packages/react-intlayer/useDictionary.md +4 -21
- package/docs/ru/packages/vite-intlayer/exports.md +15 -0
- package/docs/ru/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/ru/packages/vite-intlayer/intlayerPrune.md +77 -4
- package/docs/ru/releases/v9.md +0 -15
- package/docs/ru/self_hosting.md +60 -49
- package/docs/tr/analytics.md +222 -0
- package/docs/tr/autoFill.md +28 -9
- package/docs/tr/bundle_optimization.md +58 -25
- package/docs/tr/configuration.md +25 -8
- package/docs/tr/dictionary/file.md +2 -0
- package/docs/tr/dictionary/nesting.md +47 -30
- package/docs/tr/formatters.md +144 -190
- package/docs/tr/intlayer_CMS.md +152 -0
- package/docs/tr/intlayer_with_angular_21.md +9 -9
- package/docs/tr/intlayer_with_nestjs.md +2 -12
- package/docs/tr/intlayer_with_nextjs_15.md +1 -33
- package/docs/tr/intlayer_with_solid_start.md +1078 -0
- package/docs/tr/intlayer_with_vite+vue.md +1 -3
- package/docs/tr/live-sync.md +4 -0
- package/docs/tr/packages/intlayer/getMultilingualUrls.md +4 -18
- package/docs/tr/packages/vite-intlayer/exports.md +15 -0
- package/docs/tr/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/tr/packages/vite-intlayer/intlayerPrune.md +77 -4
- package/docs/tr/self_hosting.md +47 -50
- package/docs/uk/analytics.md +222 -0
- package/docs/uk/bundle_optimization.md +58 -25
- package/docs/uk/configuration.md +25 -8
- package/docs/uk/dictionary/nesting.md +47 -30
- package/docs/uk/formatters.md +128 -185
- package/docs/uk/intlayer_CMS.md +152 -0
- package/docs/uk/intlayer_with_angular_21.md +9 -9
- package/docs/uk/intlayer_with_nextjs_14.md +1 -26
- package/docs/uk/intlayer_with_solid_start.md +1078 -0
- package/docs/uk/live-sync.md +4 -0
- package/docs/uk/packages/react-intlayer/useDictionary.md +2 -19
- package/docs/uk/packages/vite-intlayer/exports.md +15 -0
- package/docs/uk/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/uk/packages/vite-intlayer/intlayerPrune.md +77 -4
- package/docs/uk/releases/v9.md +0 -15
- package/docs/uk/self_hosting.md +60 -50
- package/docs/ur/bundle_optimization.md +58 -25
- package/docs/ur/configuration.md +25 -8
- package/docs/ur/intlayer_with_angular_21.md +9 -9
- package/docs/vi/analytics.md +222 -0
- package/docs/vi/bundle_optimization.md +58 -25
- package/docs/vi/configuration.md +24 -8
- package/docs/vi/dictionary/nesting.md +37 -184
- package/docs/vi/formatters.md +208 -309
- package/docs/vi/intlayer_CMS.md +164 -0
- package/docs/vi/intlayer_with_angular_21.md +9 -9
- package/docs/vi/intlayer_with_nextjs_14.md +0 -25
- package/docs/vi/intlayer_with_react_router_v7_fs_routes.md +70 -63
- package/docs/vi/intlayer_with_solid_start.md +1078 -0
- package/docs/vi/live-sync.md +4 -0
- package/docs/vi/packages/intlayer/getMultilingualUrls.md +4 -18
- package/docs/vi/packages/react-intlayer/useIntlayer.md +2 -2
- package/docs/vi/packages/vite-intlayer/exports.md +15 -0
- package/docs/vi/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/vi/packages/vite-intlayer/intlayerPrune.md +77 -4
- package/docs/vi/plugins/sync-json.md +6 -6
- package/docs/vi/releases/v9.md +12 -0
- package/docs/vi/self_hosting.md +61 -50
- package/docs/zh/CI_CD.md +4 -0
- package/docs/zh/analytics.md +222 -0
- package/docs/zh/autoFill.md +28 -9
- package/docs/zh/bundle_optimization.md +58 -25
- package/docs/zh/configuration.md +24 -8
- package/docs/zh/dictionary/file.md +2 -0
- package/docs/zh/dictionary/nesting.md +47 -30
- package/docs/zh/formatters.md +140 -188
- package/docs/zh/intlayer_CMS.md +164 -0
- package/docs/zh/intlayer_with_analog.md +193 -3
- package/docs/zh/intlayer_with_angular_19.md +272 -3
- package/docs/zh/intlayer_with_angular_21.md +7 -7
- package/docs/zh/intlayer_with_create_react_app.md +348 -26
- package/docs/zh/intlayer_with_lynx+react.md +263 -4
- package/docs/zh/intlayer_with_nextjs_14.md +1 -28
- package/docs/zh/intlayer_with_nextjs_15.md +1 -33
- package/docs/zh/intlayer_with_nextjs_no_locale_path.md +558 -1
- package/docs/zh/intlayer_with_nuxt.md +182 -7
- package/docs/zh/intlayer_with_react_router_v7.md +183 -25
- package/docs/zh/intlayer_with_react_router_v7_fs_routes.md +306 -42
- package/docs/zh/intlayer_with_solid_start.md +1077 -0
- package/docs/zh/intlayer_with_storybook.md +260 -3
- package/docs/zh/intlayer_with_svelte_kit.md +428 -48
- package/docs/zh/intlayer_with_tanstack+solid.md +713 -13
- package/docs/zh/intlayer_with_tanstack.md +731 -20
- package/docs/zh/intlayer_with_vanilla.md +314 -4
- package/docs/zh/intlayer_with_vite+lit.md +465 -4
- package/docs/zh/intlayer_with_vite+preact.md +422 -116
- package/docs/zh/intlayer_with_vite+react.md +324 -45
- package/docs/zh/intlayer_with_vite+react_compiler.md +228 -13
- package/docs/zh/intlayer_with_vite+solid.md +462 -32
- package/docs/zh/intlayer_with_vite+vanilla.md +497 -4
- package/docs/zh/live-sync.md +4 -0
- package/docs/zh/mcp_server.md +3 -9
- package/docs/zh/packages/intlayer/getLocalizedUrl.md +26 -24
- package/docs/zh/packages/intlayer/getMultilingualUrls.md +4 -18
- package/docs/zh/packages/vite-intlayer/exports.md +29 -0
- package/docs/zh/packages/vite-intlayer/intlayer.md +121 -6
- package/docs/zh/packages/vite-intlayer/intlayerPrune.md +79 -6
- package/docs/zh/releases/v9.md +12 -0
- package/docs/zh/self_hosting.md +60 -50
- package/docs/zh-TW/bundle_optimization.md +58 -25
- package/docs/zh-TW/intlayer_with_angular_21.md +7 -7
- package/package.json +7 -7
- package/src/common.ts +39 -2
- package/src/generated/blog.entry.ts +66 -34
- package/src/generated/docs.entry.ts +273 -221
- package/src/generated/frequentQuestions.entry.ts +56 -24
- package/src/generated/legal.entry.ts +41 -9
|
@@ -33,7 +33,62 @@ author: aymericzip
|
|
|
33
33
|
|
|
34
34
|
请参阅 GitHub 上的[应用模板](https://github.com/aymericzip/intlayer-react-cra-template)。
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
## 为什么选择 Intlayer 而不是其他方案?
|
|
37
|
+
|
|
38
|
+
与 `react-i18next` 或 `i18next` 等主要解决方案相比,Intlayer 是一个集成了以下优化的解决方案:
|
|
39
|
+
|
|
40
|
+
<AccordionGroup>
|
|
41
|
+
|
|
42
|
+
<Accordion header="完整的 React 支持">
|
|
43
|
+
|
|
44
|
+
Intlayer 针对 React 进行了优化,提供 **组件级内容作用域**、**延迟加载的翻译** 以及国际化 (i18n) 扩展所需的所有功能。
|
|
45
|
+
|
|
46
|
+
</Accordion>
|
|
47
|
+
|
|
48
|
+
<Accordion header="Bundle 大小">
|
|
49
|
+
|
|
50
|
+
无需将庞大的 JSON 文件加载到页面中,只需加载必要的内容。Intlayer 可帮助 **将 bundle 和页面大小减少高达 50%**。
|
|
51
|
+
|
|
52
|
+
</Accordion>
|
|
53
|
+
|
|
54
|
+
<Accordion header="可维护性">
|
|
55
|
+
|
|
56
|
+
对应用程序内容的作用域划分 **便于大规模应用的维护**。您可以复制或删除单个功能文件夹,而无需审查整个内容代码库的负担。此外,Intlayer **完全类型化**,确保内容的准确性。
|
|
57
|
+
|
|
58
|
+
</Accordion>
|
|
59
|
+
|
|
60
|
+
<Accordion header="AI Agent">
|
|
61
|
+
|
|
62
|
+
共置内容 **降低大语言模型 (LLM) 所需的上下文**。Intlayer 还提供了一套工具,例如 **CLI** 用于测试缺失的翻译、**[LSP](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/lsp.md)**、**[MCP](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/mcp_server.md)** 以及 **[agent skills](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/agent_skills.md)**,使 AI Agent 的开发者体验 (DX) 更加顺畅。
|
|
63
|
+
|
|
64
|
+
</Accordion>
|
|
65
|
+
|
|
66
|
+
<Accordion header="自动化">
|
|
67
|
+
|
|
68
|
+
在 CI/CD 管道中使用自动化翻译,使用您选择的 LLM,按照您的 AI 提供商的成本计费。Intlayer 还提供 **编译器** 以自动提取内容,以及 [网络平台](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/intlayer_CMS.md) 来帮助 **后台翻译**。
|
|
69
|
+
|
|
70
|
+
</Accordion>
|
|
71
|
+
|
|
72
|
+
<Accordion header="性能">
|
|
73
|
+
|
|
74
|
+
将庞大的 JSON 文件连接到组件可能导致性能和响应性问题。Intlayer 在构建时优化您的内容加载。
|
|
75
|
+
|
|
76
|
+
</Accordion>
|
|
77
|
+
|
|
78
|
+
<Accordion header="与非开发人员协作的扩展">
|
|
79
|
+
|
|
80
|
+
Intlayer 不仅是一个 i18n 解决方案,还提供 **自托管 [可视化编辑器](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/intlayer_visual_editor.md)** 和 **[完整 CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/intlayer_CMS.md)** 来帮助您 **实时** 管理多语言内容,使与翻译人员、文案撰写人员和其他团队成员的协作无缝进行。内容可以存储在本地和/或远程。
|
|
81
|
+
|
|
82
|
+
</Accordion>
|
|
83
|
+
</AccordionGroup>
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## 在 React 应用中设置 Intlayer 的分步指南
|
|
88
|
+
|
|
89
|
+
<Steps>
|
|
90
|
+
|
|
91
|
+
<Step number={1} title="安装依赖">
|
|
37
92
|
|
|
38
93
|
使用 npm 安装必要的包:
|
|
39
94
|
|
|
@@ -53,9 +108,9 @@ yarn dlx intlayer@canary init --interactive
|
|
|
53
108
|
bunx intlayer@canary init --interactive
|
|
54
109
|
```
|
|
55
110
|
|
|
56
|
-
> `--interactive`
|
|
111
|
+
> `--interactive` 标志是可选的。如果你是 AI 代理,请使用 `intlayer-cli init`。
|
|
57
112
|
|
|
58
|
-
>
|
|
113
|
+
> 此命令将检测你的环境并安装所需的包。例如:
|
|
59
114
|
|
|
60
115
|
```bash packageManager="npm"
|
|
61
116
|
npm install intlayer react-intlayer react-scripts-intlayer
|
|
@@ -75,19 +130,191 @@ bun add intlayer react-intlayer react-scripts-intlayer
|
|
|
75
130
|
|
|
76
131
|
- **intlayer**
|
|
77
132
|
|
|
78
|
-
|
|
133
|
+
核心包,提供国际化工具用于配置管理、翻译、[内容声明](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/dictionary/content_file.md)、转译和 [CLI 命令](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/cli/index.md)。
|
|
79
134
|
|
|
80
135
|
- **react-intlayer**
|
|
81
136
|
|
|
82
|
-
将 Intlayer
|
|
137
|
+
将 Intlayer 与 React 应用集成的包。它为 React 国际化提供上下文提供者和钩子。
|
|
83
138
|
|
|
84
139
|
- **react-scripts-intlayer**
|
|
85
140
|
|
|
86
|
-
|
|
141
|
+
包含 `react-scripts-intlayer` 命令和插件,用于将 Intlayer 与基于 Create React App 的应用集成。这些插件基于 [craco](https://craco.js.org/),并包含 [Webpack](https://webpack.js.org/) bundler 的额外配置。
|
|
142
|
+
|
|
143
|
+
</Step>
|
|
144
|
+
|
|
145
|
+
<Step number={2} title="配置你的项目">
|
|
146
|
+
|
|
147
|
+
创建一个配置文件来配置应用的语言:
|
|
148
|
+
|
|
149
|
+
```typescript fileName="intlayer.config.ts" codeFormat={["typescript", "esm", "commonjs"]}
|
|
150
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
151
|
+
|
|
152
|
+
const config: IntlayerConfig = {
|
|
153
|
+
internationalization: {
|
|
154
|
+
locales: [
|
|
155
|
+
Locales.ENGLISH,
|
|
156
|
+
Locales.FRENCH,
|
|
157
|
+
Locales.SPANISH,
|
|
158
|
+
// 你的其他语言环境
|
|
159
|
+
],
|
|
160
|
+
defaultLocale: Locales.ENGLISH,
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export default config;
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
> 通过此配置文件,你可以设置本地化 URL、中间件重定向、cookie 名称、内容声明的位置和扩展名、禁用 Intlayer 控制台日志等。有关可用参数的完整列表,请参考 [配置文档](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/configuration.md)。
|
|
168
|
+
|
|
169
|
+
</Step>
|
|
170
|
+
|
|
171
|
+
<Step number={3} title="在 CRA 配置中集成 Intlayer">
|
|
172
|
+
|
|
173
|
+
更改你的脚本以使用 react-intlayer
|
|
174
|
+
|
|
175
|
+
```json fileName="package.json"
|
|
176
|
+
"scripts": {
|
|
177
|
+
"build": "react-scripts-intlayer build",
|
|
178
|
+
"start": "react-scripts-intlayer start",
|
|
179
|
+
"transpile": "intlayer build"
|
|
180
|
+
},
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
> `react-scripts-intlayer` 脚本基于 [CRACO](https://craco.js.org/)。你也可以基于 intlayer craco 插件实现自己的设置。[在此查看示例](https://github.com/aymericzip/intlayer/blob/main/examples/react-app/craco.config.js)。
|
|
184
|
+
|
|
185
|
+
</Step>
|
|
186
|
+
|
|
187
|
+
<Step number={4} title="声明你的内容">
|
|
188
|
+
|
|
189
|
+
创建和管理你的内容声明以存储翻译:
|
|
190
|
+
|
|
191
|
+
```tsx fileName="src/app.content.tsx" codeFormat={["typescript", "esm"]}
|
|
192
|
+
import { t, type Dictionary } from "intlayer";
|
|
193
|
+
import React, { type ReactNode } from "react";
|
|
194
|
+
|
|
195
|
+
const appContent = {
|
|
196
|
+
key: "app",
|
|
197
|
+
content: {
|
|
198
|
+
getStarted: t<ReactNode>({
|
|
199
|
+
zh: (
|
|
200
|
+
<>
|
|
201
|
+
编辑 <code>src/App.tsx</code> 并保存以重新加载
|
|
202
|
+
</>
|
|
203
|
+
),
|
|
204
|
+
en: (
|
|
205
|
+
<>
|
|
206
|
+
Edit <code>src/App.tsx</code> and save to reload
|
|
207
|
+
</>
|
|
208
|
+
),
|
|
209
|
+
fr: (
|
|
210
|
+
<>
|
|
211
|
+
Éditez <code>src/App.tsx</code> et enregistrez pour recharger
|
|
212
|
+
</>
|
|
213
|
+
),
|
|
214
|
+
es: (
|
|
215
|
+
<>
|
|
216
|
+
Edita <code>src/App.tsx</code> y guarda para recargar
|
|
217
|
+
</>
|
|
218
|
+
),
|
|
219
|
+
}),
|
|
220
|
+
reactLink: {
|
|
221
|
+
href: "https://reactjs.org",
|
|
222
|
+
content: t({
|
|
223
|
+
zh: "学习 React",
|
|
224
|
+
en: "Learn React",
|
|
225
|
+
fr: "Apprendre React",
|
|
226
|
+
es: "Aprender React",
|
|
227
|
+
}),
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
} satisfies Dictionary;
|
|
231
|
+
|
|
232
|
+
export default appContent;
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
> 你的内容声明可以在应用的任何地方定义,只要它们包含在 `contentDir` 目录中(默认为 `./src`)。并匹配内容声明文件扩展名(默认为 `.content.{json,ts,tsx,js,jsx,mjs,cjs,md,mdx,yaml,yml}`)。
|
|
236
|
+
|
|
237
|
+
> 有关更多详情,请参考 [内容声明文档](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/dictionary/content_file.md)。
|
|
238
|
+
|
|
239
|
+
> 如果你的内容文件包含 TSX 代码,你应该考虑在内容文件中导入 `import React from "react";`。
|
|
240
|
+
|
|
241
|
+
</Step>
|
|
242
|
+
|
|
243
|
+
<Step number={5} title="在你的代码中使用 Intlayer">
|
|
87
244
|
|
|
88
|
-
|
|
245
|
+
在整个应用中访问你的内容字典:
|
|
89
246
|
|
|
90
|
-
|
|
247
|
+
```tsx {4,7} fileName="src/App.tsx" codeFormat={["typescript", "esm"]}
|
|
248
|
+
import logo from "./logo.svg";
|
|
249
|
+
import "./App.css";
|
|
250
|
+
import type { FC } from "react";
|
|
251
|
+
import { IntlayerProvider, useIntlayer } from "react-intlayer";
|
|
252
|
+
|
|
253
|
+
const AppContent: FC = () => {
|
|
254
|
+
const content = useIntlayer("app");
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<div className="App">
|
|
258
|
+
<img src={logo} className="App-logo" alt="logo" />
|
|
259
|
+
|
|
260
|
+
{content.getStarted}
|
|
261
|
+
<a
|
|
262
|
+
className="App-link"
|
|
263
|
+
href={content.reactLink.href.value}
|
|
264
|
+
target="_blank"
|
|
265
|
+
rel="noopener noreferrer"
|
|
266
|
+
>
|
|
267
|
+
{content.reactLink.content}
|
|
268
|
+
</a>
|
|
269
|
+
</div>
|
|
270
|
+
);
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const App: FC = () => (
|
|
274
|
+
<IntlayerProvider>
|
|
275
|
+
<AppContent />
|
|
276
|
+
</IntlayerProvider>
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
export default App;
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
> 注意:如果你想在 `string` 属性中使用你的内容,例如 `alt`、`title`、`href`、`aria-label` 等,你可以使用函数的值,如下所示:
|
|
283
|
+
|
|
284
|
+
> ```html
|
|
285
|
+
> <img src="{content.image.src.value}" alt="{content.image.value}" />
|
|
286
|
+
> <img src="{content.image.src.toString()}" alt="{content.image.toString()}" />
|
|
287
|
+
> <img src="{String(content.image.src)}" alt="{String(content.image)}" />
|
|
288
|
+
> ```
|
|
289
|
+
|
|
290
|
+
> 要了解有关 `useIntlayer` 钩子的更多信息,请参考 [文档](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/packages/react-intlayer/useIntlayer.md)。
|
|
291
|
+
|
|
292
|
+
</Step>
|
|
293
|
+
|
|
294
|
+
<Step number={6} title="更改你的内容的语言" isOptional={true}>
|
|
295
|
+
|
|
296
|
+
要更改你的内容的语言,你可以使用 `useLocale` 钩子提供的 `setLocale` 函数。此函数允许你设置应用的语言环境并相应地更新内容。
|
|
297
|
+
|
|
298
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat={["typescript", "esm"]}
|
|
299
|
+
import { Locales } from "intlayer";
|
|
300
|
+
import { useLocale } from "react-intlayer";
|
|
301
|
+
|
|
302
|
+
const LocaleSwitcher = () => {
|
|
303
|
+
const { setLocale } = useLocale();
|
|
304
|
+
|
|
305
|
+
return (
|
|
306
|
+
<button onClick={() => setLocale(Locales.English)}>更改语言为英文</button>
|
|
307
|
+
);
|
|
308
|
+
};
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
> 要了解有关 `useLocale` 钩子的更多信息,请参考 [文档](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/packages/react-intlayer/useLocale.md)。
|
|
312
|
+
|
|
313
|
+
</Step>
|
|
314
|
+
|
|
315
|
+
<Step number={7} title="为你的应用添加本地化路由" isOptional={true}>
|
|
316
|
+
|
|
317
|
+
此步骤的目的是为每种语言创建唯一的路由。这对 SEO 和友好的 SEO URL 非常有用。
|
|
91
318
|
示例:
|
|
92
319
|
|
|
93
320
|
```plaintext
|
|
@@ -96,14 +323,15 @@ bun add intlayer react-intlayer react-scripts-intlayer
|
|
|
96
323
|
- https://example.com/fr/about
|
|
97
324
|
```
|
|
98
325
|
|
|
99
|
-
>
|
|
326
|
+
> 默认情况下,默认语言的路由没有前缀。如果你想为默认语言添加前缀,可以在配置中将 `middleware.prefixDefault` 选项设置为 `true`。有关更多信息,请参考 [配置文档](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/configuration.md)。
|
|
100
327
|
|
|
101
|
-
|
|
328
|
+
要为你的应用添加本地化路由,你可以创建一个 `LocaleRouter` 组件来包装应用的路由并处理基于语言环境的路由。以下是使用 [React Router](https://reactrouter.com/home) 的示例:
|
|
102
329
|
|
|
103
330
|
```tsx fileName="src/components/LocaleRouter.tsx" codeFormat={["typescript", "esm"]}
|
|
104
331
|
// 导入必要的依赖项和函数
|
|
105
332
|
import { type Locales, configuration, getPathWithoutLocale } from "intlayer"; // 来自 'intlayer' 的实用函数和类型
|
|
106
|
-
|
|
333
|
+
// 来自 'intlayer' 的实用函数和类型
|
|
334
|
+
import type { FC, PropsWithChildren } from "react"; // React 函数组件和 props 的类型
|
|
107
335
|
import { IntlayerProvider } from "react-intlayer"; // 国际化上下文的提供者
|
|
108
336
|
import {
|
|
109
337
|
BrowserRouter,
|
|
@@ -118,7 +346,7 @@ const { internationalization, middleware } = configuration;
|
|
|
118
346
|
const { locales, defaultLocale } = internationalization;
|
|
119
347
|
|
|
120
348
|
/**
|
|
121
|
-
*
|
|
349
|
+
* 一个处理本地化并用适当的语言环境上下文包装子组件的组件。
|
|
122
350
|
* 它管理基于 URL 的语言环境检测和验证。
|
|
123
351
|
*/
|
|
124
352
|
const AppLocalized: FC<PropsWithChildren<{ locale: Locales }>> = ({
|
|
@@ -127,7 +355,7 @@ const AppLocalized: FC<PropsWithChildren<{ locale: Locales }>> = ({
|
|
|
127
355
|
}) => {
|
|
128
356
|
const { pathname, search } = useLocation(); // 获取当前 URL 路径
|
|
129
357
|
|
|
130
|
-
//
|
|
358
|
+
// 确定当前语言环境,如果未提供则回退到默认语言
|
|
131
359
|
const currentLocale = locale ?? defaultLocale;
|
|
132
360
|
|
|
133
361
|
// 从路径中移除语言环境前缀以构造基本路径
|
|
@@ -136,34 +364,34 @@ const AppLocalized: FC<PropsWithChildren<{ locale: Locales }>> = ({
|
|
|
136
364
|
);
|
|
137
365
|
|
|
138
366
|
/**
|
|
139
|
-
* 如果 middleware.prefixDefault
|
|
367
|
+
* 如果 middleware.prefixDefault 为真,默认语言应始终带有前缀。
|
|
140
368
|
*/
|
|
141
369
|
if (middleware.prefixDefault) {
|
|
142
370
|
// 验证语言环境
|
|
143
371
|
if (!locale || !locales.includes(locale)) {
|
|
144
|
-
//
|
|
372
|
+
// 重定向到带有更新路径的默认语言
|
|
145
373
|
return (
|
|
146
374
|
<Navigate
|
|
147
375
|
to={`/${defaultLocale}/${pathWithoutLocale}${search}`}
|
|
148
|
-
replace //
|
|
376
|
+
replace // 用新项替换当前历史记录条目
|
|
149
377
|
/>
|
|
150
378
|
);
|
|
151
379
|
}
|
|
152
380
|
|
|
153
|
-
//
|
|
381
|
+
// 用 IntlayerProvider 包装子组件并设置当前语言环境
|
|
154
382
|
return (
|
|
155
383
|
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
156
384
|
);
|
|
157
385
|
} else {
|
|
158
386
|
/**
|
|
159
|
-
* 当 middleware.prefixDefault
|
|
160
|
-
*
|
|
387
|
+
* 当 middleware.prefixDefault 为假时,默认语言没有前缀。
|
|
388
|
+
* 确保当前语言环境有效且不是默认语言。
|
|
161
389
|
*/
|
|
162
390
|
if (
|
|
163
391
|
currentLocale.toString() !== defaultLocale.toString() &&
|
|
164
392
|
!locales
|
|
165
393
|
.filter(
|
|
166
|
-
(locale) => locale.toString() !== defaultLocale.toString() //
|
|
394
|
+
(locale) => locale.toString() !== defaultLocale.toString() // 排除默认语言
|
|
167
395
|
)
|
|
168
396
|
.includes(currentLocale) // 检查当前语言环境是否在有效语言环境列表中
|
|
169
397
|
) {
|
|
@@ -171,7 +399,7 @@ const AppLocalized: FC<PropsWithChildren<{ locale: Locales }>> = ({
|
|
|
171
399
|
return <Navigate to={`${pathWithoutLocale}${search}`} replace />;
|
|
172
400
|
}
|
|
173
401
|
|
|
174
|
-
//
|
|
402
|
+
// 用 IntlayerProvider 包装子组件并设置当前语言环境
|
|
175
403
|
return (
|
|
176
404
|
<IntlayerProvider locale={currentLocale}>{children}</IntlayerProvider>
|
|
177
405
|
);
|
|
@@ -179,8 +407,8 @@ const AppLocalized: FC<PropsWithChildren<{ locale: Locales }>> = ({
|
|
|
179
407
|
};
|
|
180
408
|
|
|
181
409
|
/**
|
|
182
|
-
*
|
|
183
|
-
* 它使用 React Router
|
|
410
|
+
* 一个设置特定于语言环境的路由的路由组件。
|
|
411
|
+
* 它使用 React Router 来管理导航和呈现本地化组件。
|
|
184
412
|
*/
|
|
185
413
|
export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
|
|
186
414
|
<BrowserRouter>
|
|
@@ -199,7 +427,7 @@ export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
|
|
|
199
427
|
))}
|
|
200
428
|
|
|
201
429
|
{
|
|
202
|
-
//
|
|
430
|
+
// 如果禁用了默认语言前缀,在根路径直接呈现子组件
|
|
203
431
|
!middleware.prefixDefault && (
|
|
204
432
|
<Route
|
|
205
433
|
path="*"
|
|
@@ -214,13 +442,13 @@ export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
|
|
|
214
442
|
);
|
|
215
443
|
```
|
|
216
444
|
|
|
217
|
-
|
|
445
|
+
然后,你可以在你的应用中使用 `LocaleRouter` 组件:
|
|
218
446
|
|
|
219
447
|
```tsx fileName="src/App.tsx" codeFormat={["typescript", "esm"]}
|
|
220
448
|
import { LocaleRouter } from "./components/LocaleRouter";
|
|
221
449
|
import type { FC } from "react";
|
|
222
450
|
|
|
223
|
-
// ...
|
|
451
|
+
// ... 你的 AppContent 组件
|
|
224
452
|
|
|
225
453
|
const App: FC = () => (
|
|
226
454
|
<LocaleRouter>
|
|
@@ -229,6 +457,100 @@ const App: FC = () => (
|
|
|
229
457
|
);
|
|
230
458
|
```
|
|
231
459
|
|
|
460
|
+
</Step>
|
|
461
|
+
|
|
462
|
+
<Step number={8} title="当语言环境更改时更改 URL" isOptional={true}>
|
|
463
|
+
|
|
464
|
+
要在语言环境更改时更改 URL,你可以使用 `useLocale` 钩子提供的 `onLocaleChange` prop。同时,你可以使用 `react-router-dom` 中的 `useLocation` 和 `useNavigate` 钩子来更新 URL 路径。
|
|
465
|
+
|
|
466
|
+
```tsx fileName="src/components/LocaleSwitcher.tsx" codeFormat={["typescript", "esm"]}
|
|
467
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
468
|
+
import {
|
|
469
|
+
Locales,
|
|
470
|
+
getHTMLTextDir,
|
|
471
|
+
getLocaleName,
|
|
472
|
+
getLocalizedUrl,
|
|
473
|
+
} from "intlayer";
|
|
474
|
+
import { useLocale } from "react-intlayer";
|
|
475
|
+
import { type FC } from "react";
|
|
476
|
+
|
|
477
|
+
const LocaleSwitcher: FC = () => {
|
|
478
|
+
const { pathname, search } = useLocation(); // 获取当前 URL 路径。示例:/fr/about?foo=bar
|
|
479
|
+
const navigate = useNavigate();
|
|
480
|
+
|
|
481
|
+
const { locale, availableLocales, setLocale } = useLocale({
|
|
482
|
+
onLocaleChange: (locale) => {
|
|
483
|
+
// 使用更新的语言环境构造 URL
|
|
484
|
+
// 示例:/es/about?foo=bar
|
|
485
|
+
const pathWithLocale = getLocalizedUrl(`${pathname}${search}`, locale);
|
|
486
|
+
|
|
487
|
+
// 更新 URL 路径
|
|
488
|
+
navigate(pathWithLocale);
|
|
489
|
+
},
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
return (
|
|
493
|
+
<div>
|
|
494
|
+
<button popoverTarget="localePopover">{getLocaleName(locale)}</button>
|
|
495
|
+
<div id="localePopover" popover="auto">
|
|
496
|
+
{availableLocales.map((localeItem) => (
|
|
497
|
+
<a
|
|
498
|
+
href={getLocalizedUrl(location.pathname, localeItem)}
|
|
499
|
+
hrefLang={localeItem}
|
|
500
|
+
aria-current={locale === localeItem ? "page" : undefined}
|
|
501
|
+
onClick={(e) => {
|
|
502
|
+
e.preventDefault();
|
|
503
|
+
setLocale(localeItem);
|
|
504
|
+
}}
|
|
505
|
+
key={localeItem}
|
|
506
|
+
>
|
|
507
|
+
<span>
|
|
508
|
+
{/* 语言环境 - 例如 FR */}
|
|
509
|
+
{localeItem}
|
|
510
|
+
</span>
|
|
511
|
+
<span>
|
|
512
|
+
{/* 该语言环境中的语言 - 例如 Français */}
|
|
513
|
+
{getLocaleName(localeItem, locale)}
|
|
514
|
+
</span>
|
|
515
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
516
|
+
{/* 当前语言环境中的语言 - 例如当前语言环境设置为 Locales.SPANISH 时的 Francés */}
|
|
517
|
+
{getLocaleName(localeItem)}
|
|
518
|
+
</span>
|
|
519
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
520
|
+
{/* 英文语言 - 例如 French */}
|
|
521
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
522
|
+
</span>
|
|
523
|
+
</a>
|
|
524
|
+
))}
|
|
525
|
+
</div>
|
|
526
|
+
</div>
|
|
527
|
+
);
|
|
528
|
+
};
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
> 文档参考:
|
|
532
|
+
>
|
|
533
|
+
> - [`useLocale` 钩子](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/packages/react-intlayer/useLocale.md)
|
|
534
|
+
> - [`getLocaleName` 钩子](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/packages/intlayer/getLocaleName.md)
|
|
535
|
+
> - [`getLocalizedUrl` 钩子](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/packages/intlayer/getLocalizedUrl.md)
|
|
536
|
+
> - [`getHTMLTextDir` 钩子](https://github.com/aymericzip/intlayer/blob/main/docs/docs/zh/packages/intlayer/getHTMLTextDir.md)
|
|
537
|
+
> - [`hrefLang` 属性](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
|
|
538
|
+
> - [`lang` 属性](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang)
|
|
539
|
+
> - [`dir` 属性](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir)
|
|
540
|
+
> - [`aria-current` 属性](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current)
|
|
541
|
+
|
|
542
|
+
</Step>
|
|
543
|
+
|
|
544
|
+
<Step number={9} title="切换 HTML 语言和方向属性" isOptional={true}>
|
|
545
|
+
|
|
546
|
+
当你的应用支持多种语言时,更新 `<html>` 标签的 `lang` 和 `dir` 属性以匹配当前语言环境至关重要。这样做可以确保:
|
|
547
|
+
|
|
548
|
+
- **可访问性**:屏幕阅读器和辅助技术依赖正确的 `lang` 属性来准确地发音和解释内容。
|
|
549
|
+
- **文本呈现**:`dir`(方向)属性确保文本按正确的顺序呈现(例如英文的从左到右、阿拉伯语或希伯来语的从右到左),这对可读性至关重要。
|
|
550
|
+
- **SEO**:搜索引擎使用 `lang` 属性来确定你页面的语言,帮助在搜索结果中提供正确的本地化内容。
|
|
551
|
+
|
|
552
|
+
通过在语言环境更改时动态更新这些属性,你可以为所有支持的语言的用户保证一致和可访问的体验。
|
|
553
|
+
|
|
232
554
|
#### 实现钩子
|
|
233
555
|
|
|
234
556
|
创建一个自定义钩子来管理 HTML 属性。该钩子监听语言环境更改并相应地更新属性:
|