@intlayer/docs 7.3.14 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blog/ar/intlayer_with_i18next.md +3 -0
- package/blog/ar/intlayer_with_next-i18next.md +3 -0
- package/blog/ar/intlayer_with_next-intl.md +3 -0
- package/blog/ar/intlayer_with_react-i18next.md +3 -0
- package/blog/ar/intlayer_with_react-intl.md +3 -0
- package/blog/ar/intlayer_with_vue-i18n.md +3 -0
- package/blog/de/intlayer_with_i18next.md +3 -0
- package/blog/de/intlayer_with_next-i18next.md +3 -0
- package/blog/de/intlayer_with_next-intl.md +3 -0
- package/blog/de/intlayer_with_react-i18next.md +3 -0
- package/blog/de/intlayer_with_react-intl.md +3 -0
- package/blog/de/intlayer_with_vue-i18n.md +3 -0
- package/blog/en/intlayer_with_i18next.md +7 -0
- package/blog/en/intlayer_with_next-i18next.md +3 -0
- package/blog/en/intlayer_with_next-intl.md +7 -0
- package/blog/en/intlayer_with_react-i18next.md +3 -0
- package/blog/en/intlayer_with_react-intl.md +3 -0
- package/blog/en/intlayer_with_vue-i18n.md +3 -0
- package/blog/en-GB/intlayer_with_i18next.md +3 -0
- package/blog/en-GB/intlayer_with_next-i18next.md +3 -0
- package/blog/en-GB/intlayer_with_next-intl.md +3 -0
- package/blog/en-GB/intlayer_with_react-i18next.md +3 -0
- package/blog/en-GB/intlayer_with_react-intl.md +3 -0
- package/blog/en-GB/intlayer_with_vue-i18n.md +3 -0
- package/blog/es/intlayer_with_i18next.md +3 -0
- package/blog/es/intlayer_with_next-i18next.md +3 -0
- package/blog/es/intlayer_with_next-intl.md +3 -0
- package/blog/es/intlayer_with_react-i18next.md +3 -0
- package/blog/es/intlayer_with_react-intl.md +3 -0
- package/blog/es/intlayer_with_vue-i18n.md +3 -0
- package/blog/fr/intlayer_with_i18next.md +3 -0
- package/blog/fr/intlayer_with_next-i18next.md +3 -0
- package/blog/fr/intlayer_with_next-intl.md +3 -0
- package/blog/fr/intlayer_with_react-i18next.md +3 -0
- package/blog/fr/intlayer_with_react-intl.md +3 -0
- package/blog/fr/intlayer_with_vue-i18n.md +3 -0
- package/blog/hi/intlayer_with_i18next.md +3 -0
- package/blog/hi/intlayer_with_next-i18next.md +3 -0
- package/blog/hi/intlayer_with_next-intl.md +3 -0
- package/blog/hi/intlayer_with_react-i18next.md +3 -0
- package/blog/hi/intlayer_with_react-intl.md +3 -0
- package/blog/hi/intlayer_with_vue-i18n.md +3 -0
- package/blog/id/intlayer_with_i18next.md +3 -0
- package/blog/id/intlayer_with_next-i18next.md +3 -0
- package/blog/id/intlayer_with_next-intl.md +3 -0
- package/blog/id/intlayer_with_react-i18next.md +3 -0
- package/blog/id/intlayer_with_react-intl.md +3 -0
- package/blog/id/intlayer_with_vue-i18n.md +3 -0
- package/blog/it/intlayer_with_i18next.md +3 -0
- package/blog/it/intlayer_with_next-i18next.md +3 -0
- package/blog/it/intlayer_with_next-intl.md +3 -0
- package/blog/it/intlayer_with_react-i18next.md +3 -0
- package/blog/it/intlayer_with_react-intl.md +3 -0
- package/blog/it/intlayer_with_vue-i18n.md +3 -0
- package/blog/ja/intlayer_with_i18next.md +3 -0
- package/blog/ja/intlayer_with_next-i18next.md +3 -0
- package/blog/ja/intlayer_with_next-intl.md +3 -0
- package/blog/ja/intlayer_with_react-i18next.md +3 -0
- package/blog/ja/intlayer_with_react-intl.md +3 -0
- package/blog/ja/intlayer_with_vue-i18n.md +3 -0
- package/blog/ko/intlayer_with_i18next.md +3 -0
- package/blog/ko/intlayer_with_next-i18next.md +3 -0
- package/blog/ko/intlayer_with_next-intl.md +3 -0
- package/blog/ko/intlayer_with_react-i18next.md +3 -0
- package/blog/ko/intlayer_with_react-intl.md +3 -0
- package/blog/ko/intlayer_with_vue-i18n.md +3 -0
- package/blog/pl/intlayer_with_i18next.md +3 -0
- package/blog/pl/intlayer_with_next-i18next.md +3 -0
- package/blog/pl/intlayer_with_next-intl.md +3 -0
- package/blog/pl/intlayer_with_react-i18next.md +3 -0
- package/blog/pl/intlayer_with_react-intl.md +3 -0
- package/blog/pl/intlayer_with_vue-i18n.md +3 -0
- package/blog/pt/intlayer_with_i18next.md +3 -0
- package/blog/pt/intlayer_with_next-i18next.md +3 -0
- package/blog/pt/intlayer_with_next-intl.md +3 -0
- package/blog/pt/intlayer_with_react-i18next.md +3 -0
- package/blog/pt/intlayer_with_react-intl.md +3 -0
- package/blog/pt/intlayer_with_vue-i18n.md +3 -0
- package/blog/ru/intlayer_with_i18next.md +3 -0
- package/blog/ru/intlayer_with_next-i18next.md +3 -0
- package/blog/ru/intlayer_with_next-intl.md +3 -0
- package/blog/ru/intlayer_with_react-i18next.md +3 -0
- package/blog/ru/intlayer_with_react-intl.md +3 -0
- package/blog/ru/intlayer_with_vue-i18n.md +3 -0
- package/blog/tr/intlayer_with_i18next.md +3 -0
- package/blog/tr/intlayer_with_next-i18next.md +3 -0
- package/blog/tr/intlayer_with_next-intl.md +3 -0
- package/blog/tr/intlayer_with_react-i18next.md +3 -0
- package/blog/tr/intlayer_with_vue-i18n.md +3 -0
- package/blog/vi/intlayer_with_i18next.md +3 -0
- package/blog/vi/intlayer_with_next-i18next.md +3 -0
- package/blog/vi/intlayer_with_next-intl.md +3 -0
- package/blog/vi/intlayer_with_react-i18next.md +3 -0
- package/blog/vi/intlayer_with_react-intl.md +3 -0
- package/blog/vi/intlayer_with_vue-i18n.md +3 -0
- package/blog/zh/intlayer_with_i18next.md +3 -0
- package/blog/zh/intlayer_with_next-i18next.md +3 -0
- package/blog/zh/intlayer_with_next-intl.md +3 -0
- package/blog/zh/intlayer_with_react-i18next.md +3 -0
- package/blog/zh/intlayer_with_react-intl.md +3 -0
- package/blog/zh/intlayer_with_vue-i18n.md +3 -0
- package/docs/ar/intlayer_with_lynx+react.md +1 -1
- package/docs/ar/intlayer_with_tanstack.md +132 -2
- package/docs/ar/intlayer_with_vite+react.md +99 -331
- package/docs/ar/plugins/sync-json.md +3 -0
- package/docs/de/intlayer_with_lynx+react.md +1 -1
- package/docs/de/intlayer_with_tanstack.md +132 -2
- package/docs/de/intlayer_with_vite+react.md +116 -380
- package/docs/de/plugins/sync-json.md +3 -0
- package/docs/en/intlayer_with_tanstack.md +131 -1
- package/docs/en/intlayer_with_vite+react.md +6 -10
- package/docs/en/plugins/sync-json.md +3 -0
- package/docs/en-GB/intlayer_with_tanstack.md +131 -1
- package/docs/en-GB/intlayer_with_vite+react.md +62 -74
- package/docs/en-GB/plugins/sync-json.md +3 -0
- package/docs/es/intlayer_with_tanstack.md +132 -2
- package/docs/es/intlayer_with_vite+react.md +101 -333
- package/docs/es/plugins/sync-json.md +3 -0
- package/docs/fr/intlayer_with_tanstack.md +132 -2
- package/docs/fr/intlayer_with_vite+react.md +101 -357
- package/docs/fr/plugins/sync-json.md +3 -0
- package/docs/hi/intlayer_with_tanstack.md +132 -2
- package/docs/hi/intlayer_with_vite+react.md +120 -333
- package/docs/hi/plugins/sync-json.md +3 -0
- package/docs/id/intlayer_with_tanstack.md +132 -2
- package/docs/id/intlayer_with_vite+react.md +7 -13
- package/docs/id/plugins/sync-json.md +3 -0
- package/docs/it/intlayer_with_lynx+react.md +1 -1
- package/docs/it/intlayer_with_tanstack.md +132 -2
- package/docs/it/intlayer_with_vite+react.md +121 -393
- package/docs/it/plugins/sync-json.md +3 -0
- package/docs/ja/intlayer_with_tanstack.md +132 -2
- package/docs/ja/intlayer_with_vite+react.md +106 -378
- package/docs/ja/plugins/sync-json.md +3 -0
- package/docs/ko/intlayer_with_lynx+react.md +1 -1
- package/docs/ko/intlayer_with_tanstack.md +132 -2
- package/docs/ko/intlayer_with_vite+react.md +90 -322
- package/docs/ko/plugins/sync-json.md +3 -0
- package/docs/pl/intlayer_with_tanstack.md +132 -2
- package/docs/pl/intlayer_with_vite+react.md +25 -21
- package/docs/pl/plugins/sync-json.md +3 -0
- package/docs/pt/intlayer_with_tanstack.md +132 -2
- package/docs/pt/intlayer_with_vite+react.md +96 -328
- package/docs/pt/plugins/sync-json.md +3 -0
- package/docs/ru/intlayer_with_lynx+react.md +1 -1
- package/docs/ru/intlayer_with_tanstack.md +132 -2
- package/docs/ru/intlayer_with_vite+react.md +109 -362
- package/docs/ru/plugins/sync-json.md +3 -0
- package/docs/tr/intlayer_with_tanstack.md +132 -2
- package/docs/tr/intlayer_with_vite+react.md +132 -366
- package/docs/tr/plugins/sync-json.md +3 -0
- package/docs/vi/intlayer_with_tanstack.md +132 -2
- package/docs/vi/intlayer_with_vite+react.md +16 -19
- package/docs/vi/plugins/sync-json.md +3 -0
- package/docs/zh/intlayer_with_tanstack.md +133 -3
- package/docs/zh/intlayer_with_vite+react.md +91 -374
- package/docs/zh/plugins/sync-json.md +3 -0
- package/frequent_questions/ar/customized_locale_list.md +1 -1
- package/frequent_questions/de/customized_locale_list.md +1 -1
- package/frequent_questions/en/customized_locale_list.md +1 -1
- package/frequent_questions/en-GB/customized_locale_list.md +1 -1
- package/frequent_questions/es/customized_locale_list.md +1 -1
- package/frequent_questions/fr/customized_locale_list.md +1 -1
- package/frequent_questions/hi/customized_locale_list.md +1 -1
- package/frequent_questions/id/customized_locale_list.md +1 -1
- package/frequent_questions/it/customized_locale_list.md +1 -1
- package/frequent_questions/ja/customized_locale_list.md +1 -1
- package/frequent_questions/ko/customized_locale_list.md +1 -1
- package/frequent_questions/pl/customized_locale_list.md +1 -1
- package/frequent_questions/pt/customized_locale_list.md +1 -1
- package/frequent_questions/ru/customized_locale_list.md +1 -1
- package/frequent_questions/tr/customized_locale_list.md +1 -1
- package/frequent_questions/vi/customized_locale_list.md +1 -1
- package/frequent_questions/zh/customized_locale_list.md +1 -1
- package/package.json +6 -6
|
@@ -19,9 +19,12 @@ slugs:
|
|
|
19
19
|
applicationTemplate: https://github.com/aymericzip/intlayer-tanstack-start-template
|
|
20
20
|
youtubeVideo: https://www.youtube.com/watch?v=_XTdKVWaeqg
|
|
21
21
|
history:
|
|
22
|
+
- version: 7.4.0
|
|
23
|
+
date: 2025-12-11
|
|
24
|
+
changes: Introduce validatePrefix y añade el paso 14: Cómo gestionar páginas 404 con rutas localizadas.
|
|
22
25
|
- version: 7.3.9
|
|
23
26
|
date: 2025-12-05
|
|
24
|
-
changes:
|
|
27
|
+
changes: Añade el paso 13: Obtener la configuración regional en tus server actions (Opcional)
|
|
25
28
|
- version: 5.8.1
|
|
26
29
|
date: 2025-09-09
|
|
27
30
|
changes: Añadido para Tanstack Start
|
|
@@ -605,7 +608,134 @@ export const getLocaleServer = createServerFn().handler(async () => {
|
|
|
605
608
|
|
|
606
609
|
---
|
|
607
610
|
|
|
608
|
-
### Paso 14:
|
|
611
|
+
### Paso 14: Gestionar páginas no encontradas (Opcional)
|
|
612
|
+
|
|
613
|
+
Cuando un usuario visita una página que no existe, puedes mostrar una página personalizada de no encontrada y el prefijo de configuración regional puede afectar la forma en que se activa la página de no encontrada.
|
|
614
|
+
|
|
615
|
+
#### Entender el manejo de 404 de TanStack Router con prefijos de configuración regional
|
|
616
|
+
|
|
617
|
+
En TanStack Router, manejar páginas 404 con rutas localizadas requiere un enfoque de múltiples capas:
|
|
618
|
+
|
|
619
|
+
1. **Ruta 404 dedicada**: Una ruta específica para mostrar la UI de 404
|
|
620
|
+
2. **Validación a nivel de ruta**: Valida los prefijos de configuración regional y redirige los inválidos a 404
|
|
621
|
+
3. **Ruta catch-all**: Captura cualquier ruta no coincidente dentro del segmento de configuración regional
|
|
622
|
+
|
|
623
|
+
```tsx fileName="src/routes/{-$locale}/404.tsx"
|
|
624
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
625
|
+
|
|
626
|
+
// Esto crea una ruta dedicada /[locale]/404
|
|
627
|
+
// Se usa tanto como una ruta directa como importada como componente en otros archivos
|
|
628
|
+
export const Route = createFileRoute("/{-$locale}/404")({
|
|
629
|
+
component: NotFoundComponent,
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
// Exportado por separado para que pueda reutilizarse en notFoundComponent y rutas catch-all
|
|
633
|
+
export function NotFoundComponent() {
|
|
634
|
+
return (
|
|
635
|
+
<div>
|
|
636
|
+
<h1>404</h1>
|
|
637
|
+
</div>
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
```tsx fileName="src/routes/__root.tsx"
|
|
643
|
+
import { createRootRoute } from "@tanstack/react-router";
|
|
644
|
+
|
|
645
|
+
// La ruta raíz sirve como el diseño de nivel superior
|
|
646
|
+
// No maneja los 404 directamente - eso se delega a las rutas hijas
|
|
647
|
+
// Esto mantiene la raíz simple y permite que las rutas conscientes de la configuración regional gestionen su propia lógica 404
|
|
648
|
+
export const Route = createRootRoute({
|
|
649
|
+
component: Outlet,
|
|
650
|
+
});
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
```tsx fileName="src/routes/{-$locale}/route.tsx"
|
|
654
|
+
import { createFileRoute, Outlet, redirect } from "@tanstack/react-router";
|
|
655
|
+
import { validatePrefix } from "intlayer";
|
|
656
|
+
import { IntlayerProvider, useLocale } from "react-intlayer";
|
|
657
|
+
|
|
658
|
+
import { LocaleSwitcher } from "@/components/locale-switcher";
|
|
659
|
+
import { NotFoundComponent } from "./404";
|
|
660
|
+
|
|
661
|
+
export const Route = createFileRoute("/{-$locale}")({
|
|
662
|
+
// beforeLoad se ejecuta antes de que la ruta se renderice (tanto en el servidor como en el cliente)
|
|
663
|
+
// Es el lugar ideal para validar el prefijo de configuración regional
|
|
664
|
+
beforeLoad: ({ params }) => {
|
|
665
|
+
// Obtener la configuración regional de los parámetros de la ruta (no de los encabezados del servidor, ya que beforeLoad se ejecuta tanto en el cliente como en el servidor)
|
|
666
|
+
const localeParam = params.locale;
|
|
667
|
+
|
|
668
|
+
// validatePrefix verifica si la configuración regional es válida según tu configuración de intlayer
|
|
669
|
+
// Retorna: { isValid: boolean, localePrefix: string }
|
|
670
|
+
// - isValid: true si el prefijo coincide con una configuración regional configurada (o está vacío cuando el prefijo es opcional)
|
|
671
|
+
// - localePrefix: el prefijo validado o el prefijo de configuración regional predeterminado para redirecciones
|
|
672
|
+
const { isValid, localePrefix } = validatePrefix(localeParam);
|
|
673
|
+
|
|
674
|
+
if (isValid) {
|
|
675
|
+
// La configuración regional es válida, permitir que la ruta se renderice normalmente
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// Prefijo de configuración regional inválido (p. ej., /xyz/about donde "xyz" no es una configuración regional válida)
|
|
680
|
+
// Redirigir a la página 404 con un prefijo de configuración regional válido
|
|
681
|
+
// Esto asegura que la página 404 siga estando correctamente localizada
|
|
682
|
+
throw redirect({
|
|
683
|
+
to: "/{-$locale}/404",
|
|
684
|
+
params: { locale: localePrefix },
|
|
685
|
+
});
|
|
686
|
+
},
|
|
687
|
+
component: RouteComponent,
|
|
688
|
+
// notFoundComponent se llama cuando una ruta hija no existe
|
|
689
|
+
// p. ej., /en/pagina-inexistente activa esto dentro del diseño /en
|
|
690
|
+
notFoundComponent: NotFoundLayout,
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
function RouteComponent() {
|
|
694
|
+
const { defaultLocale } = useLocale();
|
|
695
|
+
const { locale } = Route.useParams();
|
|
696
|
+
|
|
697
|
+
return (
|
|
698
|
+
// Envuelve todo el segmento de configuración regional con IntlayerProvider
|
|
699
|
+
// Vuelve a defaultLocale cuando el parámetro locale es undefined (modo de prefijo opcional)
|
|
700
|
+
<IntlayerProvider locale={locale ?? defaultLocale}>
|
|
701
|
+
<Outlet />
|
|
702
|
+
</IntlayerProvider>
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
// NotFoundLayout envuelve el componente 404 con IntlayerProvider
|
|
707
|
+
// Esto asegura que las traducciones sigan funcionando en la página 404
|
|
708
|
+
function NotFoundLayout() {
|
|
709
|
+
const { defaultLocale } = useLocale();
|
|
710
|
+
const { locale } = Route.useParams();
|
|
711
|
+
|
|
712
|
+
return (
|
|
713
|
+
<IntlayerProvider locale={locale ?? defaultLocale}>
|
|
714
|
+
<NotFoundComponent />
|
|
715
|
+
{/* Incluir LocaleSwitcher para que los usuarios puedan cambiar el idioma incluso en 404 */}
|
|
716
|
+
<LocaleSwitcher />
|
|
717
|
+
</IntlayerProvider>
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
```tsx fileName="src/routes/{-$locale}/$.tsx"
|
|
723
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
724
|
+
|
|
725
|
+
import { NotFoundComponent } from "./404";
|
|
726
|
+
|
|
727
|
+
// La ruta $ (splat/catch-all) coincide con cualquier ruta que no coincida con otras rutas
|
|
728
|
+
// p. ej., /en/algun/ruta/profunda/anidada/invalida
|
|
729
|
+
// Esto asegura que TODAS las rutas no coincidentes dentro de una configuración regional muestren la página 404
|
|
730
|
+
// Sin esto, las rutas profundas no coincidentes podrían mostrar una página en blanco o un error
|
|
731
|
+
export const Route = createFileRoute("/{-$locale}/$")({
|
|
732
|
+
component: NotFoundComponent,
|
|
733
|
+
});
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
---
|
|
737
|
+
|
|
738
|
+
### Paso 15: Configurar TypeScript (Opcional)
|
|
609
739
|
|
|
610
740
|
Intlayer utiliza la ampliación de módulos para aprovechar las ventajas de TypeScript y fortalecer tu base de código.
|
|
611
741
|
|