@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(i18nブリッジ)
|
|
32
33
|
|
|
34
|
+
<iframe title="IntlayerでJSON翻訳を同期状態に保つ方法" 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
|
既存のi18nスタックにIntlayerをアドオンとして使用します。このプラグインはJSONメッセージをIntlayerの辞書と同期させるので、以下が可能です:
|
|
34
37
|
|
|
35
38
|
- i18next、next-intl、react-intl、vue-i18n、next-translate、nuxt-i18n、Solid-i18next、svelte-i18nなどをそのまま利用し続けることができます。
|
|
@@ -427,7 +427,7 @@ export const App = () => {
|
|
|
427
427
|
```tsx fileName="src/components/LocaleSwitcher.tsx"
|
|
428
428
|
import { type FC } from "react";
|
|
429
429
|
import { getLocaleName } from "intlayer";
|
|
430
|
-
import { useLocale } from "intlayer";
|
|
430
|
+
import { useLocale } from "react-intlayer";
|
|
431
431
|
|
|
432
432
|
export const LocaleSwitcher: FC = () => {
|
|
433
433
|
const { setLocale, availableLocales, locale } = useLocale();
|
|
@@ -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단계 추가: 서버 액션에서 locale 가져오기 (선택 사항)
|
|
25
28
|
- version: 5.8.1
|
|
26
29
|
date: 2025-09-09
|
|
27
30
|
changes: Tanstack Start용 추가
|
|
@@ -599,7 +602,134 @@ export const getLocaleServer = createServerFn().handler(async () => {
|
|
|
599
602
|
|
|
600
603
|
---
|
|
601
604
|
|
|
602
|
-
### 14단계:
|
|
605
|
+
### 14단계: 찾을 수 없는 페이지 관리 (선택 사항)
|
|
606
|
+
|
|
607
|
+
사용자가 존재하지 않는 페이지를 방문할 때 사용자 정의 찾을 수 없음 페이지를 표시할 수 있으며, 로케일 접두사는 찾을 수 없음 페이지가 트리거되는 방식에 영향을 줄 수 있습니다.
|
|
608
|
+
|
|
609
|
+
#### 로케일 접두사로 TanStack Router의 404 처리 이해하기
|
|
610
|
+
|
|
611
|
+
TanStack Router에서 현지화된 경로로 404 페이지를 처리하려면 다층 접근 방식이 필요합니다:
|
|
612
|
+
|
|
613
|
+
1. **전용 404 경로**: 404 UI를 표시하는 특정 경로
|
|
614
|
+
2. **경로 수준 검증**: 로케일 접두사를 검증하고 잘못된 접두사를 404로 리디렉션
|
|
615
|
+
3. **Catch-all 경로**: 로케일 세그먼트 내에서 일치하지 않는 모든 경로를 캡처
|
|
616
|
+
|
|
617
|
+
```tsx fileName="src/routes/{-$locale}/404.tsx"
|
|
618
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
619
|
+
|
|
620
|
+
// 이것은 전용 /[locale]/404 경로를 생성합니다
|
|
621
|
+
// 직접 경로로 사용되거나 다른 파일에서 컴포넌트로 가져올 수 있습니다
|
|
622
|
+
export const Route = createFileRoute("/{-$locale}/404")({
|
|
623
|
+
component: NotFoundComponent,
|
|
624
|
+
});
|
|
625
|
+
|
|
626
|
+
// notFoundComponent 및 catch-all 경로에서 재사용할 수 있도록 별도로 내보냅니다
|
|
627
|
+
export function NotFoundComponent() {
|
|
628
|
+
return (
|
|
629
|
+
<div>
|
|
630
|
+
<h1>404</h1>
|
|
631
|
+
</div>
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
```tsx fileName="src/routes/__root.tsx"
|
|
637
|
+
import { createRootRoute } from "@tanstack/react-router";
|
|
638
|
+
|
|
639
|
+
// 루트 경로는 최상위 레이아웃 역할을 합니다
|
|
640
|
+
// 404를 직접 처리하지 않습니다 - 이것은 자식 경로에 위임됩니다
|
|
641
|
+
// 이것은 루트를 단순하게 유지하고 로케일 인식 경로가 자체 404 로직을 관리할 수 있게 합니다
|
|
642
|
+
export const Route = createRootRoute({
|
|
643
|
+
component: Outlet,
|
|
644
|
+
});
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
```tsx fileName="src/routes/{-$locale}/route.tsx"
|
|
648
|
+
import { createFileRoute, Outlet, redirect } from "@tanstack/react-router";
|
|
649
|
+
import { validatePrefix } from "intlayer";
|
|
650
|
+
import { IntlayerProvider, useLocale } from "react-intlayer";
|
|
651
|
+
|
|
652
|
+
import { LocaleSwitcher } from "@/components/locale-switcher";
|
|
653
|
+
import { NotFoundComponent } from "./404";
|
|
654
|
+
|
|
655
|
+
export const Route = createFileRoute("/{-$locale}")({
|
|
656
|
+
// beforeLoad는 경로가 렌더링되기 전에 실행됩니다 (서버와 클라이언트 모두에서)
|
|
657
|
+
// 로케일 접두사를 검증하기에 이상적인 장소입니다
|
|
658
|
+
beforeLoad: ({ params }) => {
|
|
659
|
+
// 경로 매개변수에서 로케일 가져오기 (서버 헤더에서 가져오지 않음, beforeLoad는 클라이언트와 서버 모두에서 실행되기 때문)
|
|
660
|
+
const localeParam = params.locale;
|
|
661
|
+
|
|
662
|
+
// validatePrefix는 로케일이 intlayer 구성에 따라 유효한지 확인합니다
|
|
663
|
+
// 반환: { isValid: boolean, localePrefix: string }
|
|
664
|
+
// - isValid: 접두사가 구성된 로케일과 일치하면 true (또는 접두사가 선택 사항일 때 비어 있음)
|
|
665
|
+
// - localePrefix: 검증된 접두사 또는 리디렉션을 위한 기본 로케일 접두사
|
|
666
|
+
const { isValid, localePrefix } = validatePrefix(localeParam);
|
|
667
|
+
|
|
668
|
+
if (isValid) {
|
|
669
|
+
// 로케일이 유효합니다. 경로가 정상적으로 렌더링되도록 허용합니다
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// 잘못된 로케일 접두사 (예: "xyz"가 유효한 로케일이 아닌 /xyz/about)
|
|
674
|
+
// 유효한 로케일 접두사가 있는 404 페이지로 리디렉션
|
|
675
|
+
// 이것은 404 페이지가 여전히 제대로 현지화되도록 보장합니다
|
|
676
|
+
throw redirect({
|
|
677
|
+
to: "/{-$locale}/404",
|
|
678
|
+
params: { locale: localePrefix },
|
|
679
|
+
});
|
|
680
|
+
},
|
|
681
|
+
component: RouteComponent,
|
|
682
|
+
// notFoundComponent는 자식 경로가 존재하지 않을 때 호출됩니다
|
|
683
|
+
// 예: /en/존재하지-않는-페이지가 /en 레이아웃 내에서 이를 트리거합니다
|
|
684
|
+
notFoundComponent: NotFoundLayout,
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
function RouteComponent() {
|
|
688
|
+
const { defaultLocale } = useLocale();
|
|
689
|
+
const { locale } = Route.useParams();
|
|
690
|
+
|
|
691
|
+
return (
|
|
692
|
+
// 전체 로케일 세그먼트를 IntlayerProvider로 래핑
|
|
693
|
+
// 로케일 매개변수가 undefined일 때 defaultLocale로 폴백 (선택적 접두사 모드)
|
|
694
|
+
<IntlayerProvider locale={locale ?? defaultLocale}>
|
|
695
|
+
<Outlet />
|
|
696
|
+
</IntlayerProvider>
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
// NotFoundLayout는 404 컴포넌트를 IntlayerProvider로 래핑합니다
|
|
701
|
+
// 이것은 404 페이지에서 번역이 여전히 작동하도록 보장합니다
|
|
702
|
+
function NotFoundLayout() {
|
|
703
|
+
const { defaultLocale } = useLocale();
|
|
704
|
+
const { locale } = Route.useParams();
|
|
705
|
+
|
|
706
|
+
return (
|
|
707
|
+
<IntlayerProvider locale={locale ?? defaultLocale}>
|
|
708
|
+
<NotFoundComponent />
|
|
709
|
+
{/* 사용자가 404에서도 언어를 변경할 수 있도록 LocaleSwitcher 포함 */}
|
|
710
|
+
<LocaleSwitcher />
|
|
711
|
+
</IntlayerProvider>
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
```tsx fileName="src/routes/{-$locale}/$.tsx"
|
|
717
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
718
|
+
|
|
719
|
+
import { NotFoundComponent } from "./404";
|
|
720
|
+
|
|
721
|
+
// $ (splat/catch-all) 경로는 다른 경로와 일치하지 않는 모든 경로와 일치합니다
|
|
722
|
+
// 예: /en/어떤/깊게/중첩된/유효하지-않은/경로
|
|
723
|
+
// 이것은 로케일 내의 일치하지 않는 모든 경로가 404 페이지를 표시하도록 보장합니다
|
|
724
|
+
// 이것이 없으면 일치하지 않는 깊은 경로가 빈 페이지나 오류를 표시할 수 있습니다
|
|
725
|
+
export const Route = createFileRoute("/{-$locale}/$")({
|
|
726
|
+
component: NotFoundComponent,
|
|
727
|
+
});
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
---
|
|
731
|
+
|
|
732
|
+
### 15단계: TypeScript 구성 (선택 사항)
|
|
603
733
|
|
|
604
734
|
Intlayer는 모듈 확장을 사용하여 TypeScript의 이점을 활용하고 코드베이스를 더욱 견고하게 만듭니다.
|
|
605
735
|
|