@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.
Files changed (175) hide show
  1. package/blog/ar/intlayer_with_i18next.md +3 -0
  2. package/blog/ar/intlayer_with_next-i18next.md +3 -0
  3. package/blog/ar/intlayer_with_next-intl.md +3 -0
  4. package/blog/ar/intlayer_with_react-i18next.md +3 -0
  5. package/blog/ar/intlayer_with_react-intl.md +3 -0
  6. package/blog/ar/intlayer_with_vue-i18n.md +3 -0
  7. package/blog/de/intlayer_with_i18next.md +3 -0
  8. package/blog/de/intlayer_with_next-i18next.md +3 -0
  9. package/blog/de/intlayer_with_next-intl.md +3 -0
  10. package/blog/de/intlayer_with_react-i18next.md +3 -0
  11. package/blog/de/intlayer_with_react-intl.md +3 -0
  12. package/blog/de/intlayer_with_vue-i18n.md +3 -0
  13. package/blog/en/intlayer_with_i18next.md +7 -0
  14. package/blog/en/intlayer_with_next-i18next.md +3 -0
  15. package/blog/en/intlayer_with_next-intl.md +7 -0
  16. package/blog/en/intlayer_with_react-i18next.md +3 -0
  17. package/blog/en/intlayer_with_react-intl.md +3 -0
  18. package/blog/en/intlayer_with_vue-i18n.md +3 -0
  19. package/blog/en-GB/intlayer_with_i18next.md +3 -0
  20. package/blog/en-GB/intlayer_with_next-i18next.md +3 -0
  21. package/blog/en-GB/intlayer_with_next-intl.md +3 -0
  22. package/blog/en-GB/intlayer_with_react-i18next.md +3 -0
  23. package/blog/en-GB/intlayer_with_react-intl.md +3 -0
  24. package/blog/en-GB/intlayer_with_vue-i18n.md +3 -0
  25. package/blog/es/intlayer_with_i18next.md +3 -0
  26. package/blog/es/intlayer_with_next-i18next.md +3 -0
  27. package/blog/es/intlayer_with_next-intl.md +3 -0
  28. package/blog/es/intlayer_with_react-i18next.md +3 -0
  29. package/blog/es/intlayer_with_react-intl.md +3 -0
  30. package/blog/es/intlayer_with_vue-i18n.md +3 -0
  31. package/blog/fr/intlayer_with_i18next.md +3 -0
  32. package/blog/fr/intlayer_with_next-i18next.md +3 -0
  33. package/blog/fr/intlayer_with_next-intl.md +3 -0
  34. package/blog/fr/intlayer_with_react-i18next.md +3 -0
  35. package/blog/fr/intlayer_with_react-intl.md +3 -0
  36. package/blog/fr/intlayer_with_vue-i18n.md +3 -0
  37. package/blog/hi/intlayer_with_i18next.md +3 -0
  38. package/blog/hi/intlayer_with_next-i18next.md +3 -0
  39. package/blog/hi/intlayer_with_next-intl.md +3 -0
  40. package/blog/hi/intlayer_with_react-i18next.md +3 -0
  41. package/blog/hi/intlayer_with_react-intl.md +3 -0
  42. package/blog/hi/intlayer_with_vue-i18n.md +3 -0
  43. package/blog/id/intlayer_with_i18next.md +3 -0
  44. package/blog/id/intlayer_with_next-i18next.md +3 -0
  45. package/blog/id/intlayer_with_next-intl.md +3 -0
  46. package/blog/id/intlayer_with_react-i18next.md +3 -0
  47. package/blog/id/intlayer_with_react-intl.md +3 -0
  48. package/blog/id/intlayer_with_vue-i18n.md +3 -0
  49. package/blog/it/intlayer_with_i18next.md +3 -0
  50. package/blog/it/intlayer_with_next-i18next.md +3 -0
  51. package/blog/it/intlayer_with_next-intl.md +3 -0
  52. package/blog/it/intlayer_with_react-i18next.md +3 -0
  53. package/blog/it/intlayer_with_react-intl.md +3 -0
  54. package/blog/it/intlayer_with_vue-i18n.md +3 -0
  55. package/blog/ja/intlayer_with_i18next.md +3 -0
  56. package/blog/ja/intlayer_with_next-i18next.md +3 -0
  57. package/blog/ja/intlayer_with_next-intl.md +3 -0
  58. package/blog/ja/intlayer_with_react-i18next.md +3 -0
  59. package/blog/ja/intlayer_with_react-intl.md +3 -0
  60. package/blog/ja/intlayer_with_vue-i18n.md +3 -0
  61. package/blog/ko/intlayer_with_i18next.md +3 -0
  62. package/blog/ko/intlayer_with_next-i18next.md +3 -0
  63. package/blog/ko/intlayer_with_next-intl.md +3 -0
  64. package/blog/ko/intlayer_with_react-i18next.md +3 -0
  65. package/blog/ko/intlayer_with_react-intl.md +3 -0
  66. package/blog/ko/intlayer_with_vue-i18n.md +3 -0
  67. package/blog/pl/intlayer_with_i18next.md +3 -0
  68. package/blog/pl/intlayer_with_next-i18next.md +3 -0
  69. package/blog/pl/intlayer_with_next-intl.md +3 -0
  70. package/blog/pl/intlayer_with_react-i18next.md +3 -0
  71. package/blog/pl/intlayer_with_react-intl.md +3 -0
  72. package/blog/pl/intlayer_with_vue-i18n.md +3 -0
  73. package/blog/pt/intlayer_with_i18next.md +3 -0
  74. package/blog/pt/intlayer_with_next-i18next.md +3 -0
  75. package/blog/pt/intlayer_with_next-intl.md +3 -0
  76. package/blog/pt/intlayer_with_react-i18next.md +3 -0
  77. package/blog/pt/intlayer_with_react-intl.md +3 -0
  78. package/blog/pt/intlayer_with_vue-i18n.md +3 -0
  79. package/blog/ru/intlayer_with_i18next.md +3 -0
  80. package/blog/ru/intlayer_with_next-i18next.md +3 -0
  81. package/blog/ru/intlayer_with_next-intl.md +3 -0
  82. package/blog/ru/intlayer_with_react-i18next.md +3 -0
  83. package/blog/ru/intlayer_with_react-intl.md +3 -0
  84. package/blog/ru/intlayer_with_vue-i18n.md +3 -0
  85. package/blog/tr/intlayer_with_i18next.md +3 -0
  86. package/blog/tr/intlayer_with_next-i18next.md +3 -0
  87. package/blog/tr/intlayer_with_next-intl.md +3 -0
  88. package/blog/tr/intlayer_with_react-i18next.md +3 -0
  89. package/blog/tr/intlayer_with_vue-i18n.md +3 -0
  90. package/blog/vi/intlayer_with_i18next.md +3 -0
  91. package/blog/vi/intlayer_with_next-i18next.md +3 -0
  92. package/blog/vi/intlayer_with_next-intl.md +3 -0
  93. package/blog/vi/intlayer_with_react-i18next.md +3 -0
  94. package/blog/vi/intlayer_with_react-intl.md +3 -0
  95. package/blog/vi/intlayer_with_vue-i18n.md +3 -0
  96. package/blog/zh/intlayer_with_i18next.md +3 -0
  97. package/blog/zh/intlayer_with_next-i18next.md +3 -0
  98. package/blog/zh/intlayer_with_next-intl.md +3 -0
  99. package/blog/zh/intlayer_with_react-i18next.md +3 -0
  100. package/blog/zh/intlayer_with_react-intl.md +3 -0
  101. package/blog/zh/intlayer_with_vue-i18n.md +3 -0
  102. package/docs/ar/intlayer_with_lynx+react.md +1 -1
  103. package/docs/ar/intlayer_with_tanstack.md +132 -2
  104. package/docs/ar/intlayer_with_vite+react.md +99 -331
  105. package/docs/ar/plugins/sync-json.md +3 -0
  106. package/docs/de/intlayer_with_lynx+react.md +1 -1
  107. package/docs/de/intlayer_with_tanstack.md +132 -2
  108. package/docs/de/intlayer_with_vite+react.md +116 -380
  109. package/docs/de/plugins/sync-json.md +3 -0
  110. package/docs/en/intlayer_with_tanstack.md +131 -1
  111. package/docs/en/intlayer_with_vite+react.md +6 -10
  112. package/docs/en/plugins/sync-json.md +3 -0
  113. package/docs/en-GB/intlayer_with_tanstack.md +131 -1
  114. package/docs/en-GB/intlayer_with_vite+react.md +62 -74
  115. package/docs/en-GB/plugins/sync-json.md +3 -0
  116. package/docs/es/intlayer_with_tanstack.md +132 -2
  117. package/docs/es/intlayer_with_vite+react.md +101 -333
  118. package/docs/es/plugins/sync-json.md +3 -0
  119. package/docs/fr/intlayer_with_tanstack.md +132 -2
  120. package/docs/fr/intlayer_with_vite+react.md +101 -357
  121. package/docs/fr/plugins/sync-json.md +3 -0
  122. package/docs/hi/intlayer_with_tanstack.md +132 -2
  123. package/docs/hi/intlayer_with_vite+react.md +120 -333
  124. package/docs/hi/plugins/sync-json.md +3 -0
  125. package/docs/id/intlayer_with_tanstack.md +132 -2
  126. package/docs/id/intlayer_with_vite+react.md +7 -13
  127. package/docs/id/plugins/sync-json.md +3 -0
  128. package/docs/it/intlayer_with_lynx+react.md +1 -1
  129. package/docs/it/intlayer_with_tanstack.md +132 -2
  130. package/docs/it/intlayer_with_vite+react.md +121 -393
  131. package/docs/it/plugins/sync-json.md +3 -0
  132. package/docs/ja/intlayer_with_tanstack.md +132 -2
  133. package/docs/ja/intlayer_with_vite+react.md +106 -378
  134. package/docs/ja/plugins/sync-json.md +3 -0
  135. package/docs/ko/intlayer_with_lynx+react.md +1 -1
  136. package/docs/ko/intlayer_with_tanstack.md +132 -2
  137. package/docs/ko/intlayer_with_vite+react.md +90 -322
  138. package/docs/ko/plugins/sync-json.md +3 -0
  139. package/docs/pl/intlayer_with_tanstack.md +132 -2
  140. package/docs/pl/intlayer_with_vite+react.md +25 -21
  141. package/docs/pl/plugins/sync-json.md +3 -0
  142. package/docs/pt/intlayer_with_tanstack.md +132 -2
  143. package/docs/pt/intlayer_with_vite+react.md +96 -328
  144. package/docs/pt/plugins/sync-json.md +3 -0
  145. package/docs/ru/intlayer_with_lynx+react.md +1 -1
  146. package/docs/ru/intlayer_with_tanstack.md +132 -2
  147. package/docs/ru/intlayer_with_vite+react.md +109 -362
  148. package/docs/ru/plugins/sync-json.md +3 -0
  149. package/docs/tr/intlayer_with_tanstack.md +132 -2
  150. package/docs/tr/intlayer_with_vite+react.md +132 -366
  151. package/docs/tr/plugins/sync-json.md +3 -0
  152. package/docs/vi/intlayer_with_tanstack.md +132 -2
  153. package/docs/vi/intlayer_with_vite+react.md +16 -19
  154. package/docs/vi/plugins/sync-json.md +3 -0
  155. package/docs/zh/intlayer_with_tanstack.md +133 -3
  156. package/docs/zh/intlayer_with_vite+react.md +91 -374
  157. package/docs/zh/plugins/sync-json.md +3 -0
  158. package/frequent_questions/ar/customized_locale_list.md +1 -1
  159. package/frequent_questions/de/customized_locale_list.md +1 -1
  160. package/frequent_questions/en/customized_locale_list.md +1 -1
  161. package/frequent_questions/en-GB/customized_locale_list.md +1 -1
  162. package/frequent_questions/es/customized_locale_list.md +1 -1
  163. package/frequent_questions/fr/customized_locale_list.md +1 -1
  164. package/frequent_questions/hi/customized_locale_list.md +1 -1
  165. package/frequent_questions/id/customized_locale_list.md +1 -1
  166. package/frequent_questions/it/customized_locale_list.md +1 -1
  167. package/frequent_questions/ja/customized_locale_list.md +1 -1
  168. package/frequent_questions/ko/customized_locale_list.md +1 -1
  169. package/frequent_questions/pl/customized_locale_list.md +1 -1
  170. package/frequent_questions/pt/customized_locale_list.md +1 -1
  171. package/frequent_questions/ru/customized_locale_list.md +1 -1
  172. package/frequent_questions/tr/customized_locale_list.md +1 -1
  173. package/frequent_questions/vi/customized_locale_list.md +1 -1
  174. package/frequent_questions/zh/customized_locale_list.md +1 -1
  175. 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: Wprowadzenie validatePrefix oraz dodanie kroku 14: Obsługa stron 404 z lokalizowanymi trasami.
