@intlayer/docs 7.3.11 → 7.3.13
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/dist/cjs/generated/docs.entry.cjs +19 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +19 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/intlayer_with_nuxt.md +294 -438
- package/docs/ar/intlayer_with_react_router_v7.md +33 -4
- package/docs/ar/intlayer_with_react_router_v7_fs_routes.md +516 -0
- package/docs/ar/intlayer_with_tanstack.md +2 -12
- package/docs/ar/intlayer_with_vite+vue.md +1 -0
- package/docs/de/intlayer_with_nuxt.md +284 -410
- package/docs/de/intlayer_with_react_router_v7.md +33 -4
- package/docs/de/intlayer_with_react_router_v7_fs_routes.md +573 -0
- package/docs/de/intlayer_with_tanstack.md +1 -0
- package/docs/de/intlayer_with_vite+vue.md +1 -0
- package/docs/en/intlayer_with_nuxt.md +237 -341
- package/docs/en/intlayer_with_react_router_v7.md +24 -0
- package/docs/en/intlayer_with_react_router_v7_fs_routes.md +570 -0
- package/docs/en/intlayer_with_tanstack.md +2 -12
- package/docs/en/intlayer_with_vite+vue.md +49 -48
- package/docs/en-GB/intlayer_with_nuxt.md +254 -378
- package/docs/en-GB/intlayer_with_react_router_v7.md +33 -4
- package/docs/en-GB/intlayer_with_react_router_v7_fs_routes.md +513 -0
- package/docs/en-GB/intlayer_with_tanstack.md +2 -12
- package/docs/en-GB/intlayer_with_vite+vue.md +1 -0
- package/docs/es/intlayer_with_nuxt.md +271 -390
- package/docs/es/intlayer_with_react_router_v7.md +33 -4
- package/docs/es/intlayer_with_react_router_v7_fs_routes.md +575 -0
- package/docs/es/intlayer_with_tanstack.md +1 -0
- package/docs/es/intlayer_with_vite+vue.md +1 -2
- package/docs/fr/intlayer_with_nuxt.md +278 -405
- package/docs/fr/intlayer_with_react_router_v7.md +34 -5
- package/docs/fr/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/fr/intlayer_with_tanstack.md +1 -0
- package/docs/fr/intlayer_with_vite+vue.md +1 -0
- package/docs/hi/intlayer_with_nuxt.md +303 -447
- package/docs/hi/intlayer_with_react_router_v7.md +33 -4
- package/docs/hi/intlayer_with_react_router_v7_fs_routes.md +518 -0
- package/docs/hi/intlayer_with_tanstack.md +2 -12
- package/docs/hi/intlayer_with_vite+vue.md +1 -0
- package/docs/id/intlayer_with_nuxt.md +266 -395
- package/docs/id/intlayer_with_react_router_v7.md +29 -4
- package/docs/id/intlayer_with_react_router_v7_fs_routes.md +521 -0
- package/docs/id/intlayer_with_tanstack.md +2 -12
- package/docs/id/intlayer_with_vite+vue.md +1 -0
- package/docs/it/intlayer_with_nuxt.md +299 -423
- package/docs/it/intlayer_with_react_router_v7.md +33 -4
- package/docs/it/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/it/intlayer_with_tanstack.md +1 -0
- package/docs/ja/intlayer_with_nuxt.md +309 -432
- package/docs/ja/intlayer_with_react_router_v7.md +33 -4
- package/docs/ja/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/ja/intlayer_with_tanstack.md +2 -12
- package/docs/ja/intlayer_with_vite+vue.md +1 -0
- package/docs/ko/intlayer_with_nuxt.md +295 -422
- package/docs/ko/intlayer_with_react_router_v7.md +33 -4
- package/docs/ko/intlayer_with_react_router_v7_fs_routes.md +515 -0
- package/docs/ko/intlayer_with_tanstack.md +2 -12
- package/docs/ko/intlayer_with_vite+vue.md +1 -0
- package/docs/pl/intlayer_with_nuxt.md +273 -476
- package/docs/pl/intlayer_with_react_router_v7.md +32 -5
- package/docs/pl/intlayer_with_react_router_v7_fs_routes.md +615 -0
- package/docs/pl/intlayer_with_tanstack.md +2 -12
- package/docs/pl/intlayer_with_vite+vue.md +1 -0
- package/docs/pt/intlayer_with_nuxt.md +277 -420
- package/docs/pt/intlayer_with_react_router_v7.md +28 -0
- package/docs/pt/intlayer_with_tanstack.md +1 -0
- package/docs/ru/intlayer_with_nuxt.md +287 -425
- package/docs/ru/intlayer_with_react_router_v7.md +33 -4
- package/docs/ru/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/ru/intlayer_with_tanstack.md +1 -0
- package/docs/ru/intlayer_with_vite+vue.md +1 -0
- package/docs/tr/intlayer_with_nuxt.md +313 -406
- package/docs/tr/intlayer_with_react_router_v7.md +33 -4
- package/docs/tr/intlayer_with_react_router_v7_fs_routes.md +572 -0
- package/docs/tr/intlayer_with_tanstack.md +2 -12
- package/docs/tr/intlayer_with_vite+vue.md +1 -0
- package/docs/vi/intlayer_with_nuxt.md +273 -418
- package/docs/vi/intlayer_with_react_router_v7.md +29 -4
- package/docs/vi/intlayer_with_react_router_v7_fs_routes.md +523 -0
- package/docs/vi/intlayer_with_tanstack.md +2 -12
- package/docs/vi/intlayer_with_vite+vue.md +1 -0
- package/docs/zh/intlayer_with_nuxt.md +300 -461
- package/docs/zh/intlayer_with_react_router_v7.md +33 -4
- package/docs/zh/intlayer_with_react_router_v7_fs_routes.md +516 -0
- package/docs/zh/intlayer_with_tanstack.md +2 -12
- package/docs/zh/intlayer_with_vite+vue.md +1 -0
- package/package.json +10 -11
- package/src/generated/docs.entry.ts +19 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-06-18
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-12-07
|
|
4
4
|
title: Jak przetłumaczyć swoją aplikację Nuxt i Vue – przewodnik i18n 2025
|
|
5
5
|
description: Dowiedz się, jak uczynić swoją stronę Nuxt i Vue wielojęzyczną. Postępuj zgodnie z dokumentacją, aby zinternacjonalizować (i18n) i przetłumaczyć ją.
|
|
6
6
|
keywords:
|
|
@@ -14,8 +14,12 @@ slugs:
|
|
|
14
14
|
- doc
|
|
15
15
|
- environment
|
|
16
16
|
- nuxt-and-vue
|
|
17
|
-
applicationTemplate: https://github.com/aymericzip/intlayer-nuxt-template
|
|
17
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-nuxt-4-template
|
|
18
|
+
youtubeVideo: https://www.youtube.com/watch?v=nhUcUAVQ6eQ
|
|
18
19
|
history:
|
|
20
|
+
- version: 7.3.11
|
|
21
|
+
date: 2025-12-07
|
|
22
|
+
changes: Aktualizacja LocaleSwitcher, SEO, metadanych
|
|
19
23
|
- version: 5.5.10
|
|
20
24
|
date: 2025-06-29
|
|
21
25
|
changes: Inicjalizacja historii
|
|
@@ -23,15 +27,13 @@ history:
|
|
|
23
27
|
|
|
24
28
|
# Przetłumacz swoją stronę Nuxt i Vue za pomocą Intlayer | Internacjonalizacja (i18n)
|
|
25
29
|
|
|
26
|
-
Zobacz [Application Template](https://github.com/aymericzip/intlayer-nuxt-template) na GitHub.
|
|
27
|
-
|
|
28
30
|
## Spis treści
|
|
29
31
|
|
|
30
32
|
<TOC/>
|
|
31
33
|
|
|
32
34
|
## Czym jest Intlayer?
|
|
33
35
|
|
|
34
|
-
**Intlayer** to innowacyjna,
|
|
36
|
+
**Intlayer** to innowacyjna, otwartoźródłowa biblioteka do internacjonalizacji (i18n), zaprojektowana, aby uprościć wsparcie wielojęzyczne w nowoczesnych aplikacjach webowych.
|
|
35
37
|
|
|
36
38
|
Dzięki Intlayer możesz:
|
|
37
39
|
|
|
@@ -44,15 +46,28 @@ Dzięki Intlayer możesz:
|
|
|
44
46
|
|
|
45
47
|
## Przewodnik krok po kroku, jak skonfigurować Intlayer w aplikacji Nuxt
|
|
46
48
|
|
|
49
|
+
<Tab defaultTab="video">
|
|
50
|
+
<TabItem label="Wideo" value="video">
|
|
51
|
+
|
|
52
|
+
<iframe title="Jak przetłumaczyć swoją aplikację Nuxt i Vue za pomocą Intlayer? Odkryj 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/nhUcUAVQ6eQ?autoplay=0&origin=http://intlayer.org&controls=0&rel=1"/>
|
|
53
|
+
|
|
54
|
+
</TabItem>
|
|
55
|
+
<TabItem label="Kod" value="code">
|
|
56
|
+
|
|
47
57
|
<iframe
|
|
48
|
-
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
58
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-4-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
49
59
|
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
50
60
|
title="Demo CodeSandbox - Jak internacjonalizować swoją aplikację za pomocą Intlayer"
|
|
51
61
|
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
52
62
|
loading="lazy"
|
|
53
63
|
/>
|
|
54
64
|
|
|
55
|
-
|
|
65
|
+
</TabItem>
|
|
66
|
+
</Tab>
|
|
67
|
+
|
|
68
|
+
Zobacz [Szablon aplikacji](https://github.com/aymericzip/intlayer-nuxt-4-template) na GitHub.
|
|
69
|
+
|
|
70
|
+
### Krok 1: Zainstaluj zależności
|
|
56
71
|
|
|
57
72
|
Zainstaluj niezbędne pakiety za pomocą npm:
|
|
58
73
|
|
|
@@ -73,15 +88,13 @@ yarn add --save-dev nuxt-intlayer
|
|
|
73
88
|
|
|
74
89
|
- **intlayer**
|
|
75
90
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
Podstawowy pakiet, który dostarcza narzędzia do internacjonalizacji do zarządzania konfiguracją, tłumaczeń, [deklaracji treści](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/content_file.md), transpilecji oraz [poleceń CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_cli.md).
|
|
91
|
+
Główny pakiet, który dostarcza narzędzia do internacjonalizacji dla zarządzania konfiguracją, tłumaczeń, [deklaracji treści](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/content_file.md), transpilecji oraz [poleceń CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/cli/index.md).
|
|
79
92
|
|
|
80
93
|
- **vue-intlayer**
|
|
81
94
|
Pakiet integrujący Intlayer z aplikacją Vue. Zawiera composables dla komponentów Vue.
|
|
82
95
|
|
|
83
96
|
- **nuxt-intlayer**
|
|
84
|
-
Moduł Nuxt
|
|
97
|
+
Moduł Nuxt, który integruje Intlayer z aplikacjami Nuxt. Zapewnia automatyczną konfigurację, middleware do wykrywania lokalizacji, zarządzanie ciasteczkami oraz przekierowania URL.
|
|
85
98
|
|
|
86
99
|
### Krok 2: Konfiguracja Twojego projektu
|
|
87
100
|
|
|
@@ -100,9 +113,6 @@ const config: IntlayerConfig = {
|
|
|
100
113
|
],
|
|
101
114
|
defaultLocale: Locales.ENGLISH,
|
|
102
115
|
},
|
|
103
|
-
content: {
|
|
104
|
-
contentDir: ["."], // Domyślnie Intlayer będzie obserwować pliki deklaracji treści z katalogu `./src`
|
|
105
|
-
},
|
|
106
116
|
};
|
|
107
117
|
|
|
108
118
|
export default config;
|
|
@@ -122,9 +132,6 @@ const config = {
|
|
|
122
132
|
],
|
|
123
133
|
defaultLocale: Locales.ENGLISH,
|
|
124
134
|
},
|
|
125
|
-
content: {
|
|
126
|
-
contentDir: ["."],
|
|
127
|
-
},
|
|
128
135
|
};
|
|
129
136
|
|
|
130
137
|
export default config;
|
|
@@ -144,15 +151,12 @@ const config = {
|
|
|
144
151
|
],
|
|
145
152
|
defaultLocale: Locales.ENGLISH,
|
|
146
153
|
},
|
|
147
|
-
content: {
|
|
148
|
-
contentDir: ["."],
|
|
149
|
-
},
|
|
150
154
|
};
|
|
151
155
|
|
|
152
156
|
module.exports = config;
|
|
153
157
|
```
|
|
154
158
|
|
|
155
|
-
>
|
|
159
|
+
> Poprzez ten plik konfiguracyjny możesz ustawić lokalizowane adresy URL, przekierowania w middleware, nazwy ciasteczek, lokalizację i rozszerzenie deklaracji zawartości, wyłączyć logi Intlayer w konsoli i wiele więcej. Aby uzyskać pełną listę dostępnych parametrów, zapoznaj się z [dokumentacją konfiguracji](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/configuration.md).
|
|
156
160
|
|
|
157
161
|
### Krok 3: Zintegruj Intlayer w swojej konfiguracji Nuxt
|
|
158
162
|
|
|
@@ -167,293 +171,46 @@ export default defineNuxtConfig({
|
|
|
167
171
|
});
|
|
168
172
|
```
|
|
169
173
|
|
|
170
|
-
> Moduł `nuxt-intlayer` automatycznie obsługuje integrację Intlayer z Nuxt. Konfiguruje budowanie deklaracji
|
|
174
|
+
> Moduł `nuxt-intlayer` automatycznie obsługuje integrację Intlayer z Nuxt. Konfiguruje budowanie deklaracji zawartości, monitoruje pliki w trybie deweloperskim, dostarcza middleware do wykrywania lokalizacji oraz zarządza lokalizowanym routingiem.
|
|
171
175
|
|
|
172
|
-
### Krok 4: Zadeklaruj swoją
|
|
176
|
+
### Krok 4: Zadeklaruj swoją zawartość
|
|
173
177
|
|
|
174
|
-
Twórz i zarządzaj deklaracjami
|
|
178
|
+
Twórz i zarządzaj swoimi deklaracjami zawartości, aby przechowywać tłumaczenia:
|
|
175
179
|
|
|
176
|
-
```tsx fileName="
|
|
177
|
-
import {
|
|
180
|
+
```tsx fileName="content/home-page.content.ts" contentDeclarationFormat="typescript"
|
|
181
|
+
import { type Dictionary, t } from "intlayer";
|
|
178
182
|
|
|
179
|
-
const
|
|
180
|
-
key: "
|
|
183
|
+
const content = {
|
|
184
|
+
key: "home-page",
|
|
181
185
|
content: {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
187
|
-
}),
|
|
188
|
-
checkOut: t({
|
|
189
|
-
pl: "Sprawdź ",
|
|
190
|
-
en: "Check out ",
|
|
191
|
-
fr: "Vérifiez ",
|
|
192
|
-
es: "Compruebe ",
|
|
193
|
-
}),
|
|
194
|
-
nuxtIntlayer: t({
|
|
195
|
-
pl: "Dokumentacja Nuxt Intlayer",
|
|
196
|
-
en: "Nuxt Intlayer documentation",
|
|
197
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
198
|
-
es: "Documentación de Nuxt Intlayer",
|
|
199
|
-
}),
|
|
200
|
-
learnMore: t({
|
|
201
|
-
pl: "Dowiedz się więcej o Nuxt w ",
|
|
202
|
-
en: "Learn more about Nuxt in the ",
|
|
203
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
204
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
186
|
+
title: t({
|
|
187
|
+
en: "Hello world",
|
|
188
|
+
fr: "Bonjour le monde",
|
|
189
|
+
es: "Hola mundo",
|
|
205
190
|
}),
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
es: "Documentación de Nuxt",
|
|
191
|
+
metaTitle: t({
|
|
192
|
+
en: "Welcome | My Application",
|
|
193
|
+
fr: "Bienvenue | Mon Application",
|
|
194
|
+
es: "Bienvenido | Mi Aplicación",
|
|
211
195
|
}),
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
fr: "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
217
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
196
|
+
metaDescription: t({
|
|
197
|
+
en: "Discover your multilingual Nuxt app homepage powered by Intlayer.",
|
|
198
|
+
fr: "Découvrez la page d'accueil multilingue de votre application Nuxt propulsée par Intlayer.",
|
|
199
|
+
es: "Descubre la página de inicio multilingüe de tu aplicación Nuxt impulsada por Intlayer.",
|
|
218
200
|
}),
|
|
219
201
|
},
|
|
220
202
|
} satisfies Dictionary;
|
|
221
203
|
|
|
222
|
-
export default
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
```javascript fileName="components/helloWorld.content.mjs" contentDeclarationFormat="esm"
|
|
226
|
-
import { t } from "intlayer";
|
|
227
|
-
|
|
228
|
-
/** @type {import('intlayer').Dictionary} */
|
|
229
|
-
const helloWorldContent = {
|
|
230
|
-
key: "helloworld",
|
|
231
|
-
content: {
|
|
232
|
-
count: t({
|
|
233
|
-
pl: "licznik to ",
|
|
234
|
-
en: "count is ",
|
|
235
|
-
fr: "le compte est ",
|
|
236
|
-
es: "el recuento es ",
|
|
237
|
-
}),
|
|
238
|
-
edit: t({
|
|
239
|
-
pl: "Edytuj <code>components/HelloWorld.vue</code> i zapisz, aby przetestować HMR",
|
|
240
|
-
en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
241
|
-
fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
242
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
243
|
-
}),
|
|
244
|
-
checkOut: t({
|
|
245
|
-
pl: "Sprawdź ",
|
|
246
|
-
en: "Check out ",
|
|
247
|
-
fr: "Vérifiez ",
|
|
248
|
-
es: "Compruebe ",
|
|
249
|
-
}),
|
|
250
|
-
nuxtIntlayer: t({
|
|
251
|
-
pl: "Dokumentacja Nuxt Intlayer",
|
|
252
|
-
en: "Nuxt Intlayer documentation",
|
|
253
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
254
|
-
es: "Documentación de Nuxt Intlayer",
|
|
255
|
-
}),
|
|
256
|
-
learnMore: t({
|
|
257
|
-
pl: "Dowiedz się więcej o Nuxt w ",
|
|
258
|
-
en: "Learn more about Nuxt in the ",
|
|
259
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
260
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
261
|
-
}),
|
|
262
|
-
nuxtDocs: t({
|
|
263
|
-
pl: "Dokumentacja Nuxt",
|
|
264
|
-
en: "Nuxt Documentation",
|
|
265
|
-
fr: "Documentation Nuxt",
|
|
266
|
-
es: "Documentación de Nuxt",
|
|
267
|
-
}),
|
|
268
|
-
readTheDocs: t({
|
|
269
|
-
pl: "Kliknij na logo Nuxt, aby dowiedzieć się więcej",
|
|
270
|
-
en: "Click on the Nuxt logo to learn more",
|
|
271
|
-
fr: "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
272
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
273
|
-
}),
|
|
274
|
-
},
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
export default helloWorldContent;
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
```javascript fileName="components/helloWorld.content.cjs" contentDeclarationFormat="commonjs"
|
|
281
|
-
const { t } = require("intlayer");
|
|
282
|
-
|
|
283
|
-
/** @type {import('intlayer').Dictionary} */
|
|
284
|
-
const helloWorldContent = {
|
|
285
|
-
key: "helloworld",
|
|
286
|
-
content: {
|
|
287
|
-
count: t({ pl: "licznik to ", en: "count is ", fr: "le compte est ", es: "el recuento es " }),
|
|
288
|
-
edit: t({
|
|
289
|
-
pl: "Edytuj <code>components/HelloWorld.vue</code> i zapisz, aby przetestować HMR",
|
|
290
|
-
en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
291
|
-
fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
292
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
293
|
-
}),
|
|
294
|
-
checkOut: t({ pl: "Sprawdź ", en: "Check out ", fr: "Vérifiez ", es: "Compruebe " }),
|
|
295
|
-
nuxtIntlayer: t({
|
|
296
|
-
pl: "Dokumentacja Nuxt Intlayer",
|
|
297
|
-
en: "Nuxt Intlayer documentation",
|
|
298
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
299
|
-
es: "Documentación de Nuxt Intlayer",
|
|
300
|
-
}),
|
|
301
|
-
learnMore: t({
|
|
302
|
-
pl: "Dowiedz się więcej o Nuxt w ",
|
|
303
|
-
en: "Learn more about Nuxt in the ",
|
|
304
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
305
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
306
|
-
}),
|
|
307
|
-
nuxtDocs: t({
|
|
308
|
-
pl: "Dokumentacja Nuxt",
|
|
309
|
-
en: "Nuxt Documentation",
|
|
310
|
-
fr: "Documentation Nuxt",
|
|
311
|
-
es: "Documentación de Nuxt",
|
|
312
|
-
}),
|
|
313
|
-
readTheDocs: t({
|
|
314
|
-
pl: "Kliknij logo Nuxt, aby dowiedzieć się więcej",
|
|
315
|
-
en: "Click on the Nuxt logo to learn more",
|
|
316
|
-
fr: "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
317
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
318
|
-
}),
|
|
319
|
-
},
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
module.exports = helloWorldContent;
|
|
323
|
-
es: "Documentación de Nuxt Intlayer",
|
|
324
|
-
}),
|
|
325
|
-
learnMore: t({
|
|
326
|
-
pl: "Dowiedz się więcej o Nuxt w ",
|
|
327
|
-
en: "Learn more about Nuxt in the ",
|
|
328
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
329
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
330
|
-
}),
|
|
331
|
-
nuxtDocs: t({
|
|
332
|
-
pl: "Dokumentacja Nuxt",
|
|
333
|
-
en: "Nuxt Documentation",
|
|
334
|
-
fr: "Documentation Nuxt",
|
|
335
|
-
es: "Documentación de Nuxt",
|
|
336
|
-
}),
|
|
337
|
-
readTheDocs: t({
|
|
338
|
-
pl: "Kliknij na logo Nuxt, aby dowiedzieć się więcej",
|
|
339
|
-
en: "Click on the Nuxt logo to learn more",
|
|
340
|
-
fr: "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
341
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
342
|
-
}),
|
|
343
|
-
},
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
module.exports = helloWorldContent;
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
```json fileName="components/helloWorld.content.json" contentDeclarationFormat="json"
|
|
350
|
-
{
|
|
351
|
-
"$schema": "https://intlayer.org/schema.json",
|
|
352
|
-
"key": "helloworld",
|
|
353
|
-
"content": {
|
|
354
|
-
"count": {
|
|
355
|
-
"nodeType": "translation",
|
|
356
|
-
"translation": {
|
|
357
|
-
"pl": "licznik to ",
|
|
358
|
-
"en": "count is ",
|
|
359
|
-
"fr": "le compte est ",
|
|
360
|
-
"es": "el recuento es "
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
"edit": {
|
|
364
|
-
"nodeType": "translation",
|
|
365
|
-
"translation": {
|
|
366
|
-
"pl": "Edytuj <code>components/HelloWorld.vue</code> i zapisz, aby przetestować HMR",
|
|
367
|
-
"en": "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
368
|
-
"fr": "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
369
|
-
"es": "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR"
|
|
370
|
-
}
|
|
371
|
-
},
|
|
372
|
-
"checkOut": {
|
|
373
|
-
"nodeType": "translation",
|
|
374
|
-
"translation": {
|
|
375
|
-
"pl": "Sprawdź ",
|
|
376
|
-
"en": "Check out ",
|
|
377
|
-
"fr": "Vérifiez ",
|
|
378
|
-
"es": "Compruebe "
|
|
379
|
-
}
|
|
380
|
-
},
|
|
381
|
-
"nuxtIntlayer": {
|
|
382
|
-
"nodeType": "translation",
|
|
383
|
-
"translation": {
|
|
384
|
-
"nodeType": "translation",
|
|
385
|
-
"translation": {
|
|
386
|
-
"pl": "licznik to ",
|
|
387
|
-
"en": "count is ",
|
|
388
|
-
"fr": "le compte est ",
|
|
389
|
-
"es": "el recuento es "
|
|
390
|
-
}
|
|
391
|
-
},
|
|
392
|
-
"edit": {
|
|
393
|
-
"nodeType": "translation",
|
|
394
|
-
"translation": {
|
|
395
|
-
"pl": "Edytuj <code>components/HelloWorld.vue</code> i zapisz, aby przetestować HMR",
|
|
396
|
-
"en": "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
397
|
-
"fr": "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
398
|
-
"es": "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR"
|
|
399
|
-
}
|
|
400
|
-
},
|
|
401
|
-
"checkOut": {
|
|
402
|
-
"nodeType": "translation",
|
|
403
|
-
"translation": {
|
|
404
|
-
"pl": "Sprawdź ",
|
|
405
|
-
"en": "Check out ",
|
|
406
|
-
"fr": "Vérifiez ",
|
|
407
|
-
"es": "Compruebe "
|
|
408
|
-
}
|
|
409
|
-
},
|
|
410
|
-
"nuxtIntlayer": {
|
|
411
|
-
"nodeType": "translation",
|
|
412
|
-
"translation": {
|
|
413
|
-
"pl": "Dokumentacja Nuxt Intlayer",
|
|
414
|
-
"en": "Nuxt Intlayer documentation",
|
|
415
|
-
"fr": "Documentation de Nuxt Intlayer",
|
|
416
|
-
"es": "Documentación de Nuxt Intlayer"
|
|
417
|
-
}
|
|
418
|
-
},
|
|
419
|
-
"learnMore": {
|
|
420
|
-
"nodeType": "translation",
|
|
421
|
-
"translation": {
|
|
422
|
-
"pl": "Dowiedz się więcej o Nuxt w ",
|
|
423
|
-
"en": "Learn more about Nuxt in the ",
|
|
424
|
-
"fr": "En savoir plus sur Nuxt dans la ",
|
|
425
|
-
"es": "Aprenda más sobre Nuxt en la "
|
|
426
|
-
}
|
|
427
|
-
},
|
|
428
|
-
"nuxtDocs": {
|
|
429
|
-
"nodeType": "translation",
|
|
430
|
-
"translation": {
|
|
431
|
-
"pl": "Dokumentacja Nuxt",
|
|
432
|
-
"en": "Nuxt Documentation",
|
|
433
|
-
"fr": "Documentation Nuxt",
|
|
434
|
-
"es": "Documentación de Nuxt"
|
|
435
|
-
}
|
|
436
|
-
},
|
|
437
|
-
"readTheDocs": {
|
|
438
|
-
"nodeType": "translation",
|
|
439
|
-
"translation": {
|
|
440
|
-
"pl": "Kliknij logo Nuxt, aby dowiedzieć się więcej",
|
|
441
|
-
"en": "Click on the Nuxt logo to learn more",
|
|
442
|
-
"fr": "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
443
|
-
"es": "Haga clic en el logotipo de Nuxt para obtener más información"
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
}
|
|
204
|
+
export default content;
|
|
448
205
|
```
|
|
449
206
|
|
|
450
|
-
> Twoje deklaracje zawartości mogą być zdefiniowane w dowolnym miejscu w Twojej aplikacji, pod warunkiem, że znajdują się w katalogu `contentDir` (domyślnie `./src`). I
|
|
207
|
+
> Twoje deklaracje zawartości mogą być zdefiniowane w dowolnym miejscu w Twojej aplikacji, pod warunkiem, że znajdują się w katalogu `contentDir` (domyślnie `./src`). I mają odpowiednie rozszerzenie pliku deklaracji zawartości (domyślnie `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
451
208
|
|
|
452
209
|
> Aby uzyskać więcej szczegółów, zapoznaj się z [dokumentacją deklaracji zawartości](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/content_file.md).
|
|
453
210
|
|
|
454
211
|
### Krok 5: Wykorzystaj Intlayer w swoim kodzie
|
|
455
212
|
|
|
456
|
-
Uzyskaj dostęp do swoich słowników zawartości w całej aplikacji Nuxt, korzystając z
|
|
213
|
+
Uzyskaj dostęp do swoich słowników zawartości w całej aplikacji Nuxt, korzystając z kompozycji `useIntlayer`:
|
|
457
214
|
|
|
458
215
|
```vue fileName="components/HelloWorld.vue"
|
|
459
216
|
<script setup lang="ts">
|
|
@@ -502,86 +259,76 @@ const countRef = ref(0);
|
|
|
502
259
|
</template>
|
|
503
260
|
```
|
|
504
261
|
|
|
505
|
-
#### Dostęp do
|
|
262
|
+
#### Dostęp do zawartości w Intlayer
|
|
506
263
|
|
|
507
|
-
Intlayer oferuje różne API do dostępu do
|
|
264
|
+
Intlayer oferuje różne API do dostępu do Twojej zawartości:
|
|
508
265
|
|
|
509
266
|
- **Składnia oparta na komponentach** (zalecana):
|
|
510
|
-
Użyj składni `<myContent />` lub `<Component :is="myContent" />`, aby wyrenderować
|
|
267
|
+
Użyj składni `<myContent />` lub `<Component :is="myContent" />`, aby wyrenderować zawartość jako węzeł Intlayer. Integruje się to bezproblemowo z [Visual Editor](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_visual_editor.md) oraz [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_CMS.md).
|
|
511
268
|
|
|
512
|
-
- **Składnia oparta na
|
|
513
|
-
Użyj `{{ myContent }}`, aby wyrenderować
|
|
269
|
+
- **Składnia oparta na łańcuchach znaków**:
|
|
270
|
+
Użyj `{{ myContent }}`, aby wyrenderować zawartość jako zwykły tekst, bez wsparcia Visual Editor.
|
|
514
271
|
|
|
515
272
|
- **Składnia surowego HTML**:
|
|
516
|
-
Użyj `<div v-html="myContent" />`, aby wyrenderować
|
|
273
|
+
Użyj `<div v-html="myContent" />`, aby wyrenderować zawartość jako surowy HTML, bez wsparcia Visual Editor.
|
|
517
274
|
|
|
518
275
|
- **Składnia destrukturyzacji**:
|
|
519
|
-
`useIntlayer`
|
|
520
|
-
- Użyj `const content = useIntlayer("myContent");` oraz `{{ content.myContent }}` / `<content.myContent />`.
|
|
521
|
-
- Lub użyj `const { myContent } = useIntlayer("myContent");` oraz `{{ myContent
|
|
276
|
+
Kompozycja `useIntlayer` zwraca Proxy z zawartością. Ten proxy można zdestrukturyzować, aby uzyskać dostęp do zawartości, zachowując reaktywność.
|
|
277
|
+
- Użyj `const content = useIntlayer("myContent");` oraz `{{ content.myContent }}` / `<content.myContent />`.
|
|
278
|
+
- Lub użyj `const { myContent } = useIntlayer("myContent");` oraz `{{ myContent}}` / `<myContent/>`, aby zdestrukturyzować zawartość.
|
|
522
279
|
|
|
523
|
-
### (
|
|
280
|
+
### (Opcjonalny) Krok 6: Zmień język swojej zawartości
|
|
524
281
|
|
|
525
|
-
Aby zmienić język swojej zawartości, możesz użyć funkcji `setLocale` dostarczonej przez
|
|
282
|
+
Aby zmienić język swojej zawartości, możesz użyć funkcji `setLocale` dostarczonej przez kompozycję `useLocale`. Funkcja ta pozwala ustawić lokalizację aplikacji i odpowiednio zaktualizować zawartość.
|
|
526
283
|
|
|
527
|
-
Utwórz komponent do przełączania między językami:
|
|
284
|
+
Utwórz komponent do przełączania między językami, używając `NuxtLink`. **Używanie linków zamiast przycisków do zmiany lokalizacji to najlepsza praktyka dla SEO i odkrywalności stron**, ponieważ pozwala wyszukiwarkom indeksować wszystkie zlokalizowane wersje Twoich stron:
|
|
528
285
|
|
|
529
286
|
```vue fileName="components/LocaleSwitcher.vue"
|
|
530
|
-
<template>
|
|
531
|
-
<div class="locale-switcher">
|
|
532
|
-
<select v-model="selectedLocale" @change="changeLocale">
|
|
533
|
-
<option v-for="loc in availableLocales" :key="loc" :value="loc">
|
|
534
|
-
{{ getLocaleName(loc) }}
|
|
535
|
-
</option>
|
|
536
|
-
</select>
|
|
537
|
-
</div>
|
|
538
|
-
</template>
|
|
539
|
-
|
|
540
287
|
<script setup lang="ts">
|
|
541
|
-
import {
|
|
542
|
-
import { getLocaleName } from "intlayer";
|
|
288
|
+
import { getLocaleName, getLocalizedUrl } from "intlayer";
|
|
543
289
|
import { useLocale } from "vue-intlayer";
|
|
544
290
|
|
|
545
|
-
//
|
|
291
|
+
// Nuxt automatycznie importuje useRoute
|
|
292
|
+
const route = useRoute();
|
|
546
293
|
const { locale, availableLocales, setLocale } = useLocale();
|
|
547
|
-
|
|
548
|
-
// Śledź wybraną lokalizację za pomocą ref
|
|
549
|
-
const selectedLocale = ref(locale.value);
|
|
550
|
-
|
|
551
|
-
// Aktualizuj lokalizację po zmianie wyboru
|
|
552
|
-
const changeLocale = () => setLocale(selectedLocale.value);
|
|
553
|
-
|
|
554
|
-
// Synchronizuj selectedLocale z globalną lokalizacją
|
|
555
|
-
watch(
|
|
556
|
-
() => locale.value,
|
|
557
|
-
(newLocale) => {
|
|
558
|
-
selectedLocale.value = newLocale;
|
|
559
|
-
}
|
|
560
|
-
);
|
|
561
294
|
</script>
|
|
295
|
+
|
|
296
|
+
<template>
|
|
297
|
+
<nav class="locale-switcher">
|
|
298
|
+
<NuxtLink
|
|
299
|
+
v-for="localeEl in availableLocales"
|
|
300
|
+
:key="localeEl"
|
|
301
|
+
:to="getLocalizedUrl(route.fullPath, localeEl)"
|
|
302
|
+
class="locale-link"
|
|
303
|
+
:class="{ 'active-locale': localeEl === locale }"
|
|
304
|
+
@click="setLocale(localeEl)"
|
|
305
|
+
>
|
|
306
|
+
{{ getLocaleName(localeEl) }}
|
|
307
|
+
</NuxtLink>
|
|
308
|
+
</nav>
|
|
562
309
|
</template>
|
|
310
|
+
```
|
|
563
311
|
|
|
564
|
-
|
|
565
|
-
.locale-switcher {
|
|
566
|
-
margin: 1rem 0;
|
|
567
|
-
}
|
|
312
|
+
> Używanie `NuxtLink` z odpowiednimi atrybutami `href` (za pomocą `getLocalizedUrl`) zapewnia, że wyszukiwarki mogą odkryć wszystkie warianty językowe Twoich stron. Jest to lepsze niż przełączanie lokalizacji wyłącznie za pomocą JavaScript, którego roboty wyszukiwarek mogą nie śledzić.
|
|
568
313
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
314
|
+
Następnie skonfiguruj swój plik `app.vue`, aby używać layoutów:
|
|
315
|
+
|
|
316
|
+
```vue fileName="app.vue"
|
|
317
|
+
<template>
|
|
318
|
+
<NuxtLayout>
|
|
319
|
+
<NuxtPage />
|
|
320
|
+
</NuxtLayout>
|
|
321
|
+
</template>
|
|
575
322
|
```
|
|
576
323
|
|
|
577
|
-
|
|
324
|
+
### (Opcjonalny) Krok 6b: Utwórz Layout z Nawigacją
|
|
578
325
|
|
|
579
|
-
|
|
326
|
+
Layouty Nuxt pozwalają zdefiniować wspólną strukturę dla Twoich stron. Utwórz domyślny layout, który zawiera przełącznik języków oraz nawigację:
|
|
327
|
+
|
|
328
|
+
```vue fileName="layouts/default.vue"
|
|
580
329
|
<script setup lang="ts">
|
|
581
|
-
import
|
|
330
|
+
import Links from "~/components/Links.vue";
|
|
582
331
|
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
583
|
-
|
|
584
|
-
const content = useIntlayer("app"); // Utwórz powiązany plik deklaracji intlayer
|
|
585
332
|
</script>
|
|
586
333
|
|
|
587
334
|
<template>
|
|
@@ -590,12 +337,17 @@ const content = useIntlayer("app"); // Utwórz powiązany plik deklaracji intlay
|
|
|
590
337
|
<LocaleSwitcher />
|
|
591
338
|
</header>
|
|
592
339
|
<main>
|
|
593
|
-
<
|
|
340
|
+
<slot />
|
|
594
341
|
</main>
|
|
342
|
+
|
|
343
|
+
<Links href="/">Strona główna</Links>
|
|
344
|
+
<Links href="/about">O nas</Links>
|
|
595
345
|
</div>
|
|
596
346
|
</template>
|
|
597
347
|
```
|
|
598
348
|
|
|
349
|
+
Komponent `Links` (pokazany poniżej) zapewnia, że wewnętrzne linki nawigacyjne są automatycznie lokalizowane.
|
|
350
|
+
|
|
599
351
|
### (Opcjonalny) Krok 7: Dodaj lokalizowane routingi do swojej aplikacji
|
|
600
352
|
|
|
601
353
|
Nuxt automatycznie obsługuje lokalizowane routingi podczas korzystania z modułu `nuxt-intlayer`. Tworzy to trasy dla każdego języka automatycznie na podstawie struktury katalogu stron.
|
|
@@ -610,249 +362,296 @@ pages/
|
|
|
610
362
|
└── index.vue → /contact, /fr/contact, /es/contact
|
|
611
363
|
```
|
|
612
364
|
|
|
613
|
-
Aby utworzyć
|
|
365
|
+
Aby utworzyć lokalizowane strony, wystarczy utworzyć pliki Vue w katalogu `pages/`. Oto dwa przykładowe pliki stron:
|
|
366
|
+
|
|
367
|
+
**Strona główna (`pages/index.vue`):**
|
|
368
|
+
|
|
369
|
+
```vue fileName="pages/index.vue"
|
|
370
|
+
<script setup lang="ts">
|
|
371
|
+
import { useIntlayer } from "vue-intlayer";
|
|
372
|
+
|
|
373
|
+
const content = useIntlayer("home-page");
|
|
374
|
+
|
|
375
|
+
useHead({
|
|
376
|
+
title: content.metaTitle.value,
|
|
377
|
+
meta: [
|
|
378
|
+
{
|
|
379
|
+
name: "description",
|
|
380
|
+
content: content.metaDescription.value,
|
|
381
|
+
},
|
|
382
|
+
],
|
|
383
|
+
});
|
|
384
|
+
</script>
|
|
385
|
+
|
|
386
|
+
<template>
|
|
387
|
+
<h1><content.title /></h1>
|
|
388
|
+
</template>
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
**Strona O nas (`pages/about.vue`):**
|
|
614
392
|
|
|
615
393
|
```vue fileName="pages/about.vue"
|
|
616
394
|
<script setup lang="ts">
|
|
617
395
|
import { useIntlayer } from "vue-intlayer";
|
|
618
396
|
|
|
619
|
-
const content = useIntlayer("about");
|
|
397
|
+
const content = useIntlayer("about-page");
|
|
398
|
+
|
|
399
|
+
useHead({
|
|
400
|
+
title: content.metaTitle.raw, // Użyj .raw, aby uzyskać dostęp do prymitywnego stringa
|
|
401
|
+
meta: [
|
|
402
|
+
{
|
|
403
|
+
name: "description",
|
|
404
|
+
content: content.metaDescription.raw, // Użyj .raw, aby uzyskać dostęp do prymitywnego łańcucha znaków
|
|
405
|
+
},
|
|
406
|
+
],
|
|
407
|
+
});
|
|
620
408
|
</script>
|
|
621
409
|
|
|
622
410
|
<template>
|
|
623
|
-
<
|
|
624
|
-
<h1>{{ content.title }}</h1>
|
|
625
|
-
<p>{{ content.description }}</p>
|
|
626
|
-
</div>
|
|
411
|
+
<h1><content.title /></h1>
|
|
627
412
|
</template>
|
|
628
413
|
```
|
|
629
414
|
|
|
415
|
+
> Uwaga: `useHead` jest automatycznie importowany w Nuxt. Możesz uzyskać dostęp do wartości content za pomocą `.value` (reaktywne) lub `.raw` (prymitywny łańcuch znaków), w zależności od potrzeb.
|
|
416
|
+
|
|
630
417
|
Moduł `nuxt-intlayer` automatycznie:
|
|
631
418
|
|
|
632
419
|
- Wykrywa preferowany język użytkownika
|
|
633
|
-
- Obsługuje przełączanie
|
|
420
|
+
- Obsługuje przełączanie języków przez URL
|
|
634
421
|
- Ustawia odpowiedni atrybut `<html lang="">`
|
|
635
422
|
- Zarządza ciasteczkami językowymi
|
|
636
|
-
- Przekierowuje użytkowników
|
|
423
|
+
- Przekierowuje użytkowników do odpowiedniego zlokalizowanego URL
|
|
637
424
|
|
|
638
|
-
### (Opcjonalny) Krok 8: Tworzenie komponentu
|
|
425
|
+
### (Opcjonalny) Krok 8: Tworzenie lokalizowanego komponentu Linków
|
|
639
426
|
|
|
640
|
-
Aby zapewnić, że nawigacja
|
|
641
|
-
|
|
642
|
-
```vue fileName="components/LocalizedLink.vue"
|
|
643
|
-
<template>
|
|
644
|
-
<NuxtLink :to="localizedHref" v-bind="$attrs">
|
|
645
|
-
<slot />
|
|
646
|
-
</NuxtLink>
|
|
647
|
-
</template>
|
|
427
|
+
Aby zapewnić, że nawigacja Twojej aplikacji respektuje bieżący język, możesz utworzyć niestandardowy komponent `Links`. Komponent ten automatycznie dodaje przedrostek z aktualnym językiem do wewnętrznych adresów URL, co jest niezbędne dla **SEO i odnajdywalności stron**.
|
|
648
428
|
|
|
429
|
+
```vue fileName="components/Links.vue"
|
|
649
430
|
<script setup lang="ts">
|
|
650
|
-
import { computed } from "vue";
|
|
651
431
|
import { getLocalizedUrl } from "intlayer";
|
|
652
432
|
import { useLocale } from "vue-intlayer";
|
|
653
433
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
434
|
+
interface Props {
|
|
435
|
+
href: string;
|
|
436
|
+
locale?: string;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const props = defineProps<Props>();
|
|
660
440
|
|
|
661
|
-
const { locale } = useLocale();
|
|
441
|
+
const { locale: currentLocale } = useLocale();
|
|
662
442
|
|
|
663
|
-
//
|
|
664
|
-
const
|
|
443
|
+
// Oblicz końcową ścieżkę
|
|
444
|
+
const finalPath = computed(() => {
|
|
445
|
+
// 1. Sprawdź, czy link jest zewnętrzny
|
|
446
|
+
const isExternal = /^https?:\/\//.test(props.href || "");
|
|
665
447
|
|
|
666
|
-
//
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
448
|
+
// 2. Jeśli zewnętrzny, zwróć go bez zmian (NuxtLink obsługuje generowanie tagu <a>)
|
|
449
|
+
if (isExternal) return props.href;
|
|
450
|
+
|
|
451
|
+
// 3. Jeśli link jest wewnętrzny, lokalizuj URL
|
|
452
|
+
const targetLocale = props.locale || currentLocale.value;
|
|
453
|
+
return getLocalizedUrl(props.href, targetLocale);
|
|
454
|
+
});
|
|
670
455
|
</script>
|
|
456
|
+
|
|
457
|
+
<template>
|
|
458
|
+
<NuxtLink :to="finalPath" v-bind="$attrs">
|
|
459
|
+
<slot />
|
|
460
|
+
</NuxtLink>
|
|
461
|
+
</template>
|
|
671
462
|
```
|
|
672
463
|
|
|
673
464
|
Następnie użyj tego komponentu w całej aplikacji:
|
|
674
465
|
|
|
675
|
-
```vue fileName="
|
|
466
|
+
```vue fileName="layouts/default.vue"
|
|
467
|
+
<script setup lang="ts">
|
|
468
|
+
import Links from "~/components/Links.vue";
|
|
469
|
+
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
470
|
+
</script>
|
|
471
|
+
|
|
676
472
|
<template>
|
|
677
473
|
<div>
|
|
678
|
-
<
|
|
679
|
-
|
|
680
|
-
</
|
|
681
|
-
<
|
|
682
|
-
|
|
683
|
-
</
|
|
474
|
+
<header>
|
|
475
|
+
<LocaleSwitcher />
|
|
476
|
+
</header>
|
|
477
|
+
<main>
|
|
478
|
+
<slot />
|
|
479
|
+
</main>
|
|
480
|
+
|
|
481
|
+
<Links href="/">Strona główna</Links>
|
|
482
|
+
<Links href="/about">O nas</Links>
|
|
684
483
|
</div>
|
|
685
484
|
</template>
|
|
686
|
-
|
|
687
|
-
<script setup lang="ts">
|
|
688
|
-
import { useIntlayer } from "vue-intlayer";
|
|
689
|
-
import LocalizedLink from "~/components/LocalizedLink.vue";
|
|
690
|
-
|
|
691
|
-
const content = useIntlayer("home");
|
|
692
|
-
</script>
|
|
693
485
|
```
|
|
694
486
|
|
|
695
|
-
|
|
487
|
+
> Korzystając z `NuxtLink` z lokalizowanymi ścieżkami, zapewniasz, że:
|
|
488
|
+
>
|
|
489
|
+
> - Wyszukiwarki mogą indeksować i przeszukiwać wszystkie wersje językowe Twoich stron
|
|
490
|
+
> - Użytkownicy mogą bezpośrednio udostępniać lokalizowane URL-e
|
|
491
|
+
> - Historia przeglądarki działa poprawnie z URL-ami poprzedzonymi prefiksem języka
|
|
492
|
+
|
|
493
|
+
### (Opcjonalny) Krok 9: Obsługa Metadanych i SEO
|
|
696
494
|
|
|
697
|
-
Nuxt oferuje doskonałe możliwości SEO. Możesz użyć Intlayer do obsługi
|
|
495
|
+
Nuxt oferuje doskonałe możliwości SEO za pomocą kompozycji `useHead` (auto-importowanej). Możesz użyć Intlayer do obsługi lokalizowanych metadanych, korzystając z akcesora `.raw` lub `.value`, aby uzyskać prymitywną wartość łańcuchową:
|
|
698
496
|
|
|
699
497
|
```vue fileName="pages/about.vue"
|
|
700
498
|
<script setup lang="ts">
|
|
701
|
-
import {
|
|
702
|
-
import { getIntlayer } from "intlayer";
|
|
703
|
-
import { useLocale } from "vue-intlayer";
|
|
499
|
+
import { useIntlayer } from "vue-intlayer";
|
|
704
500
|
|
|
705
|
-
|
|
706
|
-
const content =
|
|
501
|
+
// useHead jest auto-importowane w Nuxt
|
|
502
|
+
const content = useIntlayer("about-page");
|
|
707
503
|
|
|
708
|
-
|
|
709
|
-
title: content.
|
|
710
|
-
|
|
504
|
+
useHead({
|
|
505
|
+
title: content.metaTitle.raw, // Użyj .raw, aby uzyskać prymitywną wartość łańcuchową
|
|
506
|
+
meta: [
|
|
507
|
+
{
|
|
508
|
+
name: "description",
|
|
509
|
+
content: content.metaDescription.raw, // Użyj .raw, aby uzyskać prymitywną wartość łańcuchową
|
|
510
|
+
},
|
|
511
|
+
],
|
|
711
512
|
});
|
|
712
513
|
</script>
|
|
713
514
|
|
|
714
515
|
<template>
|
|
715
|
-
<
|
|
716
|
-
<h1>{{ content.pageTitle }}</h1>
|
|
717
|
-
<p>{{ content.pageContent }}</p>
|
|
718
|
-
</div>
|
|
516
|
+
<h1><content.title /></h1>
|
|
719
517
|
</template>
|
|
720
518
|
```
|
|
721
519
|
|
|
722
|
-
|
|
520
|
+
> Alternatywnie możesz użyć funkcji `import { getIntlayer } from "intlayer"`, aby uzyskać zawartość bez reaktywności Vue.
|
|
521
|
+
|
|
522
|
+
> **Dostęp do wartości zawartości:**
|
|
523
|
+
>
|
|
524
|
+
> - Użyj `.raw`, aby uzyskać prymitywną wartość łańcuchową (niereaktywną)
|
|
525
|
+
> - Użyj `.value`, aby uzyskać wartość reaktywną
|
|
526
|
+
> - Użyj składni komponentu `<content.key />` dla wsparcia Visual Editora
|
|
723
527
|
|
|
724
|
-
|
|
528
|
+
Utwórz odpowiednią deklarację zawartości:
|
|
529
|
+
|
|
530
|
+
```ts fileName="pages/about-page.content.ts" contentDeclarationFormat="typescript"
|
|
725
531
|
import { t, type Dictionary } from "intlayer";
|
|
726
|
-
import type { useSeoMeta } from "nuxt/app";
|
|
727
532
|
|
|
728
|
-
const
|
|
729
|
-
key: "about-
|
|
533
|
+
const aboutPageContent = {
|
|
534
|
+
key: "about-page",
|
|
730
535
|
content: {
|
|
731
|
-
|
|
732
|
-
pl: "O nas - Moja Firma",
|
|
536
|
+
metaTitle: t({
|
|
733
537
|
en: "About Us - My Company",
|
|
734
538
|
fr: "À Propos - Ma Société",
|
|
735
539
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
736
540
|
}),
|
|
737
|
-
|
|
541
|
+
metaDescription: t({
|
|
738
542
|
pl: "Dowiedz się więcej o naszej firmie i naszej misji",
|
|
739
543
|
en: "Learn more about our company and our mission",
|
|
740
544
|
fr: "En savoir plus sur notre société et notre mission",
|
|
741
545
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
742
546
|
}),
|
|
547
|
+
title: t({
|
|
548
|
+
pl: "O nas",
|
|
549
|
+
en: "About Us",
|
|
550
|
+
fr: "À Propos",
|
|
551
|
+
es: "Acerca de Nosotros",
|
|
552
|
+
}),
|
|
743
553
|
},
|
|
744
|
-
} satisfies Dictionary
|
|
554
|
+
} satisfies Dictionary;
|
|
745
555
|
|
|
746
|
-
export default
|
|
556
|
+
export default aboutPageContent;
|
|
747
557
|
```
|
|
748
558
|
|
|
749
|
-
```
|
|
559
|
+
```javascript fileName="pages/about-page.content.mjs" contentDeclarationFormat="esm"
|
|
750
560
|
import { t } from "intlayer";
|
|
751
561
|
|
|
752
562
|
/** @type {import('intlayer').Dictionary} */
|
|
753
|
-
const
|
|
754
|
-
key: "about-
|
|
563
|
+
const aboutPageContent = {
|
|
564
|
+
key: "about-page",
|
|
755
565
|
content: {
|
|
756
|
-
|
|
757
|
-
|
|
566
|
+
metaTitle: t({
|
|
567
|
+
pl: "O nas - Moja firma",
|
|
758
568
|
en: "About Us - My Company",
|
|
759
569
|
fr: "À Propos - Ma Société",
|
|
760
570
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
761
|
-
pl: "O nas - Moja Firma",
|
|
762
571
|
}),
|
|
763
|
-
|
|
764
|
-
zh: "了解更多关于我们公司和我们的使命",
|
|
572
|
+
metaDescription: t({
|
|
765
573
|
en: "Learn more about our company and our mission",
|
|
766
574
|
fr: "En savoir plus sur notre société et notre mission",
|
|
767
575
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
768
|
-
|
|
576
|
+
}),
|
|
577
|
+
title: t({
|
|
578
|
+
en: "About Us",
|
|
579
|
+
fr: "À Propos",
|
|
580
|
+
es: "Acerca de Nosotros",
|
|
769
581
|
}),
|
|
770
582
|
},
|
|
771
583
|
};
|
|
772
584
|
|
|
773
|
-
export default
|
|
585
|
+
export default aboutPageContent;
|
|
774
586
|
```
|
|
775
587
|
|
|
776
|
-
```
|
|
588
|
+
```javascript fileName="pages/about-page.content.cjs" contentDeclarationFormat="commonjs"
|
|
777
589
|
const { t } = require("intlayer");
|
|
778
590
|
|
|
779
591
|
/** @type {import('intlayer').Dictionary} */
|
|
780
|
-
const
|
|
781
|
-
key: "about-
|
|
592
|
+
const aboutPageContent = {
|
|
593
|
+
key: "about-page",
|
|
782
594
|
content: {
|
|
783
|
-
|
|
784
|
-
zh: "关于我们 - 我的公司",
|
|
595
|
+
metaTitle: t({
|
|
785
596
|
en: "About Us - My Company",
|
|
597
|
+
pl: "O nas - Moja Firma", // tytuł meta w języku polskim
|
|
786
598
|
fr: "À Propos - Ma Société",
|
|
787
599
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
788
|
-
pl: "O nas - Moja Firma",
|
|
789
600
|
}),
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
}),
|
|
793
|
-
description: t({
|
|
794
|
-
zh: "了解更多关于我们公司和我们的使命",
|
|
795
|
-
en: "Learn more about our company and our mission",
|
|
601
|
+
metaDescription: t({
|
|
602
|
+
en: "Dowiedz się więcej o naszej firmie i naszej misji",
|
|
796
603
|
fr: "En savoir plus sur notre société et notre mission",
|
|
797
604
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
798
|
-
|
|
605
|
+
}),
|
|
606
|
+
title: t({
|
|
607
|
+
en: "O nas",
|
|
608
|
+
fr: "À Propos",
|
|
609
|
+
es: "Acerca de Nosotros",
|
|
799
610
|
}),
|
|
800
611
|
},
|
|
801
612
|
};
|
|
802
613
|
|
|
803
|
-
module.exports =
|
|
614
|
+
module.exports = aboutPageContent;
|
|
804
615
|
```
|
|
805
616
|
|
|
806
|
-
```json fileName="pages/about-
|
|
617
|
+
```json fileName="pages/about-page.content.json" contentDeclarationFormat="json"
|
|
807
618
|
{
|
|
808
|
-
"
|
|
619
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
620
|
+
"key": "about-page",
|
|
809
621
|
"content": {
|
|
810
|
-
"
|
|
622
|
+
"metaTitle": {
|
|
811
623
|
"nodeType": "translation",
|
|
812
|
-
"
|
|
813
|
-
"
|
|
814
|
-
"en": "About Us - My Company",
|
|
624
|
+
"translation": {
|
|
625
|
+
"en": "O nas - Moja firma",
|
|
815
626
|
"fr": "À Propos - Ma Société",
|
|
816
|
-
"es": "Acerca de Nosotros - Mi Empresa"
|
|
817
|
-
"pl": "O nas - Moja firma"
|
|
627
|
+
"es": "Acerca de Nosotros - Mi Empresa"
|
|
818
628
|
}
|
|
819
629
|
},
|
|
820
|
-
"
|
|
630
|
+
"metaDescription": {
|
|
821
631
|
"nodeType": "translation",
|
|
822
|
-
"
|
|
823
|
-
"zh": "了解更多关于我们公司和我们的使命",
|
|
632
|
+
"translation": {
|
|
824
633
|
"en": "Learn more about our company and our mission",
|
|
825
634
|
"fr": "En savoir plus sur notre société et notre mission",
|
|
826
|
-
"es": "Conozca más sobre nuestra empresa y nuestra misión"
|
|
635
|
+
"es": "Conozca más sobre nuestra empresa y nuestra misión",
|
|
636
|
+
"pl": "Dowiedz się więcej o naszej firmie i naszej misji"
|
|
637
|
+
}
|
|
638
|
+
},
|
|
639
|
+
"title": {
|
|
640
|
+
"nodeType": "translation",
|
|
641
|
+
"translation": {
|
|
642
|
+
"en": "About Us",
|
|
643
|
+
"fr": "À Propos",
|
|
644
|
+
"es": "Acerca de Nosotros",
|
|
645
|
+
"pl": "O nas"
|
|
827
646
|
}
|
|
828
647
|
}
|
|
829
648
|
}
|
|
830
649
|
}
|
|
831
650
|
```
|
|
832
651
|
|
|
833
|
-
### Konfiguracja TypeScript
|
|
834
|
-
|
|
835
|
-
Intlayer wykorzystuje rozszerzenia modułów (module augmentation), aby korzystać z zalet TypeScript i uczynić Twoją bazę kodu bardziej solidną.
|
|
836
|
-
|
|
837
|
-

|
|
838
|
-
|
|
839
|
-

|
|
840
|
-
|
|
841
|
-
Upewnij się, że Twoja konfiguracja TypeScript zawiera automatycznie generowane typy.
|
|
842
|
-
|
|
843
|
-
```json5 fileName="tsconfig.json"
|
|
844
|
-
{
|
|
845
|
-
// ... Twoje istniejące konfiguracje TypeScript
|
|
846
|
-
"include": [
|
|
847
|
-
// ... Twoje istniejące konfiguracje TypeScript
|
|
848
|
-
".intlayer/**/*.ts", // Dołącz automatycznie generowane typy
|
|
849
|
-
],
|
|
850
|
-
}
|
|
851
|
-
```
|
|
852
|
-
|
|
853
652
|
### Konfiguracja Git
|
|
854
653
|
|
|
855
|
-
Zaleca się ignorowanie plików generowanych przez Intlayer. Pozwala to uniknąć ich
|
|
654
|
+
Zaleca się ignorowanie plików generowanych przez Intlayer. Pozwala to uniknąć ich zatwierdzania do repozytorium Git.
|
|
856
655
|
|
|
857
656
|
Aby to zrobić, możesz dodać następujące instrukcje do pliku `.gitignore`:
|
|
858
657
|
|
|
@@ -863,7 +662,7 @@ Aby to zrobić, możesz dodać następujące instrukcje do pliku `.gitignore`:
|
|
|
863
662
|
|
|
864
663
|
### Rozszerzenie VS Code
|
|
865
664
|
|
|
866
|
-
Aby poprawić doświadczenie
|
|
665
|
+
Aby poprawić swoje doświadczenie deweloperskie z Intlayer, możesz zainstalować oficjalne **rozszerzenie Intlayer dla VS Code**.
|
|
867
666
|
|
|
868
667
|
[Zainstaluj z VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
869
668
|
|
|
@@ -874,12 +673,10 @@ To rozszerzenie oferuje:
|
|
|
874
673
|
- **Podglądy w linii** przetłumaczonej zawartości.
|
|
875
674
|
- **Szybkie akcje** umożliwiające łatwe tworzenie i aktualizowanie tłumaczeń.
|
|
876
675
|
|
|
877
|
-
Aby uzyskać więcej informacji na temat korzystania z rozszerzenia, zapoznaj się z [dokumentacją rozszerzenia Intlayer VS Code](https://intlayer.org/doc/vs-code-extension).
|
|
676
|
+
Aby uzyskać więcej informacji na temat korzystania z rozszerzenia, zapoznaj się z [dokumentacją rozszerzenia Intlayer dla VS Code](https://intlayer.org/doc/vs-code-extension).
|
|
878
677
|
|
|
879
678
|
---
|
|
880
679
|
|
|
881
680
|
### Idź dalej
|
|
882
681
|
|
|
883
|
-
Aby pójść dalej, możesz zaimplementować [edytor wizualny](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_visual_editor.md) lub
|
|
884
|
-
|
|
885
|
-
---
|
|
682
|
+
Aby pójść dalej, możesz zaimplementować [edytor wizualny](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_visual_editor.md) lub wyeksportować swoją zawartość, korzystając z [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_CMS.md).
|