@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2025-09-09
|
|
3
3
|
updatedAt: 2025-09-09
|
|
4
4
|
title: Comenzando con Intlayer en Tanstack Start
|
|
5
|
-
description: Aprende cómo agregar internacionalización (i18n) a tu aplicación Tanstack Start usando Intlayer. Sigue esta guía completa para hacer tu aplicación multilingüe con enrutamiento consciente
|
|
5
|
+
description: Aprende cómo agregar internacionalización (i18n) a tu aplicación Tanstack Start usando Intlayer. Sigue esta guía completa para hacer que tu aplicación sea multilingüe con enrutamiento consciente de la configuración regional.
|
|
6
6
|
keywords:
|
|
7
7
|
- Internacionalización
|
|
8
8
|
- Documentación
|
|
@@ -11,19 +11,17 @@ keywords:
|
|
|
11
11
|
- React
|
|
12
12
|
- i18n
|
|
13
13
|
- TypeScript
|
|
14
|
-
- Enrutamiento por
|
|
14
|
+
- Enrutamiento por Configuración Regional
|
|
15
15
|
slugs:
|
|
16
16
|
- doc
|
|
17
17
|
- environment
|
|
18
|
-
- vite-and-react
|
|
19
18
|
- tanstack-start
|
|
20
|
-
applicationTemplate: https://github.com/
|
|
21
|
-
author: AydinTheFirst
|
|
19
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-tanstack-start-template
|
|
22
20
|
---
|
|
23
21
|
|
|
24
22
|
# Comenzando con la Internacionalización (i18n) usando Intlayer y Tanstack Start
|
|
25
23
|
|
|
26
|
-
Esta guía demuestra cómo integrar **Intlayer** para una internacionalización fluida en proyectos Tanstack Start con enrutamiento consciente
|
|
24
|
+
Esta guía demuestra cómo integrar **Intlayer** para una internacionalización fluida en proyectos Tanstack Start con enrutamiento consciente de la configuración regional, soporte para TypeScript y prácticas modernas de desarrollo.
|
|
27
25
|
|
|
28
26
|
## ¿Qué es Intlayer?
|
|
29
27
|
|
|
@@ -34,18 +32,18 @@ Con Intlayer, puedes:
|
|
|
34
32
|
- **Gestionar traducciones fácilmente** usando diccionarios declarativos a nivel de componente.
|
|
35
33
|
- **Localizar dinámicamente metadatos**, rutas y contenido.
|
|
36
34
|
- **Garantizar soporte para TypeScript** con tipos autogenerados, mejorando la autocompletación y la detección de errores.
|
|
37
|
-
- **Beneficiarte de características avanzadas**, como la detección y cambio dinámico de
|
|
38
|
-
- **Habilitar enrutamiento consciente
|
|
35
|
+
- **Beneficiarte de características avanzadas**, como la detección y el cambio dinámico de configuración regional.
|
|
36
|
+
- **Habilitar enrutamiento consciente de la configuración regional** con el sistema de enrutamiento basado en archivos de Tanstack Start.
|
|
39
37
|
|
|
40
38
|
---
|
|
41
39
|
|
|
42
40
|
## Guía paso a paso para configurar Intlayer en una aplicación Tanstack Start
|
|
43
41
|
|
|
44
|
-
### Paso 1: Crear
|
|
42
|
+
### Paso 1: Crear proyecto
|
|
45
43
|
|
|
46
44
|
Comienza creando un nuevo proyecto TanStack Start siguiendo la guía [Start new project](https://tanstack.com/start/latest/docs/framework/react/quick-start) en el sitio web de TanStack Start.
|
|
47
45
|
|
|
48
|
-
### Paso 2: Instalar
|
|
46
|
+
### Paso 2: Instalar paquetes de Intlayer
|
|
49
47
|
|
|
50
48
|
Instala los paquetes necesarios usando tu gestor de paquetes preferido:
|
|
51
49
|
|
|
@@ -63,19 +61,19 @@ pnpm add vite-intlayer --save-dev
|
|
|
63
61
|
|
|
64
62
|
- **intlayer**
|
|
65
63
|
|
|
66
|
-
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),
|
|
64
|
+
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), transpileación y [comandos CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/intlayer_cli.md).
|
|
67
65
|
|
|
68
66
|
- **react-intlayer**
|
|
69
67
|
El paquete que integra Intlayer con aplicaciones React. Proporciona proveedores de contexto y hooks para la internacionalización en React.
|
|
70
68
|
|
|
71
69
|
- **vite-intlayer**
|
|
72
|
-
Incluye el plugin de Vite para integrar Intlayer con el [empaquetador Vite](https://vite.dev/guide/why.html#why-bundle-for-production), así como middleware para detectar
|
|
70
|
+
Incluye el plugin de Vite 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 redirecciones de URL.
|
|
73
71
|
|
|
74
72
|
### Paso 3: Configuración de tu proyecto
|
|
75
73
|
|
|
76
|
-
|
|
74
|
+
Cree un archivo de configuración para configurar los idiomas de su aplicación:
|
|
77
75
|
|
|
78
|
-
```typescript fileName="intlayer.config.ts"
|
|
76
|
+
```typescript fileName="intlayer.config.ts"
|
|
79
77
|
import type { IntlayerConfig } from "intlayer";
|
|
80
78
|
|
|
81
79
|
import { Locales } from "intlayer";
|
|
@@ -83,90 +81,40 @@ import { Locales } from "intlayer";
|
|
|
83
81
|
const config: IntlayerConfig = {
|
|
84
82
|
internationalization: {
|
|
85
83
|
defaultLocale: Locales.ENGLISH,
|
|
86
|
-
locales: [
|
|
87
|
-
Locales.ENGLISH,
|
|
88
|
-
Locales.FRENCH,
|
|
89
|
-
Locales.SPANISH,
|
|
90
|
-
// Tus otros idiomas
|
|
91
|
-
],
|
|
84
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
92
85
|
},
|
|
93
86
|
};
|
|
94
87
|
|
|
95
88
|
export default config;
|
|
96
89
|
```
|
|
97
90
|
|
|
98
|
-
|
|
99
|
-
import { Locales } from "intlayer";
|
|
100
|
-
|
|
101
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
102
|
-
const config = {
|
|
103
|
-
internationalization: {
|
|
104
|
-
defaultLocale: Locales.ENGLISH,
|
|
105
|
-
locales: [
|
|
106
|
-
Locales.ENGLISH,
|
|
107
|
-
Locales.FRENCH,
|
|
108
|
-
Locales.SPANISH,
|
|
109
|
-
// Tus otros idiomas
|
|
110
|
-
],
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export default config;
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
118
|
-
const { Locales } = require("intlayer");
|
|
119
|
-
|
|
120
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
121
|
-
const config = {
|
|
122
|
-
internationalization: {
|
|
123
|
-
defaultLocale: Locales.ENGLISH,
|
|
124
|
-
locales: [
|
|
125
|
-
Locales.ENGLISH,
|
|
126
|
-
Locales.FRENCH,
|
|
127
|
-
Locales.SPANISH,
|
|
128
|
-
// Tus otros idiomas
|
|
129
|
-
],
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
module.exports = config;
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
> A través de este archivo de configuración, puedes configurar URLs localizadas, redirección de 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
|
+
> A través de este archivo de configuración, puede configurar URLs localizadas, redirección mediante middleware, nombres de cookies, la ubicación y extensión de sus declaraciones de contenido, desactivar los registros de Intlayer en la consola y más. Para una lista completa de los parámetros disponibles, consulte la [documentación de configuración](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/configuration.md).
|
|
137
92
|
|
|
138
93
|
### Paso 4: Integra Intlayer en tu configuración de Vite
|
|
139
94
|
|
|
140
95
|
Agrega el plugin intlayer en tu configuración:
|
|
141
96
|
|
|
142
|
-
```typescript fileName="vite.config.ts"
|
|
97
|
+
```typescript fileName="vite.config.ts"
|
|
143
98
|
import { reactRouter } from "@react-router/dev/vite";
|
|
144
99
|
import { defineConfig } from "vite";
|
|
145
|
-
import {
|
|
100
|
+
import { intlayer } from "vite-intlayer";
|
|
146
101
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
147
102
|
|
|
148
103
|
export default defineConfig({
|
|
149
|
-
plugins: [
|
|
150
|
-
reactRouter(),
|
|
151
|
-
tsconfigPaths(),
|
|
152
|
-
intlayer(),
|
|
153
|
-
intlayerMiddlewarePlugin(),
|
|
154
|
-
],
|
|
104
|
+
plugins: [reactRouter(), tsconfigPaths(), intlayer()],
|
|
155
105
|
});
|
|
156
106
|
```
|
|
157
107
|
|
|
158
|
-
> El plugin `intlayer()`
|
|
108
|
+
> El plugin `intlayer()` para Vite se utiliza para integrar Intlayer con Vite. Asegura la construcción de los archivos de declaración de contenido y los monitorea en modo desarrollo. Define variables de entorno de Intlayer dentro de la aplicación Vite. Además, proporciona alias para optimizar el rendimiento.
|
|
159
109
|
|
|
160
|
-
### Paso 5: Crear Componentes de
|
|
110
|
+
### Paso 5: Crear Componentes de Diseño
|
|
161
111
|
|
|
162
|
-
Configura tu
|
|
112
|
+
Configura tu diseño raíz y los diseños específicos por localización:
|
|
163
113
|
|
|
164
|
-
####
|
|
114
|
+
#### Diseño Raíz
|
|
165
115
|
|
|
166
|
-
```tsx fileName="src/routes/{-$locale}/route.tsx"
|
|
167
|
-
// src/routes/{-$locale}/route.tsx
|
|
116
|
+
```tsx fileName="src/routes/{-$locale}/route.tsx"
|
|
168
117
|
import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router";
|
|
169
|
-
import { configuration } from "intlayer";
|
|
170
118
|
import { IntlayerProvider, useLocale } from "react-intlayer";
|
|
171
119
|
|
|
172
120
|
import { useI18nHTMLAttributes } from "@/hooks/useI18nHTMLAttributes";
|
|
@@ -176,10 +124,11 @@ export const Route = createFileRoute("/{-$locale}")({
|
|
|
176
124
|
});
|
|
177
125
|
|
|
178
126
|
function LayoutComponent() {
|
|
127
|
+
const { defaultLocale } = useLocale();
|
|
179
128
|
const { locale } = Route.useParams();
|
|
180
129
|
|
|
181
130
|
return (
|
|
182
|
-
<IntlayerProvider locale={
|
|
131
|
+
<IntlayerProvider locale={defaultLocale}>
|
|
183
132
|
<Outlet />
|
|
184
133
|
</IntlayerProvider>
|
|
185
134
|
);
|
|
@@ -188,9 +137,9 @@ function LayoutComponent() {
|
|
|
188
137
|
|
|
189
138
|
### Paso 6: Declara Tu Contenido
|
|
190
139
|
|
|
191
|
-
Crea y
|
|
140
|
+
Crea y administra tus declaraciones de contenido para almacenar traducciones:
|
|
192
141
|
|
|
193
|
-
```tsx fileName="src/contents/page.content.ts"
|
|
142
|
+
```tsx fileName="src/contents/page.content.ts"
|
|
194
143
|
import type { Dictionary } from "intlayer";
|
|
195
144
|
|
|
196
145
|
import { t } from "intlayer";
|
|
@@ -204,20 +153,20 @@ const appContent = {
|
|
|
204
153
|
fr: "À propos",
|
|
205
154
|
}),
|
|
206
155
|
home: t({
|
|
207
|
-
en: "
|
|
156
|
+
en: "Home",
|
|
208
157
|
es: "Inicio",
|
|
209
158
|
fr: "Accueil",
|
|
210
159
|
}),
|
|
211
160
|
},
|
|
212
161
|
meta: {
|
|
213
162
|
description: t({
|
|
214
|
-
en: "
|
|
163
|
+
en: "This is an example of using Intlayer with TanStack Router",
|
|
215
164
|
es: "Este es un ejemplo de uso de Intlayer con TanStack Router",
|
|
216
165
|
fr: "Ceci est un exemple d'utilisation d'Intlayer avec TanStack Router",
|
|
217
166
|
}),
|
|
218
167
|
},
|
|
219
168
|
title: t({
|
|
220
|
-
en: "
|
|
169
|
+
en: "Welcome to Intlayer + TanStack Router",
|
|
221
170
|
es: "Bienvenido a Intlayer + TanStack Router",
|
|
222
171
|
fr: "Bienvenue à Intlayer + TanStack Router",
|
|
223
172
|
}),
|
|
@@ -225,101 +174,133 @@ const appContent = {
|
|
|
225
174
|
key: "app",
|
|
226
175
|
} satisfies Dictionary;
|
|
227
176
|
|
|
177
|
+
export default appContent;
|
|
178
|
+
fr: "Bienvenue à Intlayer + TanStack Router",
|
|
179
|
+
}),
|
|
180
|
+
},
|
|
181
|
+
key: "app",
|
|
182
|
+
} satisfies Dictionary;
|
|
183
|
+
|
|
228
184
|
export default appContent;
|
|
229
185
|
```
|
|
230
186
|
|
|
231
|
-
> Tus declaraciones de contenido pueden definirse en cualquier parte de tu aplicación tan pronto como se incluyan en el directorio `contentDir` (por defecto, `./app`). Y deben coincidir con la extensión
|
|
187
|
+
> Tus declaraciones de contenido pueden definirse en cualquier parte de tu aplicación tan pronto como se incluyan en el directorio `contentDir` (por defecto, `./app`). Y deben coincidir con la extensión de archivo de declaración de contenido (por defecto, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
232
188
|
|
|
233
189
|
> 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).
|
|
234
190
|
|
|
235
191
|
### Paso 7: Crear Componentes y Hooks Sensibles al Idioma
|
|
236
192
|
|
|
237
|
-
Crea un componente `LocalizedLink` para navegación sensible al idioma:
|
|
193
|
+
Crea un componente `LocalizedLink` para la navegación sensible al idioma:
|
|
238
194
|
|
|
239
|
-
```tsx fileName="src/components/localized-link.tsx"
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
import { Link, type
|
|
243
|
-
import {
|
|
244
|
-
|
|
195
|
+
```tsx fileName="src/components/localized-link.tsx"
|
|
196
|
+
import type { FC } from "react";
|
|
197
|
+
|
|
198
|
+
import { Link, type LinkComponentProps } from "@tanstack/react-router";
|
|
199
|
+
import { useLocale } from "react.intlayer";
|
|
200
|
+
|
|
201
|
+
export const LOCALE_ROUTE = "{-$locale}" as const;
|
|
202
|
+
|
|
203
|
+
// Utilidad principal
|
|
204
|
+
export type RemoveLocaleParam<T> = T extends string
|
|
205
|
+
? RemoveLocaleFromString<T>
|
|
206
|
+
: T;
|
|
207
|
+
|
|
208
|
+
export type To = RemoveLocaleParam<LinkComponentProps["to"]>;
|
|
209
|
+
|
|
210
|
+
type CollapseDoubleSlashes<S extends string> =
|
|
211
|
+
S extends `${infer H}//${infer T}` ? CollapseDoubleSlashes<`${H}/${T}`> : S;
|
|
245
212
|
|
|
246
213
|
type LocalizedLinkProps = {
|
|
247
|
-
to
|
|
248
|
-
} & Omit<
|
|
214
|
+
to?: To;
|
|
215
|
+
} & Omit<LinkComponentProps, "to">;
|
|
249
216
|
|
|
250
|
-
|
|
251
|
-
|
|
217
|
+
// Ayudantes
|
|
218
|
+
type RemoveAll<
|
|
219
|
+
S extends string,
|
|
220
|
+
Sub extends string,
|
|
221
|
+
> = S extends `${infer H}${Sub}${infer T}` ? RemoveAll<`${H}${T}`, Sub> : S;
|
|
252
222
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
223
|
+
type RemoveLocaleFromString<S extends string> = CollapseDoubleSlashes<
|
|
224
|
+
RemoveAll<S, typeof LOCALE_ROUTE>
|
|
225
|
+
>;
|
|
256
226
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
: getLocalizedUrl(props.to, locale);
|
|
227
|
+
export const LocalizedLink: FC<LocalizedLinkProps> = (props) => {
|
|
228
|
+
const { locale } = useLocale();
|
|
260
229
|
|
|
261
|
-
return
|
|
262
|
-
|
|
230
|
+
return (
|
|
231
|
+
<Link
|
|
232
|
+
{...props}
|
|
233
|
+
params={{
|
|
234
|
+
locale,
|
|
235
|
+
...(typeof props?.params === "object" ? props?.params : {}),
|
|
236
|
+
}}
|
|
237
|
+
to={`/${LOCALE_ROUTE}${props.to}` as LinkComponentProps["to"]}
|
|
238
|
+
/>
|
|
239
|
+
);
|
|
240
|
+
};
|
|
263
241
|
```
|
|
264
242
|
|
|
265
|
-
|
|
243
|
+
Este componente tiene dos objetivos:
|
|
266
244
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
// eslint-disable-next-line no-restricted-imports
|
|
270
|
-
import { NavigateOptions, useNavigate } from "@tanstack/react-router";
|
|
271
|
-
import { getLocalizedUrl } from "intlayer";
|
|
272
|
-
import { useLocale } from "react-intlayer";
|
|
245
|
+
- Eliminar el prefijo `{-$locale}` innecesario de la URL.
|
|
246
|
+
- Inyectar el parámetro de localización en la URL para asegurar que el usuario sea redirigido directamente a la ruta localizada.
|
|
273
247
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
248
|
+
Luego podemos crear un hook `useLocalizedNavigate` para la navegación programática:
|
|
249
|
+
|
|
250
|
+
```tsx fileName="src/hooks/useLocalizedNavigate.tsx"
|
|
251
|
+
import { useLocale } from "react.intlayer";
|
|
252
|
+
import { useNavigate } from "@tanstack/react-router";
|
|
253
|
+
import { LOCALE_ROUTE } from "@/components/localized-link";
|
|
254
|
+
import type { FileRouteTypes } from "@/routeTree.gen";
|
|
277
255
|
|
|
278
256
|
export const useLocalizedNavigate = () => {
|
|
279
257
|
const navigate = useNavigate();
|
|
258
|
+
|
|
280
259
|
const { locale } = useLocale();
|
|
281
260
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
261
|
+
type StripLocalePrefix<T extends string> = T extends
|
|
262
|
+
| `/${typeof LOCALE_ROUTE}`
|
|
263
|
+
| `/${typeof LOCALE_ROUTE}/`
|
|
264
|
+
? "/"
|
|
265
|
+
: T extends `/${typeof LOCALE_ROUTE}/${infer Rest}`
|
|
266
|
+
? `/${Rest}`
|
|
267
|
+
: never;
|
|
268
|
+
|
|
269
|
+
type LocalizedTo = StripLocalePrefix<FileRouteTypes["to"]>;
|
|
270
|
+
|
|
271
|
+
interface LocalizedNavigate {
|
|
272
|
+
(to: LocalizedTo): ReturnType<typeof navigate>;
|
|
273
|
+
(
|
|
274
|
+
opts: { to: LocalizedTo } & Record<string, unknown>
|
|
275
|
+
): ReturnType<typeof navigate>;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const localizedNavigate: LocalizedNavigate = (args: any) => {
|
|
279
|
+
if (typeof args === "string") {
|
|
280
|
+
return navigate({ to: `/${LOCALE_ROUTE}${args}`, params: { locale } });
|
|
281
|
+
}
|
|
286
282
|
|
|
287
|
-
|
|
288
|
-
const to = isExternal(options.to)
|
|
289
|
-
? options.to
|
|
290
|
-
: getLocalizedUrl(options.to, locale);
|
|
283
|
+
const { to, ...rest } = args;
|
|
291
284
|
|
|
292
|
-
|
|
285
|
+
const localedTo = `/${LOCALE_ROUTE}${to}` as any;
|
|
286
|
+
|
|
287
|
+
return navigate({ to: localedTo, params: { locale, ...rest } as any });
|
|
293
288
|
};
|
|
294
289
|
|
|
295
290
|
return localizedNavigate;
|
|
296
291
|
};
|
|
297
292
|
```
|
|
298
293
|
|
|
299
|
-
### Paso 8: Utiliza Intlayer en
|
|
300
|
-
|
|
301
|
-
Accede a tus diccionarios de contenido en toda tu aplicación:
|
|
294
|
+
### Paso 8: Utiliza Intlayer en Tus Páginas
|
|
302
295
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
```tsx fileName="src/routes/page.tsx" codeFormat="typescript"
|
|
306
|
-
// src/routes/page.tsx
|
|
307
|
-
import { useLocale } from "react-intlayer";
|
|
308
|
-
import { Navigate } from "react-router";
|
|
309
|
-
|
|
310
|
-
export default function Page() {
|
|
311
|
-
const { locale } = useLocale();
|
|
312
|
-
|
|
313
|
-
return <Navigate replace to={locale} />;
|
|
314
|
-
}
|
|
315
|
-
```
|
|
296
|
+
Accede a tus diccionarios de contenido a lo largo de toda tu aplicación:
|
|
316
297
|
|
|
317
298
|
#### Página de Inicio Localizada
|
|
318
299
|
|
|
319
|
-
```tsx fileName="src/routes/{-$locale}/index.tsx"
|
|
300
|
+
```tsx fileName="src/routes/{-$locale}/index.tsx"
|
|
320
301
|
import { createFileRoute } from "@tanstack/react-router";
|
|
321
302
|
import { getIntlayer } from "intlayer";
|
|
322
|
-
import { useIntlayer } from "react
|
|
303
|
+
import { useIntlayer } from "react.intlayer";
|
|
323
304
|
|
|
324
305
|
import LocaleSwitcher from "@/components/locale-switcher";
|
|
325
306
|
import { LocalizedLink } from "@/components/localized-link";
|
|
@@ -345,16 +326,15 @@ function RouteComponent() {
|
|
|
345
326
|
const navigate = useLocalizedNavigate();
|
|
346
327
|
|
|
347
328
|
return (
|
|
348
|
-
<div
|
|
349
|
-
<div
|
|
329
|
+
<div>
|
|
330
|
+
<div>
|
|
350
331
|
{content.title}
|
|
351
332
|
<LocaleSwitcher />
|
|
352
|
-
<div
|
|
353
|
-
<a href="/">Índice</a>
|
|
333
|
+
<div>
|
|
354
334
|
<LocalizedLink to="/">{content.links.home}</LocalizedLink>
|
|
355
335
|
<LocalizedLink to="/about">{content.links.about}</LocalizedLink>
|
|
356
336
|
</div>
|
|
357
|
-
<div
|
|
337
|
+
<div>
|
|
358
338
|
<button onClick={() => navigate({ to: "/" })}>
|
|
359
339
|
{content.links.home}
|
|
360
340
|
</button>
|
|
@@ -370,61 +350,69 @@ function RouteComponent() {
|
|
|
370
350
|
|
|
371
351
|
> Para aprender más sobre el hook `useIntlayer`, consulta la [documentación](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/packages/react-intlayer/useIntlayer.md).
|
|
372
352
|
|
|
373
|
-
### Paso 9: Crear un Componente
|
|
353
|
+
### Paso 9: Crear un Componente Selector de Idioma
|
|
374
354
|
|
|
375
355
|
Crea un componente para permitir a los usuarios cambiar de idioma:
|
|
376
356
|
|
|
377
|
-
```tsx fileName="src/components/locale-switcher.tsx"
|
|
357
|
+
```tsx fileName="src/components/locale-switcher.tsx"
|
|
358
|
+
import type { FC } from "react";
|
|
359
|
+
|
|
378
360
|
import { useLocation } from "@tanstack/react-router";
|
|
379
|
-
import {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
const {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
const { availableLocales, locale, setLocale } = useLocale({
|
|
392
|
-
onLocaleChange: (newLocale) => {
|
|
393
|
-
const pathWithLocale = getLocalizedUrl(pathname + searchStr, newLocale);
|
|
394
|
-
location.replace(pathWithLocale);
|
|
395
|
-
},
|
|
396
|
-
});
|
|
361
|
+
import { getHTMLTextDir, getLocaleName, getPathWithoutLocale } from "intlayer";
|
|
362
|
+
import { setLocaleCookie, useIntlayer, useLocale } from "react-intlayer";
|
|
363
|
+
|
|
364
|
+
import { LocalizedLink, To } from "./localized-link";
|
|
365
|
+
|
|
366
|
+
export const LocaleSwitcher: FC = () => {
|
|
367
|
+
const { localeSwitcherLabel } = useIntlayer("locale-switcher");
|
|
368
|
+
const { pathname } = useLocation();
|
|
369
|
+
|
|
370
|
+
const { availableLocales, locale } = useLocale();
|
|
371
|
+
|
|
372
|
+
const pathWithoutLocale = getPathWithoutLocale(pathname);
|
|
397
373
|
|
|
398
374
|
return (
|
|
399
|
-
<
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
375
|
+
<ol>
|
|
376
|
+
{availableLocales.map((localeEl) => (
|
|
377
|
+
<li key={localeEl}>
|
|
378
|
+
<LocalizedLink
|
|
379
|
+
aria-current={localeEl === locale ? "page" : undefined}
|
|
380
|
+
aria-label={`${localeSwitcherLabel.value} ${getLocaleName(localeEl)}`}
|
|
381
|
+
onClick={() => setLocaleCookie(localeEl)}
|
|
382
|
+
params={{ locale: localeEl }}
|
|
383
|
+
to={pathWithoutLocale as To}
|
|
384
|
+
>
|
|
385
|
+
<span>
|
|
386
|
+
{/* Localización - por ejemplo FR */}
|
|
387
|
+
{localeItem}
|
|
388
|
+
</span>
|
|
389
|
+
<span>
|
|
390
|
+
{/* Idioma en su propia localización - por ejemplo Français */}
|
|
391
|
+
{getLocaleName(localeItem, locale)}
|
|
392
|
+
</span>
|
|
393
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
394
|
+
{/* Idioma en la localización actual - por ejemplo Francés con la localización actual configurada en Locales.SPANISH */}
|
|
395
|
+
{getLocaleName(localeItem)}
|
|
396
|
+
</span>
|
|
397
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
398
|
+
{/* Idioma en inglés - por ejemplo French */}
|
|
399
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
400
|
+
</span>
|
|
401
|
+
</LocalizedLink>
|
|
402
|
+
</li>
|
|
415
403
|
))}
|
|
416
|
-
</
|
|
404
|
+
</ol>
|
|
417
405
|
);
|
|
418
|
-
}
|
|
406
|
+
};
|
|
419
407
|
```
|
|
420
408
|
|
|
421
409
|
> Para aprender más sobre el hook `useLocale`, consulta la [documentación](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/packages/react-intlayer/useLocale.md).
|
|
422
410
|
|
|
423
411
|
### Paso 10: Añadir gestión de atributos HTML (Opcional)
|
|
424
412
|
|
|
425
|
-
Crea un hook para gestionar los atributos lang y dir
|
|
413
|
+
Crea un hook para gestionar los atributos lang y dir del HTML:
|
|
426
414
|
|
|
427
|
-
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx"
|
|
415
|
+
```tsx fileName="src/hooks/useI18nHTMLAttributes.tsx"
|
|
428
416
|
// src/hooks/useI18nHTMLAttributes.tsx
|
|
429
417
|
import { getHTMLTextDir } from "intlayer";
|
|
430
418
|
import { useEffect } from "react";
|
|
@@ -442,9 +430,8 @@ export const useI18nHTMLAttributes = () => {
|
|
|
442
430
|
|
|
443
431
|
Luego úsalo en tu componente raíz:
|
|
444
432
|
|
|
445
|
-
```tsx fileName="src/routes/{-$locale}/index.tsx"
|
|
433
|
+
```tsx fileName="src/routes/{-$locale}/index.tsx"
|
|
446
434
|
import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router";
|
|
447
|
-
import { configuration } from "intlayer";
|
|
448
435
|
import { IntlayerProvider, useLocale } from "react-intlayer";
|
|
449
436
|
|
|
450
437
|
import { useI18nHTMLAttributes } from "@/hooks/useI18nHTMLAttributes"; // importar el hook
|
|
@@ -456,43 +443,44 @@ export const Route = createFileRoute("/{-$locale}")({
|
|
|
456
443
|
function LayoutComponent() {
|
|
457
444
|
useI18nHTMLAttributes(); // agregar esta línea
|
|
458
445
|
|
|
446
|
+
const { defaultLocale } = useLocale();
|
|
459
447
|
const { locale } = Route.useParams();
|
|
460
448
|
|
|
461
449
|
return (
|
|
462
|
-
<IntlayerProvider locale={locale}>
|
|
450
|
+
<IntlayerProvider locale={locale ?? defaultLocale}>
|
|
463
451
|
<Outlet />
|
|
464
452
|
</IntlayerProvider>
|
|
465
453
|
);
|
|
466
454
|
}
|
|
467
455
|
```
|
|
468
456
|
|
|
469
|
-
|
|
457
|
+
---
|
|
470
458
|
|
|
471
|
-
|
|
459
|
+
### Paso 11: Añadir middleware (Opcional)
|
|
472
460
|
|
|
473
|
-
|
|
474
|
-
# Construir diccionarios de Intlayer
|
|
475
|
-
npm run intlayer:build
|
|
461
|
+
También puedes usar el `intlayerMiddleware` para agregar enrutamiento del lado del servidor a tu aplicación. Este plugin detectará automáticamente la configuración regional actual basada en la URL y establecerá la cookie de configuración regional apropiada. Si no se especifica ninguna configuración regional, el plugin determinará la configuración regional más adecuada según las preferencias de idioma del navegador del usuario. Si no se detecta ninguna configuración regional, redirigirá a la configuración regional predeterminada.
|
|
476
462
|
|
|
477
|
-
|
|
478
|
-
npm run dev
|
|
479
|
-
```
|
|
463
|
+
> Ten en cuenta que para usar el `intlayerMiddleware` en producción, necesitas cambiar el paquete `vite-intlayer` de `devDependencies` a `dependencies`.
|
|
480
464
|
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
|
|
465
|
+
```typescript {3,7} fileName="vite.config.ts"
|
|
466
|
+
import { reactRouter } from "@react-router/dev/vite";
|
|
467
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
468
|
+
import { defineConfig } from "vite";
|
|
469
|
+
import { intlayer, intlayerMiddleware } from "vite-intlayer";
|
|
470
|
+
import tsconfigPaths from "vite-tsconfig-paths";
|
|
484
471
|
|
|
485
|
-
|
|
486
|
-
|
|
472
|
+
export default defineConfig({
|
|
473
|
+
plugins: [
|
|
474
|
+
tailwindcss(),
|
|
475
|
+
reactRouter(),
|
|
476
|
+
tsconfigPaths(),
|
|
477
|
+
intlayer(),
|
|
478
|
+
intlayerMiddleware(),
|
|
479
|
+
],
|
|
480
|
+
});
|
|
487
481
|
```
|
|
488
482
|
|
|
489
|
-
|
|
490
|
-
# Construir diccionarios de Intlayer
|
|
491
|
-
yarn intlayer:build
|
|
492
|
-
|
|
493
|
-
# Iniciar servidor de desarrollo
|
|
494
|
-
yarn dev
|
|
495
|
-
```
|
|
483
|
+
---
|
|
496
484
|
|
|
497
485
|
### Paso 12: Configurar TypeScript (Opcional)
|
|
498
486
|
|
|
@@ -502,9 +490,7 @@ Asegúrate de que tu configuración de TypeScript incluya los tipos autogenerado
|
|
|
502
490
|
|
|
503
491
|
```json5 fileName="tsconfig.json"
|
|
504
492
|
{
|
|
505
|
-
|
|
506
|
-
// ... tus configuraciones existentes de TypeScript
|
|
507
|
-
},
|
|
493
|
+
// ... tus configuraciones existentes
|
|
508
494
|
include: [
|
|
509
495
|
// ... tus inclusiones existentes
|
|
510
496
|
".intlayer/**/*.ts", // Incluir los tipos autogenerados
|
|
@@ -512,11 +498,13 @@ Asegúrate de que tu configuración de TypeScript incluya los tipos autogenerado
|
|
|
512
498
|
}
|
|
513
499
|
```
|
|
514
500
|
|
|
501
|
+
---
|
|
502
|
+
|
|
515
503
|
### Configuración de Git
|
|
516
504
|
|
|
517
505
|
Se recomienda ignorar los archivos generados por Intlayer. Esto te permite evitar comprometerlos en tu repositorio Git.
|
|
518
506
|
|
|
519
|
-
Para
|
|
507
|
+
Para hacer esto, puedes agregar las siguientes instrucciones a tu archivo `.gitignore`:
|
|
520
508
|
|
|
521
509
|
```plaintext fileName=".gitignore"
|
|
522
510
|
# Ignorar los archivos generados por Intlayer
|
|
@@ -525,71 +513,13 @@ Para hacerlo, puedes agregar las siguientes instrucciones a tu archivo `.gitigno
|
|
|
525
513
|
|
|
526
514
|
---
|
|
527
515
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
```typescript fileName="src/routes/{-$locale}/rotue.tsx" codeFormat="typescript"
|
|
531
|
-
function LayoutComponent() {
|
|
532
|
-
useI18nHTMLAttributes();
|
|
533
|
-
|
|
534
|
-
const { locale } = Route.useParams();
|
|
535
|
-
const { locale: selectedLocale } = useLocale();
|
|
536
|
-
const { defaultLocale } = configuration.internationalization;
|
|
537
|
-
const { prefixDefault } = configuration.middleware;
|
|
538
|
-
|
|
539
|
-
// Redirigir a la configuración regional predeterminada si no hay configuración regional en la URL cuando prefixDefault es verdadero
|
|
540
|
-
if (selectedLocale === defaultLocale && !locale && prefixDefault) {
|
|
541
|
-
return <Navigate replace to={defaultLocale} />;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
// Redirigir a la configuración regional seleccionada si la configuración regional en la URL no coincide con la seleccionada
|
|
545
|
-
if (selectedLocale !== defaultLocale && !locale) {
|
|
546
|
-
return <Navigate replace to={selectedLocale} />;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
return (
|
|
550
|
-
<IntlayerProvider locale={locale}>
|
|
551
|
-
<Outlet />
|
|
552
|
-
</IntlayerProvider>
|
|
553
|
-
);
|
|
554
|
-
}
|
|
555
|
-
```
|
|
556
|
-
|
|
557
|
-
## Despliegue en Producción
|
|
558
|
-
|
|
559
|
-
Al desplegar tu aplicación:
|
|
560
|
-
|
|
561
|
-
1. **Construye tu aplicación:**
|
|
562
|
-
|
|
563
|
-
```bash
|
|
564
|
-
npm run build
|
|
565
|
-
```
|
|
566
|
-
|
|
567
|
-
2. **Construye los diccionarios de Intlayer:**
|
|
568
|
-
|
|
569
|
-
```bash
|
|
570
|
-
npm run intlayer:build
|
|
571
|
-
```
|
|
572
|
-
|
|
573
|
-
3. **Mueve `vite-intlayer` a las dependencias** si usas middleware en producción:
|
|
574
|
-
```bash
|
|
575
|
-
npm install vite-intlayer --save
|
|
576
|
-
```
|
|
577
|
-
|
|
578
|
-
Tu aplicación ahora soportará:
|
|
579
|
-
|
|
580
|
-
- **Estructura de URL**: `/en`, `/en/about`, `/tr`, `/tr/about`
|
|
581
|
-
- **Detección automática de locale** basada en las preferencias del navegador
|
|
582
|
-
- **Ruteo consciente del locale** con Tanstack Start
|
|
583
|
-
- **Soporte para TypeScript** con tipos generados automáticamente
|
|
584
|
-
- **Renderizado del lado servidor** con manejo adecuado del locale
|
|
585
|
-
|
|
586
|
-
## Extensión para VS Code
|
|
516
|
+
## Extensión de VS Code
|
|
587
517
|
|
|
588
|
-
Para mejorar tu experiencia de desarrollo con Intlayer, puedes instalar la
|
|
518
|
+
Para mejorar tu experiencia de desarrollo con Intlayer, puedes instalar la **Extensión oficial de Intlayer para VS Code**.
|
|
589
519
|
|
|
590
520
|
[Instalar desde el Marketplace de VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
591
521
|
|
|
592
|
-
Esta extensión
|
|
522
|
+
Esta extensión proporciona:
|
|
593
523
|
|
|
594
524
|
- **Autocompletado** para las claves de traducción.
|
|
595
525
|
- **Detección de errores en tiempo real** para traducciones faltantes.
|
|
@@ -602,7 +532,7 @@ Para más detalles sobre cómo usar la extensión, consulta la [documentación d
|
|
|
602
532
|
|
|
603
533
|
## Ir Más Allá
|
|
604
534
|
|
|
605
|
-
Para
|
|
535
|
+
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).
|
|
606
536
|
|
|
607
537
|
---
|
|
608
538
|
|
|
@@ -615,9 +545,9 @@ Para profundizar, puedes implementar el [editor visual](https://github.com/aymer
|
|
|
615
545
|
- [Declaración de Contenido](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/dictionary/get_started.md)
|
|
616
546
|
- [Configuración](https://github.com/aymericzip/intlayer/blob/main/docs/docs/es/configuration.md)
|
|
617
547
|
|
|
618
|
-
Esta guía completa proporciona todo lo que necesitas para integrar Intlayer con Tanstack Start para una aplicación completamente internacionalizada con enrutamiento consciente
|
|
548
|
+
Esta guía completa proporciona todo lo que necesitas para integrar Intlayer con Tanstack Start para una aplicación completamente internacionalizada con enrutamiento consciente de la configuración regional y soporte para TypeScript.
|
|
619
549
|
|
|
620
|
-
## Historial de
|
|
550
|
+
## Historial de Documentación
|
|
621
551
|
|
|
622
552
|
| Versión | Fecha | Cambios |
|
|
623
553
|
| ------- | ---------- | --------------------------- |
|