@intlayer/docs 7.1.9 → 7.2.2

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 (45) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/generated/docs.entry.cjs +19 -0
  3. package/dist/cjs/generated/docs.entry.cjs.map +1 -1
  4. package/dist/esm/generated/docs.entry.mjs +19 -0
  5. package/dist/esm/generated/docs.entry.mjs.map +1 -1
  6. package/dist/types/generated/docs.entry.d.ts +1 -0
  7. package/dist/types/generated/docs.entry.d.ts.map +1 -1
  8. package/docs/ar/intlayer_with_svelte_kit.md +738 -0
  9. package/docs/ar/intlayer_with_vite+svelte.md +288 -104
  10. package/docs/de/intlayer_with_svelte_kit.md +738 -0
  11. package/docs/de/intlayer_with_vite+svelte.md +302 -101
  12. package/docs/en/intlayer_with_nextjs_16.md +10 -2
  13. package/docs/en/intlayer_with_svelte_kit.md +570 -0
  14. package/docs/en/intlayer_with_vite+svelte.md +22 -6
  15. package/docs/en/introduction.md +2 -0
  16. package/docs/en-GB/intlayer_with_svelte_kit.md +738 -0
  17. package/docs/en-GB/intlayer_with_vite+svelte.md +262 -84
  18. package/docs/es/intlayer_with_svelte_kit.md +738 -0
  19. package/docs/es/intlayer_with_vite+svelte.md +300 -107
  20. package/docs/fr/intlayer_with_svelte_kit.md +770 -0
  21. package/docs/fr/intlayer_with_vite+svelte.md +297 -101
  22. package/docs/hi/intlayer_with_svelte_kit.md +738 -0
  23. package/docs/hi/intlayer_with_vite+svelte.md +298 -108
  24. package/docs/id/intlayer_with_svelte_kit.md +738 -0
  25. package/docs/id/intlayer_with_vite+svelte.md +277 -99
  26. package/docs/it/intlayer_with_svelte_kit.md +770 -0
  27. package/docs/it/intlayer_with_vite+svelte.md +275 -99
  28. package/docs/ja/intlayer_with_svelte_kit.md +738 -0
  29. package/docs/ja/intlayer_with_vite+svelte.md +295 -110
  30. package/docs/ko/intlayer_with_svelte_kit.md +738 -0
  31. package/docs/ko/intlayer_with_vite+svelte.md +286 -199
  32. package/docs/pl/intlayer_with_svelte_kit.md +740 -0
  33. package/docs/pl/intlayer_with_vite+svelte.md +273 -101
  34. package/docs/pt/intlayer_with_svelte_kit.md +772 -0
  35. package/docs/pt/intlayer_with_vite+svelte.md +290 -96
  36. package/docs/ru/intlayer_with_svelte_kit.md +738 -0
  37. package/docs/ru/intlayer_with_vite+svelte.md +275 -99
  38. package/docs/tr/intlayer_with_svelte_kit.md +738 -0
  39. package/docs/tr/intlayer_with_vite+svelte.md +297 -119
  40. package/docs/vi/intlayer_with_svelte_kit.md +738 -0
  41. package/docs/vi/intlayer_with_vite+svelte.md +275 -102
  42. package/docs/zh/intlayer_with_svelte_kit.md +738 -0
  43. package/docs/zh/intlayer_with_vite+svelte.md +309 -107
  44. package/package.json +9 -9
  45. package/src/generated/docs.entry.ts +19 -0
