@intlayer/docs 7.1.7 → 7.1.8
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.
- package/docs/ar/intlayer_with_vite+svelte.md +35 -8
- package/docs/de/intlayer_with_vite+svelte.md +35 -8
- package/docs/en/intlayer_with_vite+svelte.md +159 -77
- package/docs/en-GB/intlayer_with_vite+svelte.md +35 -8
- package/docs/es/intlayer_with_vite+svelte.md +35 -8
- package/docs/fr/intlayer_with_vite+svelte.md +35 -8
- package/docs/hi/intlayer_with_vite+svelte.md +28 -7
- package/docs/id/intlayer_with_vite+svelte.md +35 -8
- package/docs/it/intlayer_with_vite+svelte.md +35 -8
- package/docs/ja/intlayer_with_vite+svelte.md +35 -8
- package/docs/ko/intlayer_with_vite+svelte.md +46 -14
- package/docs/pl/intlayer_with_vite+svelte.md +35 -8
- package/docs/pt/intlayer_with_vite+svelte.md +35 -8
- package/docs/ru/intlayer_with_vite+svelte.md +35 -8
- package/docs/tr/intlayer_with_vite+svelte.md +35 -8
- package/docs/vi/intlayer_with_vite+svelte.md +35 -8
- package/docs/zh/intlayer_with_vite+svelte.md +35 -8
- package/package.json +6 -6
|
@@ -139,23 +139,23 @@ module.exports = config;
|
|
|
139
139
|
|
|
140
140
|
```typescript fileName="vite.config.ts" codeFormat="typescript"
|
|
141
141
|
import { defineConfig } from "vite";
|
|
142
|
-
import
|
|
142
|
+
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
143
143
|
import { intlayer } from "vite-intlayer";
|
|
144
144
|
|
|
145
145
|
// https://vitejs.dev/config/
|
|
146
146
|
export default defineConfig({
|
|
147
|
-
plugins: [
|
|
147
|
+
plugins: [svelte(), intlayer()],
|
|
148
148
|
});
|
|
149
149
|
```
|
|
150
150
|
|
|
151
151
|
```javascript fileName="vite.config.mjs" codeFormat="esm"
|
|
152
152
|
import { defineConfig } from "vite";
|
|
153
|
-
import
|
|
153
|
+
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
154
154
|
import { intlayer } from "vite-intlayer";
|
|
155
155
|
|
|
156
156
|
// https://vitejs.dev/config/
|
|
157
157
|
export default defineConfig({
|
|
158
|
-
plugins: [
|
|
158
|
+
plugins: [svelte(), intlayer()],
|
|
159
159
|
});
|
|
160
160
|
```
|
|
161
161
|
|
|
@@ -181,7 +181,13 @@ import { t, type Dictionary } from "intlayer";
|
|
|
181
181
|
|
|
182
182
|
const appContent = {
|
|
183
183
|
key: "app",
|
|
184
|
-
content: {
|
|
184
|
+
content: {
|
|
185
|
+
title: t({
|
|
186
|
+
en: "Hello World",
|
|
187
|
+
fr: "Bonjour le monde",
|
|
188
|
+
es: "Hola mundo",
|
|
189
|
+
}),
|
|
190
|
+
},
|
|
185
191
|
} satisfies Dictionary;
|
|
186
192
|
|
|
187
193
|
export default appContent;
|
|
@@ -193,7 +199,13 @@ import { t } from "intlayer";
|
|
|
193
199
|
/** @type {import('intlayer').Dictionary} */
|
|
194
200
|
const appContent = {
|
|
195
201
|
key: "app",
|
|
196
|
-
content: {
|
|
202
|
+
content: {
|
|
203
|
+
title: t({
|
|
204
|
+
en: "Hello World",
|
|
205
|
+
fr: "Bonjour le monde",
|
|
206
|
+
es: "Hola mundo",
|
|
207
|
+
}),
|
|
208
|
+
},
|
|
197
209
|
};
|
|
198
210
|
|
|
199
211
|
export default appContent;
|
|
@@ -206,7 +218,13 @@ const { t } = require("intlayer");
|
|
|
206
218
|
// تعريف محتوى التطبيق
|
|
207
219
|
const appContent = {
|
|
208
220
|
key: "app",
|
|
209
|
-
content: {
|
|
221
|
+
content: {
|
|
222
|
+
title: t({
|
|
223
|
+
en: "Hello World",
|
|
224
|
+
fr: "Bonjour le monde",
|
|
225
|
+
es: "Hola mundo",
|
|
226
|
+
}),
|
|
227
|
+
},
|
|
210
228
|
};
|
|
211
229
|
|
|
212
230
|
module.exports = appContent;
|
|
@@ -216,7 +234,16 @@ module.exports = appContent;
|
|
|
216
234
|
{
|
|
217
235
|
"$schema": "https://intlayer.org/schema.json",
|
|
218
236
|
"key": "app",
|
|
219
|
-
"content": {
|
|
237
|
+
"content": {
|
|
238
|
+
"title": {
|
|
239
|
+
"nodeType": "translation",
|
|
240
|
+
"translation": {
|
|
241
|
+
"en": "Hello World",
|
|
242
|
+
"fr": "Bonjour le monde",
|
|
243
|
+
"es": "Hola mundo"
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
220
247
|
}
|
|
221
248
|
```
|
|
222
249
|
|
|
@@ -142,23 +142,23 @@ Fügen Sie das Intlayer-Plugin in Ihre Konfiguration ein.
|
|
|
142
142
|
|
|
143
143
|
```typescript fileName="vite.config.ts" codeFormat="typescript"
|
|
144
144
|
import { defineConfig } from "vite";
|
|
145
|
-
import
|
|
145
|
+
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
146
146
|
import { intlayer } from "vite-intlayer";
|
|
147
147
|
|
|
148
148
|
// https://vitejs.dev/config/
|
|
149
149
|
export default defineConfig({
|
|
150
|
-
plugins: [
|
|
150
|
+
plugins: [svelte(), intlayer()],
|
|
151
151
|
});
|
|
152
152
|
```
|
|
153
153
|
|
|
154
154
|
```javascript fileName="vite.config.mjs" codeFormat="esm"
|
|
155
155
|
import { defineConfig } from "vite";
|
|
156
|
-
import
|
|
156
|
+
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
157
157
|
import { intlayer } from "vite-intlayer";
|
|
158
158
|
|
|
159
159
|
// https://vitejs.dev/config/
|
|
160
160
|
export default defineConfig({
|
|
161
|
-
plugins: [
|
|
161
|
+
plugins: [svelte(), intlayer()],
|
|
162
162
|
});
|
|
163
163
|
```
|
|
164
164
|
|
|
@@ -184,7 +184,13 @@ import { t, type Dictionary } from "intlayer";
|
|
|
184
184
|
|
|
185
185
|
const appContent = {
|
|
186
186
|
key: "app",
|
|
187
|
-
content: {
|
|
187
|
+
content: {
|
|
188
|
+
title: t({
|
|
189
|
+
en: "Hello World",
|
|
190
|
+
fr: "Bonjour le monde",
|
|
191
|
+
es: "Hola mundo",
|
|
192
|
+
}),
|
|
193
|
+
},
|
|
188
194
|
} satisfies Dictionary;
|
|
189
195
|
|
|
190
196
|
export default appContent;
|
|
@@ -196,7 +202,13 @@ import { t } from "intlayer";
|
|
|
196
202
|
/** @type {import('intlayer').Dictionary} */
|
|
197
203
|
const appContent = {
|
|
198
204
|
key: "app",
|
|
199
|
-
content: {
|
|
205
|
+
content: {
|
|
206
|
+
title: t({
|
|
207
|
+
en: "Hello World",
|
|
208
|
+
fr: "Bonjour le monde",
|
|
209
|
+
es: "Hola mundo",
|
|
210
|
+
}),
|
|
211
|
+
},
|
|
200
212
|
};
|
|
201
213
|
|
|
202
214
|
export default appContent;
|
|
@@ -209,7 +221,13 @@ const { t } = require("intlayer");
|
|
|
209
221
|
// Definiert den Inhalt der Anwendung
|
|
210
222
|
const appContent = {
|
|
211
223
|
key: "app",
|
|
212
|
-
content: {
|
|
224
|
+
content: {
|
|
225
|
+
title: t({
|
|
226
|
+
en: "Hello World",
|
|
227
|
+
fr: "Bonjour le monde",
|
|
228
|
+
es: "Hola mundo",
|
|
229
|
+
}),
|
|
230
|
+
},
|
|
213
231
|
};
|
|
214
232
|
|
|
215
233
|
module.exports = appContent;
|
|
@@ -219,7 +237,16 @@ module.exports = appContent;
|
|
|
219
237
|
{
|
|
220
238
|
"$schema": "https://intlayer.org/schema.json",
|
|
221
239
|
"key": "app",
|
|
222
|
-
"content": {
|
|
240
|
+
"content": {
|
|
241
|
+
"title": {
|
|
242
|
+
"nodeType": "translation",
|
|
243
|
+
"translation": {
|
|
244
|
+
"en": "Hello World",
|
|
245
|
+
"fr": "Bonjour le monde",
|
|
246
|
+
"es": "Hola mundo"
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
223
250
|
}
|
|
224
251
|
```
|
|
225
252
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-04-18
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-11-19
|
|
4
4
|
title: How to translate your Vite and Svelte app – i18n guide 2025
|
|
5
5
|
description: Discover how to make your Vite and Svelte website multilingual. Follow the documentation to internationalize (i18n) and translate it.
|
|
6
6
|
keywords:
|
|
@@ -14,8 +14,11 @@ slugs:
|
|
|
14
14
|
- doc
|
|
15
15
|
- environment
|
|
16
16
|
- vite-and-svelte
|
|
17
|
-
|
|
17
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-vite-svelte-template
|
|
18
18
|
history:
|
|
19
|
+
- version: 5.5.11
|
|
20
|
+
date: 2025-11-19
|
|
21
|
+
changes: Update doc
|
|
19
22
|
- version: 5.5.10
|
|
20
23
|
date: 2025-06-29
|
|
21
24
|
changes: Init history
|
|
@@ -25,8 +28,6 @@ history:
|
|
|
25
28
|
|
|
26
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
|
|
27
30
|
|
|
28
|
-
<!-- See [Application Template](https://github.com/aymericzip/intlayer-solid-template) on GitHub. -->
|
|
29
|
-
|
|
30
31
|
## Table of Contents
|
|
31
32
|
|
|
32
33
|
<TOC/>
|
|
@@ -46,6 +47,16 @@ With Intlayer, you can:
|
|
|
46
47
|
|
|
47
48
|
## Step-by-Step Guide to Set Up Intlayer in a Vite and Svelte Application
|
|
48
49
|
|
|
50
|
+
<iframe
|
|
51
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-vite-react-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
|
+
See [Application Template](https://github.com/aymericzip/intlayer-vite-svelte-template) on GitHub.
|
|
59
|
+
|
|
49
60
|
### Step 1: Install Dependencies
|
|
50
61
|
|
|
51
62
|
Install the necessary packages using npm:
|
|
@@ -79,7 +90,7 @@ yarn add vite-intlayer --save-dev
|
|
|
79
90
|
|
|
80
91
|
Create a config file to configure the languages of your application:
|
|
81
92
|
|
|
82
|
-
```typescript fileName="intlayer.config.ts"
|
|
93
|
+
```typescript fileName="intlayer.config.ts"
|
|
83
94
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
84
95
|
|
|
85
96
|
const config: IntlayerConfig = {
|
|
@@ -97,80 +108,20 @@ const config: IntlayerConfig = {
|
|
|
97
108
|
export default config;
|
|
98
109
|
```
|
|
99
110
|
|
|
100
|
-
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
101
|
-
import { Locales } from "intlayer";
|
|
102
|
-
|
|
103
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
104
|
-
const config = {
|
|
105
|
-
internationalization: {
|
|
106
|
-
locales: [
|
|
107
|
-
Locales.ENGLISH,
|
|
108
|
-
Locales.FRENCH,
|
|
109
|
-
Locales.SPANISH,
|
|
110
|
-
// Your other locales
|
|
111
|
-
],
|
|
112
|
-
defaultLocale: Locales.ENGLISH,
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export default config;
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
120
|
-
const { Locales } = require("intlayer");
|
|
121
|
-
|
|
122
|
-
/** @type {import('intlayer').IntlayerConfig} */
|
|
123
|
-
const config = {
|
|
124
|
-
internationalization: {
|
|
125
|
-
locales: [
|
|
126
|
-
Locales.ENGLISH,
|
|
127
|
-
Locales.FRENCH,
|
|
128
|
-
Locales.SPANISH,
|
|
129
|
-
// Your other locales
|
|
130
|
-
],
|
|
131
|
-
defaultLocale: Locales.ENGLISH,
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
module.exports = config;
|
|
136
|
-
```
|
|
137
|
-
|
|
138
111
|
> Through this configuration file, you can set up localized URLs, middleware redirection, cookie names, the location and extension of your content declarations, disable Intlayer logs in the console, and more. For a complete list of available parameters, refer to the [configuration documentation](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/configuration.md).
|
|
139
112
|
|
|
140
113
|
### Step 3: Integrate Intlayer in Your Vite Configuration
|
|
141
114
|
|
|
142
115
|
Add the intlayer plugin into your configuration.
|
|
143
116
|
|
|
144
|
-
```typescript fileName="vite.config.ts"
|
|
117
|
+
```typescript fileName="vite.config.ts"
|
|
145
118
|
import { defineConfig } from "vite";
|
|
146
|
-
import
|
|
119
|
+
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
147
120
|
import { intlayer } from "vite-intlayer";
|
|
148
121
|
|
|
149
122
|
// https://vitejs.dev/config/
|
|
150
123
|
export default defineConfig({
|
|
151
|
-
plugins: [
|
|
152
|
-
});
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
```javascript fileName="vite.config.mjs" codeFormat="esm"
|
|
156
|
-
import { defineConfig } from "vite";
|
|
157
|
-
import react from "@vitejs/plugin-react-swc";
|
|
158
|
-
import { intlayer } from "vite-intlayer";
|
|
159
|
-
|
|
160
|
-
// https://vitejs.dev/config/
|
|
161
|
-
export default defineConfig({
|
|
162
|
-
plugins: [react(), intlayer()],
|
|
163
|
-
});
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
```javascript fileName="vite.config.cjs" codeFormat="commonjs"
|
|
167
|
-
const { defineConfig } = require("vite");
|
|
168
|
-
const react = require("@vitejs/plugin-react-swc");
|
|
169
|
-
const { intlayer } = require("vite-intlayer");
|
|
170
|
-
|
|
171
|
-
// https://vitejs.dev/config/
|
|
172
|
-
module.exports = defineConfig({
|
|
173
|
-
plugins: [react(), intlayer()],
|
|
124
|
+
plugins: [svelte(), intlayer()],
|
|
174
125
|
});
|
|
175
126
|
```
|
|
176
127
|
|
|
@@ -185,7 +136,13 @@ import { t, type Dictionary } from "intlayer";
|
|
|
185
136
|
|
|
186
137
|
const appContent = {
|
|
187
138
|
key: "app",
|
|
188
|
-
content: {
|
|
139
|
+
content: {
|
|
140
|
+
title: t({
|
|
141
|
+
en: "Hello World",
|
|
142
|
+
fr: "Bonjour le monde",
|
|
143
|
+
es: "Hola mundo",
|
|
144
|
+
}),
|
|
145
|
+
},
|
|
189
146
|
} satisfies Dictionary;
|
|
190
147
|
|
|
191
148
|
export default appContent;
|
|
@@ -197,7 +154,13 @@ import { t } from "intlayer";
|
|
|
197
154
|
/** @type {import('intlayer').Dictionary} */
|
|
198
155
|
const appContent = {
|
|
199
156
|
key: "app",
|
|
200
|
-
content: {
|
|
157
|
+
content: {
|
|
158
|
+
title: t({
|
|
159
|
+
en: "Hello World",
|
|
160
|
+
fr: "Bonjour le monde",
|
|
161
|
+
es: "Hola mundo",
|
|
162
|
+
}),
|
|
163
|
+
},
|
|
201
164
|
};
|
|
202
165
|
|
|
203
166
|
export default appContent;
|
|
@@ -209,7 +172,13 @@ const { t } = require("intlayer");
|
|
|
209
172
|
/** @type {import('intlayer').Dictionary} */
|
|
210
173
|
const appContent = {
|
|
211
174
|
key: "app",
|
|
212
|
-
content: {
|
|
175
|
+
content: {
|
|
176
|
+
title: t({
|
|
177
|
+
en: "Hello World",
|
|
178
|
+
fr: "Bonjour le monde",
|
|
179
|
+
es: "Hola mundo",
|
|
180
|
+
}),
|
|
181
|
+
},
|
|
213
182
|
};
|
|
214
183
|
|
|
215
184
|
module.exports = appContent;
|
|
@@ -219,7 +188,16 @@ module.exports = appContent;
|
|
|
219
188
|
{
|
|
220
189
|
"$schema": "https://intlayer.org/schema.json",
|
|
221
190
|
"key": "app",
|
|
222
|
-
"content": {
|
|
191
|
+
"content": {
|
|
192
|
+
"title": {
|
|
193
|
+
"nodeType": "translation",
|
|
194
|
+
"translation": {
|
|
195
|
+
"en": "Hello World",
|
|
196
|
+
"fr": "Bonjour le monde",
|
|
197
|
+
"es": "Hola mundo"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
223
201
|
}
|
|
224
202
|
```
|
|
225
203
|
|
|
@@ -229,16 +207,122 @@ module.exports = appContent;
|
|
|
229
207
|
|
|
230
208
|
### Step 5: Utilize Intlayer in Your Code
|
|
231
209
|
|
|
232
|
-
|
|
210
|
+
```svelte fileName="src/App.svelte"
|
|
211
|
+
<script>
|
|
212
|
+
import { useIntlayer } from "svelte-intlayer";
|
|
213
|
+
|
|
214
|
+
const content = useIntlayer("app");
|
|
215
|
+
</script>
|
|
216
|
+
|
|
217
|
+
<h1>{$content.title}</h1>
|
|
218
|
+
|
|
219
|
+
```
|
|
233
220
|
|
|
234
221
|
### (Optional) Step 6: Change the language of your content
|
|
235
222
|
|
|
236
|
-
|
|
223
|
+
```svelte fileName="src/App.svelte"
|
|
224
|
+
<script lang="ts">
|
|
225
|
+
import { getLocaleName } from 'intlayer';
|
|
226
|
+
import { useLocale } from 'svelte-intlayer';
|
|
227
|
+
|
|
228
|
+
// Get locale information and setLocale function
|
|
229
|
+
const { locale, availableLocales, setLocale } = useLocale();
|
|
230
|
+
|
|
231
|
+
// Handle locale change
|
|
232
|
+
const changeLocale = (event: Event) => {
|
|
233
|
+
const target = event.target as HTMLSelectElement;
|
|
234
|
+
const newLocale = target.value;
|
|
235
|
+
setLocale(newLocale);
|
|
236
|
+
};
|
|
237
|
+
</script>
|
|
238
|
+
|
|
239
|
+
<div>
|
|
240
|
+
<select value={$locale} on:change={changeLocale}>
|
|
241
|
+
{#each availableLocales ?? [] as loc}
|
|
242
|
+
<option value={loc}>
|
|
243
|
+
{getLocaleName(loc)}
|
|
244
|
+
</option>
|
|
245
|
+
{/each}
|
|
246
|
+
</select>
|
|
247
|
+
</div>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### (Optional) Step 7: Render Markdown
|
|
251
|
+
|
|
252
|
+
Intlayer supports rendering Markdown content directly in your Svelte application. By default, Markdown is treated as plain text. To convert Markdown into rich HTML, you can integrate `@humanspeak/svelte-markdown`, or a other markdown parser.
|
|
253
|
+
|
|
254
|
+
> To see how to declare markdown content using the `intlayer` package, see the [markdown doc](https://github.com/aymericzip/intlayer/tree/main/docs/en/dictionary/markdown.md).
|
|
255
|
+
|
|
256
|
+
```svelte fileName="src/App.svelte"
|
|
257
|
+
<script>
|
|
258
|
+
import { setIntlayerMarkdown } from "svelte-intlayer";
|
|
259
|
+
|
|
260
|
+
setIntlayerMarkdown((markdown) =>
|
|
261
|
+
// render the markdown content as a string
|
|
262
|
+
return markdown;
|
|
263
|
+
);
|
|
264
|
+
</script>
|
|
265
|
+
|
|
266
|
+
<h1>{$content.markdownContent}</h1>
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
> You can also access your markdown front-matter data using the `content.markdownContent.metadata.xxx` property.
|
|
270
|
+
|
|
271
|
+
### (Optional) Step 8: Set up the intlayer editor / CMS
|
|
272
|
+
|
|
273
|
+
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).
|
|
274
|
+
|
|
275
|
+
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).
|
|
276
|
+
|
|
277
|
+
In parallel, in your Svelte application, you must add the following line in a layout, or at the root of your application:
|
|
278
|
+
|
|
279
|
+
```svelte fileName="src/layout.svelte"
|
|
280
|
+
import { useIntlayerEditor } from "svelte-intlayer";
|
|
281
|
+
|
|
282
|
+
useIntlayerEditor();
|
|
283
|
+
```
|
|
237
284
|
|
|
238
285
|
### (Optional) Step 7: Add localized Routing to your application
|
|
239
286
|
|
|
240
287
|
[to complete]
|
|
241
288
|
|
|
289
|
+
In parallel, you can also use the `intlayerProxy` to add server-side routing to your application. This plugin will automatically detect the current locale based on the URL and set the appropriate locale cookie. If no locale is specified, the plugin will determine the most appropriate locale based on the user's browser language preferences. If no locale is detected, it will redirect to the default locale.
|
|
290
|
+
|
|
291
|
+
> Note that to use the `intlayerProxy` in production, you need to switch the `vite-intlayer` package from `devDependencies` to `dependencies`.
|
|
292
|
+
|
|
293
|
+
```typescript {3,7} fileName="vite.config.ts" codeFormat="typescript"
|
|
294
|
+
import { defineConfig } from "vite";
|
|
295
|
+
import react from "@vitejs/plugin-react-swc";
|
|
296
|
+
import { intlayer, intlayerProxy } from "vite-intlayer";
|
|
297
|
+
|
|
298
|
+
// https://vitejs.dev/config/
|
|
299
|
+
export default defineConfig({
|
|
300
|
+
plugins: [react(), intlayer(), intlayerProxy()],
|
|
301
|
+
});
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
```javascript {3,7} fileName="vite.config.mjs" codeFormat="esm"
|
|
305
|
+
import { defineConfig } from "vite";
|
|
306
|
+
import react from "@vitejs/plugin-react-swc";
|
|
307
|
+
import { intlayer, intlayerProxy } from "vite-intlayer";
|
|
308
|
+
|
|
309
|
+
// https://vitejs.dev/config/
|
|
310
|
+
export default defineConfig({
|
|
311
|
+
plugins: [react(), intlayer(), intlayerProxy()],
|
|
312
|
+
});
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
```javascript {3,7} fileName="vite.config.cjs" codeFormat="commonjs"
|
|
316
|
+
const { defineConfig } = require("vite");
|
|
317
|
+
const react = require("@vitejs/plugin-react-swc");
|
|
318
|
+
const { intlayer, intlayerProxy } = require("vite-intlayer");
|
|
319
|
+
|
|
320
|
+
// https://vitejs.dev/config/
|
|
321
|
+
module.exports = defineConfig({
|
|
322
|
+
plugins: [react(), intlayer(), intlayerProxy()],
|
|
323
|
+
});
|
|
324
|
+
```
|
|
325
|
+
|
|
242
326
|
### (Optional) Step 8: Change the URL when the locale changes
|
|
243
327
|
|
|
244
328
|
[to complete]
|
|
@@ -249,7 +333,7 @@ module.exports = appContent;
|
|
|
249
333
|
|
|
250
334
|
### (Optional) Step 10: Creating a Localized Link Component
|
|
251
335
|
|
|
252
|
-
[to complete]
|
|
336
|
+
[to complete] -->
|
|
253
337
|
|
|
254
338
|
### Git Configuration
|
|
255
339
|
|
|
@@ -282,5 +366,3 @@ For more details on how to use the extension, refer to the [Intlayer VS Code Ext
|
|
|
282
366
|
### Go Further
|
|
283
367
|
|
|
284
368
|
To go further, you can implement the [visual editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_visual_editor.md) or externalize your content using the [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/en/intlayer_CMS.md).
|
|
285
|
-
|
|
286
|
-
---
|
|
@@ -139,23 +139,23 @@ Add the intlayer plugin into your configuration.
|
|
|
139
139
|
|
|
140
140
|
```typescript fileName="vite.config.ts" codeFormat="typescript"
|
|
141
141
|
import { defineConfig } from "vite";
|
|
142
|
-
import
|
|
142
|
+
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
143
143
|
import { intlayer } from "vite-intlayer";
|
|
144
144
|
|
|
145
145
|
// https://vitejs.dev/config/
|
|
146
146
|
export default defineConfig({
|
|
147
|
-
plugins: [
|
|
147
|
+
plugins: [svelte(), intlayer()],
|
|
148
148
|
});
|
|
149
149
|
```
|
|
150
150
|
|
|
151
151
|
```javascript fileName="vite.config.mjs" codeFormat="esm"
|
|
152
152
|
import { defineConfig } from "vite";
|
|
153
|
-
import
|
|
153
|
+
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
154
154
|
import { intlayer } from "vite-intlayer";
|
|
155
155
|
|
|
156
156
|
// https://vitejs.dev/config/
|
|
157
157
|
export default defineConfig({
|
|
158
|
-
plugins: [
|
|
158
|
+
plugins: [svelte(), intlayer()],
|
|
159
159
|
});
|
|
160
160
|
```
|
|
161
161
|
|
|
@@ -181,7 +181,13 @@ import { t, type Dictionary } from "intlayer";
|
|
|
181
181
|
|
|
182
182
|
const appContent = {
|
|
183
183
|
key: "app",
|
|
184
|
-
content: {
|
|
184
|
+
content: {
|
|
185
|
+
title: t({
|
|
186
|
+
en: "Hello World",
|
|
187
|
+
fr: "Bonjour le monde",
|
|
188
|
+
es: "Hola mundo",
|
|
189
|
+
}),
|
|
190
|
+
},
|
|
185
191
|
} satisfies Dictionary;
|
|
186
192
|
|
|
187
193
|
export default appContent;
|
|
@@ -193,7 +199,13 @@ import { t } from "intlayer";
|
|
|
193
199
|
/** @type {import('intlayer').Dictionary} */
|
|
194
200
|
const appContent = {
|
|
195
201
|
key: "app",
|
|
196
|
-
content: {
|
|
202
|
+
content: {
|
|
203
|
+
title: t({
|
|
204
|
+
en: "Hello World",
|
|
205
|
+
fr: "Bonjour le monde",
|
|
206
|
+
es: "Hola mundo",
|
|
207
|
+
}),
|
|
208
|
+
},
|
|
197
209
|
};
|
|
198
210
|
|
|
199
211
|
export default appContent;
|
|
@@ -205,7 +217,13 @@ const { t } = require("intlayer");
|
|
|
205
217
|
/** @type {import('intlayer').Dictionary} */
|
|
206
218
|
const appContent = {
|
|
207
219
|
key: "app",
|
|
208
|
-
content: {
|
|
220
|
+
content: {
|
|
221
|
+
title: t({
|
|
222
|
+
en: "Hello World",
|
|
223
|
+
fr: "Bonjour le monde",
|
|
224
|
+
es: "Hola mundo",
|
|
225
|
+
}),
|
|
226
|
+
},
|
|
209
227
|
};
|
|
210
228
|
|
|
211
229
|
module.exports = appContent;
|
|
@@ -215,7 +233,16 @@ module.exports = appContent;
|
|
|
215
233
|
{
|
|
216
234
|
"$schema": "https://intlayer.org/schema.json",
|
|
217
235
|
"key": "app",
|
|
218
|
-
"content": {
|
|
236
|
+
"content": {
|
|
237
|
+
"title": {
|
|
238
|
+
"nodeType": "translation",
|
|
239
|
+
"translation": {
|
|
240
|
+
"en": "Hello World",
|
|
241
|
+
"fr": "Bonjour le monde",
|
|
242
|
+
"es": "Hola mundo"
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
219
246
|
}
|
|
220
247
|
```
|
|
221
248
|
|
|
@@ -142,23 +142,23 @@ Agrega el plugin intlayer en tu configuración.
|
|
|
142
142
|
|
|
143
143
|
```typescript fileName="vite.config.ts" codeFormat="typescript"
|
|
144
144
|
import { defineConfig } from "vite";
|
|
145
|
-
import
|
|
145
|
+
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
146
146
|
import { intlayer } from "vite-intlayer";
|
|
147
147
|
|
|
148
148
|
// https://vitejs.dev/config/
|
|
149
149
|
export default defineConfig({
|
|
150
|
-
plugins: [
|
|
150
|
+
plugins: [svelte(), intlayer()],
|
|
151
151
|
});
|
|
152
152
|
```
|
|
153
153
|
|
|
154
154
|
```javascript fileName="vite.config.mjs" codeFormat="esm"
|
|
155
155
|
import { defineConfig } from "vite";
|
|
156
|
-
import
|
|
156
|
+
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
157
157
|
import { intlayer } from "vite-intlayer";
|
|
158
158
|
|
|
159
159
|
// https://vitejs.dev/config/
|
|
160
160
|
export default defineConfig({
|
|
161
|
-
plugins: [
|
|
161
|
+
plugins: [svelte(), intlayer()],
|
|
162
162
|
});
|
|
163
163
|
```
|
|
164
164
|
|
|
@@ -184,7 +184,13 @@ import { t, type Dictionary } from "intlayer";
|
|
|
184
184
|
|
|
185
185
|
const appContent = {
|
|
186
186
|
key: "app",
|
|
187
|
-
content: {
|
|
187
|
+
content: {
|
|
188
|
+
title: t({
|
|
189
|
+
en: "Hello World",
|
|
190
|
+
fr: "Bonjour le monde",
|
|
191
|
+
es: "Hola mundo",
|
|
192
|
+
}),
|
|
193
|
+
},
|
|
188
194
|
} satisfies Dictionary;
|
|
189
195
|
|
|
190
196
|
export default appContent;
|
|
@@ -196,7 +202,13 @@ import { t } from "intlayer";
|
|
|
196
202
|
/** @type {import('intlayer').Dictionary} */
|
|
197
203
|
const appContent = {
|
|
198
204
|
key: "app",
|
|
199
|
-
content: {
|
|
205
|
+
content: {
|
|
206
|
+
title: t({
|
|
207
|
+
en: "Hello World",
|
|
208
|
+
fr: "Bonjour le monde",
|
|
209
|
+
es: "Hola mundo",
|
|
210
|
+
}),
|
|
211
|
+
},
|
|
200
212
|
};
|
|
201
213
|
|
|
202
214
|
export default appContent;
|
|
@@ -209,7 +221,13 @@ const { t } = require("intlayer");
|
|
|
209
221
|
// Declaración del contenido de la aplicación
|
|
210
222
|
const appContent = {
|
|
211
223
|
key: "app",
|
|
212
|
-
content: {
|
|
224
|
+
content: {
|
|
225
|
+
title: t({
|
|
226
|
+
en: "Hello World",
|
|
227
|
+
fr: "Bonjour le monde",
|
|
228
|
+
es: "Hola mundo",
|
|
229
|
+
}),
|
|
230
|
+
},
|
|
213
231
|
};
|
|
214
232
|
|
|
215
233
|
module.exports = appContent;
|
|
@@ -219,7 +237,16 @@ module.exports = appContent;
|
|
|
219
237
|
{
|
|
220
238
|
"$schema": "https://intlayer.org/schema.json",
|
|
221
239
|
"key": "app",
|
|
222
|
-
"content": {
|
|
240
|
+
"content": {
|
|
241
|
+
"title": {
|
|
242
|
+
"nodeType": "translation",
|
|
243
|
+
"translation": {
|
|
244
|
+
"en": "Hello World",
|
|
245
|
+
"fr": "Bonjour le monde",
|
|
246
|
+
"es": "Hola mundo"
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
223
250
|
}
|
|
224
251
|
```
|
|
225
252
|
|