@intlayer/docs 7.3.5 → 7.3.6

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.
@@ -137,7 +137,7 @@ Configura il layout principale e i layout specifici per locale:
137
137
  #### Layout Principale
138
138
 
139
139
  ```tsx fileName="src/routes/{-$locale}/route.tsx"
140
- import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router";
140
+ import { createFileRoute, Outlet } from "@tanstack/react-router";
141
141
  import { IntlayerProvider, useLocale } from "react-intlayer";
142
142
 
143
143
  import { useI18nHTMLAttributes } from "@/hooks/useI18nHTMLAttributes";
@@ -401,16 +401,16 @@ import {
401
401
  getLocaleName,
402
402
  getPathWithoutLocale,
403
403
  getPrefix,
404
+ Locales,
404
405
  } from "intlayer";
405
- import { setLocaleInStorage, useIntlayer, useLocale } from "react-intlayer";
406
+ import { useLocale } from "react-intlayer";
406
407
 
407
408
  import { LocalizedLink, To } from "./localized-link";
408
409
 
409
410
  export const LocaleSwitcher: FC = () => {
410
- const { localeSwitcherLabel } = useIntlayer("locale-switcher");
411
411
  const { pathname } = useLocation();
412
412
 
413
- const { availableLocales, locale } = useLocale();
413
+ const { availableLocales, locale, setLocale } = useLocale();
414
414
 
415
415
  const pathWithoutLocale = getPathWithoutLocale(pathname);
416
416
 
@@ -420,25 +420,24 @@ export const LocaleSwitcher: FC = () => {
420
420
  <li key={localeEl}>
421
421
  <LocalizedLink
422
422
  aria-current={localeEl === locale ? "page" : undefined}
423
- aria-label={`${localeSwitcherLabel.value} ${getLocaleName(localeEl)}`}
424
- onClick={() => setLocaleInStorage(localeEl)}
423
+ onClick={() => setLocale(localeEl)}
425
424
  params={{ locale: getPrefix(localeEl).localePrefix }}
426
425
  >
427
426
  <span>
428
427
  {/* Lingua - es. FR */}
429
- {localeItem}
428
+ {localeEl}
430
429
  </span>
431
430
  <span>
432
431
  {/* Lingua nella sua stessa lingua - es. Français */}
433
- {getLocaleName(localeItem, locale)}
432
+ {getLocaleName(localeEl, locale)}
434
433
  </span>
435
- <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
434
+ <span dir={getHTMLTextDir(localeEl)} lang={localeEl}>
436
435
  {/* Lingua nella lingua corrente - es. Francés con la lingua corrente impostata su Locales.SPANISH */}
437
- {getLocaleName(localeItem)}
436
+ {getLocaleName(localeEl)}
438
437
  </span>
439
438
  <span dir="ltr" lang={Locales.ENGLISH}>
440
439
  {/* Lingua in inglese - es. French */}
441
- {getLocaleName(localeItem, Locales.ENGLISH)}
440
+ {getLocaleName(localeEl, Locales.ENGLISH)}
442
441
  </span>
443
442
  </LocalizedLink>
444
443
  </li>
@@ -473,7 +472,7 @@ export const useI18nHTMLAttributes = () => {
473
472
  Poi usalo nel tuo componente root:
474
473
 
475
474
  ```tsx fileName="src/routes/{-$locale}/index.tsx"
476
- import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router";
475
+ import { createFileRoute, Outlet } from "@tanstack/react-router";
477
476
  import { IntlayerProvider, useLocale } from "react-intlayer";
478
477
 
479
478
  import { useI18nHTMLAttributes } from "@/hooks/useI18nHTMLAttributes"; // importa il hook
@@ -513,18 +512,44 @@ import tsconfigPaths from "vite-tsconfig-paths";
513
512
 
