@intlayer/docs 7.3.10 → 7.3.12

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 (90) hide show
  1. package/dist/cjs/generated/docs.entry.cjs +19 -0
  2. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  3. package/dist/esm/generated/docs.entry.mjs +19 -0
  4. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  5. package/dist/types/generated/docs.entry.d.ts +1 -0
  6. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  7. package/docs/ar/intlayer_with_nuxt.md +305 -421
  8. package/docs/ar/intlayer_with_react_router_v7.md +33 -4
  9. package/docs/ar/intlayer_with_react_router_v7_fs_routes.md +516 -0
  10. package/docs/ar/intlayer_with_tanstack.md +2 -12
  11. package/docs/ar/intlayer_with_vite+vue.md +1 -0
  12. package/docs/de/intlayer_with_nuxt.md +296 -394
  13. package/docs/de/intlayer_with_react_router_v7.md +33 -4
  14. package/docs/de/intlayer_with_react_router_v7_fs_routes.md +573 -0
  15. package/docs/de/intlayer_with_tanstack.md +1 -0
  16. package/docs/de/intlayer_with_vite+vue.md +1 -0
  17. package/docs/en/intlayer_with_nuxt.md +242 -321
  18. package/docs/en/intlayer_with_react_router_v7.md +24 -0
  19. package/docs/en/intlayer_with_react_router_v7_fs_routes.md +570 -0
  20. package/docs/en/intlayer_with_tanstack.md +2 -12
  21. package/docs/en/intlayer_with_vite+vue.md +49 -48
  22. package/docs/en-GB/intlayer_with_nuxt.md +262 -358
  23. package/docs/en-GB/intlayer_with_react_router_v7.md +33 -4
  24. package/docs/en-GB/intlayer_with_react_router_v7_fs_routes.md +513 -0
  25. package/docs/en-GB/intlayer_with_tanstack.md +2 -12
  26. package/docs/en-GB/intlayer_with_vite+vue.md +1 -0
  27. package/docs/es/intlayer_with_nuxt.md +284 -375
  28. package/docs/es/intlayer_with_react_router_v7.md +33 -4
  29. package/docs/es/intlayer_with_react_router_v7_fs_routes.md +575 -0
  30. package/docs/es/intlayer_with_tanstack.md +1 -0
  31. package/docs/es/intlayer_with_vite+vue.md +1 -2
  32. package/docs/fr/intlayer_with_nuxt.md +288 -387
  33. package/docs/fr/intlayer_with_react_router_v7.md +34 -5
  34. package/docs/fr/intlayer_with_react_router_v7_fs_routes.md +574 -0
  35. package/docs/fr/intlayer_with_tanstack.md +1 -0
  36. package/docs/fr/intlayer_with_vite+vue.md +1 -0
  37. package/docs/hi/intlayer_with_nuxt.md +318 -434
  38. package/docs/hi/intlayer_with_react_router_v7.md +33 -4
  39. package/docs/hi/intlayer_with_react_router_v7_fs_routes.md +518 -0
  40. package/docs/hi/intlayer_with_tanstack.md +2 -12
  41. package/docs/hi/intlayer_with_vite+vue.md +1 -0
  42. package/docs/id/intlayer_with_nuxt.md +275 -376
  43. package/docs/id/intlayer_with_react_router_v7.md +29 -4
  44. package/docs/id/intlayer_with_react_router_v7_fs_routes.md +521 -0
  45. package/docs/id/intlayer_with_tanstack.md +2 -12
  46. package/docs/id/intlayer_with_vite+vue.md +1 -0
  47. package/docs/it/intlayer_with_nuxt.md +312 -408
  48. package/docs/it/intlayer_with_react_router_v7.md +33 -4
  49. package/docs/it/intlayer_with_react_router_v7_fs_routes.md +574 -0
  50. package/docs/it/intlayer_with_tanstack.md +1 -0
  51. package/docs/ja/intlayer_with_nuxt.md +319 -414
  52. package/docs/ja/intlayer_with_react_router_v7.md +33 -4
  53. package/docs/ja/intlayer_with_react_router_v7_fs_routes.md +574 -0
  54. package/docs/ja/intlayer_with_tanstack.md +2 -12
  55. package/docs/ja/intlayer_with_vite+vue.md +1 -0
  56. package/docs/ko/intlayer_with_nuxt.md +307 -406
  57. package/docs/ko/intlayer_with_react_router_v7.md +33 -4
  58. package/docs/ko/intlayer_with_react_router_v7_fs_routes.md +515 -0
  59. package/docs/ko/intlayer_with_tanstack.md +2 -12
  60. package/docs/ko/intlayer_with_vite+vue.md +1 -0
  61. package/docs/pl/intlayer_with_nuxt.md +282 -457
  62. package/docs/pl/intlayer_with_react_router_v7.md +32 -5
  63. package/docs/pl/intlayer_with_react_router_v7_fs_routes.md +615 -0
  64. package/docs/pl/intlayer_with_tanstack.md +2 -12
  65. package/docs/pl/intlayer_with_vite+vue.md +1 -0
  66. package/docs/pt/intlayer_with_nuxt.md +288 -403
  67. package/docs/pt/intlayer_with_react_router_v7.md +28 -0
  68. package/docs/pt/intlayer_with_tanstack.md +1 -0
  69. package/docs/ru/intlayer_with_nuxt.md +300 -410
  70. package/docs/ru/intlayer_with_react_router_v7.md +33 -4
  71. package/docs/ru/intlayer_with_react_router_v7_fs_routes.md +574 -0
  72. package/docs/ru/intlayer_with_tanstack.md +1 -0
  73. package/docs/ru/intlayer_with_vite+vue.md +1 -0
  74. package/docs/tr/intlayer_with_nuxt.md +327 -392
  75. package/docs/tr/intlayer_with_react_router_v7.md +33 -4
  76. package/docs/tr/intlayer_with_react_router_v7_fs_routes.md +572 -0
  77. package/docs/tr/intlayer_with_tanstack.md +2 -12
  78. package/docs/tr/intlayer_with_vite+vue.md +1 -0
  79. package/docs/vi/intlayer_with_nuxt.md +282 -399
  80. package/docs/vi/intlayer_with_react_router_v7.md +29 -4
  81. package/docs/vi/intlayer_with_react_router_v7_fs_routes.md +523 -0
  82. package/docs/vi/intlayer_with_tanstack.md +2 -12
  83. package/docs/vi/intlayer_with_vite+vue.md +1 -0
  84. package/docs/zh/intlayer_with_nuxt.md +311 -444
  85. package/docs/zh/intlayer_with_react_router_v7.md +33 -4
  86. package/docs/zh/intlayer_with_react_router_v7_fs_routes.md +516 -0
  87. package/docs/zh/intlayer_with_tanstack.md +2 -12
  88. package/docs/zh/intlayer_with_vite+vue.md +1 -0
  89. package/package.json +6 -6
  90. package/src/generated/docs.entry.ts +19 -0