@@ -0,0 +1,570 @@
1
+ ---
2
+ createdAt: 2025-11-20
3
+ updatedAt: 2025-11-20
4
+ title: How to translate your SvelteKit app – i18n guide 2025
5
+ description: Discover how to make your SvelteKit website multilingual. Follow the documentation to internationalize (i18n) and translate it using Server-Side Rendering (SSR).
6
+ keywords:
7
+ - Internationalization
8
+ - Documentation
9
+ - Intlayer
10
+ - SvelteKit
11
+ - JavaScript
12
+ - SSR
13
+ slugs:
14
+ - doc
15
+ - environment
16
+ - sveltekit
17
+ applicationTemplate: https://github.com/aymericzip/intlayer-sveltekit-template
18
+ history:
19
+ - version: 7.1.10
20
+ date: 2025-11-20
21
+ changes: Init history
22
+ ---
23
+
24
+ # Translate your SvelteKit website using Intlayer | Internationalization (i18n)
25
+
26
+ ## Table of Contents
27
+
28
+ <TOC/>
29
+
30
+ ## What is Intlayer?
31
+
32
+ **Intlayer** is an innovative, open-source internationalization (i18n) library designed to simplify multilingual support in modern web applications. It works seamlessly with **SvelteKit's** Server-Side Rendering (SSR) capabilities.
33
+
34
+ With Intlayer, you can:
35
+
36
+ - **Easily manage translations** using declarative dictionaries at the component level.
37
+ - **Dynamically localize metadata**, routes, and content.
38
+ - **Ensure TypeScript support** with autogenerated types.
39
+ - **Leverage SvelteKit's SSR** for SEO-friendly internationalization.
40
+
41
+ ---
42
+
43
+ ## Step-by-Step Guide to Set Up Intlayer in a SvelteKit Application
44
+
45
+ <iframe
46
+ src="https://stackblitz.com/github/aymericzip/intlayer-sveltekit-template?embed=1&ctl=1&file=intlayer.config.ts"
47
+ className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
48
+ title="Demo CodeSandbox - Cách quốc tế hóa ứng dụng của bạn bằng Intlayer"
49
+ sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
50
+ loading="lazy"
51
+ />
52
+
53
+ See [Application Template](https://github.com/aymericzip/intlayer-sveltekit-template) on GitHub.
54
+
55
+ To get started, create a new SvelteKit project. Here is the final structure that we will make:
56
+
57
+ ```bash
58
+ .
59
+ ├── intlayer.config.ts
60
+ ├── package.json
61
+ ├── src
62
+ │ ├── app.d.ts
63
+ │   ├── app.html
64
+ │   ├── hooks.server.ts
65
+ │   ├── lib
66
+ │   │   ├── getLocale.ts
67
+ │   │   ├── LocaleSwitcher.svelte
68
+ │   │   └── LocalizedLink.svelte
69
+ │   ├── params
70
+ │   │   └── locale.ts
71
+ │   └── routes
72
+ │   ├── [[locale=locale]]
73
+ │   │   ├── +layout.svelte
74
+ │   │   ├── +layout.ts
75
+ │   │   ├── +page.svelte
76
+ │   │   ├── +page.ts
77
+ │   │   ├── about
78
+ │   │   │   ├── +page.svelte
79
+ │   │   │   ├── +page.ts
80
+ │   │   │   └── page.content.ts
81
+ │   │   ├── Counter.content.ts
82
+ │   │   ├── Counter.svelte
83
+ │   │   ├── Header.content.ts
84
+ │   │   ├── Header.svelte
85
+ │   │   ├── home.content.ts
86
+ │   │   └── layout.content.ts
87
+ │   ├── +layout.svelte
88
+ │   └── layout.css
89
+ ├── static
90
+ │   ├── favicon.svg
91
+ │   └── robots.txt
92
+ ├── svelte.config.js
93
+ ├── tsconfig.json
94
+ └── vite.config.ts
95
+ ```
96
+
97
+ ### Step 1: Install Dependencies
98
+
99
+ Install the necessary packages using npm:
100
+
101
+ ```bash packageManager="npm"
102
+ npm install intlayer svelte-intlayer
103
+ npm install vite-intlayer --save-dev
104
+ ```
105
+
106
+ ```bash packageManager="pnpm"
107
+ pnpm add intlayer svelte-intlayer
108
+ pnpm add vite-intlayer --save-dev
109
+ ```
110
+
111
+ ```bash packageManager="yarn"
112
+ yarn add intlayer svelte-intlayer
113
+ yarn add vite-intlayer --save-dev
114
+ ```
115
+
116
+ ```bash packageManager="bun"
117
+ bun add intlayer svelte-intlayer
118
+ bun add vite-intlayer --save-dev
119
+ ```
120
+
121
+ - **intlayer**: The core i18n package.
122
+ - **svelte-intlayer**: Provides context providers and stores for Svelte/SvelteKit.
123
+ - **vite-intlayer**: The Vite plugin to integrate content declarations with the build process.
124
+
125
+ ### Step 2: Configuration of your project
126
+
127
+ Create a config file in your project root:
128
+
129
+ ```typescript fileName="intlayer.config.ts"
130
+ import { Locales, type IntlayerConfig } from "intlayer";
131
+
132
+ const config: IntlayerConfig = {
133
+ internationalization: {
134
+ locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
135
+ defaultLocale: Locales.ENGLISH,
136
+ },
137
+ };
138
+
139
+ export default config;
140
+ ```
141
+
142
+ ### Step 3: Integrate Intlayer in Your Vite Configuration
143
+
144
+ Update your `vite.config.ts` to include the Intlayer plugin. This plugin handles the transpilation of your content files.
145
+
146
+ ```typescript fileName="vite.config.ts"
147
+ import { sveltekit } from "@sveltejs/kit/vite";
148
+ import { defineConfig } from "vite";
149
+ import { intlayer } from "vite-intlayer";
150
+
151
+ export default defineConfig({
152
+ plugins: [intlayer(), sveltekit()], // order matters, Intlayer should be placed before SvelteKit
153
+ });
154
+ ```
155
+
156
+ ### Step 4: Declare Your Content
157
+
158
+ Create your content declaration files anywhere in your `src` folder (e.g., `src/lib/content` or alongside your components). These files define the translatable content for your application using the `t()` function for each locale.
159
+
160
+ ```ts fileName="src/features/hero/hero.content.ts" contentDeclarationFormat="typescript"
161
+ import { t, type Dictionary } from "intlayer";
162
+
163
+ const heroContent = {
164
+ key: "hero-section",
165
+ content: {
166
+ title: t({
167
+ en: "Welcome to SvelteKit",
168
+ fr: "Bienvenue sur SvelteKit",
169
+ es: "Bienvenido a SvelteKit",
170
+ }),
171
+ },
172
+ } satisfies Dictionary;
173
+
174
+ export default heroContent;
175
+ ```
176
+
177
+ ### Step 5: Utilize Intlayer in Your Components
178
+
179
+ Now you can use the `useIntlayer` function in any Svelte component. It returns a reactive store that automatically updates when the locale changes. The function will automatically respect the current locale (both during SSR and client-side navigation).
180
+
181
+ > **Note:** `useIntlayer` returns a Svelte store, so you need to use the `$` prefix to access its reactive value (e.g., `$content.title`).
182
+
183
+ ```svelte fileName="src/lib/components/Component.svelte"
184
+ <script lang="ts">
185
+ import { useIntlayer } from "svelte-intlayer";
186
+
187
+ // "hero-section" corresponds to the key defined in Step 4
188
+ const content = useIntlayer("hero-section");
189
+ </script>
190
+
191
+ <!-- Render content as simple content -->
192
+ <h1>{$content.title}</h1>
193
+ <!-- To render the content editable using the editor -->
194
+ <h1><svelte:component this={$content.title} /></h1>
195
+ <!-- To render the content as a string -->
196
+ <div aria-label={$content.title.value}></div>
197
+ ```
198
+
199
+ ### (Optional) Step 6: Set up routing
200
+
201
+ The following steps show how to set up locale-based routing in SvelteKit. This allows your URLs to include the locale prefix (e.g., `/en/about`, `/fr/about`) for better SEO and user experience.
202
+
203
+ ```bash
204
+ .
205
+ └─── src
206
+ ├── app.d.ts # Define the locale type
207
+ ├── hooks.server.ts # Manage locale routing
208
+ ├── lib
209
+ │   └── getLocale.ts # Check the locale from the header, cookies
210
+ ├── params
211
+ │   └── locale.ts # Define the locale parameter
212
+ └── routes
213
+ ├── [[locale=locale]] # Wrap in a route group to set the locale
214
+ │   ├── +layout.svelte # Local layout for the route
215
+ │   ├── +layout.ts
216
+ │   ├── +page.svelte
217
+ │   ├── +page.ts
218
+ │   └── about
219
+ │      ├── +page.svelte
220
+ │      └── +page.ts
221
+ └── +layout.svelte # Root layout for fonts and global styles
222
+ ```
223
+
224
+ ### Step 7: Handle Server-Side Locale Detection (Hooks)
225
+
226
+ In SvelteKit, the server needs to know the user's locale to render the correct content during SSR. We use `hooks.server.ts` to detect the locale from the URL or cookies.
227
+
228
+ Create or modify `src/hooks.server.ts`:
229
+
230
+ ```typescript fileName="src/hooks.server.ts"
231
+ import type { Handle } from "@sveltejs/kit";
232
+ import { getLocalizedUrl } from "intlayer";
233
+ import { getLocale } from "$lib/getLocale";
234
+
235
+ export const handle: Handle = async ({ event, resolve }) => {
236
+ const detectedLocale = getLocale(event);
237
+
238
+ // Check if the current path already starts with a locale (e.g. /fr, /en)
239
+ const pathname = event.url.pathname;
240
+ const targetPathname = getLocalizedUrl(pathname, detectedLocale);
241
+
242
+ // If NO locale is present in the URL (e.g. user visits "/"), redirect them
243
+ if (targetPathname !== pathname) {
244
+ return new Response(undefined, {
245
+ headers: { Location: targetPathname },
246
+ status: 307, // Temporary redirect
247
+ });
248
+ }
249
+
250
+ return resolve(event, {
251
+ transformPageChunk: ({ html }) => html.replace("%lang%", detectedLocale),
252
+ });
253
+ };
254
+ ```
255
+
256
+ Then, create a helper to get the user's locale from the request event:
257
+
258
+ ```typescript fileName="src/lib/getLocale.ts"
259
+ import {
260
+ configuration,
261
+ getLocaleFromStorage,
262
+ localeDetector,
263
+ type Locale,
264
+ } from "intlayer";
265
+ import type { RequestEvent } from "@sveltejs/kit";
266
+
267
+ /**
268
+ * Get the user's locale from the request event.
269
+ * This function is used in the `handle` hook in `src/hooks.server.ts`.
270
+ *
271
+ * It first tries to get the locale from the Intlayer storage (cookies or custom headers).
272
+ * If the locale is not found, it falls back to the browser's "Accept-Language" negotiation.
273
+ *
274
+ * @param event - The request event from SvelteKit
275
+ * @returns The user's locale
276
+ */
277
+ export const getLocale = (event: RequestEvent): Locale => {
278
+ const defaultLocale = configuration?.internationalization?.defaultLocale;
279
+
280
+ // Try to get locale from Intlayer storage (Cookies or headers)
281
+ const storedLocale = getLocaleFromStorage({
282
+ // SvelteKit cookies access
283
+ getCookie: (name: string) => event.cookies.get(name) ?? null,
284
+ // SvelteKit headers access
285
+ getHeader: (name: string) => event.request.headers.get(name) ?? null,
286
+ });
287
+
288
+ if (storedLocale) {
289
+ return storedLocale;
290
+ }
291
+
292
+ // Fallback to Browser "Accept-Language" negotiation
293
+ const negotiatorHeaders: Record<string, string> = {};
294
+
295
+ // Convert SvelteKit Headers object to a plain Record<string, string>
296
+ event.request.headers.forEach((value, key) => {
297
+ negotiatorHeaders[key] = value;
298
+ });
299
+
300
+ // Check the locale from the `Accept-Language` header
301
+ const userFallbackLocale = localeDetector(negotiatorHeaders);
302
+
303
+ if (userFallbackLocale) {
304
+ return userFallbackLocale;
305
+ }
306
+
307
+ // Return default locale if no match is found
308
+ return defaultLocale;
309
+ };
310
+ ```
311
+
312
+ > `getLocaleFromStorage` will check the locale from header or cookie depending on your configuration. See [Configuration](https://intlayer.org/doc/configuration) for more details.
313
+
314
+ > The `localeDetector` function will treat the `Accept-Language` header and return the best match.
315
+
316
+ If the locale is not configured, we want to return a 404 error. To make it easier, we can create a `match` function to check if the locale is valid:
317
+
318
+ ```ts fileName="/src/params/locale.ts"
319
+ import { configuration, type Locale } from "intlayer";
320
+
321
+ export const match = (
322
+ param: Locale = configuration.internationalization.defaultLocale
323
+ ): boolean => {
324
+ return configuration.internationalization.locales.includes(param);
325
+ };
326
+ ```
327
+
328
+ > **Note:** Ensure your `src/app.d.ts` includes the locale definition:
329
+ >
330
+ > ```typescript
331
+ > declare global {
332
+ > namespace App {
333
+ > interface Locals {
334
+ > locale: import("intlayer").Locale;
335
+ > }
336
+ > }
337
+ > }
338
+ > ```
339
+
340
+ For the `+layout.svelte` file, we can remove everything, to keep only static content, not related to i18n:
341
+
342
+ ```svelte fileName="src/+layout.svelte"
343
+ <script lang="ts">
344
+ import './layout.css';
345
+
346
+ let { children } = $props();
347
+ </script>
348
+
349
+ <div class="app">
350
+ {@render children()}
351
+ </div>
352
+
353
+ <style>
354
+ .app {
355
+ /* */
356
+ }
357
+ </style>
358
+ ```
359
+
360
+ Then, create a new page and layout under the `[[locale=locale]]` group:
361
+
362
+ ```ts fileName="src/routes/[[locale=locale]]/+layout.ts"
363
+ import type { Load } from "@sveltejs/kit";
364
+ import { configuration, type Locale } from "intlayer";
365
+
366
+ export const prerender = true;
367
+
368
+ // Use the generic Load type
369
+ export const load: Load = ({ params }) => {
370
+ const locale: Locale =
371
+ (params.locale as Locale) ??
372
+ configuration.internationalization.defaultLocale;
373
+
374
+ return {
375
+ locale,
376
+ };
377
+ };
378
+ ```
379
+
380
+ ```svelte fileName="src/routes/[[locale=locale]]/+layout.svelte"
381
+ <script lang="ts">
382
+ import type { Snippet } from 'svelte';
383
+ import { useIntlayer, setupIntlayer } from 'svelte-intlayer';
384
+ import Header from './Header.svelte';
385
+ import type { LayoutData } from './$types';
386
+
387
+ let { children, data }: { children: Snippet, data: LayoutData } = $props();
388
+
389
+ // Initialize Intlayer with the locale from the route
390
+ setupIntlayer(data.locale);
391
+
392
+ // Use the layout content dictionary
393
+ const layoutContent = useIntlayer('layout');
394
+ </script>
395
+
396
+ <Header />
397
+
398
+ <main>
399
+ {@render children()}
400
+ </main>
401
+
402
+ <footer>
403
+ <p>
404
+ {$layoutContent.footer.prefix.value}{' '}
405
+ <a href="https://svelte.dev/docs/kit">{$layoutContent.footer.linkLabel.value}</a>{' '}
406
+ {$layoutContent.footer.suffix.value}
407
+ </p>
408
+ </footer>
409
+
410
+ <style>
411
+ /* */
412
+ </style>
413
+ ```
414
+
415
+ ```ts fileName="src/routes/[[locale=locale]]/+page.ts"
416
+ export const prerender = true;
417
+ ```
418
+
419
+ ```svelte fileName="src/routes/[[locale=locale]]/+page.svelte"
420
+ <script lang="ts">
421
+ import { useIntlayer } from 'svelte-intlayer';
422
+
423
+ // Use the home content dictionary
424
+ const homeContent = useIntlayer('home');
425
+ </script>
426
+
427
+ <svelte:head>
428
+ <title>{$homeContent.title.value}</title>
429
+ </svelte:head>
430
+
431
+ <section>
432
+ <h1>
433
+ {$homeContent.title}
434
+ </h1>
435
+ </section>
436
+
437
+ <style>
438
+ /* */
439
+ </style>
440
+ ```
441
+
442
+ ### (Optional) Step 8: Internationalized Links
443
+
444
+ For SEO, it is recommended to prefix your routes with the locale (e.g., `/en/about`, `/fr/about`). This component automatically prefixes any link with the current locale.
445
+
446
+ ```svelte fileName="src/lib/components/LocalizedLink.svelte"
447
+ <script lang="ts">
448
+ import { getLocalizedUrl } from "intlayer";
449
+ import { useLocale } from 'svelte-intlayer';
450
+
451
+ let { href = "" } = $props();
452
+ const { locale } = useLocale();
453
+
454
+ // Helper to prefix URL with current locale
455
+ $: localizedHref = getLocalizedUrl(href, $locale);
456
+ </script>
457
+
458
+ <a href={localizedHref}>
459
+ <slot />
460
+ </a>
461
+ ```
462
+
463
+ If you use `goto` from SvelteKit, you can use the same logic with `getLocalizedUrl` to navigate to the localized URL:
464
+
465
+ ```typescript
466
+ import { goto } from "$app/navigation";
467
+ import { getLocalizedUrl } from "intlayer";
468
+ import { useLocale } from "svelte-intlayer";
469
+
470
+ const { locale } = useLocale();
471
+ const localizedPath = getLocalizedUrl("/about", $locale);
472
+ goto(localizedPath); // Navigates to /en/about or /fr/about depending on locale
473
+ ```
474
+
475
+ ### (Optional) Step 9: Language Switcher
476
+
477
+ To allow users to switch languages, update the URL.
478
+
479
+ ```svelte fileName="src/lib/components/LanguageSwitcher.svelte"
480
+ <script lang="ts">
481
+ import { getLocalizedUrl, getLocaleName } from 'intlayer';
482
+ import { useLocale } from 'svelte-intlayer';
483
+ import { page } from '$app/stores';
484
+ import { goto } from '$app/navigation';
485
+
486
+ const { locale, setLocale, availableLocales } = useLocale({
487
+ onLocaleChange: (newLocale) => {
488
+ const localizedPath = getLocalizedUrl($page.url.pathname, newLocale);
489
+ goto(localizedPath);
490
+ },
491
+ });
492
+ </script>
493
+
494
+ <ul class="locale-list">
495
+ {#each availableLocales as localeEl}
496
+ <li>
497
+ <a
498
+ href={getLocalizedUrl($page.url.pathname, localeEl)}
499
+ onclick={(e) => {
500
+ e.preventDefault();
501
+ setLocale(localeEl); // Will set the locale in the store and trigger onLocaleChange
502
+ }}
503
+ class:active={$locale === localeEl}
504
+ >
505
+ {getLocaleName(localeEl)}
506
+ </a>
507
+ </li>
508
+ {/each}
509
+ </ul>
510
+
511
+ <style>
512
+ /* */
513
+ </style>
514
+ ```
515
+
516
+ ### (Optional) Step 10: Add backend proxy
517
+
518
+ To add a backend proxy to your SvelteKit application, you can use the `intlayerProxy` function provided by the `vite-intlayer` plugin. This plugin will automatically detect the best locale for the user based on the URL, cookies, and browser language preferences.
519
+
520
+ ```ts fileName="vite.config.ts"
521
+ import { defineConfig } from "vite";
522
+ import { intlayer, intlayerProxy } from "vite-intlayer";
523
+ import { sveltekit } from "@sveltejs/kit/vite";
524
+
525
+ // https://vitejs.dev/config/
526
+ export default defineConfig({
527
+ plugins: [intlayer(), intlayerProxy(), sveltekit()],
528
+ });
529
+ ```
530
+
531
+ ### (Optional) Step 11: Set up the intlayer editor / CMS
532
+
533
+ To set up the intlayer editor, you must follow the [intlayer editor documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md).
534
+
535
+ To set up the intlayer CMS, you must follow the [intlayer CMS documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_CMS.md).
536
+
537
+ To be able to visualize the intlayer editor selector, you will have to use the component syntax in your intlayer content.
538
+
539
+ ```svelte fileName="Component.svelte"
540
+ <script lang="ts">
541
+ import { useIntlayer } from "svelte-intlayer";
542
+
543
+ const content = useIntlayer("component");
544
+ </script>
545
+
546
+ <div>
547
+
548
+ <!-- Render content as simple content -->
549
+ <h1>{$content.title}</h1>
550
+
551
+ <!-- Render content as a component (required by the editor) -->
552
+ <svelte:component this={$content.component} />
553
+ </div>
554
+ ```
555
+
556
+ ### Git Configuration
557
+
558
+ It is recommended to ignore the files generated by Intlayer.
559
+
560
+ ```plaintext fileName=".gitignore"
561
+ # Ignore the files generated by Intlayer
562
+ .intlayer
563
+ ```
564
+
565
+ ---
566
+
567
+ ### Go Further
568
+
569
+ - **Visual Editor**: Integrate the [Intlayer Visual Editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md) to edit translations directly from the UI.
570
+ - **CMS**: Externalize your content management using the [Intlayer CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_CMS.md).
@@ -26,8 +26,6 @@ history:
26
26
 
27
27
  # Translate your Vite and Svelte website using Intlayer | Internationalization (i18n)
28
28
 
29
- > This package is in development. See the [issue](https://github.com/aymericzip/intlayer/issues/114) for more information. Show your interest in Intlayer for Svelte by liking the issue
30
-
31
29
  ## Table of Contents
32
30
 
33
31
  <TOC/>
@@ -76,6 +74,11 @@ yarn add intlayer svelte-intlayer
76
74
  yarn add vite-intlayer --save-dev
77
75
  ```
78
76
 
77
+ ```bash packageManager="bun"
78
+ bun add intlayer svelte-intlayer
79
+ bun add vite-intlayer --save-dev
80
+ ```
81
+
79
82
  - **intlayer**
80
83
 
81
84
  The core package that provides internationalization tools for configuration management, translation, [content declaration](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/dictionary/content_file.md), transpilation, and [CLI commands](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_cli.md).
@@ -449,13 +452,26 @@ const changeLocale = (event: Event) => {
449
452
  </div>
450
453
  ```
451
454
 
452
- ### (Optional) Step 9: Switch the HTML Language and Direction Attributes
455
+ ### (Optional) Step 9: Internationalized Links
453
456
 
454
- [to complete]
457
+ For SEO, it is recommended to prefix your routes with the locale (e.g., `/about`, `/fr/about`).
455
458
 
456
- ### (Optional) Step 10: Creating a Localized Link Component
459
+ ```svelte fileName="src/lib/components/Link.svelte"
460
+ <script lang="ts">
461
+ import { getLocalizedUrl } from "intlayer";
462
+ import { useLocale } from 'svelte-intlayer';
457
463
 
458
- <!-- [to complete] -->
464
+ export let href = "";
465
+ const { locale } = useLocale();
466
+
467
+ // Helper to prefix URL
468
+ $: localizedHref = getLocalizedUrl(href, $locale);
469
+ </script>
470
+
471
+ <a href={localizedHref}>
472
+ <slot />
473
+ </a>
474
+ ```
459
475
 
460
476
  ### Git Configuration
461
477
 
@@ -200,6 +200,8 @@ We’ve built Intlayer with flexibility in mind, offering seamless integration a
200
200
  - **[Intlayer with Vite + Preact](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_vite+preact.md)**
201
201
  - **[Intlayer with Vite + Vue](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_vite+vue.md)**
202
202
  - **[Intlayer with Nuxt](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_nuxt.md)**
203
+ - **[Intlayer with Vite + Svelte](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_vite+svelte.md)**
204
+ - **[Intlayer with SvelteKit](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_svelte_kit.md)**
203
205
  - **[Intlayer with Express](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_express.md)**
204
206
  - **[Intlayer with NestJS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_nestjs.md)**
205
207
  - **[Intlayer with Angular](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_with_angular.md)**