@intlayer/docs 7.3.10 → 7.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +305 -421
- 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 +296 -394
- 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 +242 -321
- 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 +262 -358
- 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 +284 -375
- 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 +288 -387
- 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 +318 -434
- 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 +275 -376
- 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 +312 -408
- 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 +319 -414
- 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 +307 -406
- 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 +282 -457
- 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 +288 -403
- 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 +300 -410
- 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 +327 -392
- 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 +282 -399
- 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 +311 -444
- 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 +6 -6
- 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=IE3XWkZ6a5U
|
|
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
|
|
|
@@ -45,14 +47,35 @@ Dzięki Intlayer możesz:
|
|
|
45
47
|
## Przewodnik krok po kroku, jak skonfigurować Intlayer w aplikacji Nuxt
|
|
46
48
|
|
|
47
49
|
<iframe
|
|
48
|
-
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
50
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-4-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
49
51
|
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
52
|
title="Demo CodeSandbox - Jak internacjonalizować swoją aplikację za pomocą Intlayer"
|
|
51
53
|
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
52
54
|
loading="lazy"
|
|
53
55
|
/>
|
|
54
56
|
|
|
55
|
-
### Krok 1:
|
|
57
|
+
### Krok 1: Zainstaluj zależności
|
|
58
|
+
|
|
59
|
+
<Tab defaultTab="video">
|
|
60
|
+
<TabItem label="Wideo" value="video">
|
|
61
|
+
|
|
62
|
+
<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/IE3XWkZ6a5U?autoplay=0&origin=http://intlayer.org&controls=0&rel=1"/>
|
|
63
|
+
|
|
64
|
+
</TabItem>
|
|
65
|
+
<TabItem label="Kod" value="code">
|
|
66
|
+
|
|
67
|
+
<iframe
|
|
68
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-4-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
69
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
70
|
+
title="Demo CodeSandbox - Jak internacjonalizować swoją aplikację za pomocą Intlayer"
|
|
71
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
72
|
+
loading="lazy"
|
|
73
|
+
/>
|
|
74
|
+
|
|
75
|
+
</TabItem>
|
|
76
|
+
</Tab>
|
|
77
|
+
|
|
78
|
+
Zobacz [Szablon aplikacji](https://github.com/aymericzip/intlayer-nuxt-4-template) na GitHub.
|
|
56
79
|
|
|
57
80
|
Zainstaluj niezbędne pakiety za pomocą npm:
|
|
58
81
|
|
|
@@ -73,15 +96,13 @@ yarn add --save-dev nuxt-intlayer
|
|
|
73
96
|
|
|
74
97
|
- **intlayer**
|
|
75
98
|
|
|
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).
|
|
99
|
+
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
100
|
|
|
80
101
|
- **vue-intlayer**
|
|
81
102
|
Pakiet integrujący Intlayer z aplikacją Vue. Zawiera composables dla komponentów Vue.
|
|
82
103
|
|
|
83
104
|
- **nuxt-intlayer**
|
|
84
|
-
Moduł Nuxt
|
|
105
|
+
Moduł Nuxt, który integruje Intlayer z aplikacjami Nuxt. Zapewnia automatyczną konfigurację, middleware do wykrywania lokalizacji, zarządzanie ciasteczkami oraz przekierowania URL.
|
|
85
106
|
|
|
86
107
|
### Krok 2: Konfiguracja Twojego projektu
|
|
87
108
|
|
|
@@ -100,9 +121,6 @@ const config: IntlayerConfig = {
|
|
|
100
121
|
],
|
|
101
122
|
defaultLocale: Locales.ENGLISH,
|
|
102
123
|
},
|
|
103
|
-
content: {
|
|
104
|
-
contentDir: ["."], // Domyślnie Intlayer będzie obserwować pliki deklaracji treści z katalogu `./src`
|
|
105
|
-
},
|
|
106
124
|
};
|
|
107
125
|
|
|
108
126
|
export default config;
|
|
@@ -122,9 +140,6 @@ const config = {
|
|
|
122
140
|
],
|
|
123
141
|
defaultLocale: Locales.ENGLISH,
|
|
124
142
|
},
|
|
125
|
-
content: {
|
|
126
|
-
contentDir: ["."],
|
|
127
|
-
},
|
|
128
143
|
};
|
|
129
144
|
|
|
130
145
|
export default config;
|
|
@@ -144,15 +159,12 @@ const config = {
|
|
|
144
159
|
],
|
|
145
160
|
defaultLocale: Locales.ENGLISH,
|
|
146
161
|
},
|
|
147
|
-
content: {
|
|
148
|
-
contentDir: ["."],
|
|
149
|
-
},
|
|
150
162
|
};
|
|
151
163
|
|
|
152
164
|
module.exports = config;
|
|
153
165
|
```
|
|
154
166
|
|
|
155
|
-
>
|
|
167
|
+
> 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
168
|
|
|
157
169
|
### Krok 3: Zintegruj Intlayer w swojej konfiguracji Nuxt
|
|
158
170
|
|
|
@@ -167,293 +179,46 @@ export default defineNuxtConfig({
|
|
|
167
179
|
});
|
|
168
180
|
```
|
|
169
181
|
|
|
170
|
-
> Moduł `nuxt-intlayer` automatycznie obsługuje integrację Intlayer z Nuxt. Konfiguruje budowanie deklaracji
|
|
182
|
+
> 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
183
|
|
|
172
|
-
### Krok 4: Zadeklaruj swoją
|
|
184
|
+
### Krok 4: Zadeklaruj swoją zawartość
|
|
173
185
|
|
|
174
|
-
Twórz i zarządzaj deklaracjami
|
|
186
|
+
Twórz i zarządzaj swoimi deklaracjami zawartości, aby przechowywać tłumaczenia:
|
|
175
187
|
|
|
176
|
-
```tsx fileName="
|
|
177
|
-
import {
|
|
188
|
+
```tsx fileName="content/home-page.content.ts" contentDeclarationFormat="typescript"
|
|
189
|
+
import { type Dictionary, t } from "intlayer";
|
|
178
190
|
|
|
179
|
-
const
|
|
180
|
-
key: "
|
|
191
|
+
const content = {
|
|
192
|
+
key: "home-page",
|
|
181
193
|
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 ",
|
|
194
|
+
title: t({
|
|
195
|
+
en: "Hello world",
|
|
196
|
+
fr: "Bonjour le monde",
|
|
197
|
+
es: "Hola mundo",
|
|
205
198
|
}),
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
es: "Documentación de Nuxt",
|
|
199
|
+
metaTitle: t({
|
|
200
|
+
en: "Welcome | My Application",
|
|
201
|
+
fr: "Bienvenue | Mon Application",
|
|
202
|
+
es: "Bienvenido | Mi Aplicación",
|
|
211
203
|
}),
|
|
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",
|
|
204
|
+
metaDescription: t({
|
|
205
|
+
en: "Discover your multilingual Nuxt app homepage powered by Intlayer.",
|
|
206
|
+
fr: "Découvrez la page d'accueil multilingue de votre application Nuxt propulsée par Intlayer.",
|
|
207
|
+
es: "Descubre la página de inicio multilingüe de tu aplicación Nuxt impulsada por Intlayer.",
|
|
218
208
|
}),
|
|
219
209
|
},
|
|
220
210
|
} satisfies Dictionary;
|
|
221
211
|
|
|
222
|
-
export default
|
|
212
|
+
export default content;
|
|
223
213
|
```
|
|
224
214
|
|
|
225
|
-
|
|
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
|
-
}
|
|
448
|
-
```
|
|
449
|
-
|
|
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 pasują do rozszerzenia pliku deklaracji zawartości (domyślnie `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
215
|
+
> 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
216
|
|
|
452
217
|
> 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
218
|
|
|
454
219
|
### Krok 5: Wykorzystaj Intlayer w swoim kodzie
|
|
455
220
|
|
|
456
|
-
Uzyskaj dostęp do swoich słowników zawartości w całej aplikacji Nuxt, korzystając z
|
|
221
|
+
Uzyskaj dostęp do swoich słowników zawartości w całej aplikacji Nuxt, korzystając z kompozycji `useIntlayer`:
|
|
457
222
|
|
|
458
223
|
```vue fileName="components/HelloWorld.vue"
|
|
459
224
|
<script setup lang="ts">
|
|
@@ -502,86 +267,76 @@ const countRef = ref(0);
|
|
|
502
267
|
</template>
|
|
503
268
|
```
|
|
504
269
|
|
|
505
|
-
#### Dostęp do
|
|
270
|
+
#### Dostęp do zawartości w Intlayer
|
|
506
271
|
|
|
507
|
-
Intlayer oferuje różne API do dostępu do
|
|
272
|
+
Intlayer oferuje różne API do dostępu do Twojej zawartości:
|
|
508
273
|
|
|
509
274
|
- **Składnia oparta na komponentach** (zalecana):
|
|
510
|
-
Użyj składni `<myContent />` lub `<Component :is="myContent" />`, aby wyrenderować
|
|
275
|
+
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
276
|
|
|
512
|
-
- **Składnia oparta na
|
|
513
|
-
Użyj `{{ myContent }}`, aby wyrenderować
|
|
277
|
+
- **Składnia oparta na łańcuchach znaków**:
|
|
278
|
+
Użyj `{{ myContent }}`, aby wyrenderować zawartość jako zwykły tekst, bez wsparcia Visual Editor.
|
|
514
279
|
|
|
515
280
|
- **Składnia surowego HTML**:
|
|
516
|
-
Użyj `<div v-html="myContent" />`, aby wyrenderować
|
|
281
|
+
Użyj `<div v-html="myContent" />`, aby wyrenderować zawartość jako surowy HTML, bez wsparcia Visual Editor.
|
|
517
282
|
|
|
518
283
|
- **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
|
|
284
|
+
Kompozycja `useIntlayer` zwraca Proxy z zawartością. Ten proxy można zdestrukturyzować, aby uzyskać dostęp do zawartości, zachowując reaktywność.
|
|
285
|
+
- Użyj `const content = useIntlayer("myContent");` oraz `{{ content.myContent }}` / `<content.myContent />`.
|
|
286
|
+
- Lub użyj `const { myContent } = useIntlayer("myContent");` oraz `{{ myContent}}` / `<myContent/>`, aby zdestrukturyzować zawartość.
|
|
522
287
|
|
|
523
|
-
### (
|
|
288
|
+
### (Opcjonalny) Krok 6: Zmień język swojej zawartości
|
|
524
289
|
|
|
525
|
-
Aby zmienić język swojej zawartości, możesz użyć funkcji `setLocale` dostarczonej przez
|
|
290
|
+
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
291
|
|
|
527
|
-
Utwórz komponent do przełączania między językami:
|
|
292
|
+
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
293
|
|
|
529
294
|
```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
295
|
<script setup lang="ts">
|
|
541
|
-
import {
|
|
542
|
-
import { getLocaleName } from "intlayer";
|
|
296
|
+
import { getLocaleName, getLocalizedUrl } from "intlayer";
|
|
543
297
|
import { useLocale } from "vue-intlayer";
|
|
544
298
|
|
|
545
|
-
//
|
|
299
|
+
// Nuxt automatycznie importuje useRoute
|
|
300
|
+
const route = useRoute();
|
|
546
301
|
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
302
|
</script>
|
|
303
|
+
|
|
304
|
+
<template>
|
|
305
|
+
<nav class="locale-switcher">
|
|
306
|
+
<NuxtLink
|
|
307
|
+
v-for="localeEl in availableLocales"
|
|
308
|
+
:key="localeEl"
|
|
309
|
+
:to="getLocalizedUrl(route.fullPath, localeEl)"
|
|
310
|
+
class="locale-link"
|
|
311
|
+
:class="{ 'active-locale': localeEl === locale }"
|
|
312
|
+
@click="setLocale(localeEl)"
|
|
313
|
+
>
|
|
314
|
+
{{ getLocaleName(localeEl) }}
|
|
315
|
+
</NuxtLink>
|
|
316
|
+
</nav>
|
|
562
317
|
</template>
|
|
318
|
+
```
|
|
563
319
|
|
|
564
|
-
|
|
565
|
-
.locale-switcher {
|
|
566
|
-
margin: 1rem 0;
|
|
567
|
-
}
|
|
320
|
+
> 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
321
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
322
|
+
Następnie skonfiguruj swój plik `app.vue`, aby używać layoutów:
|
|
323
|
+
|
|
324
|
+
```vue fileName="app.vue"
|
|
325
|
+
<template>
|
|
326
|
+
<NuxtLayout>
|
|
327
|
+
<NuxtPage />
|
|
328
|
+
</NuxtLayout>
|
|
329
|
+
</template>
|
|
575
330
|
```
|
|
576
331
|
|
|
577
|
-
|
|
332
|
+
### (Opcjonalny) Krok 6b: Utwórz Layout z Nawigacją
|
|
578
333
|
|
|
579
|
-
|
|
334
|
+
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ę:
|
|
335
|
+
|
|
336
|
+
```vue fileName="layouts/default.vue"
|
|
580
337
|
<script setup lang="ts">
|
|
581
|
-
import
|
|
338
|
+
import Links from "~/components/Links.vue";
|
|
582
339
|
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
583
|
-
|
|
584
|
-
const content = useIntlayer("app"); // Utwórz powiązany plik deklaracji intlayer
|
|
585
340
|
</script>
|
|
586
341
|
|
|
587
342
|
<template>
|
|
@@ -590,12 +345,17 @@ const content = useIntlayer("app"); // Utwórz powiązany plik deklaracji intlay
|
|
|
590
345
|
<LocaleSwitcher />
|
|
591
346
|
</header>
|
|
592
347
|
<main>
|
|
593
|
-
<
|
|
348
|
+
<slot />
|
|
594
349
|
</main>
|
|
350
|
+
|
|
351
|
+
<Links href="/">Strona główna</Links>
|
|
352
|
+
<Links href="/about">O nas</Links>
|
|
595
353
|
</div>
|
|
596
354
|
</template>
|
|
597
355
|
```
|
|
598
356
|
|
|
357
|
+
Komponent `Links` (pokazany poniżej) zapewnia, że wewnętrzne linki nawigacyjne są automatycznie lokalizowane.
|
|
358
|
+
|
|
599
359
|
### (Opcjonalny) Krok 7: Dodaj lokalizowane routingi do swojej aplikacji
|
|
600
360
|
|
|
601
361
|
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,220 +370,287 @@ pages/
|
|
|
610
370
|
└── index.vue → /contact, /fr/contact, /es/contact
|
|
611
371
|
```
|
|
612
372
|
|
|
613
|
-
Aby utworzyć
|
|
373
|
+
Aby utworzyć lokalizowane strony, wystarczy utworzyć pliki Vue w katalogu `pages/`. Oto dwa przykładowe pliki stron:
|
|
374
|
+
|
|
375
|
+
**Strona główna (`pages/index.vue`):**
|
|
376
|
+
|
|
377
|
+
```vue fileName="pages/index.vue"
|
|
378
|
+
<script setup lang="ts">
|
|
379
|
+
import { useIntlayer } from "vue-intlayer";
|
|
380
|
+
|
|
381
|
+
const content = useIntlayer("home-page");
|
|
382
|
+
|
|
383
|
+
useHead({
|
|
384
|
+
title: content.metaTitle.value,
|
|
385
|
+
meta: [
|
|
386
|
+
{
|
|
387
|
+
name: "description",
|
|
388
|
+
content: content.metaDescription.value,
|
|
389
|
+
},
|
|
390
|
+
],
|
|
391
|
+
});
|
|
392
|
+
</script>
|
|
393
|
+
|
|
394
|
+
<template>
|
|
395
|
+
<h1><content.title /></h1>
|
|
396
|
+
</template>
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**Strona O nas (`pages/about.vue`):**
|
|
614
400
|
|
|
615
401
|
```vue fileName="pages/about.vue"
|
|
616
402
|
<script setup lang="ts">
|
|
617
403
|
import { useIntlayer } from "vue-intlayer";
|
|
618
404
|
|
|
619
|
-
const content = useIntlayer("about");
|
|
405
|
+
const content = useIntlayer("about-page");
|
|
406
|
+
|
|
407
|
+
useHead({
|
|
408
|
+
title: content.metaTitle.raw, // Użyj .raw, aby uzyskać dostęp do prymitywnego stringa
|
|
409
|
+
meta: [
|
|
410
|
+
{
|
|
411
|
+
name: "description",
|
|
412
|
+
content: content.metaDescription.raw, // Użyj .raw, aby uzyskać dostęp do prymitywnego łańcucha znaków
|
|
413
|
+
},
|
|
414
|
+
],
|
|
415
|
+
});
|
|
620
416
|
</script>
|
|
621
417
|
|
|
622
418
|
<template>
|
|
623
|
-
<
|
|
624
|
-
<h1>{{ content.title }}</h1>
|
|
625
|
-
<p>{{ content.description }}</p>
|
|
626
|
-
</div>
|
|
419
|
+
<h1><content.title /></h1>
|
|
627
420
|
</template>
|
|
628
421
|
```
|
|
629
422
|
|
|
423
|
+
> 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.
|
|
424
|
+
|
|
630
425
|
Moduł `nuxt-intlayer` automatycznie:
|
|
631
426
|
|
|
632
427
|
- Wykrywa preferowany język użytkownika
|
|
633
|
-
- Obsługuje przełączanie
|
|
428
|
+
- Obsługuje przełączanie języków przez URL
|
|
634
429
|
- Ustawia odpowiedni atrybut `<html lang="">`
|
|
635
430
|
- Zarządza ciasteczkami językowymi
|
|
636
|
-
- Przekierowuje użytkowników
|
|
431
|
+
- Przekierowuje użytkowników do odpowiedniego zlokalizowanego URL
|
|
637
432
|
|
|
638
|
-
### (Opcjonalny) Krok 8: Tworzenie komponentu
|
|
433
|
+
### (Opcjonalny) Krok 8: Tworzenie lokalizowanego komponentu Linków
|
|
639
434
|
|
|
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>
|
|
435
|
+
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
436
|
|
|
437
|
+
```vue fileName="components/Links.vue"
|
|
649
438
|
<script setup lang="ts">
|
|
650
|
-
import { computed } from "vue";
|
|
651
439
|
import { getLocalizedUrl } from "intlayer";
|
|
652
440
|
import { useLocale } from "vue-intlayer";
|
|
653
441
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
442
|
+
interface Props {
|
|
443
|
+
href: string;
|
|
444
|
+
locale?: string;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
const props = defineProps<Props>();
|
|
660
448
|
|
|
661
|
-
const { locale } = useLocale();
|
|
449
|
+
const { locale: currentLocale } = useLocale();
|
|
662
450
|
|
|
663
|
-
//
|
|
664
|
-
const
|
|
451
|
+
// Oblicz końcową ścieżkę
|
|
452
|
+
const finalPath = computed(() => {
|
|
453
|
+
// 1. Sprawdź, czy link jest zewnętrzny
|
|
454
|
+
const isExternal = /^https?:\/\//.test(props.href || "");
|
|
665
455
|
|
|
666
|
-
//
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
456
|
+
// 2. Jeśli zewnętrzny, zwróć go bez zmian (NuxtLink obsługuje generowanie tagu <a>)
|
|
457
|
+
if (isExternal) return props.href;
|
|
458
|
+
|
|
459
|
+
// 3. Jeśli link jest wewnętrzny, lokalizuj URL
|
|
460
|
+
const targetLocale = props.locale || currentLocale.value;
|
|
461
|
+
return getLocalizedUrl(props.href, targetLocale);
|
|
462
|
+
});
|
|
670
463
|
</script>
|
|
464
|
+
|
|
465
|
+
<template>
|
|
466
|
+
<NuxtLink :to="finalPath" v-bind="$attrs">
|
|
467
|
+
<slot />
|
|
468
|
+
</NuxtLink>
|
|
469
|
+
</template>
|
|
671
470
|
```
|
|
672
471
|
|
|
673
472
|
Następnie użyj tego komponentu w całej aplikacji:
|
|
674
473
|
|
|
675
|
-
```vue fileName="
|
|
474
|
+
```vue fileName="layouts/default.vue"
|
|
475
|
+
<script setup lang="ts">
|
|
476
|
+
import Links from "~/components/Links.vue";
|
|
477
|
+
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
478
|
+
</script>
|
|
479
|
+
|
|
676
480
|
<template>
|
|
677
481
|
<div>
|
|
678
|
-
<
|
|
679
|
-
|
|
680
|
-
</
|
|
681
|
-
<
|
|
682
|
-
|
|
683
|
-
</
|
|
482
|
+
<header>
|
|
483
|
+
<LocaleSwitcher />
|
|
484
|
+
</header>
|
|
485
|
+
<main>
|
|
486
|
+
<slot />
|
|
487
|
+
</main>
|
|
488
|
+
|
|
489
|
+
<Links href="/">Strona główna</Links>
|
|
490
|
+
<Links href="/about">O nas</Links>
|
|
684
491
|
</div>
|
|
685
492
|
</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
493
|
```
|
|
694
494
|
|
|
695
|
-
|
|
495
|
+
> Korzystając z `NuxtLink` z lokalizowanymi ścieżkami, zapewniasz, że:
|
|
496
|
+
>
|
|
497
|
+
> - Wyszukiwarki mogą indeksować i przeszukiwać wszystkie wersje językowe Twoich stron
|
|
498
|
+
> - Użytkownicy mogą bezpośrednio udostępniać lokalizowane URL-e
|
|
499
|
+
> - Historia przeglądarki działa poprawnie z URL-ami poprzedzonymi prefiksem języka
|
|
500
|
+
|
|
501
|
+
### (Opcjonalny) Krok 9: Obsługa Metadanych i SEO
|
|
696
502
|
|
|
697
|
-
Nuxt oferuje doskonałe możliwości SEO. Możesz użyć Intlayer do obsługi
|
|
503
|
+
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
504
|
|
|
699
505
|
```vue fileName="pages/about.vue"
|
|
700
506
|
<script setup lang="ts">
|
|
701
|
-
import {
|
|
702
|
-
import { getIntlayer } from "intlayer";
|
|
703
|
-
import { useLocale } from "vue-intlayer";
|
|
507
|
+
import { useIntlayer } from "vue-intlayer";
|
|
704
508
|
|
|
705
|
-
|
|
706
|
-
const content =
|
|
509
|
+
// useHead jest auto-importowane w Nuxt
|
|
510
|
+
const content = useIntlayer("about-page");
|
|
707
511
|
|
|
708
|
-
|
|
709
|
-
title: content.
|
|
710
|
-
|
|
512
|
+
useHead({
|
|
513
|
+
title: content.metaTitle.raw, // Użyj .raw, aby uzyskać prymitywną wartość łańcuchową
|
|
514
|
+
meta: [
|
|
515
|
+
{
|
|
516
|
+
name: "description",
|
|
517
|
+
content: content.metaDescription.raw, // Użyj .raw, aby uzyskać prymitywną wartość łańcuchową
|
|
518
|
+
},
|
|
519
|
+
],
|
|
711
520
|
});
|
|
712
521
|
</script>
|
|
713
522
|
|
|
714
523
|
<template>
|
|
715
|
-
<
|
|
716
|
-
<h1>{{ content.pageTitle }}</h1>
|
|
717
|
-
<p>{{ content.pageContent }}</p>
|
|
718
|
-
</div>
|
|
524
|
+
<h1><content.title /></h1>
|
|
719
525
|
</template>
|
|
720
526
|
```
|
|
721
527
|
|
|
722
|
-
|
|
528
|
+
> Alternatywnie możesz użyć funkcji `import { getIntlayer } from "intlayer"`, aby uzyskać zawartość bez reaktywności Vue.
|
|
529
|
+
|
|
530
|
+
> **Dostęp do wartości zawartości:**
|
|
531
|
+
>
|
|
532
|
+
> - Użyj `.raw`, aby uzyskać prymitywną wartość łańcuchową (niereaktywną)
|
|
533
|
+
> - Użyj `.value`, aby uzyskać wartość reaktywną
|
|
534
|
+
> - Użyj składni komponentu `<content.key />` dla wsparcia Visual Editora
|
|
723
535
|
|
|
724
|
-
|
|
536
|
+
Utwórz odpowiednią deklarację zawartości:
|
|
537
|
+
|
|
538
|
+
```ts fileName="pages/about-page.content.ts" contentDeclarationFormat="typescript"
|
|
725
539
|
import { t, type Dictionary } from "intlayer";
|
|
726
|
-
import type { useSeoMeta } from "nuxt/app";
|
|
727
540
|
|
|
728
|
-
const
|
|
729
|
-
key: "about-
|
|
541
|
+
const aboutPageContent = {
|
|
542
|
+
key: "about-page",
|
|
730
543
|
content: {
|
|
731
|
-
|
|
732
|
-
pl: "O nas - Moja Firma",
|
|
544
|
+
metaTitle: t({
|
|
733
545
|
en: "About Us - My Company",
|
|
734
546
|
fr: "À Propos - Ma Société",
|
|
735
547
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
736
548
|
}),
|
|
737
|
-
|
|
549
|
+
metaDescription: t({
|
|
738
550
|
pl: "Dowiedz się więcej o naszej firmie i naszej misji",
|
|
739
551
|
en: "Learn more about our company and our mission",
|
|
740
552
|
fr: "En savoir plus sur notre société et notre mission",
|
|
741
553
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
742
554
|
}),
|
|
555
|
+
title: t({
|
|
556
|
+
pl: "O nas",
|
|
557
|
+
en: "About Us",
|
|
558
|
+
fr: "À Propos",
|
|
559
|
+
es: "Acerca de Nosotros",
|
|
560
|
+
}),
|
|
743
561
|
},
|
|
744
|
-
} satisfies Dictionary
|
|
562
|
+
} satisfies Dictionary;
|
|
745
563
|
|
|
746
|
-
export default
|
|
564
|
+
export default aboutPageContent;
|
|
747
565
|
```
|
|
748
566
|
|
|
749
|
-
```
|
|
567
|
+
```javascript fileName="pages/about-page.content.mjs" contentDeclarationFormat="esm"
|
|
750
568
|
import { t } from "intlayer";
|
|
751
569
|
|
|
752
570
|
/** @type {import('intlayer').Dictionary} */
|
|
753
|
-
const
|
|
754
|
-
key: "about-
|
|
571
|
+
const aboutPageContent = {
|
|
572
|
+
key: "about-page",
|
|
755
573
|
content: {
|
|
756
|
-
|
|
757
|
-
|
|
574
|
+
metaTitle: t({
|
|
575
|
+
pl: "O nas - Moja firma",
|
|
758
576
|
en: "About Us - My Company",
|
|
759
577
|
fr: "À Propos - Ma Société",
|
|
760
578
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
761
|
-
pl: "O nas - Moja Firma",
|
|
762
579
|
}),
|
|
763
|
-
|
|
764
|
-
zh: "了解更多关于我们公司和我们的使命",
|
|
580
|
+
metaDescription: t({
|
|
765
581
|
en: "Learn more about our company and our mission",
|
|
766
582
|
fr: "En savoir plus sur notre société et notre mission",
|
|
767
583
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
768
|
-
|
|
584
|
+
}),
|
|
585
|
+
title: t({
|
|
586
|
+
en: "About Us",
|
|
587
|
+
fr: "À Propos",
|
|
588
|
+
es: "Acerca de Nosotros",
|
|
769
589
|
}),
|
|
770
590
|
},
|
|
771
591
|
};
|
|
772
592
|
|
|
773
|
-
export default
|
|
593
|
+
export default aboutPageContent;
|
|
774
594
|
```
|
|
775
595
|
|
|
776
|
-
```
|
|
596
|
+
```javascript fileName="pages/about-page.content.cjs" contentDeclarationFormat="commonjs"
|
|
777
597
|
const { t } = require("intlayer");
|
|
778
598
|
|
|
779
599
|
/** @type {import('intlayer').Dictionary} */
|
|
780
|
-
const
|
|
781
|
-
key: "about-
|
|
600
|
+
const aboutPageContent = {
|
|
601
|
+
key: "about-page",
|
|
782
602
|
content: {
|
|
783
|
-
|
|
784
|
-
zh: "关于我们 - 我的公司",
|
|
603
|
+
metaTitle: t({
|
|
785
604
|
en: "About Us - My Company",
|
|
605
|
+
pl: "O nas - Moja Firma", // tytuł meta w języku polskim
|
|
786
606
|
fr: "À Propos - Ma Société",
|
|
787
607
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
788
|
-
pl: "O nas - Moja Firma",
|
|
789
608
|
}),
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
}),
|
|
793
|
-
description: t({
|
|
794
|
-
zh: "了解更多关于我们公司和我们的使命",
|
|
795
|
-
en: "Learn more about our company and our mission",
|
|
609
|
+
metaDescription: t({
|
|
610
|
+
en: "Dowiedz się więcej o naszej firmie i naszej misji",
|
|
796
611
|
fr: "En savoir plus sur notre société et notre mission",
|
|
797
612
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
798
|
-
|
|
613
|
+
}),
|
|
614
|
+
title: t({
|
|
615
|
+
en: "O nas",
|
|
616
|
+
fr: "À Propos",
|
|
617
|
+
es: "Acerca de Nosotros",
|
|
799
618
|
}),
|
|
800
619
|
},
|
|
801
620
|
};
|
|
802
621
|
|
|
803
|
-
module.exports =
|
|
622
|
+
module.exports = aboutPageContent;
|
|
804
623
|
```
|
|
805
624
|
|
|
806
|
-
```json fileName="pages/about-
|
|
625
|
+
```json fileName="pages/about-page.content.json" contentDeclarationFormat="json"
|
|
807
626
|
{
|
|
808
|
-
"
|
|
627
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
628
|
+
"key": "about-page",
|
|
809
629
|
"content": {
|
|
810
|
-
"
|
|
630
|
+
"metaTitle": {
|
|
811
631
|
"nodeType": "translation",
|
|
812
|
-
"
|
|
813
|
-
"
|
|
814
|
-
"en": "About Us - My Company",
|
|
632
|
+
"translation": {
|
|
633
|
+
"en": "O nas - Moja firma",
|
|
815
634
|
"fr": "À Propos - Ma Société",
|
|
816
|
-
"es": "Acerca de Nosotros - Mi Empresa"
|
|
817
|
-
"pl": "O nas - Moja firma"
|
|
635
|
+
"es": "Acerca de Nosotros - Mi Empresa"
|
|
818
636
|
}
|
|
819
637
|
},
|
|
820
|
-
"
|
|
638
|
+
"metaDescription": {
|
|
821
639
|
"nodeType": "translation",
|
|
822
|
-
"
|
|
823
|
-
"zh": "了解更多关于我们公司和我们的使命",
|
|
640
|
+
"translation": {
|
|
824
641
|
"en": "Learn more about our company and our mission",
|
|
825
642
|
"fr": "En savoir plus sur notre société et notre mission",
|
|
826
|
-
"es": "Conozca más sobre nuestra empresa y nuestra misión"
|
|
643
|
+
"es": "Conozca más sobre nuestra empresa y nuestra misión",
|
|
644
|
+
"pl": "Dowiedz się więcej o naszej firmie i naszej misji"
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
"title": {
|
|
648
|
+
"nodeType": "translation",
|
|
649
|
+
"translation": {
|
|
650
|
+
"en": "About Us",
|
|
651
|
+
"fr": "À Propos",
|
|
652
|
+
"es": "Acerca de Nosotros",
|
|
653
|
+
"pl": "O nas"
|
|
827
654
|
}
|
|
828
655
|
}
|
|
829
656
|
}
|
|
@@ -832,7 +659,7 @@ module.exports = aboutMetaContent;
|
|
|
832
659
|
|
|
833
660
|
### Konfiguracja TypeScript
|
|
834
661
|
|
|
835
|
-
Intlayer
|
|
662
|
+
Intlayer używa rozszerzania modułów, aby korzystać z zalet TypeScript i wzmocnić Twoją bazę kodu.
|
|
836
663
|
|
|
837
664
|

|
|
838
665
|
|
|
@@ -852,7 +679,7 @@ Upewnij się, że Twoja konfiguracja TypeScript zawiera automatycznie generowane
|
|
|
852
679
|
|
|
853
680
|
### Konfiguracja Git
|
|
854
681
|
|
|
855
|
-
Zaleca się ignorowanie plików generowanych przez Intlayer. Pozwala to uniknąć ich
|
|
682
|
+
Zaleca się ignorowanie plików generowanych przez Intlayer. Pozwala to uniknąć ich zatwierdzania do repozytorium Git.
|
|
856
683
|
|
|
857
684
|
Aby to zrobić, możesz dodać następujące instrukcje do pliku `.gitignore`:
|
|
858
685
|
|
|
@@ -863,7 +690,7 @@ Aby to zrobić, możesz dodać następujące instrukcje do pliku `.gitignore`:
|
|
|
863
690
|
|
|
864
691
|
### Rozszerzenie VS Code
|
|
865
692
|
|
|
866
|
-
Aby poprawić doświadczenie
|
|
693
|
+
Aby poprawić swoje doświadczenie deweloperskie z Intlayer, możesz zainstalować oficjalne **rozszerzenie Intlayer dla VS Code**.
|
|
867
694
|
|
|
868
695
|
[Zainstaluj z VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
869
696
|
|
|
@@ -874,12 +701,10 @@ To rozszerzenie oferuje:
|
|
|
874
701
|
- **Podglądy w linii** przetłumaczonej zawartości.
|
|
875
702
|
- **Szybkie akcje** umożliwiające łatwe tworzenie i aktualizowanie tłumaczeń.
|
|
876
703
|
|
|
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).
|
|
704
|
+
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
705
|
|
|
879
706
|
---
|
|
880
707
|
|
|
881
708
|
### Idź dalej
|
|
882
709
|
|
|
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
|
-
---
|
|
710
|
+
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).
|