@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
@@ -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 (ponti i18n)
32
33
 
34
+ <iframe title="Come mantenere sincronizzate le tue traduzioni JSON con 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
  Usa Intlayer come componente aggiuntivo al tuo stack i18n esistente. Questo plugin mantiene i tuoi messaggi JSON sincronizzati con i dizionari Intlayer così puoi:
34
37
 
35
38
  - Mantenere i18next, next-intl, react-intl, vue-i18n, next-translate, nuxt-i18n, Solid-i18next, svelte-i18n, ecc.
@@ -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: validatePrefix を導入し、ステップ14: ローカライズされたルートでの 404 ページ処理 を追加
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: ステップ13: サーバーアクション内でロケールを取得する方法(オプション)を追加
25
28
  - version: 5.8.1
26
29
  date: 2025-09-09
27
30
  changes: Tanstack Start 用に追加
@@ -594,7 +597,134 @@ export const getLocaleServer = createServerFn().handler(async () => {
594
597
 
595
598
  ---
596
599
 
597
- ### ステップ14: TypeScriptの設定(任意)
600
+ ### ステップ14: 見つからないページの管理(任意)
601
+
602
+ ユーザーが存在しないページにアクセスした場合、カスタムの見つからないページを表示でき、ロケールプレフィックスが見つからないページのトリガー方法に影響を与える可能性があります。
603
+
604
+ #### ロケールプレフィックスを使用したTanStack Routerの404処理を理解する
605
+
606
+ TanStack Routerでは、ローカライズされたルートで404ページを処理するには、多層的なアプローチが必要です:
607
+
608
+ 1. **専用の404ルート**: 404 UIを表示するための特定のルート
609
+ 2. **ルートレベルの検証**: ロケールプレフィックスを検証し、無効なものを404にリダイレクト
610
+ 3. **キャッチオールルート**: ロケールセグメント内で一致しないすべてのパスをキャプチャ
611
+
612
+ ```tsx fileName="src/routes/{-$locale}/404.tsx"
613
+ import { createFileRoute } from "@tanstack/react-router";
614
+
615
+ // これは専用の /[locale]/404 ルートを作成します
616
+ // 直接ルートとして使用されるか、他のファイルでコンポーネントとしてインポートされます
617
+ export const Route = createFileRoute("/{-$locale}/404")({
618
+ component: NotFoundComponent,
619
+ });
620
+
621
+ // notFoundComponent および catch-all ルートで再利用できるように個別にエクスポートされます
622
+ export function NotFoundComponent() {
623
+ return (
624
+ <div>
625
+ <h1>404</h1>
626
+ </div>
627
+ );
628
+ }
629
+ ```
630
+
631
+ ```tsx fileName="src/routes/__root.tsx"
632
+ import { createRootRoute } from "@tanstack/react-router";
633
+
634
+ // ルートルートは最上位レイアウトとして機能します
635
+ // 404を直接処理しません - それは子ルートに委任されます
636
+ // これにより、ルートをシンプルに保ち、ロケール対応ルートが独自の404ロジックを管理できるようになります
637
+ export const Route = createRootRoute({
638
+ component: Outlet,
639
+ });
640
+ ```
641
+
642
+ ```tsx fileName="src/routes/{-$locale}/route.tsx"
643
+ import { createFileRoute, Outlet, redirect } from "@tanstack/react-router";
644
+ import { validatePrefix } from "intlayer";
645
+ import { IntlayerProvider, useLocale } from "react-intlayer";
646
+
647
+ import { LocaleSwitcher } from "@/components/locale-switcher";
648
+ import { NotFoundComponent } from "./404";
649
+
650
+ export const Route = createFileRoute("/{-$locale}")({
651
+ // beforeLoadはルートがレンダリングされる前に実行されます(サーバーとクライアントの両方で)
652
+ // ロケールプレフィックスを検証するのに理想的な場所です
653
+ beforeLoad: ({ params }) => {
654
+ // ルートパラメータからロケールを取得(サーバーヘッダーからではない。beforeLoadはクライアントとサーバーの両方で実行されるため)
655
+ const localeParam = params.locale;
656
+
657
+ // validatePrefixは、ロケールがintlayer設定に従って有効かどうかをチェックします
658
+ // 戻り値: { isValid: boolean, localePrefix: string }
659
+ // - isValid: プレフィックスが設定されたロケールと一致する場合(またはプレフィックスがオプションの場合は空)はtrue
660
+ // - localePrefix: 検証されたプレフィックスまたはリダイレクト用のデフォルトのロケールプレフィックス
661
+ const { isValid, localePrefix } = validatePrefix(localeParam);
662
+
663
+ if (isValid) {
664
+ // ロケールが有効です。ルートが正常にレンダリングされるようにします
665
+ return;
666
+ }
667
+
668
+ // 無効なロケールプレフィックス(例: "xyz"が有効なロケールではない /xyz/about)
669
+ // 有効なロケールプレフィックスで404ページにリダイレクト
670
+ // これにより、404ページが適切にローカライズされたままになります
671
+ throw redirect({
672
+ to: "/{-$locale}/404",
673
+ params: { locale: localePrefix },
674
+ });
675
+ },
676
+ component: RouteComponent,
677
+ // notFoundComponentは子ルートが存在しないときに呼び出されます
678
+ // 例: /en/存在しないページが /en レイアウト内でこれをトリガーします
679
+ notFoundComponent: NotFoundLayout,
680
+ });
681
+
682
+ function RouteComponent() {
683
+ const { defaultLocale } = useLocale();
684
+ const { locale } = Route.useParams();
685
+
686
+ return (
687
+ // ロケールセグメント全体をIntlayerProviderでラップ
688
+ // ロケールパラメータがundefinedの場合、defaultLocaleにフォールバック(オプションプレフィックスモード)
689
+ <IntlayerProvider locale={locale ?? defaultLocale}>
690
+ <Outlet />
691
+ </IntlayerProvider>
692
+ );
693
+ }
694
+
695
+ // NotFoundLayoutは404コンポーネントをIntlayerProviderでラップします
696
+ // これにより、404ページで翻訳が引き続き機能することが保証されます
697
+ function NotFoundLayout() {
698
+ const { defaultLocale } = useLocale();
699
+ const { locale } = Route.useParams();
700
+
701
+ return (
702
+ <IntlayerProvider locale={locale ?? defaultLocale}>
703
+ <NotFoundComponent />
704
+ {/* ユーザーが404でも言語を変更できるようにLocaleSwitcherを含める */}
705
+ <LocaleSwitcher />
706
+ </IntlayerProvider>
707
+ );
708
+ }
709
+ ```
710
+
711
+ ```tsx fileName="src/routes/{-$locale}/$.tsx"
712
+ import { createFileRoute } from "@tanstack/react-router";
713
+
714
+ import { NotFoundComponent } from "./404";
715
+
716
+ // $ (splat/catch-all) ルートは、他のルートと一致しない任意のパスに一致します
717
+ // 例: /en/いくつかの/深く/ネストされた/無効な/パス
718
+ // これにより、ロケール内の一致しないすべてのパスが404ページを表示することが保証されます
719
+ // これがないと、一致しない深いパスが空白ページやエラーを表示する可能性があります
720
+ export const Route = createFileRoute("/{-$locale}/$")({
721
+ component: NotFoundComponent,
722
+ });
723
+ ```
724
+
725
+ ---
726
+
727
+ ### ステップ15: TypeScriptの設定(任意)
598
728
 
599
729
  Intlayerはモジュール拡張を使用して、TypeScriptの利点を活かし、コードベースを強化します。
600
730