22
25
  - version: 7.3.9
23
26
  date: 2025-12-05
24
- changes: Add step 13: Retrieve the locale in your server actions (Optional)
27
+ changes: Dodany krok 13: Pobieranie lokalizacji w akcjach serwerowych (Opcjonalnie)
25
28
  - version: 6.5.2
26
29
  date: 2025-10-03
27
30
  changes: Aktualizacja dokumentacji
@@ -590,7 +593,134 @@ export const getLocaleServer = createServerFn().handler(async () => {
590
593
 
591
594
  ---
592
595
 
593
- ### Krok 14: Konfiguracja TypeScript (opcjonalnie)
596
+ ### Krok 14: Zarządzanie stronami nie znalezionymi (opcjonalnie)
597
+
598
+ Gdy użytkownik odwiedza nieistniejącą stronę, możesz wyświetlić niestandardową stronę "nie znaleziono", a prefiks locale może wpływać na sposób wyzwalania strony "nie znaleziono".
599
+
600
+ #### Zrozumienie obsługi 404 w TanStack Router z prefiksami locale
601
+
602
+ W TanStack Router obsługa stron 404 z zlokalizowanymi trasami wymaga podejścia wielowarstwowego:
603
+
604
+ 1. **Dedykowana trasa 404**: Konkretna trasa do wyświetlenia interfejsu 404
605
+ 2. **Walidacja na poziomie trasy**: Weryfikuje prefiksy locale i przekierowuje nieprawidłowe do 404
606
+ 3. **Trasa catch-all**: Przechwytuje wszystkie niedopasowane ścieżki w segmencie locale
607
+
608
+ ```tsx fileName="src/routes/{-$locale}/404.tsx"
609
+ import { createFileRoute } from "@tanstack/react-router";
610
+
611
+ // To tworzy dedykowaną trasę /[locale]/404
612
+ // Jest używana zarówno jako bezpośrednia trasa, jak i importowana jako komponent w innych plikach
613
+ export const Route = createFileRoute("/{-$locale}/404")({
614
+ component: NotFoundComponent,
615
+ });
616
+
617
+ // Eksportowane osobno, aby można było ponownie użyć w notFoundComponent i trasach catch-all
618
+ export function NotFoundComponent() {
619
+ return (
620
+ <div>
621
+ <h1>404</h1>
622
+ </div>
623
+ );
624
+ }
625
+ ```
626
+
627
+ ```tsx fileName="src/routes/__root.tsx"
628
+ import { createRootRoute } from "@tanstack/react-router";
629
+
630
+ // Trasa główna służy jako układ najwyższego poziomu
631
+ // Nie obsługuje 404 bezpośrednio - to jest delegowane do tras potomnych
632
+ // To utrzymuje główną trasę prostą i pozwala trasom świadomym locale zarządzać własną logiką 404
633
+ export const Route = createRootRoute({
634
+ component: Outlet,
635
+ });
636
+ ```
637
+
638
+ ```tsx fileName="src/routes/{-$locale}/route.tsx"
639
+ import { createFileRoute, Outlet, redirect } from "@tanstack/react-router";
640
+ import { validatePrefix } from "intlayer";
641
+ import { IntlayerProvider, useLocale } from "react-intlayer";
642
+
643
+ import { LocaleSwitcher } from "@/components/locale-switcher";
644
+ import { NotFoundComponent } from "./404";
645
+
646
+ export const Route = createFileRoute("/{-$locale}")({
647
+ // beforeLoad uruchamia się przed renderowaniem trasy (zarówno na serwerze, jak i kliencie)
648
+ // To idealne miejsce do walidacji prefiksu locale
649
+ beforeLoad: ({ params }) => {
650
+ // Pobierz locale z parametrów trasy (nie z nagłówków serwera, ponieważ beforeLoad działa zarówno na kliencie, jak i serwerze)
651
+ const localeParam = params.locale;
652
+
653
+ // validatePrefix sprawdza, czy locale jest prawidłowe zgodnie z konfiguracją intlayer
654
+ // Zwraca: { isValid: boolean, localePrefix: string }
655
+ // - isValid: true, jeśli prefiks pasuje do skonfigurowanego locale (lub jest pusty, gdy prefiks jest opcjonalny)
656
+ // - localePrefix: zwalidowany prefiks lub domyślny prefiks locale do przekierowań
657
+ const { isValid, localePrefix } = validatePrefix(localeParam);
658
+
659
+ if (isValid) {
660
+ // Locale jest prawidłowe, pozwól trasie renderować się normalnie
661
+ return;
662
+ }
663
+
664
+ // Nieprawidłowy prefiks locale (np. /xyz/about, gdzie "xyz" nie jest prawidłowym locale)
665
+ // Przekieruj do strony 404 z prawidłowym prefiksem locale
666
+ // To zapewnia, że strona 404 jest nadal prawidłowo zlokalizowana
667
+ throw redirect({
668
+ to: "/{-$locale}/404",
669
+ params: { locale: localePrefix },
670
+ });
671
+ },
672
+ component: RouteComponent,
673
+ // notFoundComponent jest wywoływane, gdy trasa potomna nie istnieje
674
+ // np. /en/nieistniejaca-strona wyzwala to w układzie /en
675
+ notFoundComponent: NotFoundLayout,
676
+ });
677
+
678
+ function RouteComponent() {
679
+ const { defaultLocale } = useLocale();
680
+ const { locale } = Route.useParams();
681
+
682
+ return (
683
+ // Owiń cały segment locale w IntlayerProvider
684
+ // Powraca do defaultLocale, gdy parametr locale jest undefined (tryb opcjonalnego prefiksu)
685
+ <IntlayerProvider locale={locale ?? defaultLocale}>
686
+ <Outlet />
687
+ </IntlayerProvider>
688
+ );
689
+ }
690
+
691
+ // NotFoundLayout owija komponent 404 w IntlayerProvider
692
+ // To zapewnia, że tłumaczenia nadal działają na stronie 404
693
+ function NotFoundLayout() {
694
+ const { defaultLocale } = useLocale();
695
+ const { locale } = Route.useParams();
696
+
697
+ return (
698
+ <IntlayerProvider locale={locale ?? defaultLocale}>
699
+ <NotFoundComponent />
700
+ {/* Dołącz LocaleSwitcher, aby użytkownicy mogli zmieniać język nawet na 404 */}
701
+ <LocaleSwitcher />
702
+ </IntlayerProvider>
703
+ );
704
+ }
705
+ ```
706
+
707
+ ```tsx fileName="src/routes/{-$locale}/$.tsx"
708
+ import { createFileRoute } from "@tanstack/react-router";
709
+
710
+ import { NotFoundComponent } from "./404";
711
+
712
+ // Trasa $ (splat/catch-all) pasuje do każdej ścieżki, która nie pasuje do innych tras
713
+ // np. /en/jakas/gleboko/zagniezdzona/niewazna/sciezka
714
+ // To zapewnia, że WSZYSTKIE niedopasowane ścieżki w locale wyświetlają stronę 404
715
+ // Bez tego niedopasowane głębokie ścieżki mogą wyświetlać pustą stronę lub błąd
716
+ export const Route = createFileRoute("/{-$locale}/$")({
717
+ component: NotFoundComponent,
718
+ });
719
+ ```
720
+
721
+ ---
722
+
723
+ ### Krok 15: Konfiguracja TypeScript (opcjonalnie)
594
724
 
595
725
  Intlayer używa rozszerzenia modułów (module augmentation), aby wykorzystać zalety TypeScript i wzmocnić Twoją bazę kodu.
596
726
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  createdAt: 2024-03-07
3
- updatedAt: 2024-03-07
3
+ updatedAt: 2025-12-10
4
4
  title: Jak przetłumaczyć swoją aplikację Vite i React – przewodnik i18n 2025
5
5
  description: Dowiedz się, jak dodać internacjonalizację (i18n) do swojej aplikacji Vite i React za pomocą Intlayer. Postępuj zgodnie z tym przewodnikiem, aby uczynić swoją aplikację wielojęzyczną.
6
6
  keywords:
@@ -85,10 +85,7 @@ yarn add vite-intlayer --save-dev
85
85
  ```
86
86
 
87
87
  - **intlayer**
88
-
89
- - **intlayer**
90
-
91
- Podstawowy pakiet, który dostarcza narzędzia do internacjonalizacji do zarządzania konfiguracją, tłumaczeń, [deklaracji treści](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/content_file.md), transpilecji oraz [poleceń CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_cli.md).
88
+ Główny pakiet dostarczający narzędzia do internacjonalizacji dla zarządzania konfiguracją, tłumaczeń, [deklaracji treści](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/content_file.md), transpilecji oraz [poleceń CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/cli/index.md).
92
89
 
93
90
  - **react-intlayer**
94
91
  Pakiet integrujący Intlayer z aplikacją React. Zapewnia dostawców kontekstu oraz hooki do internacjonalizacji w React.
@@ -464,7 +461,7 @@ module.exports = appContent;
464
461
  }
465
462
  ```
466
463
 
467
- > Twoje deklaracje zawartości mogą być definiowane w dowolnym miejscu w aplikacji, pod warunkiem, że zostaną umieszczone w katalogu `contentDir` (domyślnie `./src`). I będą miały rozszerzenie pliku deklaracji zawartości (domyślnie `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
464
+ > Twoje deklaracje zawartości mogą być definiowane w dowolnym miejscu w aplikacji, pod warunkiem, że zostaną umieszczone w katalogu `contentDir` (domyślnie `./src`) i będą miały rozszerzenie pliku deklaracji zawartości (domyślnie `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
468
465
 
469
466
  > Aby uzyskać więcej szczegółów, zapoznaj się z [dokumentacją deklaracji zawartości](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/content_file.md).
470
467
 
@@ -688,7 +685,7 @@ Przykład:
688
685
 
689
686
  > Domyślnie trasy nie mają prefiksu dla domyślnej lokalizacji. Jeśli chcesz dodać prefiks dla domyślnej lokalizacji, możesz ustawić opcję `middleware.prefixDefault` na `true` w swojej konfiguracji. Więcej informacji znajdziesz w [dokumentacji konfiguracji](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/configuration.md).
690
687
 
691
- Aby dodać lokalizowane routingi do swojej aplikacji, możesz utworzyć komponent `LocaleRouter`, który opakuje trasy Twojej aplikacji i obsłuży routing oparty na lokalizacji. Oto przykład z użyciem [React Router](https://reactrouter.com/home):
688
+ Aby dodać lokalizowany routing do swojej aplikacji, możesz utworzyć komponent `LocaleRouter`, który opakuje trasy Twojej aplikacji i obsłuży routing oparty na lokalizacji. Oto przykład z użyciem [React Router](https://reactrouter.com/home):
692
689
 
693
690
  ```tsx fileName="src/components/LocaleRouter.tsx" codeFormat="typescript"
694
691
  import { localeMap } from "intlayer"; // Funkcje narzędziowe i typy z 'intlayer'
@@ -709,6 +706,16 @@ export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
709
706
  path={`${urlPrefix}/*`}
710
707
  key={locale}
711
708
  element={
709
+ <IntlayerProvider locale={locale}>{children}</IntlayerProvider>
710
+ } // Opakowuje dzieci zarządzaniem lokalizacją
711
+ />
712
+ ))}
713
+ </Routes>
714
+ </BrowserRouter>
715
+ );
716
+ ```
717
+
718
+ ```jsx fileName="src/components/LocaleRouter.mjx" codeFormat="esm"
712
719
  import { localeMap } from 'intlayer'; // Funkcje narzędziowe i typy z 'intlayer'
713
720
  import type { FC, PropsWithChildren } from 'react'; // Typy React dla komponentów funkcyjnych i propsów
714
721
  import { IntlayerProvider } from 'react-intlayer'; // Provider dla kontekstu internacjonalizacji
@@ -716,7 +723,7 @@ import { BrowserRouter, Route, Routes } from 'react-router-dom'; // Komponenty r
716
723
 
717
724
  /**
718
725
  * Komponent routera, który ustawia trasy specyficzne dla lokalizacji.
719
- * Używa React Router do zarządzania nawigacją i renderowania lokalizowanych komponentów.
726
+ * Używa React Router do zarządzania nawigacją i renderowania zlokalizowanych komponentów.
720
727
  */
721
728
  export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
722
729
  <BrowserRouter>
@@ -728,7 +735,7 @@ export const LocaleRouter: FC<PropsWithChildren> = ({ children }) => (
728
735
  key={locale}
729
736
  element={
730
737
  <IntlayerProvider locale={locale}>{children}</IntlayerProvider>
731
- } // Opakowuje dzieci zarządzaniem lokalizacją
738
+ } // Owinie dzieci w zarządzanie lokalizacją
732
739
  />
733
740
  ))}
734
741
  </Routes>
@@ -1049,8 +1056,8 @@ const LocaleSwitcher = () => {
1049
1056
  > - [`getHTMLTextDir` hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/packages/intlayer/getHTMLTextDir.md)
1050
1057
  > - [`hrefLang` attribute](https://developers.google.com/search/docs/specialty/international/localized-versions?hl=fr)
1051
1058
  > - [`lang` attribute](https://developer.mozilla.org/pl/docs/Web/HTML/Global_attributes/lang)
1052
- > - [`dir` attribute`](https://developer.mozilla.org/pl/docs/Web/HTML/Global_attributes/dir)
1053
- > - [`aria-current` attribute`](https://developer.mozilla.org/pl/docs/Web/Accessibility/ARIA/Attributes/aria-current)
1059
+ > - [`dir` attribute](https://developer.mozilla.org/pl/docs/Web/HTML/Global_attributes/dir)
1060
+ > - [`aria-current` attribute](https://developer.mozilla.org/pl/docs/Web/Accessibility/ARIA/Attributes/aria-current)
1054
1061
 
1055
1062
  Poniżej znajduje się zaktualizowany **Krok 9** z dodatkowymi wyjaśnieniami i dopracowanymi przykładami kodu:
1056
1063
 
@@ -1231,9 +1238,9 @@ module.exports = App;
1231
1238
 
1232
1239
  Wprowadzając te zmiany, twoja aplikacja:
1233
1240
 
1234
- - Zapewni, że atrybut **language** (`lang`) poprawnie odzwierciedla aktualną lokalizację, co jest ważne dla SEO i zachowania przeglądarki.
1235
- - Dostosuje **kierunek tekstu** (`dir`) zgodnie z lokalizacją, poprawiając czytelność i użyteczność dla języków o różnych kierunkach czytania.
1236
- - Zapewni bardziej **dostępne** doświadczenie, ponieważ technologie wspomagające polegają na tych atrybutach, aby działać optymalnie.
1241
+ - Upewnij się, że atrybut **language** (`lang`) poprawnie odzwierciedla aktualną lokalizację, co jest ważne dla SEO i zachowania przeglądarki.
1242
+ - Dostosuj **kierunek tekstu** (`dir`) zgodnie z lokalizacją, poprawiając czytelność i użyteczność dla języków o różnych kierunkach czytania.
1243
+ - Zapewnij bardziej **dostępne** doświadczenie, ponieważ technologie wspomagające polegają na tych atrybutach, aby działać optymalnie.
1237
1244
 
1238
1245
  ### (Opcjonalny) Krok 10: Tworzenie lokalizowanego komponentu Link
1239
1246
 
@@ -1256,11 +1263,10 @@ import {
1256
1263
  } from "react";
1257
1264
  import { useLocale } from "react-intlayer";
1258
1265
 
1259
- export interface LinkProps
1260
- extends DetailedHTMLProps<
1261
- AnchorHTMLAttributes<HTMLAnchorElement>,
1262
- HTMLAnchorElement
1263
- > {}
1266
+ export interface LinkProps extends DetailedHTMLProps<
1267
+ AnchorHTMLAttributes<HTMLAnchorElement>,
1268
+ HTMLAnchorElement
1269
+ > {}
1264
1270
 
1265
1271
  /**
1266
1272
  * Funkcja pomocnicza do sprawdzania, czy dany URL jest zewnętrzny.
@@ -1434,5 +1440,3 @@ Aby uzyskać więcej informacji na temat korzystania z rozszerzenia, zapoznaj si
1434
1440
  ### Idź dalej
1435
1441
 
1436
1442
  Aby pójść dalej, możesz zaimplementować [edytor wizualny](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_visual_editor.md) lub wyodrębnić swoją zawartość, korzystając z [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_CMS.md).
1437
-
1438
- ---
@@ -22,6 +22,7 @@ slugs:
22
22
  - doc
23
23
  - plugin
24
24
  - sync-json
25
+ youtubeVideo: https://www.youtube.com/watch?v=MpGMxniDHNg
25
26
  history:
26
27
  - version: 6.1.6
27
28
  date: 2025-10-05
@@ -30,6 +31,8 @@ history:
30
31
 
31
32
  # Sync JSON (mosty i18n)
32
33
 
34
+ <iframe title="Jak zachować synchronizację tłumaczeń JSON z Intlayer" class="m-auto aspect-[16/9] w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/MpGMxniDHNg?autoplay=0&amp;origin=http://intlayer.org&amp;controls=0&amp;rel=1"/>
35
+
33
36
  Użyj Intlayer jako dodatku do istniejącego stosu i18n. Ta wtyczka utrzymuje synchronizację Twoich komunikatów JSON ze słownikami Intlayer, dzięki czemu możesz:
34
37
 
35
38
  - Zachować i18next, next-intl, react-intl, vue-i18n, next-translate, nuxt-i18n, Solid-i18next, svelte-i18n itp.
@@ -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: Introduz validatePrefix e adiciona o passo 14: Tratamento de páginas 404 com rotas localizadas.
22
25
  - version: 7.3.9
23
26
  date: 2025-12-05
24
- changes: Add step 13: Retrieve the locale in your server actions (Optional)
27
+ changes: Adiciona o passo 13: Recuperar o locale em suas server actions (Opcional)
25
28
  - version: 5.8.1
26
29
  date: 2025-09-09
27
30
  changes: Adicionado para Tanstack Start
@@ -612,7 +615,134 @@ export const getLocaleServer = createServerFn().handler(async () => {
612
615
 
613
616
  ---
614
617
 
615
- ### Passo 14: Configurar o TypeScript (Opcional)
618
+ ### Passo 14: Gerenciar páginas não encontradas (Opcional)
619
+
620
+ Quando um usuário visita uma página inexistente, você pode exibir uma página personalizada de não encontrada e o prefixo de locale pode afetar a forma como a página de não encontrada é acionada.
621
+
622
+ #### Entendendo o tratamento de 404 do TanStack Router com prefixos de locale
623
+
624
+ No TanStack Router, lidar com páginas 404 com rotas localizadas requer uma abordagem multicamadas:
625
+
626
+ 1. **Rota 404 dedicada**: Uma rota específica para exibir a interface 404
627
+ 2. **Validação no nível da rota**: Valida os prefixos de locale e redireciona os inválidos para 404
628
+ 3. **Rota catch-all**: Captura todos os caminhos não correspondentes dentro do segmento de locale
629
+
630
+ ```tsx fileName="src/routes/{-$locale}/404.tsx"
631
+ import { createFileRoute } from "@tanstack/react-router";
632
+
633
+ // Isso cria uma rota dedicada /[locale]/404
634
+ // É usada tanto como uma rota direta quanto importada como um componente em outros arquivos
635
+ export const Route = createFileRoute("/{-$locale}/404")({
636
+ component: NotFoundComponent,
637
+ });
638
+
639
+ // Exportado separadamente para que possa ser reutilizado em notFoundComponent e rotas catch-all
640
+ export function NotFoundComponent() {
641
+ return (
642
+ <div>
643
+ <h1>404</h1>
644
+ </div>
645
+ );
646
+ }
647
+ ```
648
+
649
+ ```tsx fileName="src/routes/__root.tsx"
650
+ import { createRootRoute } from "@tanstack/react-router";
651
+
652
+ // A rota raiz serve como o layout de nível superior
653
+ // Ela não trata 404s diretamente - isso é delegado às rotas filhas
654
+ // Isso mantém a raiz simples e permite que rotas conscientes de locale gerenciem sua própria lógica 404
655
+ export const Route = createRootRoute({
656
+ component: Outlet,
657
+ });
658
+ ```
659
+
660
+ ```tsx fileName="src/routes/{-$locale}/route.tsx"
661
+ import { createFileRoute, Outlet, redirect } from "@tanstack/react-router";
662
+ import { validatePrefix } from "intlayer";
663
+ import { IntlayerProvider, useLocale } from "react-intlayer";
664
+
665
+ import { LocaleSwitcher } from "@/components/locale-switcher";
666
+ import { NotFoundComponent } from "./404";
667
+
668
+ export const Route = createFileRoute("/{-$locale}")({
669
+ // beforeLoad executa antes da rota ser renderizada (tanto no servidor quanto no cliente)
670
+ // É o lugar ideal para validar o prefixo de locale
671
+ beforeLoad: ({ params }) => {
672
+ // Obter locale dos parâmetros da rota (não dos cabeçalhos do servidor, pois beforeLoad executa tanto no cliente quanto no servidor)
673
+ const localeParam = params.locale;
674
+
675
+ // validatePrefix verifica se o locale é válido de acordo com sua configuração intlayer
676
+ // Retorna: { isValid: boolean, localePrefix: string }
677
+ // - isValid: true se o prefixo corresponder a um locale configurado (ou estiver vazio quando o prefixo for opcional)
678
+ // - localePrefix: o prefixo validado ou o prefixo de locale padrão para redirecionamentos
679
+ const { isValid, localePrefix } = validatePrefix(localeParam);
680
+
681
+ if (isValid) {
682
+ // Locale é válido, permitir que a rota seja renderizada normalmente
683
+ return;
684
+ }
685
+
686
+ // Prefixo de locale inválido (por exemplo, /xyz/about onde "xyz" não é um locale válido)
687
+ // Redirecionar para a página 404 com um prefixo de locale válido
688
+ // Isso garante que a página 404 ainda esteja adequadamente localizada
689
+ throw redirect({
690
+ to: "/{-$locale}/404",
691
+ params: { locale: localePrefix },
692
+ });
693
+ },
694
+ component: RouteComponent,
695
+ // notFoundComponent é chamado quando uma rota filha não existe
696
+ // por exemplo, /en/pagina-inexistente dispara isso dentro do layout /en
697
+ notFoundComponent: NotFoundLayout,
698
+ });
699
+
700
+ function RouteComponent() {
701
+ const { defaultLocale } = useLocale();
702
+ const { locale } = Route.useParams();
703
+
704
+ return (
705
+ // Envolver todo o segmento de locale com IntlayerProvider
706
+ // Volta para defaultLocale quando o parâmetro locale é undefined (modo de prefixo opcional)
707
+ <IntlayerProvider locale={locale ?? defaultLocale}>
708
+ <Outlet />
709
+ </IntlayerProvider>
710
+ );
711
+ }
712
+
713
+ // NotFoundLayout envolve o componente 404 com IntlayerProvider
714
+ // Isso garante que as traduções ainda funcionem na página 404
715
+ function NotFoundLayout() {
716
+ const { defaultLocale } = useLocale();
717
+ const { locale } = Route.useParams();
718
+
719
+ return (
720
+ <IntlayerProvider locale={locale ?? defaultLocale}>
721
+ <NotFoundComponent />
722
+ {/* Incluir LocaleSwitcher para que os usuários possam alterar o idioma mesmo em 404 */}
723
+ <LocaleSwitcher />
724
+ </IntlayerProvider>
725
+ );
726
+ }
727
+ ```
728
+
729
+ ```tsx fileName="src/routes/{-$locale}/$.tsx"
730
+ import { createFileRoute } from "@tanstack/react-router";
731
+
732
+ import { NotFoundComponent } from "./404";
733
+
734
+ // A rota $ (splat/catch-all) corresponde a qualquer caminho que não corresponda a outras rotas
735
+ // por exemplo, /en/algum/caminho/profundamente/aninhado/invalido
736
+ // Isso garante que TODOS os caminhos não correspondentes dentro de um locale mostrem a página 404
737
+ // Sem isso, caminhos profundos não correspondentes podem mostrar uma página em branco ou erro
738
+ export const Route = createFileRoute("/{-$locale}/$")({
739
+ component: NotFoundComponent,
740
+ });
741
+ ```
742
+
743
+ ---
744
+
745
+ ### Passo 15: Configurar o TypeScript (Opcional)
616
746
 
617
747
  O Intlayer utiliza a ampliação de módulos para aproveitar os benefícios do TypeScript e fortalecer sua base de código.
618
748