@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
@@ -42,8 +42,25 @@ Dzięki Intlayer możesz:
42
42
 
43
43
  ## Przewodnik krok po kroku, jak skonfigurować Intlayer w aplikacji Vite i Vue
44
44
 
45
+ <Tab defaultTab="video">
46
+ <TabItem label="Wideo" value="video">
47
+
48
+ <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"/>
49
+
50
+ </TabItem>
51
+ <TabItem label="Kod" value="code">
52
+
45
53
  <iframe
46
54
  src="https://stackblitz.com/github/aymericzip/intlayer-vite-vue-template?embed=1&ctl=1&file=intlayer.config.ts"
55
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
56
+ title="Demo CodeSandbox - How to Internationalize your application using Intlayer"
57
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
58
+ loading="lazy"
59
+ />
60
+
61
+ </TabItem>
62
+ </Tab>
63
+
47
64
  Zobacz [Szablon aplikacji](https://github.com/aymericzip/intlayer-vite-vue-template) na GitHub.
48
65
 
49
66
  ### Krok 1: Instalacja zależności
@@ -590,53 +607,47 @@ Przykład:
590
607
  Najpierw zainstaluj Vue Router:
591
608
 
592
609
  ```bash packageManager="npm"
593
- npm install intlayer vue-router
610
+ npm install vue-router
594
611
  ```
595
612
 
596
613
  ```bash packageManager="pnpm"
597
- pnpm add intlayer vue-router
614
+ pnpm add vue-router
598
615
  ```
599
616
 
600
617
  ```bash packageManager="yarn"
601
- yarn add intlayer vue-router
618
+ yarn add vue-router
602
619
  ```
603
620
 
604
621
  Następnie utwórz konfigurację routera, która obsługuje routing oparty na lokalizacji:
605
622
 
606
623
  ```js fileName="src/router/index.ts"
607
624
  import {
608
- configuration,
609
- getPathWithoutLocale,
610
625
  localeFlatMap,
611
- type Locales,
626
+ type Locale,
612
627
  } from 'intlayer';
613
628
  import { createIntlayerClient } from 'vue-intlayer';
614
629
  import { createRouter, createWebHistory } from 'vue-router';
615
630
  import HomeView from './views/home/HomeView.vue';
616
631
  import RootView from './views/root/Root.vue';
617
632
 
618
- // Pobierz konfigurację internacjonalizacji
619
- const { internationalization, middleware } = configuration;
620
- const { defaultLocale } = internationalization;
621
-
622
633
  /**
623
634
  * Zadeklaruj trasy z lokalizowanymi ścieżkami i metadanymi.
624
635
  */
625
- const routes = localeFlatMap((localizedData) => [
636
+ const routes = localeFlatMap(({ urlPrefix, locale }) => [
626
637
  {
627
- path: `${localizedData.urlPrefix}/`,
628
- name: `Root-${localizedData.locale}`,
638
+ path: `${urlPrefix}/`,
639
+ name: `Root-${locale}`,
629
640
  component: RootView,
630
641
  meta: {
631
- locale: localizedData.locale,
642
+ locale,
632
643
  },
633
644
  },
634
645
  {
635
- path: `${localizedData.urlPrefix}/home`,
636
- name: `Home-${localizedData.locale}`,
646
+ path: `${urlPrefix}/home`,
647
+ name: `Home-${locale}`,
637
648
  component: HomeView,
638
649
  meta: {
639
- locale: localizedData.locale,
650
+ locale,
640
651
  },
641
652
  },
642
653
  ]);
@@ -651,23 +662,11 @@ export const router = createRouter({
651
662
  router.beforeEach((to, _from, next) => {
652
663
  const client = createIntlayerClient();
653
664
 
654
- const metaLocale = to.meta.locale as Locales | undefined;
665
+ const metaLocale = to.meta.locale as Locale;
655
666
 
656
- if (metaLocale) {
657
- // Ponowne użycie lokalizacji zdefiniowanej w meta trasy
658
- client.setLocale(metaLocale);
659
- next();
660
- } else {
661
- // Domyślne zachowanie: brak lokalizacji w meta, możliwa nieznaleziona trasa
662
- // Opcjonalnie: obsłuż 404 lub przekieruj do domyślnej lokalizacji
663
- client.setLocale(defaultLocale);
664
-
665
- if (middleware.prefixDefault) {
666
- next(`/${defaultLocale}${getPathWithoutLocale(to.path)}`);
667
- } else {
668
- next(getPathWithoutLocale(to.path));
669
- }
670
- }
667
+ // Ponowne użycie lokalizacji zdefiniowanej w meta trasy
668
+ client.setLocale(metaLocale);
669
+ next();
671
670
  });
672
671
  ```
673
672
 
@@ -799,7 +798,7 @@ watch(
799
798
  Wskazówka: Dla lepszego SEO i dostępności używaj tagów takich jak `<a href="/fr/home" hreflang="fr">` do linkowania do stron zlokalizowanych, jak pokazano w Kroku 10. Pozwala to wyszukiwarkom na prawidłowe wykrywanie i indeksowanie adresów URL specyficznych dla języka. Aby zachować zachowanie SPA, możesz zapobiec domyślnej nawigacji za pomocą @click.prevent, zmienić lokalizację używając useLocale oraz programowo nawigować za pomocą Vue Router.
800
799
 
801
800
  ```html
802
- <ol class="divide-text/20 divide-y divide-dashed overflow-y-auto p-1">
801
+ <ol>
803
802
  <li>
804
803
  <a
805
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: Adicionado para Tanstack Start
@@ -47,6 +50,27 @@ Com o Intlayer, você pode:
47
50
 
48
51
  ## Guia Passo a Passo para Configurar o Intlayer em uma Aplicação Tanstack Start
49
52
 
53
+ <Tab defaultTab="video">
54
+ <TabItem label="Video" value="video">
55
+
56
+ <iframe title="A melhor solução i18n para Tanstack Start? Descubra o 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 - Como internacionalizar sua aplicação usando 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
+ Veja o [Template de aplicação](https://github.com/aymericzip/intlayer-tanstack-start-template) no GitHub.
73
+
50
74
  ### Passo 1: Criar o Projeto
51
75
 
52
76
  Comece criando um novo projeto TanStack Start seguindo o guia [Iniciar novo projeto](https://tanstack.com/start/latest/docs/framework/react/quick-start) no site do TanStack Start.
@@ -539,7 +563,55 @@ export const Route = createFileRoute("/{-$locale}/")({
539
563
 
540
564
  ---
541
565
 
542
- ### Passo 13: Configurar o TypeScript (Opcional)
566
+ ### Passo 13: Recuperar a localidade em suas ações do servidor (Opcional)
567
+
568
+ Você pode querer acessar a localidade atual de dentro de suas ações do servidor ou endpoints de API.
569
+ Você pode fazer isso usando o auxiliar `getLocale` de `intlayer`.
570
+
571
+ Aqui está um exemplo usando as funções de servidor do TanStack Start:
572
+
573
+ ```tsx fileName="src/routes/{-$locale}/index.tsx"
574
+ import { createServerFn } from "@tanstack/react-start";
575
+ import {
576
+ getRequestHeader,
577
+ getRequestHeaders,
578
+ } from "@tanstack/react-start/server";
579
+ import { getCookie, getIntlayer, getLocale } from "intlayer";
580
+
581
+ export const getLocaleServer = createServerFn().handler(async () => {
582
+ const locale = await getLocale({
583
+ // Obtenha o cookie da solicitação (padrão: 'INTLAYER_LOCALE')
584
+ getCookie: (name) => {
585
+ const cookieString = getRequestHeader("cookie");
586
+
587
+ return getCookie(name, cookieString);
588
+ },
589
+ // Obtenha o cabeçalho da solicitação (padrão: 'x-intlayer-locale')
590
+ getHeader: (name) => getRequestHeader(name),
591
+ // Fallback usando negociação Accept-Language
592
+ getAllHeaders: async () => {
593
+ const headers = getRequestHeaders();
594
+ const result: Record<string, string> = {};
595
+
596
+ // Converta o TypedHeaders em um Record<string, string> simples
597
+ for (const [key, value] of headers.entries()) {
598
+ result[key] = value;
599
+ }
600
+
601
+ return result;
602
+ },
603
+ });
604
+
605
+ // Recupere algum conteúdo usando getIntlayer()
606
+ const content = getIntlayer("app", locale);
607
+
608
+ return { locale, content };
609
+ });
610
+ ```
611
+
612
+ ---
613
+
614
+ ### Passo 14: Configurar o TypeScript (Opcional)
543
615
 
544
616
  O Intlayer utiliza a ampliação de módulos para aproveitar os benefícios do TypeScript e fortalecer sua base de código.
545
617
 
@@ -39,6 +39,27 @@ Com o Intlayer, você pode:
39
39
 
40
40
  ## Guia Passo a Passo para Configurar o Intlayer em uma Aplicação Vite e Vue
41
41
 
42
+ <Tab defaultTab="video">
43
+ <TabItem label="Vídeo" 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="Código" 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
+ Veja o [Modelo de Aplicação](https://github.com/aymericzip/intlayer-vite-vue-template) no GitHub.
62
+
42
63
  ### Passo 1: Instalar Dependências
43
64
 
44
65
  Instale os pacotes necessários usando npm:
@@ -559,53 +580,47 @@ Exemplo:
559
580
  Primeiro, instale o Vue Router:
560
581
 
561
582
  ```bash packageManager="npm"
562
- npm install intlayer vue-router
583
+ npm install vue-router
563
584
  ```
564
585
 
565
586
  ```bash packageManager="pnpm"
566
- pnpm add intlayer vue-router
587
+ pnpm add vue-router
567
588
  ```
568
589
 
569
590
  ```bash packageManager="yarn"
570
- yarn add intlayer vue-router
591
+ yarn add vue-router
571
592
  ```
572
593
 
573
594
  Então, crie uma configuração de roteador que lide com o roteamento baseado em localidade:
574
595
 
575
596
  ```js fileName="src/router/index.ts"
576
597
  import {
577
- configuration,
578
- getPathWithoutLocale,
579
598
  localeFlatMap,
580
- type Locales,
599
+ type Locale,
581
600
  } from 'intlayer';
582
601
  import { createIntlayerClient } from 'vue-intlayer';
583
602
  import { createRouter, createWebHistory } from 'vue-router';
584
603
  import HomeView from './views/home/HomeView.vue';
585
604
  import RootView from './views/root/Root.vue';
586
605
 
587
- // Obter a configuração de internacionalização
588
- const { internationalization, middleware } = configuration;
589
- const { defaultLocale } = internationalization;
590
-
591
606
  /**
592
607
  * Declarar as rotas com caminhos e metadados específicos para cada localidade.
593
608
  */
594
- const routes = localeFlatMap((localizedData) => [
609
+ const routes = localeFlatMap(({ urlPrefix, locale }) => [
595
610
  {
596
- path: `${localizedData.urlPrefix}/`,
597
- name: `Root-${localizedData.locale}`,
611
+ path: `${urlPrefix}/`,
612
+ name: `Root-${locale}`,
598
613
  component: RootView,
599
614
  meta: {
600
- locale: localizedData.locale,
615
+ locale,
601
616
  },
602
617
  },
603
618
  {
604
- path: `${localizedData.urlPrefix}/home`,
605
- name: `Home-${localizedData.locale}`,
619
+ path: `${urlPrefix}/home`,
620
+ name: `Home-${locale}`,
606
621
  component: HomeView,
607
622
  meta: {
608
- locale: localizedData.locale,
623
+ locale,
609
624
  },
610
625
  },
611
626
  ]);
@@ -620,23 +635,11 @@ export const router = createRouter({
620
635
  router.beforeEach((to, _from, next) => {
621
636
  const client = createIntlayerClient();
622
637
 
623
- const metaLocale = to.meta.locale as Locales | undefined;
638
+ const metaLocale = to.meta.locale as Locale;
624
639
 
625
- if (metaLocale) {
626
- // Reutilizar a localidade definida no meta da rota
627
- client.setLocale(metaLocale);
628
- next();
629
- } else {
630
- // Fallback: sem localidade no meta, possivelmente rota não encontrada
631
- // Opcional: tratar 404 ou redirecionar para o locale padrão
632
- client.setLocale(defaultLocale);
633
-
634
- if (middleware.prefixDefault) {
635
- next(`/${defaultLocale}${getPathWithoutLocale(to.path)}`);
636
- } else {
637
- next(getPathWithoutLocale(to.path));
638
- }
639
- }
640
+ // Reutilizar a localidade definida no meta da rota
641
+ client.setLocale(metaLocale);
642
+ next();
640
643
  });
641
644
  ```
642
645
 
@@ -778,7 +781,7 @@ watch(
778
781
  Dica: Para melhor SEO e acessibilidade, use tags como `<a href="/fr/home" hreflang="fr">` para vincular às páginas localizadas, como mostrado no Passo 10. Isso permite que os motores de busca descubram e indexem corretamente URLs específicas de idioma. Para preservar o comportamento SPA, você pode impedir a navegação padrão com @click.prevent, alterar o locale usando useLocale e navegar programaticamente usando o Vue Router.
779
782
 
780
783
  ```html
781
- <ol class="divide-text/20 divide-y divide-dashed overflow-y-auto p-1">
784
+ <ol>
782
785
  <li>
783
786
  <a
784
787
  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 @@ history:
47
50
 
48
51
  ## Пошаговое руководство по настройке Intlayer в приложении Tanstack Start
49
52
 
53
+ <Tab defaultTab="video">
54
+ <TabItem label="Video" value="video">
55
+
56
+ <iframe title="Лучшее решение i18n для Tanstack Start? Откройте для себя 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
+ См. [Шаблон приложения](https://github.com/aymericzip/intlayer-tanstack-start-template) на GitHub.
73
+
50
74
  ### Шаг 1: Создайте проект
51
75
 
52
76
  Начните с создания нового проекта TanStack Start, следуя руководству [Start new project](https://tanstack.com/start/latest/docs/framework/react/quick-start) на сайте TanStack Start.
@@ -529,7 +553,55 @@ export const Route = createFileRoute("/{-$locale}/")({
529
553
 
530
554
  ---
531
555
 
532
- ### Шаг 13: Настройка TypeScript (необязательно)
556
+ ### Шаг 13: Получение локали в серверных действиях (необязательно)
557
+
558
+ Вы можете захотеть получить доступ к текущей локали внутри ваших серверных действий или конечных точек API.
559
+ Вы можете сделать это с помощью помощника `getLocale` из `intlayer`.
560
+
561
+ Вот пример использования серверных функций TanStack Start:
562
+
563
+ ```tsx fileName="src/routes/{-$locale}/index.tsx"
564
+ import { createServerFn } from "@tanstack/react-start";
565
+ import {
566
+ getRequestHeader,
567
+ getRequestHeaders,
568
+ } from "@tanstack/react-start/server";
569
+ import { getCookie, getIntlayer, getLocale } from "intlayer";
570
+
571
+ export const getLocaleServer = createServerFn().handler(async () => {
572
+ const locale = await getLocale({
573
+ // Получить cookie из запроса (по умолчанию: 'INTLAYER_LOCALE')
574
+ getCookie: (name) => {
575
+ const cookieString = getRequestHeader("cookie");
576
+
577
+ return getCookie(name, cookieString);
578
+ },
579
+ // Получить заголовок из запроса (по умолчанию: 'x-intlayer-locale')
580
+ getHeader: (name) => getRequestHeader(name),
581
+ // Резервный вариант с использованием согласования Accept-Language
582
+ getAllHeaders: async () => {
583
+ const headers = getRequestHeaders();
584
+ const result: Record<string, string> = {};
585
+
586
+ // Преобразовать TypedHeaders в простой Record<string, string>
587
+ for (const [key, value] of headers.entries()) {
588
+ result[key] = value;
589
+ }
590
+
591
+ return result;
592
+ },
593
+ });
594
+
595
+ // Получить контент с помощью getIntlayer()
596
+ const content = getIntlayer("app", locale);
597
+
598
+ return { locale, content };
599
+ });
600
+ ```
601
+
602
+ ---
603
+
604
+ ### Шаг 14: Настройка TypeScript (необязательно)
533
605
 
534
606
  Intlayer использует расширение модулей (module augmentation), чтобы использовать преимущества TypeScript и сделать вашу кодовую базу более надежной.
535
607
 
@@ -40,6 +40,27 @@ history:
40
40
 
41
41
  ## Пошаговое руководство по настройке Intlayer в приложении на Vite и Vue
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
+ Смотрите [Шаблон приложения](https://github.com/aymericzip/intlayer-vite-vue-template) на GitHub.
63
+
43
64
  ### Шаг 1: Установка зависимостей
44
65
 
45
66
  Установите необходимые пакеты с помощью npm:
@@ -562,53 +583,47 @@ const content = useIntlayer("app"); // Создайте связанный фа
562
583
  Сначала установите Vue Router:
563
584
 
564
585
  ```bash packageManager="npm"
565
- npm install intlayer vue-router
586
+ npm install vue-router
566
587
  ```
567
588
 
568
589
  ```bash packageManager="pnpm"
569
- pnpm add intlayer vue-router
590
+ pnpm add vue-router
570
591
  ```
571
592
 
572
593
  ```bash packageManager="yarn"
573
- yarn add intlayer vue-router
594
+ yarn add vue-router
574
595
  ```
575
596
 
576
597
  Затем создайте конфигурацию роутера, которая обрабатывает маршрутизацию на основе локали:
577
598
 
578
599
  ```js fileName="src/router/index.ts"
579
600
  import {
580
- configuration,
581
- getPathWithoutLocale,
582
601
  localeFlatMap,
583
- type Locales,
602
+ type Locale,
584
603
  } from 'intlayer';
585
604
  import { createIntlayerClient } from 'vue-intlayer';
586
605
  import { createRouter, createWebHistory } from 'vue-router';
587
606
  import HomeView from './views/home/HomeView.vue';
588
607
  import RootView from './views/root/Root.vue';
589
608
 
590
- // Получить конфигурацию интернационализации
591
- const { internationalization, middleware } = configuration;
592
- const { defaultLocale } = internationalization;
593
-
594
609
  /**
595
610
  * Объявить маршруты с путями и метаданными, специфичными для локали.
596
611
  */
597
- const routes = localeFlatMap((localizedData) => [
612
+ const routes = localeFlatMap(({ urlPrefix, locale }) => [
598
613
  {
599
- path: `${localizedData.urlPrefix}/`,
600
- name: `Root-${localizedData.locale}`,
614
+ path: `${urlPrefix}/`,
615
+ name: `Root-${locale}`,
601
616
  component: RootView,
602
617
  meta: {
603
- locale: localizedData.locale,
618
+ locale,
604
619
  },
605
620
  },
606
621
  {
607
- path: `${localizedData.urlPrefix}/home`,
608
- name: `Home-${localizedData.locale}`,
622
+ path: `${urlPrefix}/home`,
623
+ name: `Home-${locale}`,
609
624
  component: HomeView,
610
625
  meta: {
611
- locale: localizedData.locale,
626
+ locale,
612
627
  },
613
628
  },
614
629
  ]);
@@ -623,23 +638,11 @@ export const router = createRouter({
623
638
  router.beforeEach((to, _from, next) => {
624
639
  const client = createIntlayerClient();
625
640
 
626
- const metaLocale = to.meta.locale as Locales | undefined;
641
+ const metaLocale = to.meta.locale as Locale;
627
642
 
628
- if (metaLocale) {
629
- // Используем локаль, определённую в метаданных маршрута
630
- client.setLocale(metaLocale);
631
- next();
632
- } else {
633
- // Запасной вариант: локаль в метаданных отсутствует, возможно, маршрут не найден
634
- // Необязательно: обработка 404 или перенаправление на локаль по умолчанию
635
- client.setLocale(defaultLocale);
636
-
637
- if (middleware.prefixDefault) {
638
- next(`/${defaultLocale}${getPathWithoutLocale(to.path)}`);
639
- } else {
640
- next(getPathWithoutLocale(to.path));
641
- }
642
- }
643
+ // Используем локаль, определённую в метаданных маршрута
644
+ client.setLocale(metaLocale);
645
+ next();
643
646
  });
644
647
  ```
645
648
 
@@ -779,7 +782,7 @@ watch(
779
782
  Совет: Для лучшей SEO и доступности используйте теги вида `<a href="/fr/home" hreflang="fr">` для ссылок на локализованные страницы, как показано в Шаге 10. Это позволяет поисковым системам правильно обнаруживать и индексировать URL-адреса, специфичные для языка. Чтобы сохранить поведение SPA, вы можете предотвратить стандартную навигацию с помощью @click.prevent, изменить локаль с помощью useLocale и программно перейти с помощью Vue Router.
780
783
 
781
784
  ```html
782
- <ol class="divide-text/20 divide-y divide-dashed overflow-y-auto p-1">
785
+ <ol>
783
786
  <li>
784
787
  <a
785
788
  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: Doküman güncellemesi
@@ -50,6 +53,27 @@ Intlayer ile şunları yapabilirsiniz:
50
53
 
51
54
  ## Tanstack Start Uygulamasında Intlayer Kurulumu için Adım Adım Rehber
52
55
 
56
+ <Tab defaultTab="video">
57
+ <TabItem label="Video" value="video">
58
+
59
+ <iframe title="Tanstack Start için en iyi i18n çözümü mü? Intlayer'ı keşfedin" 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
+
64
+ <iframe
65
+ src="https://stackblitz.com/github/aymericzip/intlayer-tanstack-start-template?embed=1&ctl=1&file=intlayer.config.ts"
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"
67
+ title="Demo CodeSandbox - Intlayer kullanarak uygulamanızı nasıl uluslararasılaştıracağınız"
68
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
69
+ loading="lazy"
70
+ />
71
+
72
+ </TabItem>
73
+ </Tab>
74
+
75
+ GitHub'da [Uygulama Şablonu](https://github.com/aymericzip/intlayer-tanstack-start-template) sayfasına bakın.
76
+
53
77
  ### Adım 1: Proje Oluşturma
54
78
 
55
79
  TanStack Start web sitesindeki [Yeni proje başlatma](https://tanstack.com/start/latest/docs/framework/react/quick-start) rehberini takip ederek yeni bir TanStack Start projesi oluşturun.
@@ -542,7 +566,55 @@ export const Route = createFileRoute("/{-$locale}/")({
542
566
 
543
567
  ---
544
568
 
545
- ### Adım 13: TypeScript Yapılandırması (İsteğe Bağlı)
569
+ ### Step 13: Retrieve the locale in your server actions (Optional)
570
+
571
+ You may want to access the current locale from inside your server actions or API endpoints.
572
+ You can do this using the `getLocale` helper from `intlayer`.
573
+
574
+ Here's an example using TanStack Start's server functions:
575
+
576
+ ```tsx fileName="src/routes/{-$locale}/index.tsx"
577
+ import { createServerFn } from "@tanstack/react-start";
578
+ import {
579
+ getRequestHeader,
580
+ getRequestHeaders,
581
+ } from "@tanstack/react-start/server";
582
+ import { getCookie, getIntlayer, getLocale } from "intlayer";
583
+
584
+ export const getLocaleServer = createServerFn().handler(async () => {
585
+ const locale = await getLocale({
586
+ // Get the cookie from the request (default: 'INTLAYER_LOCALE')
587
+ getCookie: (name) => {
588
+ const cookieString = getRequestHeader("cookie");
589
+
590
+ return getCookie(name, cookieString);
591
+ },
592
+ // Get the header from the request (default: 'x-intlayer-locale')
593
+ getHeader: (name) => getRequestHeader(name),
594
+ // Fallback using Accept-Language negotiation
595
+ getAllHeaders: async () => {
596
+ const headers = getRequestHeaders();
597
+ const result: Record<string, string> = {};
598
+
599
+ // Convert the TypedHeaders into a plain Record<string, string>
600
+ for (const [key, value] of headers.entries()) {
601
+ result[key] = value;
602
+ }
603
+
604
+ return result;
605
+ },
606
+ });
607
+
608
+ // Retrieve some content using getIntlayer()
609
+ const content = getIntlayer("app", locale);
610
+
611
+ return { locale, content };
612
+ });
613
+ ```
614
+
615
+ ---
616
+
617
+ ### Adım 14: TypeScript Yapılandırması (İsteğe Bağlı)
546
618
 
547
619
  Intlayer, TypeScript'in avantajlarından yararlanmak ve kod tabanınızı daha güçlü hale getirmek için modül genişletme (module augmentation) kullanır.
548
620