@intlayer/docs 7.5.9 → 7.5.10
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/README.md +9 -2
- 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/cli/push.md +1 -1
- package/docs/ar/configuration.md +3 -3
- package/docs/ar/interest_of_intlayer.md +1 -1
- package/docs/ar/intlayer_CMS.md +5 -5
- package/docs/ar/intlayer_with_express.md +1 -0
- package/docs/ar/intlayer_with_fastify.md +516 -0
- package/docs/ar/readme.md +1 -1
- package/docs/de/cli/push.md +1 -1
- package/docs/de/configuration.md +3 -3
- package/docs/de/interest_of_intlayer.md +1 -1
- package/docs/de/intlayer_CMS.md +5 -5
- package/docs/de/intlayer_with_express.md +1 -0
- package/docs/de/intlayer_with_fastify.md +449 -0
- package/docs/de/readme.md +1 -1
- package/docs/en/cli/push.md +1 -1
- package/docs/en/configuration.md +3 -3
- package/docs/en/interest_of_intlayer.md +1 -1
- package/docs/en/intlayer_CMS.md +5 -5
- package/docs/en/intlayer_with_express.md +1 -0
- package/docs/en/intlayer_with_fastify.md +439 -0
- package/docs/en/readme.md +3 -1
- package/docs/en-GB/cli/push.md +1 -1
- package/docs/en-GB/configuration.md +3 -3
- package/docs/en-GB/interest_of_intlayer.md +1 -1
- package/docs/en-GB/intlayer_CMS.md +5 -5
- package/docs/en-GB/intlayer_with_express.md +1 -0
- package/docs/en-GB/intlayer_with_fastify.md +445 -0
- package/docs/en-GB/readme.md +3 -1
- package/docs/es/cli/push.md +1 -1
- package/docs/es/configuration.md +3 -3
- package/docs/es/interest_of_intlayer.md +1 -1
- package/docs/es/intlayer_CMS.md +5 -5
- package/docs/es/intlayer_with_express.md +1 -0
- package/docs/es/intlayer_with_fastify.md +480 -0
- package/docs/es/readme.md +1 -1
- package/docs/fr/cli/push.md +1 -1
- package/docs/fr/configuration.md +3 -3
- package/docs/fr/interest_of_intlayer.md +1 -1
- package/docs/fr/intlayer_CMS.md +5 -5
- package/docs/fr/intlayer_with_express.md +1 -0
- package/docs/fr/intlayer_with_fastify.md +439 -0
- package/docs/fr/readme.md +1 -1
- package/docs/hi/cli/push.md +1 -1
- package/docs/hi/configuration.md +3 -3
- package/docs/hi/interest_of_intlayer.md +1 -1
- package/docs/hi/intlayer_CMS.md +5 -5
- package/docs/hi/intlayer_with_express.md +1 -0
- package/docs/hi/intlayer_with_fastify.md +540 -0
- package/docs/hi/readme.md +1 -1
- package/docs/id/cli/push.md +1 -1
- package/docs/id/configuration.md +3 -3
- package/docs/id/interest_of_intlayer.md +1 -1
- package/docs/id/intlayer_CMS.md +5 -5
- package/docs/id/intlayer_with_express.md +1 -0
- package/docs/id/intlayer_with_fastify.md +470 -0
- package/docs/id/readme.md +1 -1
- package/docs/it/cli/push.md +1 -1
- package/docs/it/configuration.md +3 -3
- package/docs/it/interest_of_intlayer.md +1 -1
- package/docs/it/intlayer_CMS.md +5 -5
- package/docs/it/intlayer_with_express.md +1 -0
- package/docs/it/intlayer_with_fastify.md +445 -0
- package/docs/it/readme.md +1 -1
- package/docs/ja/cli/push.md +1 -1
- package/docs/ja/configuration.md +3 -3
- package/docs/ja/interest_of_intlayer.md +1 -1
- package/docs/ja/intlayer_CMS.md +5 -5
- package/docs/ja/intlayer_with_express.md +1 -0
- package/docs/ja/intlayer_with_fastify.md +516 -0
- package/docs/ja/readme.md +1 -1
- package/docs/ko/cli/push.md +1 -1
- package/docs/ko/configuration.md +3 -3
- package/docs/ko/interest_of_intlayer.md +1 -1
- package/docs/ko/intlayer_CMS.md +5 -5
- package/docs/ko/intlayer_with_express.md +1 -0
- package/docs/ko/intlayer_with_fastify.md +463 -0
- package/docs/ko/readme.md +1 -1
- package/docs/pl/cli/push.md +1 -1
- package/docs/pl/configuration.md +3 -3
- package/docs/pl/interest_of_intlayer.md +1 -1
- package/docs/pl/intlayer_CMS.md +5 -5
- package/docs/pl/intlayer_with_express.md +1 -0
- package/docs/pl/intlayer_with_fastify.md +457 -0
- package/docs/pl/readme.md +1 -1
- package/docs/pt/cli/push.md +1 -1
- package/docs/pt/configuration.md +3 -3
- package/docs/pt/interest_of_intlayer.md +1 -1
- package/docs/pt/intlayer_CMS.md +5 -5
- package/docs/pt/intlayer_with_express.md +1 -0
- package/docs/pt/intlayer_with_fastify.md +502 -0
- package/docs/pt/readme.md +1 -1
- package/docs/ru/cli/push.md +1 -1
- package/docs/ru/configuration.md +3 -3
- package/docs/ru/interest_of_intlayer.md +1 -1
- package/docs/ru/intlayer_CMS.md +5 -5
- package/docs/ru/intlayer_with_express.md +1 -0
- package/docs/ru/intlayer_with_fastify.md +468 -0
- package/docs/ru/readme.md +1 -1
- package/docs/tr/cli/push.md +1 -1
- package/docs/tr/configuration.md +3 -3
- package/docs/tr/interest_of_intlayer.md +1 -1
- package/docs/tr/intlayer_CMS.md +5 -5
- package/docs/tr/intlayer_with_express.md +1 -0
- package/docs/tr/intlayer_with_fastify.md +471 -0
- package/docs/tr/readme.md +1 -1
- package/docs/vi/cli/push.md +1 -1
- package/docs/vi/configuration.md +3 -3
- package/docs/vi/interest_of_intlayer.md +1 -1
- package/docs/vi/intlayer_CMS.md +5 -5
- package/docs/vi/intlayer_with_express.md +1 -0
- package/docs/vi/intlayer_with_fastify.md +490 -0
- package/docs/vi/readme.md +1 -1
- package/docs/zh/cli/push.md +1 -1
- package/docs/zh/configuration.md +3 -3
- package/docs/zh/interest_of_intlayer.md +1 -1
- package/docs/zh/intlayer_CMS.md +5 -5
- package/docs/zh/intlayer_with_express.md +1 -0
- package/docs/zh/intlayer_with_fastify.md +451 -0
- package/docs/zh/readme.md +1 -1
- package/package.json +6 -6
- package/src/generated/docs.entry.ts +19 -0
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-12-30
|
|
3
|
+
updatedAt: 2025-12-30
|
|
4
|
+
title: "Jak przetłumaczyć backend Fastify – przewodnik i18n 2026"
|
|
5
|
+
description: "Dowiedz się, jak uczynić backend Fastify wielojęzycznym. Postępuj zgodnie z dokumentacją, aby zinternacjonalizować (i18n) i przetłumaczyć go."
|
|
6
|
+
keywords:
|
|
7
|
+
- Internacjonalizacja
|
|
8
|
+
- Dokumentacja
|
|
9
|
+
- Intlayer
|
|
10
|
+
- Fastify
|
|
11
|
+
- JavaScript
|
|
12
|
+
- Backend
|
|
13
|
+
slugs:
|
|
14
|
+
- doc
|
|
15
|
+
- environment
|
|
16
|
+
- fastify
|
|
17
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-fastify-template
|
|
18
|
+
history:
|
|
19
|
+
- version: 7.6.0
|
|
20
|
+
date: 2025-12-31
|
|
21
|
+
changes: Dodano polecenie init
|
|
22
|
+
- version: 7.6.0
|
|
23
|
+
date: 2025-12-31
|
|
24
|
+
changes: Inicjalizacja historii
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Przetłumacz backend Fastify przy użyciu Intlayer | Internacjonalizacja (i18n)
|
|
28
|
+
|
|
29
|
+
`fastify-intlayer` to potężny plugin do internacjonalizacji (i18n) dla aplikacji Fastify, zaprojektowany, aby uczynić twoje usługi backendowe globalnie dostępnymi poprzez dostarczanie zlokalizowanych odpowiedzi na podstawie preferencji klienta.
|
|
30
|
+
|
|
31
|
+
### Praktyczne przypadki użycia
|
|
32
|
+
|
|
33
|
+
- **Wyświetlanie błędów backendu w języku użytkownika**: Gdy wystąpi błąd, wyświetlanie komunikatów w ojczystym języku użytkownika poprawia zrozumienie i zmniejsza frustrację. Jest to szczególnie przydatne dla dynamicznych komunikatów o błędach, które mogą być pokazywane w komponentach front-endowych, takich jak toasty czy modalne okna.
|
|
34
|
+
|
|
35
|
+
`fastify-intlayer` to potężna wtyczka do internacjonalizacji (i18n) dla aplikacji Fastify, zaprojektowana, by uczynić Twoje serwisy backendowe globalnie dostępnymi, dostarczając zlokalizowane odpowiedzi zgodnie z preferencjami klienta.
|
|
36
|
+
|
|
37
|
+
### Praktyczne zastosowania
|
|
38
|
+
|
|
39
|
+
- **Wyświetlanie błędów backendu w języku użytkownika**: Gdy wystąpi błąd, wyświetlanie komunikatów w języku ojczystym użytkownika poprawia zrozumienie i zmniejsza frustrację. Jest to szczególnie przydatne w przypadku dynamicznych komunikatów o błędach, które mogą być pokazywane w komponentach front-endowych, takich jak toasty czy modale.
|
|
40
|
+
- **Pobieranie wielojęzycznych treści**: W aplikacjach pobierających treści z bazy danych internacjonalizacja zapewnia możliwość serwowania tych treści w wielu językach. Jest to kluczowe dla platform takich jak serwisy e-commerce czy systemy zarządzania treścią (CMS), które muszą wyświetlać opisy produktów, artykuły i inne treści w języku preferowanym przez użytkownika.
|
|
41
|
+
- **Pobieranie treści wielojęzycznych**: Dla aplikacji pobierających treści z bazy danych, internacjonalizacja zapewnia możliwość serwowania tych treści w wielu językach. Jest to kluczowe dla platform takich jak serwisy e-commerce czy systemy zarządzania treścią, które muszą wyświetlać opisy produktów, artykuły i inne treści w języku preferowanym przez użytkownika.
|
|
42
|
+
- **Wysyłanie wiadomości e-mail w wielu językach**: Niezależnie czy to wiadomości transakcyjne, kampanie marketingowe czy powiadomienia, wysyłanie e-maili w języku odbiorcy może znacząco zwiększyć zaangażowanie i skuteczność.
|
|
43
|
+
- **Wielojęzyczne powiadomienia push**: Dla aplikacji mobilnych wysyłanie powiadomień push w preferowanym języku użytkownika może zwiększyć zaangażowanie i retencję. Ten osobisty akcent sprawia, że powiadomienia wydają się bardziej istotne i skłaniają do działania.
|
|
44
|
+
- **Inne formy komunikacji**: Każda forma komunikacji ze strony backendu, taka jak wiadomości SMS, alerty systemowe czy aktualizacje interfejsu użytkownika, zyskuje na użyciu języka użytkownika, co zapewnia przejrzystość i poprawia ogólne doświadczenie użytkownika.
|
|
45
|
+
|
|
46
|
+
Dzięki internacjonalizacji backendu Twoja aplikacja nie tylko szanuje różnice kulturowe, ale także lepiej dopasowuje się do potrzeb rynków globalnych, co czyni to kluczowym krokiem w skalowaniu usług na cały świat.
|
|
47
|
+
|
|
48
|
+
## Pierwsze kroki
|
|
49
|
+
|
|
50
|
+
### Instalacja
|
|
51
|
+
|
|
52
|
+
Aby rozpocząć korzystanie z `fastify-intlayer`, zainstaluj pakiet za pomocą npm:
|
|
53
|
+
|
|
54
|
+
```bash packageManager="npm"
|
|
55
|
+
npm install intlayer fastify-intlayer
|
|
56
|
+
npx intlayer init
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```bash packageManager="pnpm"
|
|
61
|
+
pnpm add intlayer fastify-intlayer
|
|
62
|
+
pnpm intlayer init
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```bash packageManager="yarn"
|
|
67
|
+
yarn add intlayer fastify-intlayer
|
|
68
|
+
yarn intlayer init
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```bash packageManager="bun"
|
|
73
|
+
bun add intlayer fastify-intlayer
|
|
74
|
+
bunx intlayer init
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Konfiguracja
|
|
79
|
+
|
|
80
|
+
Skonfiguruj ustawienia internacjonalizacji, tworząc plik `intlayer.config.ts` w katalogu głównym projektu:
|
|
81
|
+
|
|
82
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
83
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
84
|
+
|
|
85
|
+
const config: IntlayerConfig = {
|
|
86
|
+
internationalization: {
|
|
87
|
+
locales: [
|
|
88
|
+
Locales.ENGLISH,
|
|
89
|
+
Locales.FRENCH,
|
|
90
|
+
Locales.SPANISH_MEXICO,
|
|
91
|
+
Locales.SPANISH_SPAIN,
|
|
92
|
+
],
|
|
93
|
+
defaultLocale: Locales.ENGLISH,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default config;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
101
|
+
import { Locales } from "intlayer";
|
|
102
|
+
|
|
103
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
104
|
+
const config = {
|
|
105
|
+
internationalization: {
|
|
106
|
+
locales: [
|
|
107
|
+
Locales.ENGLISH,
|
|
108
|
+
Locales.FRENCH,
|
|
109
|
+
Locales.SPANISH_MEXICO,
|
|
110
|
+
Locales.SPANISH_SPAIN,
|
|
111
|
+
],
|
|
112
|
+
defaultLocale: Locales.ENGLISH,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export default config;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
120
|
+
const { Locales } = require("intlayer");
|
|
121
|
+
|
|
122
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
123
|
+
const config = {
|
|
124
|
+
internationalization: {
|
|
125
|
+
locales: [
|
|
126
|
+
Locales.ENGLISH,
|
|
127
|
+
Locales.FRENCH,
|
|
128
|
+
Locales.SPANISH_MEXICO,
|
|
129
|
+
Locales.SPANISH_SPAIN,
|
|
130
|
+
],
|
|
131
|
+
defaultLocale: Locales.ENGLISH,
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
module.exports = config;
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Deklarowanie treści
|
|
139
|
+
|
|
140
|
+
Twórz i zarządzaj deklaracjami treści, aby przechowywać tłumaczenia:
|
|
141
|
+
|
|
142
|
+
```typescript fileName="src/index.content.ts" contentDeclarationFormat="typescript"
|
|
143
|
+
import { t, type Dictionary } from "intlayer";
|
|
144
|
+
|
|
145
|
+
const indexContent = {
|
|
146
|
+
key: "index",
|
|
147
|
+
content: {
|
|
148
|
+
exampleOfContent: t({
|
|
149
|
+
pl: "Przykład zwracanej treści w języku angielskim",
|
|
150
|
+
en: "Example of returned content in English",
|
|
151
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
152
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
153
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
154
|
+
}),
|
|
155
|
+
},
|
|
156
|
+
} satisfies Dictionary;
|
|
157
|
+
|
|
158
|
+
export default indexContent;
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
```javascript fileName="src/index.content.mjs" contentDeclarationFormat="esm"
|
|
162
|
+
import { t } from "intlayer";
|
|
163
|
+
|
|
164
|
+
/** @type {import('intlayer').Dictionary} */
|
|
165
|
+
const indexContent = {
|
|
166
|
+
key: "index",
|
|
167
|
+
content: {
|
|
168
|
+
exampleOfContent: t({
|
|
169
|
+
pl: "Przykład zwracanej treści w języku angielskim",
|
|
170
|
+
en: "Example of returned content in English",
|
|
171
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
172
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
173
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
174
|
+
}),
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export default indexContent;
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
```javascript fileName="src/index.content.cjs" contentDeclarationFormat="commonjs"
|
|
182
|
+
const { t } = require("intlayer");
|
|
183
|
+
|
|
184
|
+
/** @type {import('intlayer').Dictionary} */
|
|
185
|
+
const indexContent = {
|
|
186
|
+
key: "index",
|
|
187
|
+
content: {
|
|
188
|
+
exampleOfContent: t({
|
|
189
|
+
pl: "Przykład zwracanej treści w języku angielskim",
|
|
190
|
+
en: "Example of returned content in English",
|
|
191
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
192
|
+
"pl": "Przykład zwróconej zawartości w języku polskim",
|
|
193
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
194
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
195
|
+
}),
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
module.exports = indexContent;
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
```json fileName="src/index.content.json" contentDeclarationFormat="json"
|
|
203
|
+
{
|
|
204
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
205
|
+
"key": "index",
|
|
206
|
+
"content": {
|
|
207
|
+
"exampleOfContent": {
|
|
208
|
+
"nodeType": "translation",
|
|
209
|
+
"translation": {
|
|
210
|
+
"pl": "Przykład zwróconej zawartości w języku polskim",
|
|
211
|
+
"en": "Example of returned content in English",
|
|
212
|
+
"fr": "Exemple de contenu renvoyé en français",
|
|
213
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
214
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)"
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
> Deklaracje zawartości mogą być zdefiniowane w dowolnym miejscu 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}`).
|
|
222
|
+
|
|
223
|
+
> Po więcej szczegółów odnieś się do [dokumentacji deklaracji zawartości](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/content_file.md).
|
|
224
|
+
|
|
225
|
+
### Konfiguracja aplikacji Fastify
|
|
226
|
+
|
|
227
|
+
Skonfiguruj swoją aplikację Fastify, aby korzystała z `fastify-intlayer`:
|
|
228
|
+
|
|
229
|
+
```typescript fileName="src/index.ts" codeFormat="typescript"
|
|
230
|
+
import Fastify from "fastify";
|
|
231
|
+
import { intlayer, t, getDictionary, getIntlayer } from "fastify-intlayer";
|
|
232
|
+
import dictionaryExample from "./index.content";
|
|
233
|
+
|
|
234
|
+
const fastify = Fastify({ logger: true });
|
|
235
|
+
|
|
236
|
+
// Załaduj wtyczkę internacjonalizacji
|
|
237
|
+
await fastify.register(intlayer);
|
|
238
|
+
|
|
239
|
+
// Trasy
|
|
240
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
241
|
+
return t({
|
|
242
|
+
pl: "Przykład zwróconej zawartości w języku polskim",
|
|
243
|
+
en: "Example of returned content in English",
|
|
244
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
245
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
246
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
251
|
+
return getIntlayer("index").exampleOfContent;
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
255
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// Uruchom serwer
|
|
259
|
+
const start = async () => {
|
|
260
|
+
try {
|
|
261
|
+
await fastify.listen({ port: 3000 });
|
|
262
|
+
} catch (err) {
|
|
263
|
+
fastify.log.error(err);
|
|
264
|
+
process.exit(1);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
start();
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
```javascript fileName="src/index.mjs" codeFormat="esm"
|
|
272
|
+
import Fastify from "fastify";
|
|
273
|
+
import { intlayer, t, getDictionary, getIntlayer } from "fastify-intlayer";
|
|
274
|
+
import dictionaryExample from "./index.content";
|
|
275
|
+
|
|
276
|
+
const fastify = Fastify({ logger: true });
|
|
277
|
+
|
|
278
|
+
// Załaduj wtyczkę internacjonalizacji
|
|
279
|
+
await fastify.register(intlayer);
|
|
280
|
+
|
|
281
|
+
// Trasy
|
|
282
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
283
|
+
return t({
|
|
284
|
+
pl: "Przykład zwracanej treści w języku polskim",
|
|
285
|
+
en: "Example of returned content in English",
|
|
286
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
287
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
288
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
293
|
+
return getIntlayer("index").exampleOfContent;
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
javascript fileName="src/index.mjs" codeFormat="esm"
|
|
297
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
298
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
// Uruchom serwer
|
|
302
|
+
const start = async () => {
|
|
303
|
+
try {
|
|
304
|
+
await fastify.listen({ port: 3000 });
|
|
305
|
+
} catch (err) {
|
|
306
|
+
fastify.log.error(err);
|
|
307
|
+
process.exit(1);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
start();
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
```javascript fileName="src/index.cjs" codeFormat="commonjs"
|
|
315
|
+
const Fastify = require("fastify");
|
|
316
|
+
const { intlayer, t, getDictionary, getIntlayer } = require("fastify-intlayer");
|
|
317
|
+
const dictionaryExample = require("./index.content");
|
|
318
|
+
|
|
319
|
+
const fastify = Fastify({ logger: true });
|
|
320
|
+
|
|
321
|
+
// Funkcja uruchamiająca serwer obsługująca async/await
|
|
322
|
+
const start = async () => {
|
|
323
|
+
try {
|
|
324
|
+
// Załaduj wtyczkę internacjonalizacji
|
|
325
|
+
await fastify.register(intlayer);
|
|
326
|
+
|
|
327
|
+
// Trasy
|
|
328
|
+
fastify.get("/t_example", async (_req, reply) => {
|
|
329
|
+
return t({
|
|
330
|
+
pl: "Przykład zwróconej treści w języku polskim",
|
|
331
|
+
en: "Example of returned content in English",
|
|
332
|
+
fr: "Exemple de contenu renvoyé en français",
|
|
333
|
+
"es-ES": "Ejemplo de contenido devuelto en español (España)",
|
|
334
|
+
"es-MX": "Ejemplo de contenido devuelto en español (México)",
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
fastify.get("/getIntlayer_example", async (_req, reply) => {
|
|
339
|
+
return getIntlayer("index").exampleOfContent;
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
fastify.get("/getDictionary_example", async (_req, reply) => {
|
|
343
|
+
return getDictionary(dictionaryExample).exampleOfContent;
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
await fastify.listen({ port: 3000 });
|
|
347
|
+
} catch (err) {
|
|
348
|
+
fastify.log.error(err);
|
|
349
|
+
process.exit(1);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
start();
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Zgodność
|
|
357
|
+
|
|
358
|
+
`fastify-intlayer` jest w pełni zgodny z:
|
|
359
|
+
|
|
360
|
+
- [`react-intlayer`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/packages/react-intlayer/index.md) dla aplikacji React
|
|
361
|
+
- [`next-intlayer`](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/packages/next-intlayer/index.md) dla aplikacji Next.js
|
|
362
|
+
|
|
363
|
+
- [`react-intlayer`](<https://www.google.com/search?q=%5Bhttps://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/packages/react-intlayer/index.md%5D(https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/packages/react-intlayer/index.md)>) dla aplikacji React
|
|
364
|
+
- [`next-intlayer`](<https://www.google.com/search?q=%5Bhttps://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/packages/next-intlayer/index.md%5D(https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/packages/next-intlayer/index.md)>) dla aplikacji Next.js
|
|
365
|
+
- [`vite-intlayer`](<https://www.google.com/search?q=%5Bhttps://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/packages/vite-intlayer/index.md%5D(https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/packages/vite-intlayer/index.md)>) dla aplikacji Vite
|
|
366
|
+
|
|
367
|
+
Działa również bezproblemowo z dowolnym rozwiązaniem do internacjonalizacji w różnych środowiskach, w tym w przeglądarkach i w żądaniach API. Możesz dostosować middleware, aby wykrywać lokalizę przez nagłówki lub ciasteczka:
|
|
368
|
+
|
|
369
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
370
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
371
|
+
|
|
372
|
+
const config: IntlayerConfig = {
|
|
373
|
+
// ... Inne opcje konfiguracji
|
|
374
|
+
middleware: {
|
|
375
|
+
headerName: "my-locale-header",
|
|
376
|
+
cookieName: "my-locale-cookie",
|
|
377
|
+
},
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
export default config;
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
384
|
+
import { Locales } from "intlayer";
|
|
385
|
+
|
|
386
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
387
|
+
const config = {
|
|
388
|
+
// ... Inne opcje konfiguracji
|
|
389
|
+
middleware: {
|
|
390
|
+
headerName: "my-locale-header",
|
|
391
|
+
cookieName: "my-locale-cookie",
|
|
392
|
+
},
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
export default config;
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
399
|
+
const { Locales } = require("intlayer");
|
|
400
|
+
|
|
401
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
402
|
+
const config = {
|
|
403
|
+
// ... Inne opcje konfiguracji
|
|
404
|
+
middleware: {
|
|
405
|
+
headerName: "my-locale-header",
|
|
406
|
+
cookieName: "my-locale-cookie",
|
|
407
|
+
},
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
module.exports = config;
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
Domyślnie `fastify-intlayer` zinterpretuje nagłówek `Accept-Language`, aby określić preferowany język klienta.
|
|
414
|
+
|
|
415
|
+
> Więcej informacji na temat konfiguracji i zagadnień zaawansowanych znajdziesz w naszej [dokumentacji](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/configuration.md).
|
|
416
|
+
|
|
417
|
+
### Konfiguracja TypeScript
|
|
418
|
+
|
|
419
|
+
`fastify-intlayer` wykorzystuje rozbudowane możliwości TypeScript, aby usprawnić proces internacjonalizacji. Statyczne typowanie TypeScript zapewnia, że każdy klucz tłumaczenia jest uwzględniony, zmniejszając ryzyko brakujących tłumaczeń i poprawiając konserwowalność.
|
|
420
|
+
|
|
421
|
+
Upewnij się, że autogenerowane typy (domyślnie w ./types/intlayer.d.ts) są uwzględnione w pliku tsconfig.json.
|
|
422
|
+
|
|
423
|
+
```json5 fileName="tsconfig.json"
|
|
424
|
+
{
|
|
425
|
+
// ... Twoje istniejące konfiguracje TypeScript
|
|
426
|
+
"include": [
|
|
427
|
+
// ... Twoje istniejące konfiguracje TypeScript
|
|
428
|
+
".intlayer/**/*.ts", // Uwzględnij autogenerowane typy
|
|
429
|
+
],
|
|
430
|
+
}
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### Rozszerzenie VS Code
|
|
434
|
+
|
|
435
|
+
Aby poprawić doświadczenie deweloperskie z Intlayer, możesz zainstalować oficjalne rozszerzenie **Intlayer dla VS Code**.
|
|
436
|
+
|
|
437
|
+
[Zainstaluj z VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
438
|
+
|
|
439
|
+
To rozszerzenie zapewnia:
|
|
440
|
+
|
|
441
|
+
- **Autouzupełnianie** kluczy tłumaczeń.
|
|
442
|
+
- **Wykrywanie błędów w czasie rzeczywistym** dla brakujących tłumaczeń.
|
|
443
|
+
- **Podgląd przetłumaczonej zawartości bezpośrednio w edytorze**.
|
|
444
|
+
- **Szybkie akcje** umożliwiające łatwe tworzenie i aktualizowanie tłumaczeń.
|
|
445
|
+
|
|
446
|
+
Aby uzyskać więcej informacji o sposobie korzystania z rozszerzenia, zapoznaj się z dokumentacją [Intlayer VS Code Extension](https://intlayer.org/doc/vs-code-extension).
|
|
447
|
+
|
|
448
|
+
### Konfiguracja Git
|
|
449
|
+
|
|
450
|
+
Zaleca się ignorowanie plików generowanych przez Intlayer. Pozwala to uniknąć ich zatwierdzania do repozytorium Git.
|
|
451
|
+
|
|
452
|
+
Aby to zrobić, możesz dodać następujące instrukcje do pliku `.gitignore`:
|
|
453
|
+
|
|
454
|
+
```plaintext fileName=".gitignore"
|
|
455
|
+
# Ignoruj pliki generowane przez Intlayer
|
|
456
|
+
.intlayer
|
|
457
|
+
```
|
package/docs/pl/readme.md
CHANGED
|
@@ -50,7 +50,7 @@ Dzięki **plikom z treścią dla każdego języka**, **autouzupełnianiu w TypeS
|
|
|
50
50
|
| Funkcja | Opis |
|
|
51
51
|
| --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
52
52
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/frameworks.png?raw=true" alt="Funkcja" width="700"> | **Wsparcie dla wielu frameworków**<br><br>Intlayer jest kompatybilny ze wszystkimi głównymi frameworkami i bibliotekami, w tym Next.js, React, Vite, Vue.js, Nuxt, Preact, Express i wieloma innymi. |
|
|
53
|
-
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.
|
|
53
|
+
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/javascript_content_management.jpg?raw=true" alt="Funkcja" width="700"> | **Zarządzanie treścią oparte na JavaScript**<br><br>Wykorzystaj elastyczność JavaScript do efektywnego definiowania i zarządzania swoją treścią. <br><br> - [Deklaracja treści](https://intlayer.org/doc/concept/content) |
|
|
54
54
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/per_locale_content_declaration_file.png?raw=true" alt="Funkcja" width="700"> | **Plik deklaracji treści dla każdego języka**<br><br>Przyspiesz swój rozwój, deklarując treść raz, przed automatycznym generowaniem.<br><br> - [Plik deklaracji treści dla każdego języka](https://intlayer.org/doc/concept/per-locale-file) |
|
|
55
55
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/autocompletion.png?raw=true" alt="Funkcja" width="700"> | **Środowisko z bezpiecznym typowaniem**<br><br>Wykorzystaj TypeScript, aby zapewnić, że definicje treści i kod są wolne od błędów, a także skorzystaj z autouzupełniania w IDE.<br><br> - [Konfiguracja TypeScript](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
|
56
56
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/config_file.png?raw=true" alt="Funkcja" width="700"> | **Uproszczona konfiguracja**<br><br>Rozpocznij pracę szybko przy minimalnej konfiguracji. Łatwo dostosuj ustawienia dotyczące internacjonalizacji, routingu, AI, budowania oraz obsługi treści. <br><br> - [Poznaj integrację z Next.js](https://intlayer.org/doc/environment/nextjs) |
|
package/docs/pt/cli/push.md
CHANGED
|
@@ -23,7 +23,7 @@ slugs:
|
|
|
23
23
|
npx intlayer dictionary push
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
Se o [editor Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_visual_editor.md) estiver instalado, você também pode enviar dicionários para o editor. Este comando permitirá tornar os dicionários disponíveis para [o editor](https://intlayer.org/
|
|
26
|
+
Se o [editor Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_visual_editor.md) estiver instalado, você também pode enviar dicionários para o editor. Este comando permitirá tornar os dicionários disponíveis para [o editor](https://app.intlayer.org/). Dessa forma, você pode compartilhar seus dicionários com sua equipe e editar seu conteúdo sem precisar alterar o código da sua aplicação.
|
|
27
27
|
|
|
28
28
|
## Apelidos:
|
|
29
29
|
|
package/docs/pt/configuration.md
CHANGED
|
@@ -242,14 +242,14 @@ Define configurações relacionadas ao editor integrado, incluindo porta do serv
|
|
|
242
242
|
- **clientId**:
|
|
243
243
|
- _Tipo_: `string` | `undefined`
|
|
244
244
|
- _Padrão_: `undefined`
|
|
245
|
-
- _Descrição_: clientId e clientSecret permitem que os pacotes intlayer autentiquem com o backend usando autenticação oAuth2. Um token de acesso é usado para autenticar o usuário relacionado ao projeto. Para obter um token de acesso, acesse https://intlayer.org/
|
|
245
|
+
- _Descrição_: clientId e clientSecret permitem que os pacotes intlayer autentiquem com o backend usando autenticação oAuth2. Um token de acesso é usado para autenticar o usuário relacionado ao projeto. Para obter um token de acesso, acesse https://app.intlayer.org/project e crie uma conta.
|
|
246
246
|
- _Exemplo_: `true`
|
|
247
247
|
- _Nota_: Importante: O clientId e o clientSecret devem ser mantidos em segredo e não compartilhados publicamente. Por favor, certifique-se de mantê-los em um local seguro, como variáveis de ambiente.
|
|
248
248
|
|
|
249
249
|
- **clientSecret**:
|
|
250
250
|
- _Tipo_: `string` | `undefined`
|
|
251
251
|
- _Padrão_: `undefined`
|
|
252
|
-
- _Descrição_: clientId e clientSecret permitem que os pacotes intlayer se autentiquem com o backend usando autenticação oAuth2. Um token de acesso é usado para autenticar o usuário relacionado ao projeto. Para obter um token de acesso, acesse https://intlayer.org/
|
|
252
|
+
- _Descrição_: clientId e clientSecret permitem que os pacotes intlayer se autentiquem com o backend usando autenticação oAuth2. Um token de acesso é usado para autenticar o usuário relacionado ao projeto. Para obter um token de acesso, acesse https://app.intlayer.org/project e crie uma conta.
|
|
253
253
|
- _Exemplo_: `true`
|
|
254
254
|
- _Nota_: Importante: O clientId e o clientSecret devem ser mantidos em sigilo e não compartilhados publicamente. Por favor, certifique-se de mantê-los em um local seguro, como variáveis de ambiente.
|
|
255
255
|
|
|
@@ -465,7 +465,7 @@ Configurações que controlam o logger, incluindo o prefixo a ser usado.
|
|
|
465
465
|
|
|
466
466
|
Configurações que controlam os recursos de IA do Intlayer, incluindo o provedor, modelo e chave de API.
|
|
467
467
|
|
|
468
|
-
Esta configuração é opcional se você estiver registrado no [Painel do Intlayer](https://intlayer.org/
|
|
468
|
+
Esta configuração é opcional se você estiver registrado no [Painel do Intlayer](https://app.intlayer.org/project) usando uma chave de acesso. O Intlayer gerenciará automaticamente a solução de IA mais eficiente e econômica para suas necessidades. Usar as opções padrão garante melhor manutenção a longo prazo, pois o Intlayer atualiza continuamente para usar os modelos mais relevantes.
|
|
469
469
|
|
|
470
470
|
Se preferir usar sua própria chave de API ou modelo específico, você pode definir sua configuração personalizada de IA.
|
|
471
471
|
Esta configuração de IA será usada globalmente em todo o seu ambiente Intlayer. Os comandos CLI usarão essas configurações como padrão para os comandos (por exemplo, `fill`), assim como o SDK, Editor Visual e CMS. Você pode substituir esses valores padrão para casos de uso específicos usando parâmetros de comando.
|
|
@@ -230,7 +230,7 @@ Esta abordagem permite que você:
|
|
|
230
230
|
| Recurso | Descrição |
|
|
231
231
|
| ------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
232
232
|
|  | **Suporte Multiplataformas**<br><br>O Intlayer é compatível com todos os principais frameworks e bibliotecas, incluindo Next.js, React, Vite, Vue.js, Nuxt, Preact, Express, e mais. |
|
|
233
|
-
|  | **Gestão de Conteúdo com JavaScript**<br><br>Aproveite a flexibilidade do JavaScript para definir e gerir o seu conteúdo de forma eficiente. <br><br> - [Declaração de conteúdo](https://intlayer.org/doc/concept/content) |
|
|
234
234
|
|  | **Ficheiro de Declaração de Conteúdo por Localidade**<br><br>Acelere o seu desenvolvimento declarando o seu conteúdo uma vez, antes da geração automática.<br><br> - [Ficheiro de Declaração de Conteúdo por Localidade](https://intlayer.org/doc/concept/per-locale-file) |
|
|
235
235
|
|  | **Ambiente com Tipagem Segura**<br><br>Aproveite o TypeScript para garantir que suas definições de conteúdo e código estejam livres de erros, além de beneficiar-se do autocompletar do IDE.<br><br> - [Configuração do TypeScript](https://intlayer.org/doc/environment/vite-and-react#configure-typescript) |
|
|
236
236
|
|  | **Configuração Simplificada**<br><br>Comece rapidamente com configuração mínima. Ajuste facilmente as configurações para internacionalização, roteamento, IA, build e gerenciamento de conteúdo.<br><br> - [Explore a integração com Next.js](https://intlayer.org/doc/environment/nextjs) |
|
package/docs/pt/intlayer_CMS.md
CHANGED
|
@@ -92,7 +92,7 @@ const config: IntlayerConfig = {
|
|
|
92
92
|
*
|
|
93
93
|
* Client ID e client secret são necessários para ativar o editor.
|
|
94
94
|
* Eles permitem identificar o usuário que está editando o conteúdo.
|
|
95
|
-
* Podem ser obtidos criando um novo cliente no Painel do Intlayer - Projetos (https://intlayer.org/
|
|
95
|
+
* Podem ser obtidos criando um novo cliente no Painel do Intlayer - Projetos (https://app.intlayer.org/projects).
|
|
96
96
|
* clientId: process.env.INTLAYER_CLIENT_ID,
|
|
97
97
|
* clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
98
98
|
*/
|
|
@@ -142,7 +142,7 @@ const config = {
|
|
|
142
142
|
*
|
|
143
143
|
* O ID do cliente e o segredo do cliente são necessários para ativar o editor.
|
|
144
144
|
* Eles permitem identificar o utilizador que está a editar o conteúdo.
|
|
145
|
-
* Podem ser obtidos criando um novo cliente no Intlayer Dashboard - Projects (https://intlayer.org/
|
|
145
|
+
* Podem ser obtidos criando um novo cliente no Intlayer Dashboard - Projects (https://app.intlayer.org/projects).
|
|
146
146
|
* clientId: process.env.INTLAYER_CLIENT_ID,
|
|
147
147
|
* clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
148
148
|
*/
|
|
@@ -192,7 +192,7 @@ const config = {
|
|
|
192
192
|
*
|
|
193
193
|
* O Client ID e o client secret são necessários para ativar o editor.
|
|
194
194
|
* Eles permitem identificar o utilizador que está a editar o conteúdo.
|
|
195
|
-
* Podem ser obtidos criando um novo cliente no Intlayer Dashboard - Projects (https://intlayer.org/
|
|
195
|
+
* Podem ser obtidos criando um novo cliente no Intlayer Dashboard - Projects (https://app.intlayer.org/projects).
|
|
196
196
|
* clientId: process.env.INTLAYER_CLIENT_ID,
|
|
197
197
|
* clientSecret: process.env.INTLAYER_CLIENT_SECRET,
|
|
198
198
|
*/
|
|
@@ -224,7 +224,7 @@ const config = {
|
|
|
224
224
|
module.exports = config;
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
-
> Se não tiver um client ID e client secret, pode obtê-los criando um novo cliente no [Intlayer Dashboard - Projects](https://intlayer.org/
|
|
227
|
+
> Se não tiver um client ID e client secret, pode obtê-los criando um novo cliente no [Intlayer Dashboard - Projects](https://app.intlayer.org/projects).
|
|
228
228
|
|
|
229
229
|
> Para ver todos os parâmetros disponíveis, consulte a [documentação de configuração](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/configuration.md).
|
|
230
230
|
|
|
@@ -264,7 +264,7 @@ Este comando envia os seus dicionários de conteúdo iniciais, tornando-os dispo
|
|
|
264
264
|
|
|
265
265
|
### Editar o dicionário
|
|
266
266
|
|
|
267
|
-
Depois, poderá ver e gerir o seu dicionário no [Intlayer CMS](https://intlayer.org/
|
|
267
|
+
Depois, poderá ver e gerir o seu dicionário no [Intlayer CMS](https://app.intlayer.org/content).
|
|
268
268
|
|
|
269
269
|
## Sincronização ao vivo
|
|
270
270
|
|