@intlayer/docs 7.3.8 → 7.3.10

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 (35) hide show
  1. package/docs/ar/intlayer_with_tanstack.md +73 -1
  2. package/docs/ar/intlayer_with_vite+vue.md +37 -34
  3. package/docs/de/intlayer_with_tanstack.md +73 -1
  4. package/docs/de/intlayer_with_vite+vue.md +37 -34
  5. package/docs/en/intlayer_with_tanstack.md +63 -1
  6. package/docs/en/intlayer_with_vite+vue.md +27 -34
  7. package/docs/en-GB/intlayer_with_tanstack.md +73 -1
  8. package/docs/en-GB/intlayer_with_vite+vue.md +37 -34
  9. package/docs/es/intlayer_with_tanstack.md +73 -1
  10. package/docs/es/intlayer_with_vite+vue.md +37 -36
  11. package/docs/fr/intlayer_with_tanstack.md +73 -1
  12. package/docs/fr/intlayer_with_vite+vue.md +37 -36
  13. package/docs/hi/intlayer_with_tanstack.md +73 -1
  14. package/docs/hi/intlayer_with_vite+vue.md +37 -34
  15. package/docs/id/intlayer_with_tanstack.md +63 -1
  16. package/docs/id/intlayer_with_vite+vue.md +28 -35
  17. package/docs/it/intlayer_with_tanstack.md +73 -1
  18. package/docs/it/intlayer_with_vite+vue.md +37 -34
  19. package/docs/ja/intlayer_with_tanstack.md +73 -1
  20. package/docs/ja/intlayer_with_vite+vue.md +37 -34
  21. package/docs/ko/intlayer_with_tanstack.md +73 -1
  22. package/docs/ko/intlayer_with_vite+vue.md +37 -34
  23. package/docs/pl/intlayer_with_tanstack.md +63 -1
  24. package/docs/pl/intlayer_with_vite+vue.md +33 -34
  25. package/docs/pt/intlayer_with_tanstack.md +73 -1
  26. package/docs/pt/intlayer_with_vite+vue.md +37 -34
  27. package/docs/ru/intlayer_with_tanstack.md +73 -1
  28. package/docs/ru/intlayer_with_vite+vue.md +37 -34
  29. package/docs/tr/intlayer_with_tanstack.md +73 -1
  30. package/docs/tr/intlayer_with_vite+vue.md +37 -34
  31. package/docs/vi/intlayer_with_tanstack.md +63 -1
  32. package/docs/vi/intlayer_with_vite+vue.md +33 -34
  33. package/docs/zh/intlayer_with_tanstack.md +73 -1
  34. package/docs/zh/intlayer_with_vite+vue.md +37 -34
  35. package/package.json +6 -6
@@ -39,6 +39,27 @@ Con Intlayer, puoi:
39
39
 
40
40
  ## Guida passo-passo per configurare Intlayer in un'applicazione Vite e Vue
41
41
 