@@ -18,6 +18,7 @@ slugs:
18
18
  - vite-and-react
19
19
  - react-router-v7
20
20
  applicationTemplate: https://github.com/aymericzip/intlayer-react-router-v7-template
21
+ youtubeVideo: https://www.youtube.com/watch?v=dS9L7uJeak4
21
22
  history:
22
23
  - version: 6.1.5
23
24
  date: 2025-10-03
@@ -31,7 +32,7 @@ history:
31
32
 
32
33
  Panduan ini menunjukkan cara mengintegrasikan **Intlayer** untuk internasionalisasi yang mulus dalam proyek React Router v7 dengan routing yang mendukung locale, dukungan TypeScript, dan praktik pengembangan modern.
33
34
 
34
- ## Daftar Isi
35
+ ## Table of Contents
35
36
 
36
37
  <TOC/>
37
38
 
@@ -85,6 +86,29 @@ pnpm add vite-intlayer --save-dev
85
86
 
86
87
  ### Langkah 2: Konfigurasi proyek Anda
87
88
 
89
+ ## Panduan Langkah demi Langkah untuk Mengatur Intlayer dalam Aplikasi React Router v7 dengan Rute Berbasis Sistem File
90
+
91
+ <Tab defaultTab="video">
92
+ <TabItem label="Video" value="video">
93
+
94
+ <iframe title="How to translate your React Router v7 app using 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/dS9L7uJeak4?autoplay=0&amp;origin=http://intlayer.org&amp;controls=0&amp;rel=1"/>
95
+
96
+ </TabItem>
97
+ <TabItem label="Code" value="code">
98
+
99
+ <iframe
100
+ src="https://stackblitz.com/github/aymericzip/intlayer-react-router-v7-template?embed=1&ctl=1&file=intlayer.config.ts"
101
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
102
+ title="Demo CodeSandbox - How to Internationalize your application using Intlayer"
103
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
104
+ loading="lazy"
105
+ />
106
+
107
+ </TabItem>
108
+ </Tab>
109
+
110
+ See [Application Template](https://github.com/aymericzip/intlayer-react-router-v7-template) on GitHub.
111
+
88
112
  Buat file konfigurasi untuk mengatur bahasa aplikasi Anda:
89
113
 
90
114
  ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
@@ -325,6 +349,7 @@ import {
325
349
  getLocaleName,
326
350
  getLocalizedUrl,
327
351
  getPathWithoutLocale,
352
+ Locales,
328
353
  } from "intlayer";
329
354
  import { setLocaleInStorage, useIntlayer, useLocale } from "react-intlayer";
330
355
  import { Link, useLocation } from "react-router";
@@ -418,13 +443,13 @@ Anda juga dapat menggunakan `intlayerProxy` untuk menambahkan routing sisi serve
418
443
  > Perlu dicatat bahwa untuk menggunakan `intlayerProxy` di produksi, Anda perlu memindahkan paket `vite-intlayer` dari `devDependencies` ke `dependencies`.
419
444
 
420
445
  ```typescript {3,7} fileName="vite.config.ts"
446
+ import { reactRouter } from "@react-router/dev/vite";
421
447
  import { defineConfig } from "vite";
422
- import react from "@vitejs/plugin-react-swc";
423
448
  import { intlayer, intlayerProxy } from "vite-intlayer";
449
+ import tsconfigPaths from "vite-tsconfig-paths";
424
450
 
425
- // https://vitejs.dev/config/
426
451
  export default defineConfig({
427
- plugins: [react(), intlayer(), intlayerProxy()],
452
+ plugins: [reactRouter(), tsconfigPaths(), intlayer(), intlayerProxy()],
428
453
  });
429
454
  ```
430
455
 
@@ -0,0 +1,521 @@
1
+ ---
2
+ createdAt: 2025-09-04
3
+ updatedAt: 2025-10-03
4
+ title: Cara menerjemahkan aplikasi React Router v7 Anda – panduan i18n 2025
5
+ description: Pelajari cara menambahkan internasionalisasi (i18n) ke aplikasi React Router v7 Anda menggunakan Intlayer. Ikuti panduan komprehensif ini untuk membuat aplikasi Anda multibahasa dengan routing yang mendukung locale.
6
+ keywords:
7
+ - Internasionalisasi
8
+ - Dokumentasi
9
+ - Intlayer
10
+ - React Router v7
11
+ - React
12
+ - i18n
13
+ - TypeScript
14
+ - Routing Locale
15
+ slugs:
16
+ - doc
17
+ - environment
18
+ - vite-and-react
19
+ - react-router-v7-fs-routes
20
+ applicationTemplate: https://github.com/aymericzip/intlayer-react-router-v7-template
21
+ youtubeVideo: https://www.youtube.com/watch?v=dS9L7uJeak4
22
+ history:
23
+ - version: 6.1.5
24
+ date: 2025-10-03
25
+ changes: Memperbarui dokumen
26
+ - version: 5.8.2
27
+ date: 2025-09-04
28
+ changes: Ditambahkan untuk React Router v7
29
+ ---
30
+
31
+ # Terjemahkan situs web React Router v7 Anda menggunakan Intlayer | Internasionalisasi (i18n)
32
+
33
+ Panduan ini menunjukkan cara mengintegrasikan **Intlayer** untuk internasionalisasi yang mulus dalam proyek React Router v7 dengan routing yang mendukung locale, dukungan TypeScript, dan praktik pengembangan modern.
34
+
35
+ ## Table of Contents
36
+
37
+ <TOC/>
38
+
39
+ ## Apa itu Intlayer?
40
+
41
+ **Intlayer** adalah pustaka internasionalisasi (i18n) open-source yang inovatif, dirancang untuk menyederhanakan dukungan multibahasa dalam aplikasi web modern.
42
+
43
+ Dengan Intlayer, Anda dapat:
44
+
45
+ - **Mengelola terjemahan dengan mudah** menggunakan kamus deklaratif di tingkat komponen.
46
+ - **Melokalkan metadata**, rute, dan konten secara dinamis.
47
+ - **Memastikan dukungan TypeScript** dengan tipe yang dihasilkan secara otomatis, meningkatkan autocompletion dan deteksi kesalahan.
48
+ - **Manfaatkan fitur canggih**, seperti deteksi dan pergantian locale secara dinamis.
49
+ - **Aktifkan routing yang mendukung locale** dengan sistem routing berbasis konfigurasi React Router v7.
50
+
51
+ ---
52
+
53
+ ## Panduan Langkah demi Langkah untuk Mengatur Intlayer dalam Aplikasi React Router v7
54
+
55
+ <iframe
56
+ src="https://stackblitz.com/github/aymericzip/intlayer-react-router-v7-template?embed=1&ctl=1&file=intlayer.config.ts"
57
+ 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
+ title="Demo CodeSandbox - Cara Menginternasionalisasi aplikasi Anda menggunakan Intlayer"
59
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
60
+ loading="lazy"
61
+ />
62
+
63
+ ### Langkah 1: Pasang Dependencies
64
+
65
+ Pasang paket yang diperlukan menggunakan manajer paket pilihan Anda:
66
+
67
+ ```bash packageManager="npm"
68
+ npm install intlayer react-intlayer
69
+ npm install vite-intlayer --save-dev
70
+ ```
71
+
72
+ ```bash packageManager="pnpm"
73
+ pnpm add intlayer react-intlayer
74
+ pnpm add vite-intlayer --save-dev
75
+ ```
76
+
77
+ - **intlayer**
78
+
79
+ Paket inti yang menyediakan alat internasionalisasi untuk manajemen konfigurasi, terjemahan, [deklarasi konten](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/content_file.md), transpile, dan [perintah CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_cli.md).
80
+
81
+ - **react-intlayer**
82
+ Paket yang mengintegrasikan Intlayer dengan aplikasi React. Ini menyediakan context providers dan hooks untuk internasionalisasi React.
83
+
84
+ - **vite-intlayer**
85
+ Menyertakan plugin Vite untuk mengintegrasikan Intlayer dengan [Vite bundler](https://vite.dev/guide/why.html#why-bundle-for-production), serta middleware untuk mendeteksi locale yang dipilih pengguna, mengelola cookie, dan menangani pengalihan URL.
86
+
87
+ ### Langkah 2: Konfigurasi proyek Anda
88
+
89
+ ## Panduan Langkah demi Langkah untuk Mengatur Intlayer dalam Aplikasi React Router v7 dengan Rute Berbasis Sistem File
90
+
91
+ <Tab defaultTab="video">
92
+ <TabItem label="Video" value="video">
93
+
94
+ <iframe title="How to translate your React Router v7 (File-System Routes) app using 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/dS9L7uJeak4?autoplay=0&amp;origin=http://intlayer.org&amp;controls=0&amp;rel=1"/>
95
+
96
+ </TabItem>
97
+ <TabItem label="Code" value="code">
98
+
99
+ <iframe
100
+ src="https://stackblitz.com/github/aymericzip/intlayer-react-router-v7-template?embed=1&ctl=1&file=intlayer.config.ts"
101
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
102
+ title="Demo CodeSandbox - How to Internationalize your application using Intlayer"
103
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
104
+ loading="lazy"
105
+ />
106
+
107
+ </TabItem>
108
+ </Tab>
109
+
110
+ See [Application Template](https://github.com/aymericzip/intlayer-react-router-v7-template) on GitHub.
111
+
112
+ Buat file konfigurasi untuk mengatur bahasa aplikasi Anda:
113
+
114
+ ```typescript fileName="intlayer.config.ts" codeFormat="typescript"
115
+ import { type IntlayerConfig, Locales } from "intlayer";
116
+
117
+ const config: IntlayerConfig = {
118
+ internationalization: {
119
+ defaultLocale: Locales.ENGLISH,
120
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
121
+ },
122
+ };
123
+
124
+ export default config;
125
+ ```
126
+
127
+ ```javascript fileName="intlayer.config.mjs" codeFormat="esm"
128
+ import { Locales } from "intlayer";
129
+
130
+ /** @type {import('intlayer').IntlayerConfig} */
131
+ const config = {
132
+ internationalization: {
133
+ defaultLocale: Locales.ENGLISH,
134
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
135
+ },
136
+ };
137
+
138
+ export default config;
139
+ ```
140
+
141
+ ```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
142
+ const { Locales } = require("intlayer");
143
+
144
+ /** @type {import('intlayer').IntlayerConfig} */
145
+ const config = {
146
+ internationalization: {
147
+ defaultLocale: Locales.ENGLISH,
148
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
149
+ },
150
+ };
151
+
152
+ module.exports = config;
153
+ ```
154
+
155
+ > Melalui file konfigurasi ini, Anda dapat mengatur URL yang dilokalkan, pengalihan middleware, nama cookie, lokasi dan ekstensi deklarasi konten Anda, menonaktifkan log Intlayer di konsol, dan lainnya. Untuk daftar lengkap parameter yang tersedia, lihat [dokumentasi konfigurasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/configuration.md).
156
+
157
+ ### Langkah 3: Integrasikan Intlayer dalam Konfigurasi Vite Anda
158
+
159
+ Tambahkan plugin intlayer ke dalam konfigurasi Anda:
160
+
161
+ ```typescript fileName="vite.config.ts"
162
+ import { reactRouter } from "@react-router/dev/vite";
163
+ import { defineConfig } from "vite";
164
+ import { intlayer } from "vite-intlayer";
165
+ import tsconfigPaths from "vite-tsconfig-paths";
166
+
167
+ export default defineConfig({
168
+ plugins: [reactRouter(), tsconfigPaths(), intlayer()],
169
+ });
170
+ ```
171
+
172
+ > Plugin Vite `intlayer()` digunakan untuk mengintegrasikan Intlayer dengan Vite. Plugin ini memastikan pembuatan file deklarasi konten dan memantau file tersebut dalam mode pengembangan. Plugin ini juga mendefinisikan variabel lingkungan Intlayer di dalam aplikasi Vite. Selain itu, plugin ini menyediakan alias untuk mengoptimalkan performa.
173
+
174
+ ### Langkah 4: Konfigurasikan Rute React Router v7
175
+
176
+ Atur konfigurasi routing Anda dengan rute yang mendukung lokal:
177
+
178
+ ```typescript fileName="app/routes.ts"
179
+ import { layout, route, type RouteConfig } from "@react-router/dev/routes";
180
+
181
+ export default [
182
+ layout("routes/layout.tsx", [
183
+ route("/:lang?", "routes/page.tsx"), // Halaman beranda yang dilokalkan
184
+ route("/:lang?/about", "routes/about/page.tsx"), // Halaman about yang dilokalkan
185
+ ]),
186
+ ] satisfies RouteConfig;
187
+ ```
188
+
189
+ ### Langkah 5: Buat Komponen Layout
190
+
191
+ Atur layout root Anda dan layout spesifik lokal:
192
+
193
+ #### Layout Root
194
+
195
+ ```tsx fileName="app/routes/layout.tsx"
196
+ import { IntlayerProvider } from "react-intlayer";
197
+ import { Outlet } from "react-router";
198
+
199
+ import type { Route } from "./+types/layout";
200
+
201
+ export default function RootLayout({ params }: Route.ComponentProps) {
202
+ const { locale } = params;
203
+
204
+ return (
205
+ <IntlayerProvider locale={locale}>
206
+ <Outlet />
207
+ </IntlayerProvider>
208
+ );
209
+ }
210
+ ```
211
+
212
+ ### Langkah 6: Deklarasikan Konten Anda
213
+
214
+ Buat dan kelola deklarasi konten Anda untuk menyimpan terjemahan:
215
+
216
+ ```tsx fileName="app/routes/[lang]/page.content.ts"
217
+ import { t, type Dictionary } from "intlayer";
218
+
219
+ const pageContent = {
220
+ key: "page",
221
+ content: {
222
+ title: t({
223
+ en: "Welcome to React Router v7 + Intlayer",
224
+ es: "Bienvenido a React Router v7 + Intlayer",
225
+ fr: "Bienvenue sur React Router v7 + Intlayer",
226
+ }),
227
+ description: t({
228
+ en: "Bangun aplikasi multibahasa dengan mudah menggunakan React Router v7 dan Intlayer.",
229
+ es: "Cree aplicaciones multilingües fácilmente usando React Router v7 y Intlayer.",
230
+ fr: "Créez des applications multilingues facilement avec React Router v7 et Intlayer.",
231
+ }),
232
+ aboutLink: t({
233
+ en: "Pelajari Tentang Kami",
234
+ es: "Aprender Sobre Nosotros",
235
+ fr: "En savoir plus sur nous",
236
+ }),
237
+ homeLink: t({
238
+ en: "Beranda",
239
+ es: "Inicio",
240
+ fr: "Accueil",
241
+ }),
242
+ },
243
+ } satisfies Dictionary;
244
+
245
+ export default pageContent;
246
+ ```
247
+
248
+ > Deklarasi konten Anda dapat didefinisikan di mana saja dalam aplikasi Anda selama sudah dimasukkan ke dalam direktori `contentDir` (secara default, `./app`). Dan sesuai dengan ekstensi file deklarasi konten (secara default, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
249
+
250
+ > Untuk detail lebih lanjut, lihat [dokumentasi deklarasi konten](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/content_file.md).
251
+
252
+ ### Langkah 7: Buat Komponen yang Menyadari Locale
253
+
254
+ Buat komponen `LocalizedLink` untuk navigasi yang menyadari locale:
255
+
256
+ ```tsx fileName="app/components/localized-link.tsx"
257
+ import type { FC } from "react";
258
+
259
+ import { getLocalizedUrl, type LocalesValues } from "intlayer";
260
+ import { useLocale } from "react-intlayer";
261
+ import { Link, type LinkProps, type To } from "react-router";
262
+
263
+ const isExternalLink = (to: string) => /^(https?:)?\/\//.test(to);
264
+
265
+ export const locacalizeTo = (to: To, locale: LocalesValues): To => {
266
+ if (typeof to === "string") {
267
+ if (isExternalLink(to)) {
268
+ return to;
269
+ }
270
+
271
+ return getLocalizedUrl(to, locale);
272
+ }
273
+
274
+ if (isExternalLink(to.pathname ?? "")) {
275
+ return to;
276
+ }
277
+
278
+ return {
279
+ ...to,
280
+ pathname: getLocalizedUrl(to.pathname ?? "", locale),
281
+ };
282
+ };
283
+
284
+ export const LocalizedLink: FC<LinkProps> = (props) => {
285
+ const { locale } = useLocale();
286
+
287
+ return <Link {...props} to={locacalizeTo(props.to, locale)} />;
288
+ };
289
+ ```
290
+
291
+ Jika Anda ingin menavigasi ke rute yang sudah dilokalkan, Anda dapat menggunakan hook `useLocalizedNavigate`:
292
+
293
+ ```tsx fileName="app/hooks/useLocalizedNavigate.ts"
294
+ import { useLocale } from "react-intlayer";
295
+ import { type NavigateOptions, type To, useNavigate } from "react-router";
296
+
297
+ import { locacalizeTo } from "~/components/localized-link";
298
+
299
+ export const useLocalizedNavigate = () => {
300
+ const navigate = useNavigate();
301
+ const { locale } = useLocale();
302
+
303
+ const localizedNavigate = (to: To, options?: NavigateOptions) => {
304
+ const localedTo = locacalizeTo(to, locale);
305
+
306
+ navigate(localedTo, options);
307
+ };
308
+
309
+ return localizedNavigate;
310
+ };
311
+ ```
312
+
313
+ ### Langkah 8: Gunakan Intlayer di Halaman Anda
314
+
315
+ Akses kamus konten Anda di seluruh aplikasi:
316
+
317
+ #### Halaman Beranda yang Dilokalkan
318
+
319
+ ```tsx fileName="app/routes/[lang]/page.tsx"
320
+ import { useIntlayer } from "react-intlayer";
321
+ import { LocalizedLink } from "~/components/localized-link";
322
+
323
+ export default function Page() {
324
+ const { title, description, aboutLink } = useIntlayer("page");
325
+
326
+ return (
327
+ <div>
328
+ <h1>{title}</h1>
329
+ <p>{description}</p>
330
+ <nav>
331
+ <LocalizedLink to="/about">{aboutLink}</LocalizedLink>
332
+ </nav>
333
+ </div>
334
+ );
335
+ }
336
+ ```
337
+
338
+ > Untuk mempelajari lebih lanjut tentang hook `useIntlayer`, lihat [dokumentasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/react-intlayer/useIntlayer.md).
339
+
340
+ ### Langkah 9: Buat Komponen Locale Switcher
341
+
342
+ Buat komponen untuk memungkinkan pengguna mengganti bahasa:
343
+
344
+ ```tsx fileName="app/components/locale-switcher.tsx"
345
+ import type { FC } from "react";
346
+
347
+ import {
348
+ getHTMLTextDir,
349
+ getLocaleName,
350
+ getLocalizedUrl,
351
+ getPathWithoutLocale,
352
+ Locales,
353
+ } from "intlayer";
354
+ import { setLocaleInStorage, useIntlayer, useLocale } from "react-intlayer";
355
+ import { Link, useLocation } from "react-router";
356
+
357
+ export const LocaleSwitcher: FC = () => {
358
+ const { localeSwitcherLabel } = useIntlayer("locale-switcher");
359
+ const { pathname } = useLocation();
360
+
361
+ const { availableLocales, locale } = useLocale();
362
+
363
+ const pathWithoutLocale = getPathWithoutLocale(pathname);
364
+
365
+ return (
366
+ <ol>
367
+ {availableLocales.map((localeItem) => (
368
+ <li key={localeItem}>
369
+ <Link
370
+ aria-current={localeItem === locale ? "page" : undefined}
371
+ aria-label={`${localeSwitcherLabel.value} ${getLocaleName(localeItem)}`}
372
+ onClick={() => setLocale(localeItem)}
373
+ to={getLocalizedUrl(pathWithoutLocale, localeItem)}
374
+ >
375
+ <span>
376
+ {/* Locale - misal FR */}
377
+ {localeItem}
378
+ </span>
379
+ <span>
380
+ {/* Bahasa dalam Locale-nya sendiri - misalnya Français */}
381
+ {getLocaleName(localeItem, locale)}
382
+ </span>
383
+ <span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
384
+ {/* Bahasa dalam Locale saat ini - misalnya Francés dengan locale saat ini disetel ke Locales.SPANISH */}
385
+ {getLocaleName(localeItem)}
386
+ </span>
387
+ <span dir="ltr" lang={Locales.ENGLISH}>
388
+ {/* Bahasa dalam Bahasa Inggris - misalnya French */}
389
+ {getLocaleName(localeItem, Locales.ENGLISH)}
390
+ </span>
391
+ </Link>
392
+ </li>
393
+ ))}
394
+ </ol>
395
+ );
396
+ };
397
+ ```
398
+
399
+ > Untuk mempelajari lebih lanjut tentang hook `useLocale`, lihat [dokumentasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/react-intlayer/useLocale.md).
400
+
401
+ ### Langkah 10: Tambahkan Manajemen Atribut HTML (Opsional)
402
+
403
+ Buat hook untuk mengelola atribut lang dan dir HTML:
404
+
405
+ ```tsx fileName="app/hooks/useI18nHTMLAttributes.tsx"
406
+ import { getHTMLTextDir } from "intlayer";
407
+ import { useEffect } from "react";
408
+ import { useLocale } from "react-intlayer";
409
+
410
+ export const useI18nHTMLAttributes = () => {
411
+ const { locale } = useLocale();
412
+
413
+ useEffect(() => {
414
+ document.documentElement.lang = locale;
415
+ document.documentElement.dir = getHTMLTextDir(locale);
416
+ }, [locale]);
417
+ };
418
+ ```
419
+
420
+ Kemudian gunakan di komponen root Anda:
421
+
422
+ ```tsx fileName="app/routes/layout.tsx"
423
+ import { Outlet } from "react-router";
424
+ import { IntlayerProvider } from "react.intlayer";
425
+
426
+ import { useI18nHTMLAttributes } from "app/hooks/useI18nHTMLAttributes"; // impor hook
427
+
428
+ export default function RootLayout() {
429
+ useI18nHTMLAttributes(); // panggil hook
430
+
431
+ return (
432
+ <IntlayerProvider>
433
+ <Outlet />
434
+ </IntlayerProvider>
435
+ );
436
+ }
437
+ ```
438
+
439
+ ### Langkah 11: Tambahkan middleware (Opsional)
440
+
441
+ Anda juga dapat menggunakan `intlayerProxy` untuk menambahkan routing sisi server ke aplikasi Anda. Plugin ini akan secara otomatis mendeteksi locale saat ini berdasarkan URL dan mengatur cookie locale yang sesuai. Jika tidak ada locale yang ditentukan, plugin akan menentukan locale yang paling sesuai berdasarkan preferensi bahasa browser pengguna. Jika tidak ada locale yang terdeteksi, maka akan mengarahkan ulang ke locale default.
442
+
443
+ > Perlu dicatat bahwa untuk menggunakan `intlayerProxy` di produksi, Anda perlu memindahkan paket `vite-intlayer` dari `devDependencies` ke `dependencies`.
444
+
445
+ ```typescript {3,7} fileName="vite.config.ts"
446
+ import { reactRouter } from "@react-router/dev/vite";
447
+ import { defineConfig } from "vite";
448
+ import { intlayer, intlayerProxy } from "vite-intlayer";
449
+ import tsconfigPaths from "vite-tsconfig-paths";
450
+
451
+ export default defineConfig({
452
+ plugins: [reactRouter(), tsconfigPaths(), intlayer(), intlayerProxy()],
453
+ });
454
+ ```
455
+
456
+ ---
457
+
458
+ ## Konfigurasi TypeScript
459
+
460
+ Intlayer menggunakan module augmentation untuk mendapatkan manfaat dari TypeScript dan membuat codebase Anda lebih kuat.
461
+
462
+ Pastikan konfigurasi TypeScript Anda menyertakan tipe yang dihasilkan secara otomatis:
463
+
464
+ ```json5 fileName="tsconfig.json"
465
+ {
466
+ // ... konfigurasi Anda yang sudah ada
467
+ include: [
468
+ // ... include Anda yang sudah ada
469
+ ".intlayer/**/*.ts", // Sertakan tipe yang dihasilkan secara otomatis
470
+ ],
471
+ }
472
+ ```
473
+
474
+ ---
475
+
476
+ ## Konfigurasi Git
477
+
478
+ Disarankan untuk mengabaikan file yang dihasilkan oleh Intlayer. Ini memungkinkan Anda untuk menghindari meng-commit file tersebut ke repositori Git Anda.
479
+
480
+ Untuk melakukannya, Anda dapat menambahkan instruksi berikut ke file `.gitignore` Anda:
481
+
482
+ ```plaintext fileName=".gitignore"
483
+ # Abaikan file yang dihasilkan oleh Intlayer
484
+ .intlayer
485
+ ```
486
+
487
+ ---
488
+
489
+ ## Ekstensi VS Code
490
+
491
+ Untuk meningkatkan pengalaman pengembangan Anda dengan Intlayer, Anda dapat menginstal **Ekstensi Intlayer VS Code** resmi.
492
+
493
+ [Pasang dari VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
494
+
495
+ Ekstensi ini menyediakan:
496
+
497
+ - **Autocompletion** untuk kunci terjemahan.
498
+ - **Deteksi kesalahan secara real-time** untuk terjemahan yang hilang.
499
+ - **Pratinjau inline** dari konten yang diterjemahkan.
500
+ - **Tindakan cepat** untuk dengan mudah membuat dan memperbarui terjemahan.
501
+
502
+ Untuk detail lebih lanjut tentang cara menggunakan ekstensi ini, lihat [dokumentasi Ekstensi VS Code Intlayer](https://intlayer.org/doc/vs-code-extension).
503
+
504
+ ---
505
+
506
+ ## Melangkah Lebih Jauh
507
+
508
+ Untuk melangkah lebih jauh, Anda dapat mengimplementasikan [editor visual](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_visual_editor.md) atau mengeksternalisasi konten Anda menggunakan [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/intlayer_CMS.md).
509
+
510
+ ---
511
+
512
+ ## Referensi Dokumentasi
513
+
514
+ - [Dokumentasi Intlayer](https://intlayer.org)
515
+ - [Dokumentasi React Router v7](https://reactrouter.com/)
516
+ - [useIntlayer hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/react-intlayer/useIntlayer.md)
517
+ - [useLocale hook](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/packages/react-intlayer/useLocale.md)
518
+ - [Deklarasi Konten](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/dictionary/content_file.md)
519
+ - [Konfigurasi](https://github.com/aymericzip/intlayer/blob/main/docs/docs/id/configuration.md)
520
+
521
+ Panduan komprehensif ini menyediakan semua yang Anda butuhkan untuk mengintegrasikan Intlayer dengan React Router v7 guna aplikasi yang sepenuhnya diinternasionalkan dengan routing yang mengenali locale dan dukungan TypeScript.
@@ -17,6 +17,7 @@ slugs:
17
17
  - environment
18
18
  - tanstack-start
19
19
  applicationTemplate: https://github.com/aymericzip/intlayer-tanstack-start-template
20
+ youtubeVideo: https://www.youtube.com/watch?v=_XTdKVWaeqg
20
21
  history:
21
22
  - version: 7.3.9
22
23
  date: 2025-12-05
@@ -578,19 +579,8 @@ export const getLocaleServer = createServerFn().handler(async () => {
578
579
  return getCookie(name, cookieString);
579
580
  },
580
581
  // Get the header from the request (default: 'x-intlayer-locale')
581
- getHeader: (name) => getRequestHeader(name),
582
582
  // Fallback using Accept-Language negotiation
583
- getAllHeaders: async () => {
584
- const headers = getRequestHeaders();
585
- const result: Record<string, string> = {};
586
-
587
- // Convert the TypedHeaders into a plain Record<string, string>
588
- for (const [key, value] of headers.entries()) {
589
- result[key] = value;
590
- }
591
-
592
- return result;
593
- },
583
+ getHeader: (name) => getRequestHeader(name),
594
584
  });
595
585
 
596
586
  // Retrieve some content using getIntlayer()
@@ -15,6 +15,7 @@ slugs:
15
15
  - environment
16
16
  - vite-and-vue
17
17
  applicationTemplate: https://github.com/aymericzip/intlayer-vite-vue-template
18
+ youtubeVideo: https://www.youtube.com/watch?v=IE3XWkZ6a5U
18
19
  history:
19
20
  - version: 5.5.10
20
21
  date: 2025-06-29