@intlayer/docs 6.1.5 → 6.1.6
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/next-i18next_vs_next-intl_vs_intlayer.md +404 -173
- package/blog/de/next-i18next_vs_next-intl_vs_intlayer.md +262 -113
- package/blog/en/intlayer_with_next-i18next.mdx +431 -0
- package/blog/en/intlayer_with_next-intl.mdx +335 -0
- package/blog/en/next-i18next_vs_next-intl_vs_intlayer.md +463 -209
- package/blog/en-GB/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/es/next-i18next_vs_next-intl_vs_intlayer.md +185 -71
- package/blog/fr/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/it/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/ja/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/ko/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/pt/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/blog/ru/next-i18next_vs_next-intl_vs_intlayer.md +36 -28
- package/blog/tr/next-i18next_vs_next-intl_vs_intlayer.md +2 -0
- package/blog/zh/next-i18next_vs_next-intl_vs_intlayer.md +38 -28
- package/dist/cjs/generated/docs.entry.cjs +32 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +32 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +2 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/component_i18n.md +186 -0
- package/docs/ar/intlayer_with_angular.md +2 -2
- package/docs/ar/intlayer_with_astro.md +246 -0
- package/docs/ar/intlayer_with_create_react_app.md +3 -2
- package/docs/ar/intlayer_with_express.md +2 -2
- package/docs/ar/intlayer_with_nestjs.md +2 -2
- package/docs/ar/intlayer_with_nextjs_14.md +2 -2
- package/docs/ar/intlayer_with_nextjs_15.md +2 -2
- package/docs/ar/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ar/intlayer_with_nuxt.md +2 -2
- package/docs/ar/intlayer_with_react_native+expo.md +11 -20
- package/docs/ar/intlayer_with_react_router_v7.md +195 -241
- package/docs/ar/intlayer_with_tanstack.md +198 -272
- package/docs/ar/intlayer_with_vite+preact.md +9 -9
- package/docs/ar/intlayer_with_vite+react.md +7 -7
- package/docs/ar/intlayer_with_vite+vue.md +9 -9
- package/docs/ar/vs_code_extension.md +48 -109
- package/docs/de/component_i18n.md +186 -0
- package/docs/de/intlayer_with_angular.md +2 -2
- package/docs/de/intlayer_with_astro.md +246 -0
- package/docs/de/intlayer_with_create_react_app.md +2 -2
- package/docs/de/intlayer_with_express.md +2 -2
- package/docs/de/intlayer_with_nestjs.md +2 -2
- package/docs/de/intlayer_with_nextjs_14.md +2 -2
- package/docs/de/intlayer_with_nextjs_15.md +2 -2
- package/docs/de/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/de/intlayer_with_nuxt.md +2 -2
- package/docs/de/intlayer_with_react_native+expo.md +11 -20
- package/docs/de/intlayer_with_react_router_v7.md +193 -242
- package/docs/de/intlayer_with_tanstack.md +194 -266
- package/docs/de/intlayer_with_vite+preact.md +9 -9
- package/docs/de/intlayer_with_vite+react.md +9 -9
- package/docs/de/intlayer_with_vite+vue.md +11 -11
- package/docs/de/packages/vite-intlayer/index.md +3 -3
- package/docs/de/vs_code_extension.md +46 -107
- package/docs/en/component_i18n.md +186 -0
- package/docs/en/how_works_intlayer.md +1 -1
- package/docs/en/index.md +1 -1
- package/docs/en/intlayer_cli.md +1 -1
- package/docs/en/intlayer_with_angular.md +4 -4
- package/docs/en/intlayer_with_astro.md +246 -0
- package/docs/en/intlayer_with_create_react_app.md +4 -4
- package/docs/en/intlayer_with_express.md +3 -3
- package/docs/en/intlayer_with_lynx+react.md +1 -1
- package/docs/en/intlayer_with_nestjs.md +2 -2
- package/docs/en/intlayer_with_nextjs_14.md +31 -5
- package/docs/en/intlayer_with_nextjs_15.md +31 -5
- package/docs/en/intlayer_with_nextjs_page_router.md +5 -5
- package/docs/en/intlayer_with_nuxt.md +4 -4
- package/docs/en/intlayer_with_react_native+expo.md +46 -24
- package/docs/en/intlayer_with_react_router_v7.md +164 -211
- package/docs/en/intlayer_with_tanstack.md +166 -241
- package/docs/en/intlayer_with_vite+preact.md +12 -12
- package/docs/en/intlayer_with_vite+react.md +12 -12
- package/docs/en/intlayer_with_vite+solid.md +2 -2
- package/docs/en/intlayer_with_vite+svelte.md +2 -2
- package/docs/en/intlayer_with_vite+vue.md +12 -12
- package/docs/en/introduction.md +1 -1
- package/docs/en/packages/next-intlayer/useDictionary.md +1 -1
- package/docs/en/packages/next-intlayer/useIntlayer.md +1 -1
- package/docs/en/packages/react-intlayer/useDictionary.md +1 -1
- package/docs/en/packages/react-intlayer/useI18n.md +1 -1
- package/docs/en/packages/react-intlayer/useIntlayer.md +1 -1
- package/docs/en/releases/v6.md +1 -0
- package/docs/en/roadmap.md +1 -1
- package/docs/en/vs_code_extension.md +24 -114
- package/docs/en-GB/component_i18n.md +186 -0
- package/docs/en-GB/intlayer_with_angular.md +3 -3
- package/docs/en-GB/intlayer_with_astro.md +246 -0
- package/docs/en-GB/intlayer_with_create_react_app.md +5 -4
- package/docs/en-GB/intlayer_with_express.md +2 -2
- package/docs/en-GB/intlayer_with_nestjs.md +2 -2
- package/docs/en-GB/intlayer_with_nextjs_14.md +4 -4
- package/docs/en-GB/intlayer_with_nextjs_15.md +2 -2
- package/docs/en-GB/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/en-GB/intlayer_with_nuxt.md +2 -2
- package/docs/en-GB/intlayer_with_react_native+expo.md +11 -20
- package/docs/en-GB/intlayer_with_react_router_v7.md +171 -220
- package/docs/en-GB/intlayer_with_tanstack.md +174 -248
- package/docs/en-GB/intlayer_with_vite+preact.md +9 -9
- package/docs/en-GB/intlayer_with_vite+react.md +9 -9
- package/docs/en-GB/intlayer_with_vite+vue.md +11 -11
- package/docs/en-GB/packages/next-intlayer/useIntlayer.md +1 -1
- package/docs/en-GB/packages/react-intlayer/useIntlayer.md +1 -1
- package/docs/en-GB/vs_code_extension.md +42 -103
- package/docs/es/component_i18n.md +182 -0
- package/docs/es/intlayer_with_angular.md +2 -2
- package/docs/es/intlayer_with_astro.md +246 -0
- package/docs/es/intlayer_with_create_react_app.md +3 -2
- package/docs/es/intlayer_with_express.md +2 -2
- package/docs/es/intlayer_with_nextjs_14.md +2 -2
- package/docs/es/intlayer_with_nextjs_15.md +2 -2
- package/docs/es/intlayer_with_react_native+expo.md +11 -20
- package/docs/es/intlayer_with_react_router_v7.md +188 -232
- package/docs/es/intlayer_with_tanstack.md +203 -273
- package/docs/es/intlayer_with_vite+preact.md +7 -7
- package/docs/es/intlayer_with_vite+react.md +7 -7
- package/docs/es/intlayer_with_vite+vue.md +9 -9
- package/docs/es/vs_code_extension.md +53 -114
- package/docs/fr/component_i18n.md +186 -0
- package/docs/fr/intlayer_with_angular.md +2 -2
- package/docs/fr/intlayer_with_astro.md +246 -0
- package/docs/fr/intlayer_with_create_react_app.md +3 -2
- package/docs/fr/intlayer_with_express.md +2 -2
- package/docs/fr/intlayer_with_nestjs.md +2 -2
- package/docs/fr/intlayer_with_nextjs_14.md +2 -2
- package/docs/fr/intlayer_with_react_native+expo.md +11 -20
- package/docs/fr/intlayer_with_react_router_v7.md +188 -248
- package/docs/fr/intlayer_with_tanstack.md +192 -265
- package/docs/fr/intlayer_with_vite+preact.md +7 -7
- package/docs/fr/intlayer_with_vite+react.md +7 -7
- package/docs/fr/intlayer_with_vite+vue.md +9 -9
- package/docs/fr/vs_code_extension.md +50 -111
- package/docs/hi/component_i18n.md +186 -0
- package/docs/hi/intlayer_cli.md +1 -4
- package/docs/hi/intlayer_with_angular.md +2 -2
- package/docs/hi/intlayer_with_astro.md +246 -0
- package/docs/hi/intlayer_with_create_react_app.md +2 -2
- package/docs/hi/intlayer_with_express.md +2 -2
- package/docs/hi/intlayer_with_nestjs.md +2 -2
- package/docs/hi/intlayer_with_nextjs_14.md +2 -2
- package/docs/hi/intlayer_with_nextjs_15.md +2 -2
- package/docs/hi/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/hi/intlayer_with_nuxt.md +2 -2
- package/docs/hi/intlayer_with_react_native+expo.md +11 -20
- package/docs/hi/intlayer_with_react_router_v7.md +199 -243
- package/docs/hi/intlayer_with_tanstack.md +210 -285
- package/docs/hi/intlayer_with_vite+preact.md +9 -9
- package/docs/hi/intlayer_with_vite+react.md +9 -9
- package/docs/hi/intlayer_with_vite+solid.md +1 -1
- package/docs/hi/intlayer_with_vite+vue.md +11 -11
- package/docs/hi/vs_code_extension.md +49 -110
- package/docs/it/component_i18n.md +186 -0
- package/docs/it/intlayer_with_angular.md +2 -2
- package/docs/it/intlayer_with_astro.md +246 -0
- package/docs/it/intlayer_with_create_react_app.md +3 -2
- package/docs/it/intlayer_with_express.md +2 -2
- package/docs/it/intlayer_with_nestjs.md +2 -2
- package/docs/it/intlayer_with_nextjs_14.md +2 -2
- package/docs/it/intlayer_with_nextjs_15.md +2 -2
- package/docs/it/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/it/intlayer_with_nuxt.md +2 -2
- package/docs/it/intlayer_with_react_native+expo.md +11 -21
- package/docs/it/intlayer_with_react_router_v7.md +195 -242
- package/docs/it/intlayer_with_tanstack.md +203 -267
- package/docs/it/intlayer_with_vite+preact.md +9 -9
- package/docs/it/intlayer_with_vite+react.md +13 -11
- package/docs/it/intlayer_with_vite+vue.md +11 -11
- package/docs/it/vs_code_extension.md +50 -111
- package/docs/ja/component_i18n.md +186 -0
- package/docs/ja/intlayer_with_angular.md +2 -2
- package/docs/ja/intlayer_with_astro.md +246 -0
- package/docs/ja/intlayer_with_create_react_app.md +3 -2
- package/docs/ja/intlayer_with_express.md +2 -2
- package/docs/ja/intlayer_with_nestjs.md +2 -2
- package/docs/ja/intlayer_with_nextjs_14.md +2 -2
- package/docs/ja/intlayer_with_nextjs_15.md +2 -2
- package/docs/ja/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ja/intlayer_with_nuxt.md +2 -2
- package/docs/ja/intlayer_with_react_native+expo.md +18 -29
- package/docs/ja/intlayer_with_react_router_v7.md +204 -250
- package/docs/ja/intlayer_with_tanstack.md +218 -286
- package/docs/ja/intlayer_with_vite+preact.md +9 -9
- package/docs/ja/intlayer_with_vite+react.md +11 -11
- package/docs/ja/intlayer_with_vite+vue.md +11 -11
- package/docs/ja/vs_code_extension.md +50 -111
- package/docs/ko/component_i18n.md +186 -0
- package/docs/ko/intlayer_with_angular.md +2 -2
- package/docs/ko/intlayer_with_astro.md +246 -0
- package/docs/ko/intlayer_with_create_react_app.md +3 -2
- package/docs/ko/intlayer_with_express.md +2 -2
- package/docs/ko/intlayer_with_nestjs.md +2 -2
- package/docs/ko/intlayer_with_nextjs_14.md +2 -2
- package/docs/ko/intlayer_with_nextjs_15.md +2 -2
- package/docs/ko/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ko/intlayer_with_nuxt.md +2 -2
- package/docs/ko/intlayer_with_react_native+expo.md +19 -28
- package/docs/ko/intlayer_with_react_router_v7.md +190 -244
- package/docs/ko/intlayer_with_tanstack.md +200 -270
- package/docs/ko/intlayer_with_vite+preact.md +9 -9
- package/docs/ko/intlayer_with_vite+react.md +9 -9
- package/docs/ko/intlayer_with_vite+vue.md +11 -11
- package/docs/ko/vs_code_extension.md +48 -109
- package/docs/pt/component_i18n.md +186 -0
- package/docs/pt/intlayer_with_angular.md +2 -2
- package/docs/pt/intlayer_with_astro.md +246 -0
- package/docs/pt/intlayer_with_create_react_app.md +3 -2
- package/docs/pt/intlayer_with_express.md +2 -2
- package/docs/pt/intlayer_with_nestjs.md +2 -2
- package/docs/pt/intlayer_with_nextjs_14.md +2 -2
- package/docs/pt/intlayer_with_nextjs_15.md +2 -2
- package/docs/pt/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/pt/intlayer_with_nuxt.md +2 -2
- package/docs/pt/intlayer_with_react_native+expo.md +11 -20
- package/docs/pt/intlayer_with_react_router_v7.md +7 -13
- package/docs/pt/intlayer_with_tanstack.md +183 -258
- package/docs/pt/intlayer_with_vite+preact.md +9 -9
- package/docs/pt/intlayer_with_vite+react.md +9 -9
- package/docs/pt/intlayer_with_vite+vue.md +9 -9
- package/docs/pt/vs_code_extension.md +46 -107
- package/docs/ru/component_i18n.md +186 -0
- package/docs/ru/intlayer_with_angular.md +2 -2
- package/docs/ru/intlayer_with_astro.md +246 -0
- package/docs/ru/intlayer_with_create_react_app.md +3 -2
- package/docs/ru/intlayer_with_express.md +2 -2
- package/docs/ru/intlayer_with_nestjs.md +2 -2
- package/docs/ru/intlayer_with_nextjs_14.md +2 -2
- package/docs/ru/intlayer_with_nextjs_15.md +2 -2
- package/docs/ru/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/ru/intlayer_with_nuxt.md +2 -2
- package/docs/ru/intlayer_with_react_native+expo.md +11 -20
- package/docs/ru/intlayer_with_react_router_v7.md +192 -238
- package/docs/ru/intlayer_with_tanstack.md +197 -269
- package/docs/ru/intlayer_with_vite+preact.md +9 -9
- package/docs/ru/intlayer_with_vite+react.md +9 -9
- package/docs/ru/intlayer_with_vite+vue.md +11 -11
- package/docs/ru/vs_code_extension.md +48 -109
- package/docs/tr/component_i18n.md +186 -0
- package/docs/tr/how_works_intlayer.md +1 -1
- package/docs/tr/index.md +1 -1
- package/docs/tr/intlayer_cli.md +1 -1
- package/docs/tr/intlayer_with_angular.md +4 -4
- package/docs/tr/intlayer_with_astro.md +246 -0
- package/docs/tr/intlayer_with_create_react_app.md +4 -4
- package/docs/tr/intlayer_with_express.md +3 -3
- package/docs/tr/intlayer_with_lynx+react.md +1 -1
- package/docs/tr/intlayer_with_nestjs.md +2 -2
- package/docs/tr/intlayer_with_nextjs_14.md +2 -2
- package/docs/tr/intlayer_with_nextjs_15.md +4 -4
- package/docs/tr/intlayer_with_nextjs_page_router.md +5 -5
- package/docs/tr/intlayer_with_nuxt.md +4 -4
- package/docs/tr/intlayer_with_react_native+expo.md +12 -21
- package/docs/tr/intlayer_with_react_router_v7.md +222 -267
- package/docs/tr/intlayer_with_tanstack.md +400 -303
- package/docs/tr/intlayer_with_vite+preact.md +12 -12
- package/docs/tr/intlayer_with_vite+react.md +12 -12
- package/docs/tr/intlayer_with_vite+solid.md +2 -2
- package/docs/tr/intlayer_with_vite+svelte.md +2 -2
- package/docs/tr/intlayer_with_vite+vue.md +12 -12
- package/docs/tr/introduction.md +1 -1
- package/docs/tr/packages/react-intlayer/useDictionary.md +1 -1
- package/docs/tr/packages/react-intlayer/useI18n.md +1 -1
- package/docs/tr/roadmap.md +1 -1
- package/docs/tr/vs_code_extension.md +54 -115
- package/docs/zh/component_i18n.md +186 -0
- package/docs/zh/intlayer_with_angular.md +2 -2
- package/docs/zh/intlayer_with_astro.md +246 -0
- package/docs/zh/intlayer_with_create_react_app.md +3 -2
- package/docs/zh/intlayer_with_express.md +2 -2
- package/docs/zh/intlayer_with_nestjs.md +2 -2
- package/docs/zh/intlayer_with_nextjs_14.md +2 -2
- package/docs/zh/intlayer_with_nextjs_15.md +2 -2
- package/docs/zh/intlayer_with_nextjs_page_router.md +2 -2
- package/docs/zh/intlayer_with_nuxt.md +2 -2
- package/docs/zh/intlayer_with_react_native+expo.md +19 -28
- package/docs/zh/intlayer_with_react_router_v7.md +200 -248
- package/docs/zh/intlayer_with_tanstack.md +208 -283
- package/docs/zh/intlayer_with_vite+preact.md +9 -9
- package/docs/zh/intlayer_with_vite+react.md +9 -9
- package/docs/zh/intlayer_with_vite+vue.md +9 -9
- package/docs/zh/vs_code_extension.md +51 -105
- package/package.json +10 -10
- package/src/generated/docs.entry.ts +32 -0
|
@@ -1048,38 +1048,38 @@ const App = () => (
|
|
|
1048
1048
|
module.exports = App;
|
|
1049
1049
|
```
|
|
1050
1050
|
|
|
1051
|
-
In parallel, you can also use the `
|
|
1051
|
+
In parallel, you can also use the `intlayerMiddleware` to add server-side routing to your application. This plugin will automatically detect the current locale based on the URL and set the appropriate locale cookie. If no locale is specified, the plugin will determine the most appropriate locale based on the user's browser language preferences. If no locale is detected, it will redirect to the default locale.
|
|
1052
1052
|
|
|
1053
1053
|
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
1054
1054
|
import { defineConfig } from "vite";
|
|
1055
1055
|
import preact from "@preact/preset-vite";
|
|
1056
|
-
import { intlayer,
|
|
1056
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
1057
1057
|
|
|
1058
1058
|
// https://vitejs.dev/config/
|
|
1059
1059
|
export default defineConfig({
|
|
1060
|
-
plugins: [preact(), intlayer(),
|
|
1060
|
+
plugins: [preact(), intlayer(), intlayerMiddleware()],
|
|
1061
1061
|
});
|
|
1062
1062
|
```
|
|
1063
1063
|
|
|
1064
1064
|
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
1065
1065
|
import { defineConfig } from "vite";
|
|
1066
1066
|
import preact from "@preact/preset-vite";
|
|
1067
|
-
import { intlayer,
|
|
1067
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
1068
1068
|
|
|
1069
1069
|
// https://vitejs.dev/config/
|
|
1070
1070
|
export default defineConfig({
|
|
1071
|
-
plugins: [preact(), intlayer(),
|
|
1071
|
+
plugins: [preact(), intlayer(), intlayerMiddleware()],
|
|
1072
1072
|
});
|
|
1073
1073
|
```
|
|
1074
1074
|
|
|
1075
1075
|
```javascript {3,7} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
1076
1076
|
const { defineConfig } = require("vite");
|
|
1077
1077
|
const preact = require("@preact/preset-vite");
|
|
1078
|
-
const { intlayer,
|
|
1078
|
+
const { intlayer, intlayerMiddleware } = require("vite-intlayer");
|
|
1079
1079
|
|
|
1080
1080
|
// https://vitejs.dev/config/
|
|
1081
1081
|
module.exports = defineConfig({
|
|
1082
|
-
plugins: [preact(), intlayer(),
|
|
1082
|
+
plugins: [preact(), intlayer(), intlayerMiddleware()],
|
|
1083
1083
|
});
|
|
1084
1084
|
```
|
|
1085
1085
|
|
|
@@ -1614,9 +1614,9 @@ module.exports = { LocalizedLink, checkIsExternalLink };
|
|
|
1614
1614
|
|
|
1615
1615
|
Intlayer uses module augmentation to gain the benefits of TypeScript and strengthen your codebase.
|
|
1616
1616
|
|
|
1617
|
-

|
|
1618
1618
|
|
|
1619
|
-

|
|
1620
1620
|
|
|
1621
1621
|
Ensure your TypeScript configuration includes the autogenerated types.
|
|
1622
1622
|
|
|
@@ -1037,38 +1037,38 @@ const App = () => (
|
|
|
1037
1037
|
);
|
|
1038
1038
|
```
|
|
1039
1039
|
|
|
1040
|
-
In parallel, you can also use the `
|
|
1040
|
+
In parallel, you can also use the `intlayerMiddleware` to add server-side routing to your application. This plugin will automatically detect the current locale based on the URL and set the appropriate locale cookie. If no locale is specified, the plugin will determine the most appropriate locale based on the user's browser language preferences. If no locale is detected, it will redirect to the default locale.
|
|
1041
1041
|
|
|
1042
1042
|
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
1043
1043
|
import { defineConfig } from "vite";
|
|
1044
1044
|
import react from "@vitejs/plugin-react-swc";
|
|
1045
|
-
import { intlayer,
|
|
1045
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
1046
1046
|
|
|
1047
1047
|
// https://vitejs.dev/config/
|
|
1048
1048
|
export default defineConfig({
|
|
1049
|
-
plugins: [react(), intlayer(),
|
|
1049
|
+
plugins: [react(), intlayer(), intlayerMiddleware()],
|
|
1050
1050
|
});
|
|
1051
1051
|
```
|
|
1052
1052
|
|
|
1053
1053
|
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
1054
1054
|
import { defineConfig } from "vite";
|
|
1055
1055
|
import react from "@vitejs/plugin-react-swc";
|
|
1056
|
-
import { intlayer,
|
|
1056
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
1057
1057
|
|
|
1058
1058
|
// https://vitejs.dev/config/
|
|
1059
1059
|
export default defineConfig({
|
|
1060
|
-
plugins: [react(), intlayer(),
|
|
1060
|
+
plugins: [react(), intlayer(), intlayerMiddleware()],
|
|
1061
1061
|
});
|
|
1062
1062
|
```
|
|
1063
1063
|
|
|
1064
1064
|
```javascript {3,7} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
1065
1065
|
const { defineConfig } = require("vite");
|
|
1066
1066
|
const react = require("@vitejs/plugin-react-swc");
|
|
1067
|
-
const { intlayer,
|
|
1067
|
+
const { intlayer, intlayerMiddleware } = require("vite-intlayer");
|
|
1068
1068
|
|
|
1069
1069
|
// https://vitejs.dev/config/
|
|
1070
1070
|
module.exports = defineConfig({
|
|
1071
|
-
plugins: [react(), intlayer(),
|
|
1071
|
+
plugins: [react(), intlayer(), intlayerMiddleware()],
|
|
1072
1072
|
});
|
|
1073
1073
|
```
|
|
1074
1074
|
|
|
@@ -1632,9 +1632,9 @@ By integrating this `Link` component across your application, you maintain a coh
|
|
|
1632
1632
|
|
|
1633
1633
|
Intlayer uses module augmentation to take advantage of TypeScript and make your codebase stronger.
|
|
1634
1634
|
|
|
1635
|
-

|
|
1636
1636
|
|
|
1637
|
-

|
|
1638
1638
|
|
|
1639
1639
|
Ensure your TypeScript configuration includes the autogenerated types.
|
|
1640
1640
|
|
|
@@ -672,38 +672,38 @@ import LocaleSwitcher from "@components/LocaleSwitcher.vue";
|
|
|
672
672
|
</template>
|
|
673
673
|
```
|
|
674
674
|
|
|
675
|
-
In parallel, you can also use the `
|
|
675
|
+
In parallel, you can also use the `intlayerMiddleware` to add server-side routing to your application. This plugin will automatically detect the current locale based on the URL and set the appropriate locale cookie. If no locale is specified, the plugin will determine the most appropriate locale based on the user's browser language preferences. If no locale is detected, it will redirect to the default locale.
|
|
676
676
|
|
|
677
677
|
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
678
678
|
import { defineConfig } from "vite";
|
|
679
679
|
import vue from "@vitejs/plugin-vue";
|
|
680
|
-
import { intlayer,
|
|
680
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
681
681
|
|
|
682
682
|
// https://vitejs.dev/config/
|
|
683
683
|
export default defineConfig({
|
|
684
|
-
plugins: [vue(), intlayer(),
|
|
684
|
+
plugins: [vue(), intlayer(), intlayerMiddleware()],
|
|
685
685
|
});
|
|
686
686
|
```
|
|
687
687
|
|
|
688
688
|
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
689
689
|
import { defineConfig } from "vite";
|
|
690
690
|
import vue from "@vitejs/plugin-vue";
|
|
691
|
-
import { intlayer,
|
|
691
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
692
692
|
|
|
693
693
|
// https://vitejs.dev/config/
|
|
694
694
|
export default defineConfig({
|
|
695
|
-
plugins: [vue(), intlayer(),
|
|
695
|
+
plugins: [vue(), intlayer(), intlayerMiddleware()],
|
|
696
696
|
});
|
|
697
697
|
```
|
|
698
698
|
|
|
699
699
|
```javascript {3,7} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
700
700
|
const { defineConfig } = require("vite");
|
|
701
701
|
const vue = require("@vitejs/plugin-vue");
|
|
702
|
-
const { intlayer,
|
|
702
|
+
const { intlayer, intlayerMiddleware } = require("vite-intlayer");
|
|
703
703
|
|
|
704
704
|
// https://vitejs.dev/config/
|
|
705
705
|
module.exports = defineConfig({
|
|
706
|
-
plugins: [vue(), intlayer(),
|
|
706
|
+
plugins: [vue(), intlayer(), intlayerMiddleware()],
|
|
707
707
|
});
|
|
708
708
|
```
|
|
709
709
|
|
|
@@ -721,9 +721,9 @@ To automatically update the URL when the user changes the language, you can modi
|
|
|
721
721
|
</select>
|
|
722
722
|
</div>
|
|
723
723
|
const { defineConfig } = require("vite"); const vue =
|
|
724
|
-
require("@vitejs/plugin-vue"); const { intlayer,
|
|
724
|
+
require("@vitejs/plugin-vue"); const { intlayer, intlayerMiddleware } =
|
|
725
725
|
require("vite-intlayer"); // https://vitejs.dev/config/ module.exports =
|
|
726
|
-
defineConfig({ plugins: [vue(), intlayer(),
|
|
726
|
+
defineConfig({ plugins: [vue(), intlayer(), intlayerMiddleware()], });
|
|
727
727
|
</template>
|
|
728
728
|
```
|
|
729
729
|
|
|
@@ -1062,9 +1062,9 @@ const { myMarkdownContent } = useIntlayer("my-component");
|
|
|
1062
1062
|
|
|
1063
1063
|
Intlayer uses module augmentation to leverage the benefits of TypeScript and strengthen your codebase.
|
|
1064
1064
|
|
|
1065
|
-

|
|
1066
1066
|
|
|
1067
|
-

|
|
1068
1068
|
|
|
1069
1069
|
Ensure your TypeScript configuration includes the auto-generated types.
|
|
1070
1070
|
|
|
@@ -65,7 +65,7 @@ Depending on whether you're working on client-side or server-side components in
|
|
|
65
65
|
|
|
66
66
|
It is crucial that all content keys are defined within content declaration files to prevent runtime errors and ensure type safety. This approach also facilitates TypeScript integration for compile-time validation.
|
|
67
67
|
|
|
68
|
-
Instructions for setting up content declaration files are available [here](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/
|
|
68
|
+
Instructions for setting up content declaration files are available [here](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md).
|
|
69
69
|
|
|
70
70
|
It's crucial that all content keys are defined within content declaration files to prevent runtime errors and ensure type safety. This approach also facilitates TypeScript integration for compile-time validation.
|
|
71
71
|
|
|
@@ -65,7 +65,7 @@ The hook accepts two parameters:
|
|
|
65
65
|
|
|
66
66
|
## Dictionary
|
|
67
67
|
|
|
68
|
-
All dictionary keys must be declared within content declaration files to enhance type safety and avoid errors. You can find the [setup instructions here](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/
|
|
68
|
+
All dictionary keys must be declared within content declaration files to enhance type safety and avoid errors. You can find the [setup instructions here](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md).
|
|
69
69
|
|
|
70
70
|
## Example Usage in React
|
|
71
71
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-03-17
|
|
3
|
-
updatedAt: 2025-09-
|
|
3
|
+
updatedAt: 2025-09-30
|
|
4
4
|
title: Official VS Code Extension
|
|
5
5
|
description: Learn how to use the Intlayer extension in VS Code to enhance your development workflow. Quickly navigate between localised content and manage your dictionaries efficiently.
|
|
6
6
|
keywords:
|
|
@@ -23,92 +23,36 @@ slugs:
|
|
|
23
23
|
|
|
24
24
|
[**Intlayer**](https://marketplace.visualstudio.com/items?itemName=Intlayer.intlayer-vs-code-extension) is the official Visual Studio Code extension for **Intlayer**, designed to improve the developer experience when working with localised content in your projects.
|
|
25
25
|
|
|
26
|
-

|
|
26
|
+

|
|
27
27
|
|
|
28
28
|
Extension link: [https://marketplace.visualstudio.com/items?itemName=Intlayer.intlayer-vs-code-extension](https://marketplace.visualstudio.com/items?itemName=Intlayer.intlayer-vs-code-extension)
|
|
29
29
|
|
|
30
30
|
## Features
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+

|
|
33
33
|
|
|
34
|
-
**
|
|
35
|
-
**Seamless Integration** – Works effortlessly with **react-intlayer** and **next-intlayer** projects.
|
|
36
|
-
**Multi-language Support** – Supports localised content across different languages.
|
|
37
|
-
**VS Code Integration** – Smoothly integrates with VS Code’s navigation and command palette.
|
|
38
|
-
|
|
39
|
-
### Dictionary Management Commands
|
|
40
|
-
|
|
41
|
-
Manage your content dictionaries directly from VS Code:
|
|
42
|
-
|
|
43
|
-
- **Build Dictionaries** – Generate content files based on your project structure.
|
|
44
|
-
- **Push Dictionaries** – Upload the latest dictionary content to your repository.
|
|
45
|
-
- **Pull Dictionaries** – Synchronise the latest dictionary content from your repository to your local environment.
|
|
34
|
+
- **Instant Navigation** – Quickly jump to the correct content file when clicking on a `useIntlayer` key.
|
|
46
35
|
- **Fill Dictionaries** – Populate dictionaries with content from your project.
|
|
47
|
-
- **Test Dictionaries** – Identify missing or incomplete translations.
|
|
48
|
-
|
|
49
|
-
### Content Declaration Generator
|
|
50
|
-
|
|
51
|
-
Easily generate structured dictionary files in different formats:
|
|
52
36
|
|
|
53
|
-
|
|
37
|
+

|
|
54
38
|
|
|
55
|
-
|
|
39
|
+
- **Easy access to Intlayer Commands** – Build, push, pull, fill, test content dictionaries with ease.
|
|
56
40
|
|
|
57
|
-
|
|
58
|
-
const MyComponent = () => {
|
|
59
|
-
const { myTranslatedContent } = useIntlayer("my-component");
|
|
41
|
+

|
|
60
42
|
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Generated file in TypeScript format:
|
|
43
|
+
- **Content Declaration Generator** – Create dictionary content files in various formats (`.ts`, `.esm`, `.cjs`, `.json`).
|
|
66
44
|
|
|
67
|
-
|
|
68
|
-
import { t, type Dictionary } from "intlayer";
|
|
45
|
+

|
|
69
46
|
|
|
70
|
-
|
|
71
|
-
key: "my-component",
|
|
72
|
-
content: {
|
|
73
|
-
myTranslatedContent: t({
|
|
74
|
-
en: "Hello World",
|
|
75
|
-
es: "Hola Mundo",
|
|
76
|
-
fr: "Bonjour le monde",
|
|
77
|
-
}),
|
|
78
|
-
},
|
|
79
|
-
};
|
|
47
|
+
- **Test Dictionaries** – Test dictionaries for missing translations.
|
|
80
48
|
|
|
81
|
-
|
|
82
|
-
```
|
|
49
|
+

|
|
83
50
|
|
|
84
|
-
|
|
51
|
+
- **Keep your dictionaries up to date** – Keep your dictionaries up to date with the latest content from your project.
|
|
85
52
|
|
|
86
|
-
|
|
87
|
-
- **ES Module (`.esm`)**
|
|
88
|
-
- **CommonJS (`.cjs`)**
|
|
89
|
-
- **JSON (`.json`)**
|
|
90
|
-
|
|
91
|
-
### Intlayer Tab (Activity Bar)
|
|
53
|
+

|
|
92
54
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
- **Search**: A live search bar to quickly filter dictionaries and their content. Typing updates the results instantly.
|
|
96
|
-
- **Dictionaries**: A tree view of your environments/projects, dictionary keys, and the files contributing entries. You can:
|
|
97
|
-
- Click a file to open it in the editor.
|
|
98
|
-
- Use the toolbar to run actions: Build, Pull, Push, Fill, Refresh, Test, and Create Dictionary File.
|
|
99
|
-
- Use the context menu for item‑specific actions:
|
|
100
|
-
- On a dictionary: Pull or Push
|
|
101
|
-
- On a file: Fill Dictionary
|
|
102
|
-
- When you switch editors, the tree will reveal the matching file if it belongs to a dictionary.
|
|
103
|
-
|
|
104
|
-
## Installation
|
|
105
|
-
|
|
106
|
-
You can install **Intlayer** directly from the VS Code Marketplace:
|
|
107
|
-
|
|
108
|
-
1. Open **VS Code**.
|
|
109
|
-
2. Go to the **Extensions Marketplace**.
|
|
110
|
-
3. Search for **"Intlayer"**.
|
|
111
|
-
4. Click **Install**.
|
|
55
|
+
- **Intlayer Tab (Activity Bar)** – Browse and search dictionaries from a dedicated side tab with toolbar and context actions (Build, Pull, Push, Fill, Refresh, Test, Create File).
|
|
112
56
|
|
|
113
57
|
## Usage
|
|
114
58
|
|
|
@@ -124,60 +68,55 @@ You can install **Intlayer** directly from the VS Code Marketplace:
|
|
|
124
68
|
3. **Command-click** (`⌘+Click` on macOS) or **Ctrl+Click** (on Windows/Linux) on the key (e.g., `"app"`).
|
|
125
69
|
4. VS Code will automatically open the corresponding dictionary file, e.g., `src/app.content.ts`.
|
|
126
70
|
|
|
127
|
-
### Managing Content Dictionaries
|
|
128
|
-
|
|
129
71
|
### Intlayer Tab (Activity Bar)
|
|
130
72
|
|
|
131
73
|
Use the side tab to browse and manage dictionaries:
|
|
132
74
|
|
|
133
75
|
- Open the Intlayer icon in the Activity Bar.
|
|
134
76
|
- In **Search**, type to filter dictionaries and entries in real time.
|
|
135
|
-
- In **Dictionaries**, browse environments, dictionaries, and files. Use the toolbar for Build, Pull, Push, Fill, Refresh, Test, and Create Dictionary File. Right
|
|
77
|
+
- In **Dictionaries**, browse environments, dictionaries, and files. Use the toolbar for Build, Pull, Push, Fill, Refresh, Test, and Create Dictionary File. Right-click for context actions (Pull/Push on dictionaries, Fill on files). The current editor file auto-reveals in the tree when applicable.
|
|
136
78
|
|
|
137
|
-
|
|
79
|
+
### Accessing the commands
|
|
138
80
|
|
|
139
|
-
|
|
81
|
+
You can access the commands from the **Command Palette**.
|
|
140
82
|
|
|
141
83
|
```sh
|
|
142
84
|
Cmd + Shift + P (macOS) / Ctrl + Shift + P (Windows/Linux)
|
|
143
85
|
```
|
|
144
86
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
1. Open the **Command Palette**.
|
|
152
|
-
2. Search for **Push Dictionaries**.
|
|
153
|
-
3. Select the dictionaries to push and confirm.
|
|
154
|
-
|
|
155
|
-
#### Pulling Dictionaries
|
|
87
|
+
- **Build Dictionaries**
|
|
88
|
+
- **Push Dictionaries**
|
|
89
|
+
- **Pull Dictionaries**
|
|
90
|
+
- **Fill Dictionaries**
|
|
91
|
+
- **Test Dictionaries**
|
|
92
|
+
- **Create Dictionary File**
|
|
156
93
|
|
|
157
|
-
|
|
94
|
+
### Loading Environment Variables
|
|
158
95
|
|
|
159
|
-
|
|
160
|
-
2. Search for **Pull Dictionaries**.
|
|
161
|
-
3. Choose the dictionaries to pull.
|
|
96
|
+
Intlayer recommends storing your AI API keys, as well as the Intlayer client ID and secret, in environment variables.
|
|
162
97
|
|
|
163
|
-
|
|
98
|
+
The extension can load environment variables from your workspace to run Intlayer commands with the correct context.
|
|
164
99
|
|
|
165
|
-
|
|
100
|
+
- **Load order (by priority)**: `.env.<env>.local` → `.env.<env>` → `.env.local` → `.env`
|
|
101
|
+
- **Non-destructive**: existing `process.env` values are not overridden.
|
|
102
|
+
- **Scope**: files are resolved from the configured base directory (defaults to the workspace root).
|
|
166
103
|
|
|
167
|
-
|
|
168
|
-
2. Search for **Fill Dictionaries**.
|
|
169
|
-
3. Run the command to populate dictionaries.
|
|
104
|
+
#### Selecting the active environment
|
|
170
105
|
|
|
171
|
-
|
|
106
|
+
- **Command Palette**: open the palette and run `Intlayer: Select Environment`, then choose the environment (e.g., `development`, `staging`, `production`). The extension will attempt to load the first available file in the priority list above and show a notification like “Loaded env from .env.<env>.local”.
|
|
107
|
+
- **Settings**: go to `Settings → Extensions → Intlayer`, and set:
|
|
108
|
+
- **Environment**: the environment name used to resolve `.env.<env>*` files.
|
|
109
|
+
- (Optional) **Env File**: an explicit path to a `.env` file. When provided, it takes precedence over the inferred list.
|
|
172
110
|
|
|
173
|
-
|
|
111
|
+
#### Monorepos and custom directories
|
|
174
112
|
|
|
175
|
-
|
|
176
|
-
2. Search for **Test Dictionaries**.
|
|
177
|
-
3. Review the reported issues and fix as needed.
|
|
113
|
+
If your `.env` files reside outside the workspace root, set the **Base Directory** in `Settings → Extensions → Intlayer`. The loader will search for `.env` files relative to that directory.
|
|
178
114
|
|
|
179
115
|
## Doc History
|
|
180
116
|
|
|
181
|
-
| Version | Date | Changes
|
|
182
|
-
| ------- | ---------- |
|
|
183
|
-
|
|
|
117
|
+
| Version | Date | Changes |
|
|
118
|
+
| ------- | ---------- | ----------------------------------- |
|
|
119
|
+
| 6.1.5 | 2025-09-30 | Added demo gif |
|
|
120
|
+
| 6.1.0 | 2025-09-24 | Added environment selection section |
|
|
121
|
+
| 6.0.0 | 2025-09-22 | Intlayer Tab / Fill & Test commands |
|
|
122
|
+
| 5.5.10 | 2025-06-29 | Initial history |
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2024-03-07
|
|
3
|
+
updatedAt: 2025-09-30
|
|
4
|
+
title: Hacer un componente multilingüe (biblioteca i18n) en React y Next.js
|
|
5
|
+
description: Aprende a declarar y recuperar contenido localizado para construir un componente multilingüe de React o Next.js con Intlayer.
|
|
6
|
+
keywords:
|
|
7
|
+
- i18n
|
|
8
|
+
- componente
|
|
9
|
+
- react
|
|
10
|
+
- multilingüe
|
|
11
|
+
- next.js
|
|
12
|
+
- intlayer
|
|
13
|
+
slugs:
|
|
14
|
+
- doc
|
|
15
|
+
- component
|
|
16
|
+
- i18n
|
|
17
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-vite-react-template
|
|
18
|
+
youtubeVideo: https://www.youtube.com/watch?v=dS9L7uJeak4
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# Cómo hacer un componente multilingüe (i18n) con Intlayer
|
|
22
|
+
|
|
23
|
+
Esta guía muestra los pasos mínimos para hacer que un componente de interfaz sea multilingüe en dos configuraciones comunes:
|
|
24
|
+
|
|
25
|
+
- React (Vite/SPA)
|
|
26
|
+
- Next.js (App Router)
|
|
27
|
+
|
|
28
|
+
Primero declararás tu contenido y luego lo recuperarás en tu componente.
|
|
29
|
+
|
|
30
|
+
## 1) Declara tu contenido (compartido para React y Next.js)
|
|
31
|
+
|
|
32
|
+
Crea un archivo de declaración de contenido cerca de tu componente. Esto mantiene las traducciones cerca del lugar donde se usan y habilita la seguridad de tipos.
|
|
33
|
+
|
|
34
|
+
```ts fileName="component.content.ts"
|
|
35
|
+
import { t, type Dictionary } from "intlayer";
|
|
36
|
+
|
|
37
|
+
const componentContent = {
|
|
38
|
+
key: "component-example",
|
|
39
|
+
content: {
|
|
40
|
+
title: t({
|
|
41
|
+
en: "Hello",
|
|
42
|
+
fr: "Bonjour",
|
|
43
|
+
es: "Hola",
|
|
44
|
+
}),
|
|
45
|
+
description: t({
|
|
46
|
+
en: "A multilingual React component",
|
|
47
|
+
fr: "Un composant React multilingue",
|
|
48
|
+
es: "Un componente React multilingüe",
|
|
49
|
+
}),
|
|
50
|
+
},
|
|
51
|
+
} satisfies Dictionary;
|
|
52
|
+
|
|
53
|
+
export default componentContent;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
También se admite JSON si prefieres archivos de configuración.
|
|
57
|
+
|
|
58
|
+
```json fileName="component.content.json"
|
|
59
|
+
{
|
|
60
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
61
|
+
"key": "component-example",
|
|
62
|
+
"content": {
|
|
63
|
+
"title": {
|
|
64
|
+
"nodeType": "translation",
|
|
65
|
+
"translation": { "en": "Hello", "fr": "Bonjour", "es": "Hola" }
|
|
66
|
+
},
|
|
67
|
+
"description": {
|
|
68
|
+
"nodeType": "translation",
|
|
69
|
+
"translation": {
|
|
70
|
+
"en": "A multilingual React component",
|
|
71
|
+
"fr": "Un composant React multilingue",
|
|
72
|
+
"es": "Un componente React multilingüe"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 2) Recupera tu contenido
|
|
80
|
+
|
|
81
|
+
### Caso A — Aplicación React (Vite/SPA)
|
|
82
|
+
|
|
83
|
+
Enfoque por defecto: usa `useIntlayer` para recuperar por clave. Esto mantiene los componentes ligeros y tipados.
|
|
84
|
+
|
|
85
|
+
```tsx fileName="ComponentExample.tsx"
|
|
86
|
+
import { useIntlayer } from "react-intlayer";
|
|
87
|
+
|
|
88
|
+
export function ComponentExample() {
|
|
89
|
+
const content = useIntlayer("component-example");
|
|
90
|
+
return (
|
|
91
|
+
<div>
|
|
92
|
+
<h1>{content.title}</h1>
|
|
93
|
+
<p>{content.description}</p>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Renderizado en servidor o fuera del provider: usa `react-intlayer/server` y pasa un `locale` explícito cuando sea necesario.
|
|
100
|
+
|
|
101
|
+
```tsx fileName="ServerRenderedExample.tsx"
|
|
102
|
+
import { useIntlayer } from "react-intlayer/server";
|
|
103
|
+
|
|
104
|
+
export function ServerRenderedExample({ locale }: { locale: string }) {
|
|
105
|
+
const content = useIntlayer("component-example", locale);
|
|
106
|
+
return (
|
|
107
|
+
<>
|
|
108
|
+
<h1>{content.title}</h1>
|
|
109
|
+
<p>{content.description}</p>
|
|
110
|
+
</>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Alternativa: `useDictionary` puede leer un objeto declarado completo si prefieres colocar la estructura en el punto de uso.
|
|
116
|
+
|
|
117
|
+
```tsx fileName="ComponentWithDictionary.tsx"
|
|
118
|
+
import { useDictionary } from "react-intlayer";
|
|
119
|
+
import componentContent from "./component.content";
|
|
120
|
+
|
|
121
|
+
export function ComponentWithDictionary() {
|
|
122
|
+
const { title, description } = useDictionary(componentContent);
|
|
123
|
+
return (
|
|
124
|
+
<div>
|
|
125
|
+
<h1>{title}</h1>
|
|
126
|
+
<p>{description}</p>
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Caso B — Next.js (App Router)
|
|
133
|
+
|
|
134
|
+
Prefiere componentes de servidor por seguridad y rendimiento. Usa `useIntlayer` de `next-intlayer/server` en archivos de servidor, y `useIntlayer` de `next-intlayer` en componentes cliente.
|
|
135
|
+
|
|
136
|
+
```tsx fileName="app/[locale]/example/ServerComponent.tsx"
|
|
137
|
+
import { useIntlayer } from "next-intlayer/server";
|
|
138
|
+
|
|
139
|
+
export default function ServerComponent() {
|
|
140
|
+
const content = useIntlayer("component-example");
|
|
141
|
+
return (
|
|
142
|
+
<>
|
|
143
|
+
<h1>{content.title}</h1>
|
|
144
|
+
<p>{content.description}</p>
|
|
145
|
+
</>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
```tsx fileName="app/[locale]/example/ClientComponent.tsx"
|
|
151
|
+
"use client";
|
|
152
|
+
|
|
153
|
+
import { useIntlayer } from "next-intlayer";
|
|
154
|
+
|
|
155
|
+
export function ClientComponent() {
|
|
156
|
+
const content = useIntlayer("component-example");
|
|
157
|
+
return (
|
|
158
|
+
<div>
|
|
159
|
+
<h1>{content.title}</h1>
|
|
160
|
+
<p>{content.description}</p>
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Consejo: Para metadatos de página y SEO, también puedes obtener contenido con `getIntlayer` y generar URLs multilingües con `getMultilingualUrls`.
|
|
167
|
+
|
|
168
|
+
## Por qué el enfoque de componentes de Intlayer es el mejor
|
|
169
|
+
|
|
170
|
+
- Colocación: Las declaraciones de contenido viven cerca de los componentes, reduciendo la deriva y mejorando la reutilización en los sistemas de diseño.
|
|
171
|
+
- Seguridad de tipos: Las claves y estructuras están fuertemente tipadas; las traducciones faltantes aparecen en tiempo de build en lugar de en tiempo de ejecución.
|
|
172
|
+
- Server-first: Funciona de forma nativa en componentes de servidor para mejor seguridad y rendimiento; los hooks de cliente siguen siendo ergonómicos.
|
|
173
|
+
- Tree-shaking: Solo se incluye el contenido usado por el componente, manteniendo cargas pequeñas en aplicaciones grandes.
|
|
174
|
+
- DX y herramientas: Middleware incorporado, asistentes de SEO y traducciones opcionales mediante Editor Visual/IA agilizan el trabajo diario.
|
|
175
|
+
|
|
176
|
+
## Guías y referencias relacionadas
|
|
177
|
+
|
|
178
|
+
- Configuración React (Vite): https://intlayer.org/doc/environment/vite-and-react
|
|
179
|
+
- React Router v7: https://intlayer.org/doc/environment/vite-and-react/react-router-v7
|
|
180
|
+
- TanStack Start: https://intlayer.org/doc/environment/vite-and-react/tanstack-start
|
|
181
|
+
- Configuración Next.js: https://intlayer.org/doc/environment/nextjs
|
|
182
|
+
- Por qué Intlayer vs. next-intl vs. next-i18next: https://intlayer.org/blog/next-i18next-vs-next-intl-vs-intlayer
|
|
@@ -642,9 +642,9 @@ Para escenarios más complejos, puedes crear un pipe para renderizar el HTML de
|
|
|
642
642
|
|
|
643
643
|
Intlayer utiliza la ampliación de módulos para aprovechar las ventajas de TypeScript y fortalecer tu base de código.
|
|
644
644
|
|
|
645
|
-

|
|
646
646
|
|
|
647
|
-

|
|
648
648
|
|
|
649
649
|
Asegúrate de que tu configuración de TypeScript incluya los tipos autogenerados.
|
|
650
650
|
|