@intlayer/docs 6.1.6-canary.0 → 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/en/next-i18next_vs_next-intl_vs_intlayer.md +71 -80
- package/dist/cjs/generated/docs.entry.cjs +16 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +16 -0
- package/dist/esm/generated/docs.entry.mjs.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/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/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/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 +13 -4
- package/docs/en/intlayer_with_nextjs_15.md +13 -4
- 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-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/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/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/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/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/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/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/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/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/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/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/package.json +11 -11
- package/src/generated/docs.entry.ts +16 -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
|
|
|
@@ -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
|
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2024-03-07
|
|
3
|
+
updatedAt: 2025-10-03
|
|
4
|
+
title: Comenzando con Intlayer en Astro
|
|
5
|
+
description: Aprende cómo agregar internacionalización (i18n) a tu aplicación Vite y React usando Intlayer. Sigue esta guía para hacer tu aplicación multilingüe.
|
|
6
|
+
keywords:
|
|
7
|
+
- Internacionalización
|
|
8
|
+
- Documentación
|
|
9
|
+
- Intlayer
|
|
10
|
+
- Vite
|
|
11
|
+
- React
|
|
12
|
+
- i18n
|
|
13
|
+
- JavaScript
|
|
14
|
+
slugs:
|
|
15
|
+
- doc
|
|
16
|
+
- environment
|
|
17
|
+
- astro
|
|
18
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-astro-template
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# Comenzando con la internacionalización (i18n) usando Intlayer y Astro
|
|
22
|
+
|
|
23
|
+
Consulta el [Plantilla de Aplicación](https://github.com/aymericzip/intlayer-astro-template) en GitHub.
|
|
24
|
+
|
|
25
|
+
## ¿Qué es Intlayer?
|
|
26
|
+
|
|
27
|
+
**Intlayer** es una biblioteca innovadora y de código abierto para internacionalización (i18n) diseñada para simplificar el soporte multilingüe en aplicaciones web modernas.
|
|
28
|
+
|
|
29
|
+
Con Intlayer, puedes:
|
|
30
|
+
|
|
31
|
+
- **Gestionar traducciones fácilmente** usando diccionarios declarativos a nivel de componente.
|
|
32
|
+
- **Localizar dinámicamente metadatos**, rutas y contenido.
|
|
33
|
+
- **Garantizar soporte para TypeScript** con tipos autogenerados, mejorando la autocompletación y la detección de errores.
|
|
34
|
+
- **Beneficiarte de funciones avanzadas**, como la detección y el cambio dinámico de locales.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Guía paso a paso para configurar Intlayer en Astro
|
|
39
|
+
|
|
40
|
+
### Paso 1: Instalar dependencias
|
|
41
|
+
|
|
42
|
+
Instala los paquetes necesarios usando tu gestor de paquetes:
|
|
43
|
+
|
|
44
|
+
```bash packageManager="npm"
|
|
45
|
+
npm install intlayer astro-intlayer
|
|
46
|
+
# Opcional: agregar soporte para React island
|
|
47
|
+
npm install react react-dom react-intlayer @astrojs/react
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```bash packageManager="pnpm"
|
|
51
|
+
pnpm add intlayer astro-intlayer
|
|
52
|
+
# Opcional: añadir soporte para islas React
|
|
53
|
+
pnpm add react react-dom react-intlayer @astrojs/react
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```bash packageManager="yarn"
|
|
57
|
+
yarn add intlayer astro-intlayer
|
|
58
|
+
# Opcional: añadir soporte para islas React
|
|
59
|
+
yarn add react react-dom react-intlayer @astrojs/react
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- **intlayer**
|
|
63
|
+
El paquete principal que proporciona herramientas de internacionalización para la gestión de configuración, traducción, [declaración de contenido](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/dictionary/get_started.md), transpilación y [comandos CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_cli.md).
|
|
64
|
+
|
|
65
|
+
- **astro-intlayer**
|
|
66
|
+
Incluye el plugin de integración de Astro para integrar Intlayer con el [empaquetador Vite](https://vite.dev/guide/why.html#why-bundle-for-production), así como middleware para detectar la configuración regional preferida del usuario, gestionar cookies y manejar la redirección de URL.
|
|
67
|
+
|
|
68
|
+
### Paso 2: Configuración de tu proyecto
|
|
69
|
+
|
|
70
|
+
Crea un archivo de configuración para configurar los idiomas de tu aplicación:
|
|
71
|
+
|
|
72
|
+
```typescript fileName="intlayer.config.ts"
|
|
73
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
74
|
+
|
|
75
|
+
const config: IntlayerConfig = {
|
|
76
|
+
internationalization: {
|
|
77
|
+
locales: [
|
|
78
|
+
Locales.ENGLISH,
|
|
79
|
+
Locales.FRENCH,
|
|
80
|
+
Locales.SPANISH,
|
|
81
|
+
// Tus otros locales
|
|
82
|
+
],
|
|
83
|
+
defaultLocale: Locales.ENGLISH,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default config;
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
> A través de este archivo de configuración, puedes configurar URLs localizadas, redirección mediante middleware, nombres de cookies, la ubicación y extensión de tus declaraciones de contenido, desactivar los registros de Intlayer en la consola y más. Para una lista completa de los parámetros disponibles, consulta la [documentación de configuración](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/configuration.md).
|
|
91
|
+
|
|
92
|
+
### Paso 3: Integra Intlayer en tu configuración de Astro
|
|
93
|
+
|
|
94
|
+
Agrega el plugin intlayer en tu configuración.
|
|
95
|
+
|
|
96
|
+
```typescript fileName="astro.config.ts"
|
|
97
|
+
// @ts-check
|
|
98
|
+
|
|
99
|
+
import { intlayer } from "astro-intlayer";
|
|
100
|
+
import { defineConfig } from "astro/config";
|
|
101
|
+
|
|
102
|
+
// https://astro.build/config
|
|
103
|
+
export default defineConfig({
|
|
104
|
+
integrations: [intlayer()],
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
> El plugin de integración `intlayer()` para Astro se utiliza para integrar Intlayer con Astro. Asegura la construcción de archivos de declaración de contenido y los supervisa en modo de desarrollo. Define variables de entorno de Intlayer dentro de la aplicación Astro. Además, proporciona alias para optimizar el rendimiento.
|
|
109
|
+
|
|
110
|
+
### Paso 4: Declara tu contenido
|
|
111
|
+
|
|
112
|
+
Crea y administra tus declaraciones de contenido para almacenar traducciones:
|
|
113
|
+
|
|
114
|
+
```tsx fileName="src/app.content.tsx"
|
|
115
|
+
import { t, type Dictionary } from "intlayer";
|
|
116
|
+
import type { ReactNode } from "react";
|
|
117
|
+
|
|
118
|
+
const appContent = {
|
|
119
|
+
key: "app",
|
|
120
|
+
content: {
|
|
121
|
+
title: t({
|
|
122
|
+
en: "Hello World",
|
|
123
|
+
fr: "Bonjour le monde",
|
|
124
|
+
es: "Hola mundo",
|
|
125
|
+
}),
|
|
126
|
+
},
|
|
127
|
+
} satisfies Dictionary;
|
|
128
|
+
|
|
129
|
+
export default appContent;
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
> Tus declaraciones de contenido pueden definirse en cualquier parte de tu aplicación siempre que se incluyan en el directorio `contentDir` (por defecto, `./src`). Y coincidan con la extensión de archivo de declaración de contenido (por defecto, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
133
|
+
|
|
134
|
+
> Para más detalles, consulta la [documentación de declaración de contenido](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/dictionary/get_started.md).
|
|
135
|
+
|
|
136
|
+
### Paso 5: Usa tu contenido en Astro
|
|
137
|
+
|
|
138
|
+
Puedes consumir diccionarios directamente en archivos `.astro` usando los helpers principales exportados por `intlayer`.
|
|
139
|
+
|
|
140
|
+
```astro fileName="src/pages/index.astro"
|
|
141
|
+
<!-- astro -->
|
|
142
|
+
---
|
|
143
|
+
import { getIntlayer } from "intlayer";
|
|
144
|
+
import appContent from "../app.content";
|
|
145
|
+
|
|
146
|
+
const { title } = getIntlayer('app');
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
<html lang="en">
|
|
150
|
+
<head>
|
|
151
|
+
<meta charset="utf-8" />
|
|
152
|
+
<meta name="viewport" content="width=device-width" />
|
|
153
|
+
<title>{title}</title>
|
|
154
|
+
</head>
|
|
155
|
+
<body>
|
|
156
|
+
<h1>{title}</h1>
|
|
157
|
+
</body>
|
|
158
|
+
</html>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Paso 6: Enrutamiento localizado
|
|
162
|
+
|
|
163
|
+
Crea un segmento de ruta dinámica para servir páginas localizadas, por ejemplo `src/pages/[locale]/index.astro`:
|
|
164
|
+
|
|
165
|
+
```astro fileName="src/pages/[locale]/index.astro"
|
|
166
|
+
<!-- astro -->
|
|
167
|
+
---
|
|
168
|
+
import { getIntlayer } from "intlayer";
|
|
169
|
+
|
|
170
|
+
const { title } = getIntlayer('app');
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
<h1>{title}</h1>
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
La integración de Astro añade un middleware de Vite durante el desarrollo que ayuda con el enrutamiento consciente del locale y las definiciones de entorno. Aún puedes enlazar entre locales usando tu propia lógica o funciones utilitarias como `getLocalizedUrl` de `intlayer`.
|
|
177
|
+
|
|
178
|
+
### Paso 7: Continúa usando tu framework favorito
|
|
179
|
+
|
|
180
|
+
Continúa usando tu framework favorito para construir tu aplicación.
|
|
181
|
+
|
|
182
|
+
- Intlayer + React: [Intlayer con React](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_with_vite+react.md)
|
|
183
|
+
- Intlayer + Vue: [Intlayer con Vue](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_with_vite+vue.md)
|
|
184
|
+
- Intlayer + Svelte: [Intlayer con Svelte](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_with_vite+svelte.md)
|
|
185
|
+
- Intlayer + Solid: [Intlayer con Solid](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_with_vite+solid.md)
|
|
186
|
+
- Intlayer + Preact: [Intlayer con Preact](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_with_vite+preact.md)
|
|
187
|
+
|
|
188
|
+
### Configurar TypeScript
|
|
189
|
+
|
|
190
|
+
Intlayer utiliza la ampliación de módulos para aprovechar los beneficios de TypeScript y fortalecer tu base de código.
|
|
191
|
+
|
|
192
|
+

|
|
193
|
+
|
|
194
|
+

|
|
195
|
+
|
|
196
|
+
Asegúrate de que tu configuración de TypeScript incluya los tipos autogenerados.
|
|
197
|
+
|
|
198
|
+
```json5 fileName="tsconfig.json"
|
|
199
|
+
{
|
|
200
|
+
// ... Tus configuraciones existentes de TypeScript
|
|
201
|
+
"include": [
|
|
202
|
+
// ... Tus configuraciones existentes de TypeScript
|
|
203
|
+
".intlayer/**/*.ts", // Incluir los tipos autogenerados
|
|
204
|
+
],
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Configuración de Git
|
|
209
|
+
|
|
210
|
+
Se recomienda ignorar los archivos generados por Intlayer. Esto te permite evitar comprometerlos en tu repositorio Git.
|
|
211
|
+
|
|
212
|
+
Para hacer esto, puedes agregar las siguientes instrucciones a tu archivo `.gitignore`:
|
|
213
|
+
|
|
214
|
+
```plaintext
|
|
215
|
+
# Ignorar los archivos generados por Intlayer
|
|
216
|
+
.intlayer
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Extensión de VS Code
|
|
220
|
+
|
|
221
|
+
Para mejorar tu experiencia de desarrollo con Intlayer, puedes instalar la **Extensión oficial de Intlayer para VS Code**.
|
|
222
|
+
|
|
223
|
+
[Instalar desde el Marketplace de VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
224
|
+
|
|
225
|
+
Esta extensión proporciona:
|
|
226
|
+
|
|
227
|
+
- **Autocompletado** para las claves de traducción.
|
|
228
|
+
- **Detección de errores en tiempo real** para traducciones faltantes.
|
|
229
|
+
- **Vistas previas en línea** del contenido traducido.
|
|
230
|
+
- **Acciones rápidas** para crear y actualizar traducciones fácilmente.
|
|
231
|
+
|
|
232
|
+
Para más detalles sobre cómo usar la extensión, consulta la [documentación de la Extensión de Intlayer para VS Code](https://intlayer.org/doc/vs-code-extension).
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
### Ir Más Allá
|
|
237
|
+
|
|
238
|
+
Para ir más allá, puedes implementar el [editor visual](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_visual_editor.md) o externalizar tu contenido usando el [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_CMS.md).
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Historial del Documento
|
|
243
|
+
|
|
244
|
+
| Versión | Fecha | Cambios |
|
|
245
|
+
| ------- | ---------- | ------------------------------------------------------------ |
|
|
246
|
+
| 6.2.0 | 2025-10-03 | Actualización para integración con Astro, configuración, uso |
|
|
@@ -1159,9 +1159,10 @@ Al aplicar estos cambios, tu aplicación:
|
|
|
1159
1159
|
|
|
1160
1160
|
Intlayer utiliza la ampliación de módulos para obtener beneficios de TypeScript y fortalecer tu base de código.
|
|
1161
1161
|
|
|
1162
|
-

|
|
1163
|
+
|
|
1164
|
+

|
|
1163
1165
|
|
|
1164
|
-

|
|
1165
1166
|
Asegúrate de que tu configuración de TypeScript incluya los tipos autogenerados.
|
|
1166
1167
|
|
|
1167
1168
|
```json5 fileName="tsconfig.json"
|
|
@@ -393,9 +393,9 @@ Por defecto, `express-intlayer` interpretará la cabecera `Accept-Language` para
|
|
|
393
393
|
|
|
394
394
|
`express-intlayer` aprovecha las robustas capacidades de TypeScript para mejorar el proceso de internacionalización. El tipado estático de TypeScript garantiza que cada clave de traducción esté contemplada, reduciendo el riesgo de traducciones faltantes y mejorando el mantenimiento.
|
|
395
395
|
|
|
396
|
-

|
|
397
397
|
|
|
398
|
-

|
|
399
399
|
|
|
400
400
|
Asegúrate de que los tipos autogenerados (por defecto en ./types/intlayer.d.ts) estén incluidos en tu archivo tsconfig.json.
|
|
401
401
|
|
|
@@ -1451,9 +1451,9 @@ yarn add @intlayer/swc --save-dev
|
|
|
1451
1451
|
|
|
1452
1452
|
Intlayer utiliza la ampliación de módulos para aprovechar las ventajas de TypeScript y fortalecer tu base de código.
|
|
1453
1453
|
|
|
1454
|
-

|
|
1455
1455
|
|
|
1456
|
-

|
|
1457
1457
|
|
|
1458
1458
|
Asegúrate de que tu configuración de TypeScript incluya los tipos generados automáticamente.
|
|
1459
1459
|
|
|
@@ -1456,9 +1456,9 @@ yarn add @intlayer/swc --save-dev
|
|
|
1456
1456
|
|
|
1457
1457
|
Intlayer utiliza la ampliación de módulos para aprovechar las ventajas de TypeScript y fortalecer tu base de código.
|
|
1458
1458
|
|
|
1459
|
-

|
|
1460
1460
|
|
|
1461
|
-

|
|
1462
1462
|
|
|
1463
1463
|
Asegúrate de que tu configuración de TypeScript incluya los tipos autogenerados.
|
|
1464
1464
|
|
|
@@ -148,28 +148,25 @@ module.exports = (async () => {
|
|
|
148
148
|
|
|
149
149
|
## Paso 4: Añadir el proveedor de Intlayer
|
|
150
150
|
|
|
151
|
-
Para mantener sincronizado el idioma del usuario en toda tu aplicación, necesitas envolver tu componente raíz con el componente `IntlayerProvider` de `react-intlayer`.
|
|
151
|
+
Para mantener sincronizado el idioma del usuario en toda tu aplicación, necesitas envolver tu componente raíz con el componente `IntlayerProvider` de `react-intlayer-native`.
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
> Asegúrate de usar el proveedor de `react-native-intlayer` en lugar de `react-intlayer`. La exportación de `react-native-intlayer` incluye polyfills para la API web.
|
|
154
154
|
|
|
155
155
|
```tsx fileName="app/_layout.tsx" codeFormat="typescript"
|
|
156
156
|
import { Stack } from "expo-router";
|
|
157
157
|
import { getLocales } from "expo-localization";
|
|
158
|
-
import {
|
|
159
|
-
import { intlayerPolyfill } from "react-native-intlayer";
|
|
158
|
+
import { IntlayerProvider } from "react-native-intlayer";
|
|
160
159
|
import { type FC } from "react";
|
|
161
160
|
|
|
162
|
-
intlayerPolyfill();
|
|
163
|
-
|
|
164
161
|
const getDeviceLocale = () => getLocales()[0]?.languageTag;
|
|
165
162
|
|
|
166
163
|
const RootLayout: FC = () => {
|
|
167
164
|
return (
|
|
168
|
-
<
|
|
165
|
+
<IntlayerProvider defaultLocale={getDeviceLocale()}>
|
|
169
166
|
<Stack>
|
|
170
167
|
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
|
171
168
|
</Stack>
|
|
172
|
-
</
|
|
169
|
+
</IntlayerProvider>
|
|
173
170
|
);
|
|
174
171
|
};
|
|
175
172
|
|
|
@@ -179,20 +176,17 @@ export default RootLayout;
|
|
|
179
176
|
```jsx fileName="app/_layout.mjx" codeFormat="esm"
|
|
180
177
|
import { Stack } from "expo-router";
|
|
181
178
|
import { getLocales } from "expo-localization";
|
|
182
|
-
import {
|
|
183
|
-
import { intlayerPolyfill } from "react-native-intlayer";
|
|
184
|
-
|
|
185
|
-
intlayerPolyfill();
|
|
179
|
+
import { IntlayerProvider } from "react-native-intlayer";
|
|
186
180
|
|
|
187
181
|
const getDeviceLocale = () => getLocales()[0]?.languageTag;
|
|
188
182
|
|
|
189
183
|
const RootLayout = () => {
|
|
190
184
|
return (
|
|
191
|
-
<
|
|
185
|
+
<IntlayerProvider defaultLocale={getDeviceLocale()}>
|
|
192
186
|
<Stack>
|
|
193
187
|
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
|
194
188
|
</Stack>
|
|
195
|
-
</
|
|
189
|
+
</IntlayerProvider>
|
|
196
190
|
);
|
|
197
191
|
};
|
|
198
192
|
|
|
@@ -202,21 +196,18 @@ export default RootLayout;
|
|
|
202
196
|
```jsx fileName="app/_layout.cjx" codeFormat="commonjs"
|
|
203
197
|
const { Stack } = require("expo-router");
|
|
204
198
|
const { getLocales } = require("expo-localization");
|
|
205
|
-
const {
|
|
206
|
-
const { intlayerPolyfill } = require("react-native-intlayer");
|
|
207
|
-
|
|
208
|
-
intlayerPolyfill();
|
|
199
|
+
const { IntlayerProvider } = require("react-native-intlayer");
|
|
209
200
|
|
|
210
201
|
// Obtiene la configuración regional del dispositivo
|
|
211
202
|
const getDeviceLocale = () => getLocales()[0]?.languageTag;
|
|
212
203
|
|
|
213
204
|
const RootLayout = () => {
|
|
214
205
|
return (
|
|
215
|
-
<
|
|
206
|
+
<IntlayerProvider defaultLocale={getDeviceLocale()}>
|
|
216
207
|
<Stack>
|
|
217
208
|
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
|
218
209
|
</Stack>
|
|
219
|
-
</
|
|
210
|
+
</IntlayerProvider>
|
|
220
211
|
);
|
|
221
212
|
};
|
|
222
213
|
|