514
513
  export default defineConfig({
515
514
  plugins: [
515
+ intlayerProxy(), // Il proxy dovrebbe essere posizionato prima del server se usi Nitro
516
516
  tailwindcss(),
517
517
  reactRouter(),
518
518
  tsconfigPaths(),
519
519
  intlayer(),
520
- intlayerProxy(),
521
520
  ],
522
521
  });
523
522
  ```
524
523
 
525
524
  ---
526
525
 
527
- ### Passo 12: Configurare TypeScript (Opzionale)
526
+ ### Passo 12: Internazionalizzare i metadati (Opzionale)
527
+
528
+ Puoi anche utilizzare l'hook `getIntlayer` per accedere ai tuoi dizionari di contenuto in tutta la tua applicazione:
529
+
530
+ ```tsx fileName="src/routes/{-$locale}/index.tsx"
531
+ import { createFileRoute } from "@tanstack/react-router";
532
+ import { getIntlayer } from "intlayer";
533
+
534
+ export const Route = createFileRoute("/{-$locale}/")({
535
+ component: RouteComponent,
536
+ head: ({ params }) => {
537
+ const { locale } = params;
538
+ const metaContent = getIntlayer("page-metadata", locale);
539
+
540
+ return {
541
+ meta: [
542
+ { title: metaContent.title },
543
+ { content: metaContent.description, name: "description" },
544
+ ],
545
+ };
546
+ },
547
+ });
548
+ ```
549
+
550
+ ---
551
+
552
+ ### Passo 13: Configurare TypeScript (Opzionale)
528
553
 
529
554
  Intlayer utilizza l'augmentation dei moduli per sfruttare i vantaggi di TypeScript e rendere il tuo codice più robusto.
530
555
 
@@ -542,32 +567,6 @@ Assicurati che la tua configurazione di TypeScript includa i tipi generati autom
542
567
 
543
568
  ---
544
569
 
545
- ### Passo 13: Adattare Nitro (Opzionale)
546
-
547
- Se stai utilizzando Nitro per il tuo output di produzione, nitro non includerà la directory `.intlayer` nella directory di output. Devi copiarla manualmente.
548
-
549
- Esempio utilizzando lo script di build:
550
-
551
- ```json5 fileName="package.json"
552
- {
553
- "scripts": {
554
- "dev": "vite dev --port 3000",
555
- "build": "vite build && cpr .intlayer .output/.intlayer", // Copia cartella .intlayer
556
- "serve": "vite preview",
557
- },
558
- }
559
- ```
560
-
561
- > cpr è usato per adattare il comando e farlo funzionare su Windows.
562
- > Dovrai installare l'utilità `cpr` per utilizzare questo comando.
563
- >
564
- > - `npm install --save-dev cpr`
565
- > - `yarn add --dev cpr`
566
- > - `pnpm add --save-dev cpr`
567
- > - `bun add --save-dev cpr`
568
-
569
- ---
570
-
571
570
  ### Configurazione Git
572
571
 
573
572
  Si consiglia di ignorare i file generati da Intlayer. Questo ti permette di evitare di committarli nel tuo repository Git.
@@ -136,7 +136,7 @@ export default config;
136
136
  #### ルートレイアウト
137
137
 
138
138
  ```tsx fileName="src/routes/{-$locale}/route.tsx"
139
- import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router";
139
+ import { createFileRoute, Outlet } from "@tanstack/react-router";
140
140
  import { IntlayerProvider, useLocale } from "react-intlayer";
141
141
 
142
142
  import { useI18nHTMLAttributes } from "@/hooks/useI18nHTMLAttributes";
@@ -384,16 +384,16 @@ import {
384
384
  getLocaleName,
385
385
  getPathWithoutLocale,
386
386
  getPrefix,
387
+ Locales,
387
388
  } from "intlayer";
388
- import { setLocaleInStorage, useIntlayer, useLocale } from "react-intlayer";
389
+ import { useLocale } from "react-intlayer";
389
390
 
390
391
  import { LocalizedLink, To } from "./localized-link";
391
392
 
