@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
|
@@ -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&origin=http://intlayer.org&controls=0&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:
|
|
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:
|
|
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
|
|