42
+ <Tab defaultTab="video">
43
+ <TabItem label="Video" value="video">
44
+
45
+ <iframe title="The best i18n solution for Vite and Vue? Discover 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/IE3XWkZ6a5U?autoplay=0&amp;origin=http://intlayer.org&amp;controls=0&amp;rel=1"/>
46
+
47
+ </TabItem>
48
+ <TabItem label="Codice" value="code">
49
+
50
+ <iframe
51
+ src="https://stackblitz.com/github/aymericzip/intlayer-vite-vue-template?embed=1&ctl=1&file=intlayer.config.ts"
52
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
53
+ title="Demo CodeSandbox - How to Internationalize your application using Intlayer"
54
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
55
+ loading="lazy"
56
+ />
57
+
58
+ </TabItem>
59
+ </Tab>
60
+
61
+ Vedi il [Modello di Applicazione](https://github.com/aymericzip/intlayer-vite-vue-template) su GitHub.
62
+
42
63
  ### Passo 1: Installa le dipendenze
43
64
 
44
65
  Installa i pacchetti necessari usando npm:
@@ -580,53 +601,47 @@ Esempio:
580
601
  Per prima cosa, installa Vue Router:
581
602
 
582
603
  ```bash packageManager="npm"
583
- npm install intlayer vue-router
604
+ npm install vue-router
584
605
  ```
585
606
 
586
607
  ```bash packageManager="pnpm"
587
- pnpm add intlayer vue-router
608
+ pnpm add vue-router
588
609
  ```
589
610
 
590
611
  ```bash packageManager="yarn"
591
- yarn add intlayer vue-router
612
+ yarn add vue-router
592
613
  ```
593
614
 
594
615
  Quindi, crea una configurazione del router che gestisca il routing basato sulla localizzazione:
595
616
 
596
617
  ```js fileName="src/router/index.ts"
597
618
  import {
598
- configuration,
599
- getPathWithoutLocale,
600
619
  localeFlatMap,
601
- type Locales,
620
+ type Locale,
602
621
  } from 'intlayer';
603
622
  import { createIntlayerClient } from 'vue-intlayer';
604
623
  import { createRouter, createWebHistory } from 'vue-router';
605
624
  import HomeView from './views/home/HomeView.vue';
606
625
  import RootView from './views/root/Root.vue';
607
626
 
608
- // Ottieni la configurazione per l'internazionalizzazione
609
- const { internationalization, middleware } = configuration;
610
- const { defaultLocale } = internationalization;
611
-
612
627
  /**
613
628
  * Dichiara le rotte con percorsi e metadati specifici per la localizzazione.
614
629
  */
615
- const routes = localeFlatMap((localizedData) => [
630
+ const routes = localeFlatMap(({ urlPrefix, locale }) => [
616
631
  {
617
- path: `${localizedData.urlPrefix}/`,
618
- name: `Root-${localizedData.locale}`,
632
+ path: `${urlPrefix}/`,
633
+ name: `Root-${locale}`,
619
634
  component: RootView,
620
635
  meta: {
621
- locale: localizedData.locale,
636
+ locale,
622
637
  },
623
638
  },
624
639
  {
625
- path: `${localizedData.urlPrefix}/home`,
626
- name: `Home-${localizedData.locale}`,
640
+ path: `${urlPrefix}/home`,
641
+ name: `Home-${locale}`,
627
642
  component: HomeView,
628
643
  meta: {
629
- locale: localizedData.locale,
644
+ locale,
630
645
  },
631
646
  },
632
647
  ]);
@@ -641,23 +656,11 @@ export const router = createRouter({
641
656
  router.beforeEach((to, _from, next) => {
642
657
  const client = createIntlayerClient();
643
658
 
644
- const metaLocale = to.meta.locale as Locales | undefined;
659
+ const metaLocale = to.meta.locale as Locale;
645
660
 
646
- if (metaLocale) {
647
- // Riutilizza la localizzazione definita nei meta della rotta
648
- client.setLocale(metaLocale);
649
- next();
650
- } else {
651
- // Fallback: nessuna localizzazione nei meta, possibile rotta non corrispondente
652
- // Opzionale: gestire il 404 o reindirizzare alla lingua predefinita
653
- client.setLocale(defaultLocale);
654
-
655
- if (middleware.prefixDefault) {
656
- next(`/${defaultLocale}${getPathWithoutLocale(to.path)}`);
657
- } else {
658
- next(getPathWithoutLocale(to.path));
659
- }
660
- }
661
+ // Riutilizza la localizzazione definita nei meta della rotta
662
+ client.setLocale(metaLocale);
663
+ next();
661
664
  });
662
665
  ```
663
666
 
@@ -795,7 +798,7 @@ watch(
795
798
  Suggerimento: Per una migliore SEO e accessibilità, usa tag come `<a href="/fr/home" hreflang="fr">` per collegarti alle pagine localizzate, come mostrato nel Passo 10. Questo permette ai motori di ricerca di scoprire e indicizzare correttamente gli URL specifici per lingua. Per preservare il comportamento SPA, puoi prevenire la navigazione predefinita con @click.prevent, cambiare la localizzazione usando useLocale e navigare programmaticamente con Vue Router.
796
799
 
797
800
  ```html
798
- <ol class="divide-text/20 divide-y divide-dashed overflow-y-auto p-1">
801
+ <ol>
799
802
  <li>
800
803
  <a
801
804
  hreflang="x-default"
@@ -18,6 +18,9 @@ slugs:
18
18
  - tanstack-start
19
19
  applicationTemplate: https://github.com/aymericzip/intlayer-tanstack-start-template
20
20
  history:
21
+ - version: 7.3.9
22
+ date: 2025-12-05
23
+ changes: Add step 13: Retrieve the locale in your server actions (Optional)
21
24
  - version: 5.8.1
22
25
  date: 2025-09-09
23
26
  changes: Tanstack Start 用に追加
@@ -47,6 +50,27 @@ Intlayerを使うことで、以下が可能になります:
47
50
 
48
51
  ## Tanstack StartアプリケーションでIntlayerをセットアップするステップバイステップガイド
49
52
 
53
+ <Tab defaultTab="video">
54
+ <TabItem label="Video" value="video">
55
+
56
+ <iframe title="Tanstack Startに最適なi18nソリューション?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/_XTdKVWaeqg?autoplay=0&amp;origin=http://intlayer.org&amp;controls=0&amp;rel=1"/>
57
+
58
+ </TabItem>
59
+ <TabItem label="Code" value="code">
60
+
61
+ <iframe
62
+ src="https://stackblitz.com/github/aymericzip/intlayer-tanstack-start-template?embed=1&ctl=1&file=intlayer.config.ts"
63
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
64
+ title="Demo CodeSandbox - Intlayerを使用してアプリケーションを国際化する方法"
65
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
66
+ loading="lazy"
67
+ />
68
+
69
+ </TabItem>
70
+ </Tab>
71
+
72
+ GitHubで[アプリケーションテンプレート](https://github.com/aymericzip/intlayer-tanstack-start-template)を参照してください。
73
+
50
74
  ### ステップ1:プロジェクトの作成
51
75
 
52
76
  TanStack Startの公式サイトにある[新規プロジェクトの開始](https://tanstack.com/start/latest/docs/framework/react/quick-start)ガイドに従って、新しいTanStack Startプロジェクトを作成します。
@@ -532,7 +556,55 @@ export const Route = createFileRoute("/{-$locale}/")({
532
556
 
533
557
  ---
534
558
 
535
- ### ステップ13: TypeScriptの設定(任意)
559
+ ### Step 13: Retrieve the locale in your server actions (Optional)
560
+
561
+ You may want to access the current locale from inside your server actions or API endpoints.
562
+ You can do this using the `getLocale` helper from `intlayer`.
563
+
564
+ Here's an example using TanStack Start's server functions:
565
+
566
+ ```tsx fileName="src/routes/{-$locale}/index.tsx"
567
+ import { createServerFn } from "@tanstack/react-start";
568
+ import {
569
+ getRequestHeader,
570
+ getRequestHeaders,
571
+ } from "@tanstack/react-start/server";
572
+ import { getCookie, getIntlayer, getLocale } from "intlayer";
573
+
574
+ export const getLocaleServer = createServerFn().handler(async () => {
575
+ const locale = await getLocale({
576
+ // Get the cookie from the request (default: 'INTLAYER_LOCALE')
577
+ getCookie: (name) => {
578
+ const cookieString = getRequestHeader("cookie");
579
+
580
+ return getCookie(name, cookieString);
581
+ },
582
+ // Get the header from the request (default: 'x-intlayer-locale')
583
+ getHeader: (name) => getRequestHeader(name),
584
+ // Fallback using Accept-Language negotiation
585
+ getAllHeaders: async () => {
586
+ const headers = getRequestHeaders();
587
+ const result: Record<string, string> = {};
588
+
589
+ // Convert the TypedHeaders into a plain Record<string, string>
590
+ for (const [key, value] of headers.entries()) {
591
+ result[key] = value;
592
+ }
593
+
594
+ return result;
595
+ },
596
+ });
597
+
598
+ // Retrieve some content using getIntlayer()
599
+ const content = getIntlayer("app", locale);
600
+
601
+ return { locale, content };
602
+ });
603
+ ```
604
+
605
+ ---
606
+
607
+ ### ステップ14: TypeScriptの設定(任意)
536
608
 
537
609
  Intlayerはモジュール拡張を使用して、TypeScriptの利点を活かし、コードベースを強化します。
538
610
 
@@ -40,6 +40,27 @@ Intlayer を使うと、以下が可能です:
40
40
 
41
41
  ## Vite と Vue アプリケーションに Intlayer をセットアップするステップバイステップガイド
42
42
 
43
+ <Tab defaultTab="video">
44
+ <TabItem label="ビデオ" value="video">
45
+
46
+ <iframe title="The best i18n solution for Vite and Vue? Discover 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/IE3XWkZ6a5U?autoplay=0&amp;origin=http://intlayer.org&amp;controls=0&amp;rel=1"/>
47
+
48
+ </TabItem>
49
+ <TabItem label="コード" value="code">
50
+
51
+ <iframe
52
+ src="https://stackblitz.com/github/aymericzip/intlayer-vite-vue-template?embed=1&ctl=1&file=intlayer.config.ts"
53
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
54
+ title="Demo CodeSandbox - How to Internationalize your application using Intlayer"
55
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
56
+ loading="lazy"
57
+ />
58
+
59
+ </TabItem>
60
+ </Tab>
61
+
62
+ GitHub の [アプリケーションテンプレート](https://github.com/aymericzip/intlayer-vite-vue-template) を参照してください。
63
+
43
64
  ### ステップ 1: 依存パッケージのインストール
44
65
 
45
66
  npm を使って必要なパッケージをインストールします:
@@ -570,53 +591,47 @@ Vueアプリケーションにローカライズされたルーティングを
570
591
  まず、Vue Routerをインストールします:
571
592
 
572
593
  ```bash packageManager="npm"
573
- npm install intlayer vue-router
594
+ npm install vue-router
574
595
  ```
575
596
 
576
597
  ```bash packageManager="pnpm"
577
- pnpm add intlayer vue-router
598
+ pnpm add vue-router
578
599
  ```
579
600
 
580
601
  ```bash packageManager="yarn"
581
- yarn add intlayer vue-router
602
+ yarn add vue-router
582
603
  ```
583
604
 
584
605
  次に、ロケールベースのルーティングを処理するルーター設定を作成します:
585
606
 
586
607
  ```js fileName="src/router/index.ts"
587
608
  import {
588
- configuration,
589
- getPathWithoutLocale,
590
609
  localeFlatMap,
591
- type Locales,
610
+ type Locale,
592
611
  } from 'intlayer';
593
612
  import { createIntlayerClient } from 'vue-intlayer';
594
613
  import { createRouter, createWebHistory } from 'vue-router';
595
614
  import HomeView from './views/home/HomeView.vue';
596
615
  import RootView from './views/root/Root.vue';
597
616
 
598
- // 国際化設定を取得
599
- const { internationalization, middleware } = configuration;
600
- const { defaultLocale } = internationalization;
601
-
602
617
  /**
603
618
  * ロケール固有のパスとメタデータを持つルートを宣言します。
604
619
  */
605
- const routes = localeFlatMap((localizedData) => [
620
+ const routes = localeFlatMap(({ urlPrefix, locale }) => [
606
621
  {
607
- path: `${localizedData.urlPrefix}/`,
608
- name: `Root-${localizedData.locale}`,
622
+ path: `${urlPrefix}/`,
623
+ name: `Root-${locale}`,
609
624
  component: RootView,
610
625
  meta: {
611
- locale: localizedData.locale,
626
+ locale,
612
627
  },
613
628
  },
614
629
  {
615
- path: `${localizedData.urlPrefix}/home`,
616
- name: `Home-${localizedData.locale}`,
630
+ path: `${urlPrefix}/home`,
631
+ name: `Home-${locale}`,
617
632
  component: HomeView,
618
633
  meta: {
619
- locale: localizedData.locale,
634
+ locale,
620
635
  },
621
636
  },
622
637
  ]);
@@ -631,23 +646,11 @@ export const router = createRouter({
631
646
  router.beforeEach((to, _from, next) => {
632
647
  const client = createIntlayerClient();
633
648
 
634
- const metaLocale = to.meta.locale as Locales | undefined;
649
+ const metaLocale = to.meta.locale as Locale;
635
650
 
636
- if (metaLocale) {
637
- // ルートのメタに定義されたロケールを再利用
638
- client.setLocale(metaLocale);
639
- next();
640
- } else {
641
- // フォールバック: メタにロケールがない場合、おそらく一致しないルート
642
- // オプション: 404を処理するか、デフォルトのロケールにリダイレクトする
643
- client.setLocale(defaultLocale);
644
-
645
- if (middleware.prefixDefault) {
646
- next(`/${defaultLocale}${getPathWithoutLocale(to.path)}`);
647
- } else {
648
- next(getPathWithoutLocale(to.path));
649
- }
650
- }
651
+ // ルートのメタに定義されたロケールを再利用
652
+ client.setLocale(metaLocale);
653
+ next();
651
654
  });
652
655
  ```
653
656
 
@@ -785,7 +788,7 @@ watch(
785
788
  ヒント: SEOとアクセシビリティを向上させるために、ステップ10で示したように、ローカライズされたページへのリンクには `<a href="/fr/home" hreflang="fr">` のようなタグを使用してください。これにより、検索エンジンは言語別のURLを正しく検出しインデックス化できます。SPAの動作を維持するためには、@click.preventでデフォルトのナビゲーションを防止し、useLocaleでロケールを変更し、Vue Routerを使ってプログラム的にナビゲートすることが可能です。
786
789
 
787
790
  ```html
788
- <ol class="divide-text/20 divide-y divide-dashed overflow-y-auto p-1">
791
+ <ol>
789
792
  <li>
790
793
  <a
791
794
  hreflang="x-default"
@@ -18,6 +18,9 @@ slugs:
18
18
  - tanstack-start
19
19
  applicationTemplate: https://github.com/aymericzip/intlayer-tanstack-start-template
20
20
  history:
21
+ - version: 7.3.9
22
+ date: 2025-12-05
23
+ changes: Add step 13: Retrieve the locale in your server actions (Optional)
21
24
  - version: 5.8.1
22
25
  date: 2025-09-09
23
26
  changes: Tanstack Start용 추가
@@ -47,6 +50,27 @@ Intlayer를 사용하면 다음을 할 수 있습니다:
47
50
 
48
51
  ## Tanstack Start 애플리케이션에서 Intlayer 설정 단계별 가이드
49
52
 
53
+ <Tab defaultTab="video">
54
+ <TabItem label="Video" value="video">
55
+
56
+ <iframe title="Tanstack Start를 위한 최고의 i18n 솔루션? 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/_XTdKVWaeqg?autoplay=0&amp;origin=http://intlayer.org&amp;controls=0&amp;rel=1"/>
57
+
58
+ </TabItem>
59
+ <TabItem label="Code" value="code">
60
+
61
+ <iframe
62
+ src="https://stackblitz.com/github/aymericzip/intlayer-tanstack-start-template?embed=1&ctl=1&file=intlayer.config.ts"
63
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
64
+ title="Demo CodeSandbox - Intlayer를 사용하여 애플리케이션을 국제화하는 방법"
65
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
66
+ loading="lazy"
67
+ />
68
+
69
+ </TabItem>
70
+ </Tab>
71
+
72
+ GitHub에서 [애플리케이션 템플릿](https://github.com/aymericzip/intlayer-tanstack-start-template)을 참조하세요.
73
+
50
74
  ### 1단계: 프로젝트 생성
51
75
 
52
76
  TanStack Start 웹사이트의 [새 프로젝트 시작하기](https://tanstack.com/start/latest/docs/framework/react/quick-start) 가이드를 따라 새 TanStack Start 프로젝트를 생성합니다.
@@ -537,7 +561,55 @@ export const Route = createFileRoute("/{-$locale}/")({
537
561
 
538
562
  ---
539
563
 
540
- ### 13단계: TypeScript 구성 (선택 사항)
564
+ ### Step 13: Retrieve the locale in your server actions (Optional)
565
+
566
+ You may want to access the current locale from inside your server actions or API endpoints.
567
+ You can do this using the `getLocale` helper from `intlayer`.
568
+
569
+ Here's an example using TanStack Start's server functions:
570
+
571
+ ```tsx fileName="src/routes/{-$locale}/index.tsx"
572
+ import { createServerFn } from "@tanstack/react-start";
573
+ import {
574
+ getRequestHeader,
575
+ getRequestHeaders,
576
+ } from "@tanstack/react-start/server";
577
+ import { getCookie, getIntlayer, getLocale } from "intlayer";
578
+
579
+ export const getLocaleServer = createServerFn().handler(async () => {
580
+ const locale = await getLocale({
581
+ // Get the cookie from the request (default: 'INTLAYER_LOCALE')
582
+ getCookie: (name) => {
583
+ const cookieString = getRequestHeader("cookie");
584
+
585
+ return getCookie(name, cookieString);
586
+ },
587
+ // Get the header from the request (default: 'x-intlayer-locale')
588
+ getHeader: (name) => getRequestHeader(name),
589
+ // Fallback using Accept-Language negotiation
590
+ getAllHeaders: async () => {
591
+ const headers = getRequestHeaders();
592
+ const result: Record<string, string> = {};
593
+
594
+ // Convert the TypedHeaders into a plain Record<string, string>
595
+ for (const [key, value] of headers.entries()) {
596
+ result[key] = value;
597
+ }
598
+
599
+ return result;
600
+ },
601
+ });
602
+
603
+ // Retrieve some content using getIntlayer()
604
+ const content = getIntlayer("app", locale);
605
+
606
+ return { locale, content };
607
+ });
608
+ ```
609
+
610
+ ---
611
+
612
+ ### 14단계: TypeScript 구성 (선택 사항)
541
613
 
542
614
  Intlayer는 모듈 확장을 사용하여 TypeScript의 이점을 활용하고 코드베이스를 더욱 견고하게 만듭니다.
543
615
 
@@ -40,6 +40,27 @@ Intlayer를 사용하면 다음을 할 수 있습니다:
40
40
 
41
41
  ## Vite와 Vue 애플리케이션에서 Intlayer 설정 단계별 가이드
42
42
 
43
+ <Tab defaultTab="video">
44
+ <TabItem label="비디오" value="video">
45
+
46
+ <iframe title="The best i18n solution for Vite and Vue? Discover 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/IE3XWkZ6a5U?autoplay=0&amp;origin=http://intlayer.org&amp;controls=0&amp;rel=1"/>
47
+
48
+ </TabItem>
49
+ <TabItem label="코드" value="code">
50
+
51
+ <iframe
52
+ src="https://stackblitz.com/github/aymericzip/intlayer-vite-vue-template?embed=1&ctl=1&file=intlayer.config.ts"
53
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
54
+ title="Demo CodeSandbox - How to Internationalize your application using Intlayer"
55
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
56
+ loading="lazy"
57
+ />
58
+
59
+ </TabItem>
60
+ </Tab>
61
+
62
+ GitHub에서 [애플리케이션 템플릿](https://github.com/aymericzip/intlayer-vite-vue-template)을 확인하세요.
63
+
43
64
  ### 1단계: 의존성 설치
44
65
 
45
66
  npm을 사용하여 필요한 패키지를 설치하세요:
@@ -574,53 +595,47 @@ Vue 애플리케이션에 지역화된 라우팅을 추가하는 것은 일반
574
595
  먼저, Vue Router를 설치하세요:
575
596
 
576
597
  ```bash packageManager="npm"
577
- npm install intlayer vue-router
598
+ npm install vue-router
578
599
  ```
579
600
 
580
601
  ```bash packageManager="pnpm"
581
- pnpm add intlayer vue-router
602
+ pnpm add vue-router
582
603
  ```
583
604
 
584
605
  ```bash packageManager="yarn"
585
- yarn add intlayer vue-router
606
+ yarn add vue-router
586
607
  ```
587
608
 
588
609
  그런 다음, 로케일 기반 라우팅을 처리하는 라우터 구성을 만듭니다:
589
610
 
590
611
  ```js fileName="src/router/index.ts"
591
612
  import {
592
- configuration,
593
- getPathWithoutLocale,
594
613
  localeFlatMap,
595
- type Locales,
614
+ type Locale,
596
615
  } from 'intlayer';
597
616
  import { createIntlayerClient } from 'vue-intlayer';
598
617
  import { createRouter, createWebHistory } from 'vue-router';
599
618
  import HomeView from './views/home/HomeView.vue';
600
619
  import RootView from './views/root/Root.vue';
601
620
 
602
- // 국제화 구성 가져오기
603
- const { internationalization, middleware } = configuration;
604
- const { defaultLocale } = internationalization;
605
-
606
621
  /**
607
622
  * 로케일별 경로와 메타데이터를 가진 라우트를 선언합니다.
608
623
  */
609
- const routes = localeFlatMap((localizedData) => [
624
+ const routes = localeFlatMap(({ urlPrefix, locale }) => [
610
625
  {
611
- path: `${localizedData.urlPrefix}/`,
612
- name: `Root-${localizedData.locale}`,
626
+ path: `${urlPrefix}/`,
627
+ name: `Root-${locale}`,
613
628
  component: RootView,
614
629
  meta: {
615
- locale: localizedData.locale,
630
+ locale,
616
631
  },
617
632
  },
618
633
  {
619
- path: `${localizedData.urlPrefix}/home`,
620
- name: `Home-${localizedData.locale}`,
634
+ path: `${urlPrefix}/home`,
635
+ name: `Home-${locale}`,
621
636
  component: HomeView,
622
637
  meta: {
623
- locale: localizedData.locale,
638
+ locale,
624
639
  },
625
640
  },
626
641
  ]);
@@ -635,23 +650,11 @@ export const router = createRouter({
635
650
  router.beforeEach((to, _from, next) => {
636
651
  const client = createIntlayerClient();
637
652
 
638
- const metaLocale = to.meta.locale as Locales | undefined;
653
+ const metaLocale = to.meta.locale as Locale;
639
654
 
640
- if (metaLocale) {
641
- // 라우트 메타에 정의된 로케일 재사용
642
- client.setLocale(metaLocale);
643
- next();
644
- } else {
645
- // 대체 처리: 메타에 로케일이 없거나, 일치하지 않는 라우트일 가능성
646
- // 선택 사항: 404 처리 또는 기본 로케일로 리디렉션
647
- client.setLocale(defaultLocale);
648
-
649
- if (middleware.prefixDefault) {
650
- next(`/${defaultLocale}${getPathWithoutLocale(to.path)}`);
651
- } else {
652
- next(getPathWithoutLocale(to.path));
653
- }
654
- }
655
+ // 라우트 메타에 정의된 로케일 재사용
656
+ client.setLocale(metaLocale);
657
+ next();
655
658
  });
656
659
  ```
657
660
 
@@ -789,7 +792,7 @@ watch(
789
792
  팁: 더 나은 SEO 및 접근성을 위해, 10단계에서 보여준 것처럼 `<a href="/fr/home" hreflang="fr">`와 같은 태그를 사용하여 지역화된 페이지에 링크하세요. 이렇게 하면 검색 엔진이 언어별 URL을 올바르게 발견하고 색인화할 수 있습니다. SPA 동작을 유지하려면 @click.prevent로 기본 내비게이션을 방지하고, useLocale을 사용해 로케일을 변경하며, Vue Router를 통해 프로그래밍 방식으로 이동할 수 있습니다.
790
793
 
791
794
  ```html
792
- <ol class="divide-text/20 divide-y divide-dashed overflow-y-auto p-1">
795
+ <ol>
793
796
  <li>
794
797
  <a
795
798
  hreflang="x-default"
@@ -18,6 +18,9 @@ slugs:
18
18
  - tanstack-start
19
19
  applicationTemplate: https://github.com/aymericzip/intlayer-tanstack-start-template
20
20
  history:
21
+ - version: 7.3.9
22
+ date: 2025-12-05
23
+ changes: Add step 13: Retrieve the locale in your server actions (Optional)
21
24
  - version: 6.5.2
22
25
  date: 2025-10-03
23
26
  changes: Aktualizacja dokumentacji
@@ -50,6 +53,14 @@ Dzięki Intlayer możesz:
50
53
 
51
54
  ## Przewodnik krok po kroku, jak skonfigurować Intlayer w aplikacji Tanstack Start
52
55
 
56
+ <Tab defaultTab="video">
57
+ <TabItem label="Video" value="video">
58
+
59
+ <iframe title="Najlepsze rozwiązanie i18n dla Tanstack Start? Odkryj 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/_XTdKVWaeqg?autoplay=0&amp;origin=http://intlayer.org&amp;controls=0&amp;rel=1"/>
60
+
61
+ </TabItem>
62
+ <TabItem label="Code" value="code">
63
+
53
64
  <iframe
54
65
  src="https://stackblitz.com/github/aymericzip/intlayer-tanstack-start-template?embed=1&ctl=1&file=intlayer.config.ts"
55
66
  className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
@@ -58,6 +69,9 @@ Dzięki Intlayer możesz:
58
69
  loading="lazy"
59
70
  />
60
71
 
72
+ </TabItem>
73
+ </Tab>
74
+
61
75
  Zobacz [Szablon aplikacji](https://github.com/aymericzip/intlayer-tanstack-start-template) na GitHub.
62
76
 
63
77
  ### Krok 1: Utwórz projekt
@@ -538,7 +552,55 @@ export const Route = createFileRoute("/{-$locale}/")({
538
552
 
539
553
  ---
540
554
 
541
- ### Krok 13: Konfiguracja TypeScript (opcjonalnie)
555
+ ### Step 13: Retrieve the locale in your server actions (Optional)
556
+
557
+ You may want to access the current locale from inside your server actions or API endpoints.
558
+ You can do this using the `getLocale` helper from `intlayer`.
559
+
560
+ Here's an example using TanStack Start's server functions:
561
+
562
+ ```tsx fileName="src/routes/{-$locale}/index.tsx"
563
+ import { createServerFn } from "@tanstack/react-start";
564
+ import {
565
+ getRequestHeader,
566
+ getRequestHeaders,
567
+ } from "@tanstack/react-start/server";
568
+ import { getCookie, getIntlayer, getLocale } from "intlayer";
569
+
570
+ export const getLocaleServer = createServerFn().handler(async () => {
571
+ const locale = await getLocale({
572
+ // Get the cookie from the request (default: 'INTLAYER_LOCALE')
573
+ getCookie: (name) => {
574
+ const cookieString = getRequestHeader("cookie");
575
+
576
+ return getCookie(name, cookieString);
577
+ },
578
+ // Get the header from the request (default: 'x-intlayer-locale')
579
+ getHeader: (name) => getRequestHeader(name),
580
+ // Fallback using Accept-Language negotiation
581
+ getAllHeaders: async () => {
582
+ const headers = getRequestHeaders();
583
+ const result: Record<string, string> = {};
584
+
585
+ // Convert the TypedHeaders into a plain Record<string, string>
586
+ for (const [key, value] of headers.entries()) {
587
+ result[key] = value;
588
+ }
589
+
590
+ return result;
591
+ },
592
+ });
593
+
594
+ // Retrieve some content using getIntlayer()
595
+ const content = getIntlayer("app", locale);
596
+
597
+ return { locale, content };
598
+ });
599
+ ```
600
+
601
+ ---
602
+
603
+ ### Krok 14: Konfiguracja TypeScript (opcjonalnie)
542
604
 
543
605
  Intlayer używa rozszerzenia modułów (module augmentation), aby wykorzystać zalety TypeScript i wzmocnić Twoją bazę kodu.
544
606