392
393
  export const LocaleSwitcher: FC = () => {
393
- const { localeSwitcherLabel } = useIntlayer("locale-switcher");
394
394
  const { pathname } = useLocation();
395
395
 
396
- const { availableLocales, locale } = useLocale();
396
+ const { availableLocales, locale, setLocale } = useLocale();
397
397
 
398
398
  const pathWithoutLocale = getPathWithoutLocale(pathname);
399
399
 
@@ -403,25 +403,24 @@ export const LocaleSwitcher: FC = () => {
403
403
  <li key={localeEl}>
404
404
  <LocalizedLink
405
405
  aria-current={localeEl === locale ? "page" : undefined}
406
- aria-label={`${localeSwitcherLabel.value} ${getLocaleName(localeEl)}`}
407
- onClick={() => setLocaleInStorage(localeEl)}
406
+ onClick={() => setLocale(localeEl)}
408
407
  params={{ locale: getPrefix(localeEl).localePrefix }}
409
408
  >
410
409
  <span>
411
410
  {/* ロケール - 例: FR */}
412
- {localeItem}
411
+ {localeEl}
413
412
  </span>
414
413
  <span>
415
414
  {/* 自身のロケールでの言語名 - 例: Français */}
416
- {getLocaleName(localeItem, locale)}
415
+ {getLocaleName(localeEl, locale)}
417
416
  </span>
418
- <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
417
+ <span dir={getHTMLTextDir(localeEl)} lang={localeEl}>
419
418
  {/* 現在のロケールでの言語名 - 例: Locales.SPANISHに設定された場合のFrancés */}
420
- {getLocaleName(localeItem)}
419
+ {getLocaleName(localeEl)}
421
420
  </span>
422
421
  <span dir="ltr" lang={Locales.ENGLISH}>
423
422
  {/* 英語での言語名 - 例: French */}
424
- {getLocaleName(localeItem, Locales.ENGLISH)}
423
+ {getLocaleName(localeEl, Locales.ENGLISH)}
425
424
  </span>
426
425
  </LocalizedLink>
427
426
  </li>
@@ -456,7 +455,7 @@ export const useI18nHTMLAttributes = () => {
456
455
  次に、ルートコンポーネントでこれを使用します:
457
456
 
458
457
  ```tsx fileName="src/routes/{-$locale}/index.tsx"
459
- import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router";
458
+ import { createFileRoute, Outlet } from "@tanstack/react-router";
460
459
  import { IntlayerProvider, useLocale } from "react-intlayer";
461
460
 
462
461
  import { useI18nHTMLAttributes } from "@/hooks/useI18nHTMLAttributes"; // フックをインポート
@@ -496,18 +495,44 @@ import tsconfigPaths from "vite-tsconfig-paths";
496
495
 
497
496
  export default defineConfig({
498
497
  plugins: [
498
+ intlayerProxy(), // Nitroを使用する場合、プロキシはサーバーの前に配置する必要があります
499
499
  tailwindcss(),
500
500
  reactRouter(),
501
501
  tsconfigPaths(),
502
502
  intlayer(),
503
- intlayerProxy(),
504
503
  ],
505
504
  });
506
505
  ```
507
506
 
508
507
  ---
509
508
 
510
- ### ステップ12: TypeScriptの設定(任意)
509
+ ### ステップ12: メタデータの国際化(任意)
510
+
511
+ アプリケーション全体でコンテンツ辞書にアクセスするために、`getIntlayer` フックを使用することもできます:
512
+
513
+ ```tsx fileName="src/routes/{-$locale}/index.tsx"
514
+ import { createFileRoute } from "@tanstack/react-router";
515
+ import { getIntlayer } from "intlayer";
516
+
517
+ export const Route = createFileRoute("/{-$locale}/")({
518
+ component: RouteComponent,
519
+ head: ({ params }) => {
520
+ const { locale } = params;
521
+ const metaContent = getIntlayer("page-metadata", locale);
522
+
523
+ return {
524
+ meta: [
525
+ { title: metaContent.title },
526
+ { content: metaContent.description, name: "description" },
527
+ ],
528
+ };
529
+ },
530
+ });
531
+ ```
532
+
533
+ ---
534
+
535
+ ### ステップ13: TypeScriptの設定(任意)
511
536
 
512
537
  Intlayerはモジュール拡張を使用して、TypeScriptの利点を活かし、コードベースを強化します。
513
538
 
@@ -525,32 +550,6 @@ TypeScriptの設定に自動生成された型が含まれていることを確
525
550
 
526
551
  ---
527
552
 
528
- ### ステップ13: Nitroの調整(任意)
529
-
530
- 本番出力にNitroを使用している場合、nitroは出力ディレクトリに `.intlayer` ディレクトリを含めません。手動でコピーする必要があります。
531
-
532
- ビルドスクリプトを使用した例:
533
-
534
- ```json5 fileName="package.json"
535
- {
536
- "scripts": {
537
- "dev": "vite dev --port 3000",
538
- "build": "vite build && cpr -r .intlayer .output/.intlayer", // .intlayerフォルダをコピー
539
- "serve": "vite preview",
540
- },
541
- }
542
- ```
543
-
544
- > cprはWindowsで機能するようにコマンドを適応させるために使用されます。
545
- > このコマンドを使用するには、`cpr` ユーティリティをインストールする必要があります。
546
- >
547
- > - `npm install --save-dev cpr`
548
- > - `yarn add --dev cpr`
549
- > - `pnpm add --save-dev cpr`
550
- > - `bun add --save-dev cpr`
551
-
552
- ---
553
-
554
553
  ### Gitの設定
555
554
 
556
555
  Intlayerによって生成されたファイルはGitリポジトリにコミットしないように、無視することを推奨します。
@@ -132,7 +132,7 @@ export default config;
132
132
  #### 루트 레이아웃
133
133
 
134
134
  ```tsx fileName="src/routes/{-$locale}/route.tsx"
135
- import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router";
135
+ import { createFileRoute, Outlet } from "@tanstack/react-router";
136
136
  import { IntlayerProvider, useLocale } from "react-intlayer";
137
137
 
138
138
  import { useI18nHTMLAttributes } from "@/hooks/useI18nHTMLAttributes";
@@ -389,16 +389,16 @@ import {
389
389
  getLocaleName,
390
390
  getPathWithoutLocale,
391
391
  getPrefix,
392
+ Locales,
392
393
  } from "intlayer";
393
- import { setLocaleInStorage, useIntlayer, useLocale } from "react-intlayer";
394
+ import { useLocale } from "react-intlayer";
394
395
 
395
396
  import { LocalizedLink, To } from "./localized-link";
396
397
 
397
398
  export const LocaleSwitcher: FC = () => {
398
- const { localeSwitcherLabel } = useIntlayer("locale-switcher");
399
399
  const { pathname } = useLocation();
400
400
 
401
- const { availableLocales, locale } = useLocale();
401
+ const { availableLocales, locale, setLocale } = useLocale();
402
402
 
403
403
  const pathWithoutLocale = getPathWithoutLocale(pathname);
404
404
 
@@ -408,25 +408,24 @@ export const LocaleSwitcher: FC = () => {
408
408
  <li key={localeEl}>
409
409
  <LocalizedLink
410
410
  aria-current={localeEl === locale ? "page" : undefined}
411
- aria-label={`${localeSwitcherLabel.value} ${getLocaleName(localeEl)}`}
412
- onClick={() => setLocaleInStorage(localeEl)}
411
+ onClick={() => setLocale(localeEl)}
413
412
  params={{ locale: getPrefix(localeEl).localePrefix }}
414
413
  >
415
414
  <span>
416
415
  {/* 로케일 - 예: FR */}
417
- {localeItem}
416
+ {localeEl}
418
417
  </span>
419
418
  <span>
420
419
  {/* 해당 로케일 내 언어 - 예: Français */}
421
- {getLocaleName(localeItem, locale)}
420
+ {getLocaleName(localeEl, locale)}
422
421
  </span>
423
- <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
422
+ <span dir={getHTMLTextDir(localeEl)} lang={localeEl}>
424
423
  {/* 현재 로케일 내 언어 - 예: 현재 로케일이 Locales.SPANISH일 때 Francés */}
425
- {getLocaleName(localeItem)}
424
+ {getLocaleName(localeEl)}
426
425
  </span>
427
426
  <span dir="ltr" lang={Locales.ENGLISH}>
428
427
  {/* 영어로 된 언어 - 예: French */}
429
- {getLocaleName(localeItem, Locales.ENGLISH)}
428
+ {getLocaleName(localeEl, Locales.ENGLISH)}
430
429
  </span>
431
430
  </LocalizedLink>
432
431
  </li>
@@ -461,7 +460,7 @@ export const useI18nHTMLAttributes = () => {
461
460
  그런 다음 루트 컴포넌트에서 사용하세요:
462
461
 
463
462
  ```tsx fileName="src/routes/{-$locale}/index.tsx"
464
- import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router";
463
+ import { createFileRoute, Outlet } from "@tanstack/react-router";
465
464
  import { IntlayerProvider, useLocale } from "react-intlayer";
466
465
 
467
466
  import { useI18nHTMLAttributes } from "@/hooks/useI18nHTMLAttributes"; // 훅을 임포트합니다.
@@ -501,18 +500,44 @@ import tsconfigPaths from "vite-tsconfig-paths";
501
500
 
502
501
  export default defineConfig({
503
502
  plugins: [
503
+ intlayerProxy(), // Nitro를 사용하는 경우 프록시는 서버 앞에 배치해야 합니다
504
504
  tailwindcss(),
505
505
  reactRouter(),
506
506
  tsconfigPaths(),
507
507
  intlayer(),
508
- intlayerProxy(),
509
508
  ],
510
509
  });
511
510
  ```
512
511
 
513
512
  ---
514
513
 
515
- ### 12단계: TypeScript 구성 (선택 사항)
514
+ ### 12단계: 메타데이터 국제화 (선택 사항)
515
+
516
+ 애플리케이션 전체에서 콘텐츠 사전에 액세스하기 위해 `getIntlayer` 훅을 사용할 수도 있습니다:
517
+
518
+ ```tsx fileName="src/routes/{-$locale}/index.tsx"
519
+ import { createFileRoute } from "@tanstack/react-router";
520
+ import { getIntlayer } from "intlayer";
521
+
522
+ export const Route = createFileRoute("/{-$locale}/")({
523
+ component: RouteComponent,
524
+ head: ({ params }) => {
525
+ const { locale } = params;
526
+ const metaContent = getIntlayer("page-metadata", locale);
527
+
528
+ return {
529
+ meta: [
530
+ { title: metaContent.title },
531
+ { content: metaContent.description, name: "description" },
532
+ ],
533
+ };
534
+ },
535
+ });
536
+ ```
537
+
538
+ ---
539
+
540
+ ### 13단계: TypeScript 구성 (선택 사항)
516
541
 
517
542
  Intlayer는 모듈 확장을 사용하여 TypeScript의 이점을 활용하고 코드베이스를 더욱 견고하게 만듭니다.
518
543
 
@@ -530,32 +555,6 @@ TypeScript 구성에 자동 생성된 타입이 포함되어 있는지 확인하
530
555
 
531
556
  ---
532
557
 
533
- ### 13단계: Nitro 조정 (선택 사항)
534
-
535
- 프로덕션 출력에 Nitro를 사용하는 경우, nitro는 출력 디렉토리에 `.intlayer` 디렉토리를 포함하지 않습니다. 수동으로 복사해야 합니다.
536
-
537
- 빌드 스크립트를 사용한 예제:
538
-
539
- ```json5 fileName="package.json"
540
- {
541
- "scripts": {
542
- "dev": "vite dev --port 3000",
543
- "build": "vite build && cpr -r .intlayer .output/.intlayer", // .intlayer 폴더 복사
544
- "serve": "vite preview",
545
- },
546
- }
547
- ```
548
-
549
- > cpr은 Windows에서 작동하도록 명령을 조정하는 데 사용됩니다.
550
- > 이 명령을 사용하려면 `cpr` 유틸리티를 설치해야 합니다.
551
- >
552
- > - `npm install --save-dev cpr`
553
- > - `yarn add --dev cpr`
554
- > - `pnpm add --save-dev cpr`
555
- > - `bun add --save-dev cpr`
556
-
557
- ---
558
-
559
558
  ### Git 구성
560
559
 
561
560
  Intlayer가 생성한 파일은 Git 저장소에 커밋하지 않도록 무시하는 것이 권장됩니다.
@@ -147,7 +147,7 @@ Skonfiguruj swój główny layout oraz layouty specyficzne dla lokalizacji:
147
147
  #### Główny Layout
148
148
 
149
149
  ```tsx fileName="src/routes/{-$locale}/route.tsx"
150
- import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router";
150
+ import { createFileRoute, Outlet } from "@tanstack/react-router";
151
151
  import { IntlayerProvider, useLocale } from "react-intlayer";
152
152
 
153
153
  import { useI18nHTMLAttributes } from "@/hooks/useI18nHTMLAttributes";
@@ -390,16 +390,16 @@ import {
390
390
  getLocaleName,
391
391
  getPathWithoutLocale,
392
392
  getPrefix,
393
+ Locales,
393
394
  } from "intlayer";
394
- import { setLocaleInStorage, useIntlayer, useLocale } from "react-intlayer";
395
+ import { useLocale } from "react-intlayer";
395
396
 
396
397
  import { LocalizedLink, To } from "./localized-link";
397
398
 
398
399
  export const LocaleSwitcher: FC = () => {
399
- const { localeSwitcherLabel } = useIntlayer("locale-switcher");
400
400
  const { pathname } = useLocation();
401
401
 
402
- const { availableLocales, locale } = useLocale();
402
+ const { availableLocales, locale, setLocale } = useLocale();
403
403
 
404
404
  const pathWithoutLocale = getPathWithoutLocale(pathname);
405
405
 
@@ -409,25 +409,24 @@ export const LocaleSwitcher: FC = () => {
409
409
  <li key={localeEl}>
410
410
  <LocalizedLink
411
411
  aria-current={localeEl === locale ? "page" : undefined}
412
- aria-label={`${localeSwitcherLabel.value} ${getLocaleName(localeEl)}`}
413
- onClick={() => setLocaleInStorage(localeEl)}
412
+ onClick={() => setLocale(localeEl)}
414
413
  params={{ locale: getPrefix(localeEl).localePrefix }}
415
414
  >
416
415
  <span>
417
416
  {/* Lokalizacja - np. FR */}
418
- {localeItem}
417
+ {localeEl}
419
418
  </span>
420
419
  <span>
421
420
  {/* Język w swojej własnej lokalizacji - np. Français */}
422
- {getLocaleName(localeItem, locale)}
421
+ {getLocaleName(localeEl, locale)}
423
422
  </span>
424
- <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
423
+ <span dir={getHTMLTextDir(localeEl)} lang={localeEl}>
425
424
  {/* Język w bieżącej lokalizacji - np. Francés przy ustawionej lokalizacji Locales.SPANISH */}
426
- {getLocaleName(localeItem)}
425
+ {getLocaleName(localeEl)}
427
426
  </span>
428
427
  <span dir="ltr" lang={Locales.ENGLISH}>
429
428
  {/* Język po angielsku - np. French */}
430
- {getLocaleName(localeItem, Locales.ENGLISH)}
429
+ {getLocaleName(localeEl, Locales.ENGLISH)}
431
430
  </span>
432
431
  </LocalizedLink>
433
432
  </li>
@@ -462,7 +461,7 @@ export const useI18nHTMLAttributes = () => {
462
461
  Następnie użyj go w swoim komponencie root:
463
462
 
464
463
  ```tsx fileName="src/routes/{-$locale}/index.tsx"
465
- import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router";
464
+ import { createFileRoute, Outlet } from "@tanstack/react-router";
466
465
  import { IntlayerProvider, useLocale } from "react-intlayer";
467
466
 
468
467
  import { useI18nHTMLAttributes } from "@/hooks/useI18nHTMLAttributes"; // importuj hook
@@ -502,18 +501,44 @@ import tsconfigPaths from "vite-tsconfig-paths";
502
501
 
503
502
  export default defineConfig({
504
503
  plugins: [
504
+ intlayerProxy(), // Proxy powinno być umieszczone przed serwerem, jeśli używasz Nitro
505
505
  tailwindcss(),
506
506
  reactRouter(),
507
507
  tsconfigPaths(),
508
508
  intlayer(),
509
- intlayerProxy(),
510
509
  ],
511
510
  });
512
511
  ```
513
512
 
514
513
  ---
515
514
 
516
- ### Krok 12: Konfiguracja TypeScript (opcjonalnie)
515
+ ### Krok 12: Internacjonalizacja metadanych (opcjonalnie)
516
+
517
+ Możesz również użyć hooka `getIntlayer`, aby uzyskać dostęp do słowników treści w całej aplikacji:
518
+
519
+ ```tsx fileName="src/routes/{-$locale}/index.tsx"
520
+ import { createFileRoute } from "@tanstack/react-router";
521
+ import { getIntlayer } from "intlayer";
522
+
523
+ export const Route = createFileRoute("/{-$locale}/")({
524
+ component: RouteComponent,
525
+ head: ({ params }) => {
526
+ const { locale } = params;
527
+ const metaContent = getIntlayer("page-metadata", locale);
528
+
529
+ return {
530
+ meta: [
531
+ { title: metaContent.title },
532
+ { content: metaContent.description, name: "description" },
533
+ ],
534
+ };
535
+ },
536
+ });
537
+ ```
538
+
539
+ ---
540
+
541
+ ### Krok 13: Konfiguracja TypeScript (opcjonalnie)
517
542
 
518
543
  Intlayer używa rozszerzenia modułów (module augmentation), aby wykorzystać zalety TypeScript i wzmocnić Twoją bazę kodu.
519
544
 
@@ -531,32 +556,6 @@ Upewnij się, że Twoja konfiguracja TypeScript zawiera automatycznie generowane
531
556
 
532
557
  ---
533
558
 
534
- ### Krok 13: Dostosowanie Nitro (opcjonalnie)
535
-
536
- Jeśli używasz Nitro dla swojego wyjścia produkcyjnego, nitro nie będzie zawierać katalogu `.intlayer` w katalogu wyjściowym. Musisz skopiować go ręcznie.
537
-
538
- Przykład używający skryptu build:
539
-
540
- ```json5 fileName="package.json"
541
- {
542
- "scripts": {
543
- "dev": "vite dev --port 3000",
544
- "build": "vite build && cpr -r .intlayer .output/.intlayer", // Skopiuj folder .intlayer
545
- "serve": "vite preview",
546
- },
547
- }
548
- ```
549
-
550
- > cpr jest używany do dostosowania komendy, aby działała na Windows.
551
- > Będziesz musiał zainstalować narzędzie `cpr`, aby użyć tego polecenia.
552
- >
553
- > - `npm install --save-dev cpr`
554
- > - `yarn add --dev cpr`
555
- > - `pnpm add --save-dev cpr`
556
- > - `bun add --save-dev cpr`
557
-
558
- ---
559
-
560
559
  ### Konfiguracja Git
561
560
 
562
561
  Zaleca się ignorowanie plików generowanych przez Intlayer. Pozwala to uniknąć ich zatwierdzania do repozytorium Git.