@intlayer/docs 7.0.5 → 7.0.6
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/blog/ar/intlayer_with_i18next.md +72 -19
- package/blog/ar/intlayer_with_next-i18next.md +61 -36
- package/blog/ar/intlayer_with_next-intl.md +61 -13
- package/blog/ar/intlayer_with_react-i18next.md +67 -18
- package/blog/ar/intlayer_with_react-intl.md +66 -13
- package/blog/ar/intlayer_with_vue-i18n.md +180 -0
- package/blog/de/intlayer_with_i18next.md +61 -26
- package/blog/de/intlayer_with_next-i18next.md +66 -17
- package/blog/de/intlayer_with_next-intl.md +62 -13
- package/blog/de/intlayer_with_react-i18next.md +66 -17
- package/blog/de/intlayer_with_react-intl.md +66 -14
- package/blog/de/intlayer_with_vue-i18n.md +178 -0
- package/blog/en/intlayer_with_i18next.md +53 -2
- package/blog/en/intlayer_with_next-i18next.md +52 -16
- package/blog/en/intlayer_with_next-intl.md +49 -0
- package/blog/en/intlayer_with_react-i18next.md +50 -1
- package/blog/en/intlayer_with_react-intl.md +53 -0
- package/blog/en/intlayer_with_vue-i18n.md +178 -0
- package/blog/en-GB/intlayer_with_i18next.md +58 -7
- package/blog/en-GB/intlayer_with_next-i18next.md +55 -9
- package/blog/en-GB/intlayer_with_next-intl.md +55 -6
- package/blog/en-GB/intlayer_with_react-i18next.md +55 -6
- package/blog/en-GB/intlayer_with_react-intl.md +56 -3
- package/blog/en-GB/intlayer_with_vue-i18n.md +180 -0
- package/blog/es/intlayer_with_i18next.md +69 -18
- package/blog/es/intlayer_with_next-i18next.md +70 -24
- package/blog/es/intlayer_with_next-intl.md +64 -13
- package/blog/es/intlayer_with_react-i18next.md +61 -12
- package/blog/es/intlayer_with_react-intl.md +65 -12
- package/blog/es/intlayer_with_vue-i18n.md +178 -0
- package/blog/fr/intlayer_with_i18next.md +77 -16
- package/blog/fr/intlayer_with_next-i18next.md +55 -31
- package/blog/fr/intlayer_with_next-intl.md +57 -7
- package/blog/fr/intlayer_with_react-i18next.md +64 -7
- package/blog/fr/intlayer_with_react-intl.md +63 -10
- package/blog/fr/intlayer_with_vue-i18n.md +178 -0
- package/blog/hi/intlayer_with_i18next.md +67 -16
- package/blog/hi/intlayer_with_next-i18next.md +69 -23
- package/blog/hi/intlayer_with_next-intl.md +61 -8
- package/blog/hi/intlayer_with_react-i18next.md +63 -14
- package/blog/hi/intlayer_with_react-intl.md +66 -13
- package/blog/hi/intlayer_with_vue-i18n.md +180 -0
- package/blog/id/intlayer_with_i18next.md +65 -14
- package/blog/id/intlayer_with_next-i18next.md +58 -12
- package/blog/id/intlayer_with_next-intl.md +60 -11
- package/blog/id/intlayer_with_react-i18next.md +59 -10
- package/blog/id/intlayer_with_react-intl.md +66 -13
- package/blog/id/intlayer_with_vue-i18n.md +178 -0
- package/blog/it/intlayer_with_i18next.md +70 -19
- package/blog/it/intlayer_with_next-i18next.md +68 -22
- package/blog/it/intlayer_with_next-intl.md +62 -12
- package/blog/it/intlayer_with_react-i18next.md +65 -16
- package/blog/it/intlayer_with_react-intl.md +67 -14
- package/blog/it/intlayer_with_vue-i18n.md +178 -0
- package/blog/ja/intlayer_with_i18next.md +74 -24
- package/blog/ja/intlayer_with_next-i18next.md +60 -37
- package/blog/ja/intlayer_with_next-intl.md +63 -15
- package/blog/ja/intlayer_with_react-i18next.md +70 -21
- package/blog/ja/intlayer_with_react-intl.md +73 -21
- package/blog/ja/intlayer_with_vue-i18n.md +180 -0
- package/blog/ko/intlayer_with_i18next.md +60 -29
- package/blog/ko/intlayer_with_next-i18next.md +59 -32
- package/blog/ko/intlayer_with_next-intl.md +52 -23
- package/blog/ko/intlayer_with_react-i18next.md +65 -16
- package/blog/ko/intlayer_with_react-intl.md +74 -22
- package/blog/ko/intlayer_with_vue-i18n.md +180 -0
- package/blog/pl/intlayer_with_i18next.md +63 -12
- package/blog/pl/intlayer_with_next-i18next.md +74 -17
- package/blog/pl/intlayer_with_next-intl.md +59 -8
- package/blog/pl/intlayer_with_react-i18next.md +59 -10
- package/blog/pl/intlayer_with_react-intl.md +65 -12
- package/blog/pl/intlayer_with_vue-i18n.md +180 -0
- package/blog/pt/intlayer_with_i18next.md +67 -16
- package/blog/pt/intlayer_with_next-i18next.md +65 -19
- package/blog/pt/intlayer_with_next-intl.md +62 -12
- package/blog/pt/intlayer_with_react-i18next.md +67 -18
- package/blog/pt/intlayer_with_react-intl.md +62 -10
- package/blog/pt/intlayer_with_vue-i18n.md +178 -0
- package/blog/ru/intlayer_with_i18next.md +68 -15
- package/blog/ru/intlayer_with_next-i18next.md +71 -25
- package/blog/ru/intlayer_with_next-intl.md +56 -7
- package/blog/ru/intlayer_with_react-i18next.md +65 -16
- package/blog/ru/intlayer_with_react-intl.md +69 -16
- package/blog/ru/intlayer_with_vue-i18n.md +180 -0
- package/blog/tr/intlayer_with_i18next.md +67 -16
- package/blog/tr/intlayer_with_next-i18next.md +78 -21
- package/blog/tr/intlayer_with_next-intl.md +69 -18
- package/blog/tr/intlayer_with_react-i18next.md +65 -16
- package/blog/tr/intlayer_with_react-intl.md +71 -19
- package/blog/tr/intlayer_with_vue-i18n.md +180 -0
- package/blog/vi/intlayer_with_i18next.md +64 -13
- package/blog/vi/intlayer_with_next-i18next.md +72 -26
- package/blog/vi/intlayer_with_next-intl.md +62 -11
- package/blog/vi/intlayer_with_react-i18next.md +66 -17
- package/blog/vi/intlayer_with_react-intl.md +70 -17
- package/blog/vi/intlayer_with_vue-i18n.md +180 -0
- package/blog/zh/intlayer_with_i18next.md +67 -17
- package/blog/zh/intlayer_with_next-i18next.md +67 -22
- package/blog/zh/intlayer_with_next-intl.md +61 -13
- package/blog/zh/intlayer_with_react-i18next.md +67 -18
- package/blog/zh/intlayer_with_react-intl.md +69 -17
- package/blog/zh/intlayer_with_vue-i18n.md +180 -0
- package/dist/cjs/generated/blog.entry.cjs +19 -0
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/esm/generated/blog.entry.mjs +19 -0
- package/dist/esm/generated/blog.entry.mjs.map +1 -1
- package/dist/types/generated/blog.entry.d.ts +1 -0
- package/dist/types/generated/blog.entry.d.ts.map +1 -1
- package/docs/ar/intlayer_with_nextjs_15.md +36 -9
- package/docs/ar/intlayer_with_nextjs_16.md +36 -9
- package/docs/de/intlayer_with_nextjs_15.md +36 -9
- package/docs/de/intlayer_with_nextjs_16.md +24 -6
- package/docs/en/intlayer_with_nextjs_14.md +37 -9
- package/docs/en/intlayer_with_nextjs_15.md +40 -10
- package/docs/en/intlayer_with_nextjs_16.md +40 -10
- package/docs/en/plugins/sync-json.md +152 -55
- package/docs/en/releases/v7.md +1 -1
- package/docs/en-GB/intlayer_with_nextjs_15.md +36 -9
- package/docs/en-GB/intlayer_with_nextjs_16.md +36 -9
- package/docs/en-GB/releases/v7.md +1 -1
- package/docs/es/intlayer_with_nextjs_15.md +36 -9
- package/docs/es/intlayer_with_nextjs_16.md +36 -9
- package/docs/fr/intlayer_with_nextjs_15.md +36 -9
- package/docs/fr/intlayer_with_nextjs_16.md +37 -24
- package/docs/hi/intlayer_with_nextjs_15.md +36 -9
- package/docs/hi/intlayer_with_nextjs_16.md +36 -9
- package/docs/id/intlayer_with_nextjs_16.md +36 -9
- package/docs/it/intlayer_with_nextjs_15.md +36 -9
- package/docs/it/intlayer_with_nextjs_16.md +36 -9
- package/docs/ja/intlayer_with_nextjs_15.md +36 -9
- package/docs/ja/intlayer_with_nextjs_16.md +36 -9
- package/docs/ko/intlayer_with_nextjs_15.md +36 -9
- package/docs/ko/intlayer_with_nextjs_16.md +36 -9
- package/docs/pl/intlayer_with_nextjs_16.md +36 -9
- package/docs/pt/intlayer_with_nextjs_15.md +36 -9
- package/docs/pt/intlayer_with_nextjs_16.md +36 -9
- package/docs/ru/intlayer_with_nextjs_15.md +36 -9
- package/docs/ru/intlayer_with_nextjs_16.md +36 -9
- package/docs/tr/intlayer_with_nextjs_15.md +36 -9
- package/docs/tr/intlayer_with_nextjs_16.md +39 -21
- package/docs/vi/intlayer_with_nextjs_16.md +36 -9
- package/docs/zh/intlayer_with_nextjs_15.md +36 -9
- package/docs/zh/intlayer_with_nextjs_16.md +36 -9
- package/package.json +14 -14
- package/src/generated/blog.entry.ts +19 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-08-23
|
|
3
|
+
updatedAt: 2025-10-29
|
|
4
|
+
title: Intlayer i vue-i18n
|
|
5
|
+
description: Integracja Intlayer z vue-i18n dla kompleksowego rozwiązania internacjonalizacji Vue.js
|
|
6
|
+
keywords:
|
|
7
|
+
- vue-i18n
|
|
8
|
+
- Intlayer
|
|
9
|
+
- Internacjonalizacja
|
|
10
|
+
- Blog
|
|
11
|
+
- Vue.js
|
|
12
|
+
- Nuxt
|
|
13
|
+
- JavaScript
|
|
14
|
+
- Vue
|
|
15
|
+
slugs:
|
|
16
|
+
- blog
|
|
17
|
+
- intlayer-with-vue-i18n
|
|
18
|
+
history:
|
|
19
|
+
- version: 7.0.6
|
|
20
|
+
date: 2025-11-01
|
|
21
|
+
changes: Dodanie wtyczki loadJSON
|
|
22
|
+
- version: 7.0.0
|
|
23
|
+
date: 2025-10-29
|
|
24
|
+
changes: Zmiana na wtyczkę syncJSON oraz kompleksowa przebudowa
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Internacjonalizacja (i18n) Vue.js z vue-i18n i Intlayer
|
|
28
|
+
|
|
29
|
+
## Spis treści
|
|
30
|
+
|
|
31
|
+
<TOC/>
|
|
32
|
+
|
|
33
|
+
## Czym jest Intlayer?
|
|
34
|
+
|
|
35
|
+
**Intlayer** to innowacyjna, otwartoźródłowa biblioteka do internacjonalizacji, zaprojektowana w celu rozwiązania niedoskonałości tradycyjnych rozwiązań i18n. Oferuje nowoczesne podejście do zarządzania treścią w aplikacjach Vue.js i Nuxt.
|
|
36
|
+
|
|
37
|
+
Zobacz konkretne porównanie z vue-i18n w naszym wpisie na blogu [vue-i18n vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/pl/vue-i18n_vs_intlayer.md).
|
|
38
|
+
|
|
39
|
+
## Dlaczego łączyć Intlayer z vue-i18n?
|
|
40
|
+
|
|
41
|
+
Chociaż Intlayer zapewnia doskonałe, samodzielne rozwiązanie i18n (zobacz nasz [przewodnik integracji z Vue.js](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/intlayer_with_vite+vue.md)), możesz chcieć połączyć je z vue-i18n z kilku powodów:
|
|
42
|
+
|
|
43
|
+
1. **Istniejąca baza kodu**: Masz już wdrożoną implementację vue-i18n i chcesz stopniowo przejść na ulepszone doświadczenie deweloperskie oferowane przez Intlayer.
|
|
44
|
+
2. **Wymagania dotyczące kompatybilności wstecznej**: Twój projekt wymaga zgodności z istniejącymi wtyczkami lub procesami vue-i18n.
|
|
45
|
+
3. **Znajomość zespołu**: Twój zespół dobrze zna vue-i18n, ale chce lepszego zarządzania treścią.
|
|
46
|
+
4. **Korzystanie z funkcji Intlayer**: Chcesz korzystać z funkcji Intlayer, takich jak deklaracja treści, automatyzacja tłumaczeń, testowanie tłumaczeń i inne.
|
|
47
|
+
|
|
48
|
+
**W tym celu Intlayer może być zaimplementowany jako adapter dla vue-i18n, aby pomóc w automatyzacji tłumaczeń JSON w CLI lub pipeline'ach CI/CD, testowaniu tłumaczeń i innych zadaniach.**
|
|
49
|
+
|
|
50
|
+
Ten przewodnik pokazuje, jak wykorzystać zaawansowany system deklaracji treści Intlayer, jednocześnie zachowując kompatybilność z vue-i18n.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Przewodnik krok po kroku: Konfiguracja Intlayer z vue-i18n
|
|
55
|
+
|
|
56
|
+
### Krok 1: Instalacja zależności
|
|
57
|
+
|
|
58
|
+
Zainstaluj niezbędne pakiety, używając preferowanego menedżera pakietów:
|
|
59
|
+
|
|
60
|
+
```bash packageManager="npm"
|
|
61
|
+
npm install intlayer @intlayer/sync-json-plugin
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```bash packageManager="pnpm"
|
|
65
|
+
pnpm add intlayer @intlayer/sync-json-plugin
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```bash packageManager="yarn"
|
|
69
|
+
yarn add intlayer @intlayer/sync-json-plugin
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```bash packageManager="bun"
|
|
73
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Wyjaśnienie pakietów:**
|
|
77
|
+
|
|
78
|
+
- **intlayer**: Główna biblioteka do deklaracji i zarządzania treścią
|
|
79
|
+
- **@intlayer/sync-json-plugin**: Wtyczka do synchronizacji deklaracji treści Intlayer z formatem JSON vue-i18n
|
|
80
|
+
|
|
81
|
+
### Krok 2: Implementacja wtyczki Intlayer do opakowania JSON
|
|
82
|
+
|
|
83
|
+
Utwórz plik konfiguracyjny Intlayer, aby zdefiniować obsługiwane lokalizacje:
|
|
84
|
+
|
|
85
|
+
**Jeśli chcesz również eksportować słowniki JSON dla vue-i18n**, dodaj wtyczkę `syncJSON`:
|
|
86
|
+
|
|
87
|
+
```typescript fileName="intlayer.config.ts"
|
|
88
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
89
|
+
import { syncJSON } from "@intlayer/sync-json-plugin";
|
|
90
|
+
|
|
91
|
+
const config: IntlayerConfig = {
|
|
92
|
+
internationalization: {
|
|
93
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
94
|
+
defaultLocale: Locales.ENGLISH,
|
|
95
|
+
},
|
|
96
|
+
plugins: [
|
|
97
|
+
syncJSON({
|
|
98
|
+
source: ({ key, locale }) => `./src/locales/${locale}/${key}.json`,
|
|
99
|
+
}),
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default config;
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Wtyczka `syncJSON` automatycznie opakuje JSON. Będzie odczytywać i zapisywać pliki JSON bez zmiany architektury zawartości.
|
|
107
|
+
|
|
108
|
+
Jeśli chcesz, aby JSON współistniał z plikami deklaracji treści Intlayer (`.content`), Intlayer postąpi w następujący sposób:
|
|
109
|
+
|
|
110
|
+
1. załaduje zarówno pliki JSON, jak i pliki deklaracji treści, a następnie przekształci je w słownik Intlayer.
|
|
111
|
+
2. jeśli wystąpią konflikty między JSON a plikami deklaracji treści, Intlayer dokona scalania wszystkich słowników. W zależności od priorytetu wtyczek oraz pliku deklaracji treści (wszystko jest konfigurowalne).
|
|
112
|
+
|
|
113
|
+
Jeśli zmiany zostaną dokonane za pomocą CLI do tłumaczenia JSON lub za pomocą CMS, Intlayer zaktualizuje plik JSON o nowe tłumaczenia.
|
|
114
|
+
|
|
115
|
+
Aby zobaczyć więcej szczegółów dotyczących wtyczki `syncJSON`, proszę zapoznać się z [dokumentacją wtyczki syncJSON](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/plugins/sync-json.md).
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### (Opcjonalny) Krok 3: Implementacja tłumaczeń JSON per-komponent
|
|
120
|
+
|
|
121
|
+
Domyślnie Intlayer załaduje, scali i zsynchronizuje zarówno pliki JSON, jak i pliki deklaracji treści. Zobacz [dokumentację deklaracji treści](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pl/dictionary/content_file.md) po więcej szczegółów. Jednak jeśli wolisz, używając wtyczki Intlayer, możesz również zaimplementować zarządzanie JSON per-komponent, zlokalizowanym w dowolnym miejscu w Twoim kodzie.
|
|
122
|
+
|
|
123
|
+
W tym celu możesz użyć wtyczki `loadJSON`.
|
|
124
|
+
|
|
125
|
+
```ts fileName="intlayer.config.ts"
|
|
126
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
127
|
+
import { loadJSON, syncJSON } from "@intlayer/sync-json-plugin";
|
|
128
|
+
|
|
129
|
+
const config: IntlayerConfig = {
|
|
130
|
+
internationalization: {
|
|
131
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
132
|
+
defaultLocale: Locales.ENGLISH,
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
// Synchronizuj swoje obecne pliki JSON ze słownikami Intlayer
|
|
136
|
+
plugins: [
|
|
137
|
+
/**
|
|
138
|
+
* Załaduje wszystkie pliki JSON w katalogu src, które pasują do wzorca {key}.i18n.json
|
|
139
|
+
*/
|
|
140
|
+
loadJSON({
|
|
141
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
142
|
+
locale: Locales.ENGLISH,
|
|
143
|
+
priority: 1, // Zapewnia, że te pliki JSON mają pierwszeństwo przed plikami w `./locales/en/${key}.json`
|
|
144
|
+
}),
|
|
145
|
+
/**
|
|
146
|
+
* Załaduje oraz zapisze wynik i tłumaczenia z powrotem do plików JSON w katalogu locales
|
|
147
|
+
*/
|
|
148
|
+
syncJSON({
|
|
149
|
+
source: ({ key, locale }) => `./src/locales/${locale}/${key}.json`,
|
|
150
|
+
priority: 0,
|
|
151
|
+
}),
|
|
152
|
+
],
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export default config;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
To spowoduje załadowanie wszystkich plików JSON w katalogu `src`, które pasują do wzorca `{key}.i18n.json` i załaduje je jako słowniki Intlayer.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Konfiguracja Git
|
|
163
|
+
|
|
164
|
+
Wyklucz generowane pliki z kontroli wersji:
|
|
165
|
+
|
|
166
|
+
```plaintext fileName=".gitignore"
|
|
167
|
+
# Ignoruj pliki generowane przez Intlayer
|
|
168
|
+
.intlayer
|
|
169
|
+
intl
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Te pliki są automatycznie generowane podczas procesu budowania i nie muszą być zatwierdzane do Twojego repozytorium.
|
|
173
|
+
|
|
174
|
+
### Rozszerzenie VS Code
|
|
175
|
+
|
|
176
|
+
Dla lepszego doświadczenia programistycznego zainstaluj oficjalne **rozszerzenie Intlayer dla VS Code**:
|
|
177
|
+
|
|
178
|
+
[Zainstaluj z Marketplace VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
179
|
+
|
|
180
|
+
[Zainstaluj z rynku VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2024-12-24
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-11-01
|
|
4
4
|
title: Como automatizar suas traduções JSON do i18next usando Intlayer
|
|
5
5
|
description: Automatize suas traduções JSON com Intlayer e i18next para uma internacionalização aprimorada em aplicações JavaScript.
|
|
6
6
|
keywords:
|
|
@@ -20,28 +20,32 @@ slugs:
|
|
|
20
20
|
- blog
|
|
21
21
|
- intlayer-with-i18next
|
|
22
22
|
history:
|
|
23
|
+
- version: 7.0.6
|
|
24
|
+
date: 2025-11-01
|
|
25
|
+
changes: Adicionado plugin loadJSON
|
|
23
26
|
- version: 7.0.0
|
|
24
27
|
date: 2025-10-29
|
|
25
|
-
changes:
|
|
28
|
+
changes: Alterado para plugin syncJSON
|
|
26
29
|
---
|
|
27
30
|
|
|
28
31
|
# Como automatizar suas traduções JSON do i18next usando Intlayer
|
|
29
32
|
|
|
30
33
|
## O que é o Intlayer?
|
|
31
34
|
|
|
32
|
-
**Intlayer** é uma biblioteca inovadora e de
|
|
35
|
+
**Intlayer** é uma biblioteca inovadora e open-source de internacionalização, projetada para resolver as limitações das soluções tradicionais de i18n. Ela oferece uma abordagem moderna para o gerenciamento de conteúdo em aplicações JavaScript.
|
|
33
36
|
|
|
34
37
|
Veja uma comparação concreta com o i18next em nosso post no blog [next-i18next vs. next-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/pt/next-i18next_vs_next-intl_vs_intlayer.md).
|
|
35
38
|
|
|
36
39
|
## Por que combinar Intlayer com i18next?
|
|
37
40
|
|
|
38
|
-
Embora o Intlayer forneça uma excelente solução
|
|
41
|
+
Embora o Intlayer forneça uma excelente solução i18n independente (veja nosso [guia de integração com Next.js](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_with_nextjs_16.md)), você pode querer combiná-lo com o i18next por vários motivos:
|
|
39
42
|
|
|
40
|
-
1. **Base de código existente**: Você
|
|
43
|
+
1. **Base de código existente**: Você possui uma implementação estabelecida do i18next e deseja migrar gradualmente para a melhor experiência de desenvolvedor do Intlayer.
|
|
41
44
|
2. **Requisitos legados**: Seu projeto requer compatibilidade com plugins ou fluxos de trabalho existentes do i18next.
|
|
42
45
|
3. **Familiaridade da equipe**: Sua equipe está confortável com o i18next, mas deseja um melhor gerenciamento de conteúdo.
|
|
46
|
+
4. **Uso dos recursos do Intlayer**: Você quer usar recursos do Intlayer como declaração de conteúdo, gerenciamento de chaves de tradução, status da tradução e mais.
|
|
43
47
|
|
|
44
|
-
**Para isso, o Intlayer pode ser implementado como um adaptador para o i18next, ajudando a automatizar suas traduções JSON em
|
|
48
|
+
**Para isso, o Intlayer pode ser implementado como um adaptador para o i18next, ajudando a automatizar suas traduções JSON em CLI ou pipelines CI/CD, testar suas traduções e muito mais.**
|
|
45
49
|
|
|
46
50
|
Este guia mostra como aproveitar o sistema superior de declaração de conteúdo do Intlayer enquanto mantém a compatibilidade com o i18next.
|
|
47
51
|
|
|
@@ -49,7 +53,7 @@ Este guia mostra como aproveitar o sistema superior de declaração de conteúdo
|
|
|
49
53
|
|
|
50
54
|
<TOC/>
|
|
51
55
|
|
|
52
|
-
## Guia passo a passo para configurar o Intlayer com i18next
|
|
56
|
+
## Guia passo a passo para configurar o Intlayer com o i18next
|
|
53
57
|
|
|
54
58
|
### Passo 1: Instalar dependências
|
|
55
59
|
|
|
@@ -67,6 +71,10 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
67
71
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
68
72
|
```
|
|
69
73
|
|
|
74
|
+
```bash packageManager="bun"
|
|
75
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
76
|
+
```
|
|
77
|
+
|
|
70
78
|
**Descrição dos pacotes:**
|
|
71
79
|
|
|
72
80
|
- **intlayer**: Biblioteca principal para gerenciamento de internacionalização, declaração de conteúdo e construção
|
|
@@ -74,7 +82,7 @@ yarn add intlayer @intlayer/sync-json-plugin
|
|
|
74
82
|
|
|
75
83
|
### Passo 2: Implemente o plugin Intlayer para encapsular o JSON
|
|
76
84
|
|
|
77
|
-
Crie um arquivo de configuração do Intlayer para definir os locais suportados:
|
|
85
|
+
Crie um arquivo de configuração do Intlayer para definir os seus locais suportados:
|
|
78
86
|
|
|
79
87
|
**Se você também quiser exportar dicionários JSON para o i18next**, adicione o plugin `syncJSON`:
|
|
80
88
|
|
|
@@ -89,7 +97,7 @@ const config: IntlayerConfig = {
|
|
|
89
97
|
},
|
|
90
98
|
plugins: [
|
|
91
99
|
syncJSON({
|
|
92
|
-
source: ({ key, locale }) => `./
|
|
100
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
93
101
|
}),
|
|
94
102
|
],
|
|
95
103
|
};
|
|
@@ -99,12 +107,57 @@ export default config;
|
|
|
99
107
|
|
|
100
108
|
O plugin `syncJSON` irá automaticamente encapsular o JSON. Ele irá ler e escrever os arquivos JSON sem alterar a arquitetura do conteúdo.
|
|
101
109
|
|
|
102
|
-
Se você quiser fazer coexistir esse JSON com arquivos de declaração de conteúdo do Intlayer (`.content`), o Intlayer procederá da seguinte forma:
|
|
110
|
+
Se você quiser fazer coexistir esse JSON com arquivos de declaração de conteúdo do Intlayer (arquivos `.content`), o Intlayer procederá da seguinte forma:
|
|
111
|
+
|
|
112
|
+
1. carregar tanto os arquivos JSON quanto os arquivos de declaração de conteúdo e transformá-los em um dicionário do Intlayer.
|
|
113
|
+
2. se houver conflitos entre o JSON e os arquivos de declaração de conteúdo, o Intlayer realizará a mesclagem de todos esses dicionários. Dependendo da prioridade dos plugins e da do arquivo de declaração de conteúdo (tudo é configurável).
|
|
114
|
+
|
|
115
|
+
Se alterações forem feitas usando a CLI para traduzir o JSON, ou usando o CMS, o Intlayer atualizará o arquivo JSON com as novas traduções.
|
|
116
|
+
|
|
117
|
+
Para ver mais detalhes sobre o plugin `syncJSON`, consulte a [documentação do plugin syncJSON](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/plugins/sync-json.md).
|
|
118
|
+
|
|
119
|
+
### (Opcional) Passo 3: Implementar traduções JSON por componente
|
|
120
|
+
|
|
121
|
+
Por padrão, o Intlayer irá carregar, mesclar e sincronizar tanto os arquivos JSON quanto os arquivos de declaração de conteúdo. Veja [a documentação da declaração de conteúdo](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/content_file.md) para mais detalhes. Mas, se preferir, usando um plugin do Intlayer, você também pode implementar o gerenciamento por componente de JSON localizado em qualquer lugar da sua base de código.
|
|
122
|
+
|
|
123
|
+
Para isso, você pode usar o plugin `loadJSON`.
|
|
124
|
+
|
|
125
|
+
```ts fileName="intlayer.config.ts"
|
|
126
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
127
|
+
import { loadJSON, syncJSON } from "@intlayer/sync-json-plugin";
|
|
128
|
+
|
|
129
|
+
const config: IntlayerConfig = {
|
|
130
|
+
internationalization: {
|
|
131
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
132
|
+
defaultLocale: Locales.ENGLISH,
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
// Mantenha seus arquivos JSON atuais sincronizados com os dicionários do Intlayer
|
|
136
|
+
plugins: [
|
|
137
|
+
/**
|
|
138
|
+
* Carregará todos os arquivos JSON na pasta src que correspondem ao padrão {key}.i18n.json
|
|
139
|
+
*/
|
|
140
|
+
loadJSON({
|
|
141
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
142
|
+
locale: Locales.ENGLISH,
|
|
143
|
+
priority: 1, // Garante que esses arquivos JSON tenham precedência sobre os arquivos em `./locales/en/${key}.json`
|
|
144
|
+
}),
|
|
145
|
+
/**
|
|
146
|
+
* Carregará e gravará a saída e as traduções de volta nos arquivos JSON no diretório de locais
|
|
147
|
+
*/
|
|
148
|
+
syncJSON({
|
|
149
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
150
|
+
priority: 0,
|
|
151
|
+
}),
|
|
152
|
+
],
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export default config;
|
|
156
|
+
```
|
|
103
157
|
|
|
104
|
-
|
|
105
|
-
2. se houver conflitos entre o JSON e os arquivos de declaração de conteúdo, o Intlayer irá proceder à mesclagem de todos esses dicionários. Dependendo da prioridade dos plugins e da do arquivo de declaração de conteúdo (todos são configuráveis).
|
|
158
|
+
Isso carregará todos os arquivos JSON no diretório `src` que correspondem ao padrão `{key}.i18n.json` e os carregará como dicionários do Intlayer.
|
|
106
159
|
|
|
107
|
-
|
|
160
|
+
---
|
|
108
161
|
|
|
109
162
|
## Configuração do Git
|
|
110
163
|
|
|
@@ -115,12 +168,10 @@ Se alterações forem feitas usando o CLI para traduzir o JSON, ou usando o CMS,
|
|
|
115
168
|
.intlayer
|
|
116
169
|
```
|
|
117
170
|
|
|
118
|
-
Esses arquivos podem ser regenerados durante
|
|
171
|
+
Esses arquivos podem ser regenerados durante seu processo de build e não precisam ser commitados no controle de versão.
|
|
119
172
|
|
|
120
173
|
### Extensão VS Code
|
|
121
174
|
|
|
122
175
|
Para uma melhor experiência de desenvolvimento, instale a extensão oficial **Intlayer VS Code Extension**:
|
|
123
176
|
|
|
124
177
|
[Instalar no VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
125
|
-
|
|
126
|
-
[Instalar a partir do Marketplace do VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2025-08-23
|
|
3
3
|
updatedAt: 2025-10-29
|
|
4
4
|
title: Intlayer e next-i18next
|
|
5
|
-
description: Integre o Intlayer com next-i18next para uma solução abrangente de internacionalização Next.js
|
|
5
|
+
description: Integre o Intlayer com o next-i18next para uma solução abrangente de internacionalização Next.js
|
|
6
6
|
keywords:
|
|
7
7
|
- i18next
|
|
8
8
|
- next-i18next
|
|
@@ -16,9 +16,12 @@ slugs:
|
|
|
16
16
|
- blog
|
|
17
17
|
- intlayer-with-next-i18next
|
|
18
18
|
history:
|
|
19
|
+
- version: 7.0.6
|
|
20
|
+
date: 2025-11-01
|
|
21
|
+
changes: Adicionado plugin loadJSON
|
|
19
22
|
- version: 7.0.0
|
|
20
23
|
date: 2025-10-29
|
|
21
|
-
changes:
|
|
24
|
+
changes: Alterado para plugin syncJSON e reescrita abrangente
|
|
22
25
|
---
|
|
23
26
|
|
|
24
27
|
# Internacionalização (i18n) Next.js com next-i18next e Intlayer
|
|
@@ -27,7 +30,7 @@ history:
|
|
|
27
30
|
|
|
28
31
|
<TOC/>
|
|
29
32
|
|
|
30
|
-
## O que é next-i18next?
|
|
33
|
+
## O que é o next-i18next?
|
|
31
34
|
|
|
32
35
|
**next-i18next** é um dos frameworks de internacionalização (i18n) mais populares para aplicações Next.js. Construído sobre o poderoso ecossistema **i18next**, ele oferece uma solução abrangente para gerenciar traduções, localização e troca de idiomas em projetos Next.js.
|
|
33
36
|
|
|
@@ -46,13 +49,13 @@ Veja uma comparação concreta com o next-intl em nosso post no blog [next-i18ne
|
|
|
46
49
|
|
|
47
50
|
## Por que combinar o Intlayer com o next-i18next?
|
|
48
51
|
|
|
49
|
-
|
|
52
|
+
Enquanto o Intlayer oferece uma excelente solução i18n independente (veja nosso [guia de integração com Next.js](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_with_nextjs_16.md)), você pode querer combiná-lo com o next-i18next por várias razões:
|
|
50
53
|
|
|
51
|
-
1. **Base de código existente**: Você possui uma implementação
|
|
54
|
+
1. **Base de código existente**: Você possui uma implementação consolidada do next-i18next e deseja migrar gradualmente para a melhor experiência de desenvolvedor do Intlayer.
|
|
52
55
|
2. **Requisitos legados**: Seu projeto requer compatibilidade com plugins ou fluxos de trabalho existentes do i18next.
|
|
53
56
|
3. **Familiaridade da equipe**: Sua equipe está confortável com o next-i18next, mas deseja um melhor gerenciamento de conteúdo.
|
|
54
57
|
|
|
55
|
-
**Para isso, o Intlayer pode ser implementado como um adaptador para o next-i18next para ajudar a automatizar suas traduções JSON em CLI ou pipelines CI/CD, testar suas traduções e muito mais.**
|
|
58
|
+
**Para isso, o Intlayer pode ser implementado como um adaptador para o next-i18next para ajudar a automatizar suas traduções JSON em CLI ou pipelines de CI/CD, testar suas traduções e muito mais.**
|
|
56
59
|
|
|
57
60
|
Este guia mostra como aproveitar o sistema superior de declaração de conteúdo do Intlayer enquanto mantém a compatibilidade com o next-i18next.
|
|
58
61
|
|
|
@@ -76,13 +79,13 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
76
79
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
77
80
|
```
|
|
78
81
|
|
|
82
|
+
```bash packageManager="bun"
|
|
83
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
84
|
+
```
|
|
85
|
+
|
|
79
86
|
**Explicações dos pacotes:**
|
|
80
87
|
|
|
81
88
|
- **intlayer**: Biblioteca principal para declaração e gerenciamento de conteúdo
|
|
82
|
-
- **next-intlayer**: Camada de integração Next.js com plugins de build
|
|
83
|
-
- **i18next**: Framework principal de i18n
|
|
84
|
-
- **next-i18next**: Wrapper Next.js para i18next
|
|
85
|
-
- **i18next-resources-to-backend**: Carregamento dinâmico de recursos para i18next
|
|
86
89
|
- **@intlayer/sync-json-plugin**: Plugin para sincronizar declarações de conteúdo do Intlayer para o formato JSON do i18next
|
|
87
90
|
|
|
88
91
|
### Passo 2: Implemente o plugin Intlayer para encapsular o JSON
|
|
@@ -102,7 +105,7 @@ const config: IntlayerConfig = {
|
|
|
102
105
|
},
|
|
103
106
|
plugins: [
|
|
104
107
|
syncJSON({
|
|
105
|
-
source: ({ key, locale }) => `./
|
|
108
|
+
source: ({ key, locale }) => `./public/locales/${locale}/${key}.json`,
|
|
106
109
|
}),
|
|
107
110
|
],
|
|
108
111
|
};
|
|
@@ -112,13 +115,58 @@ export default config;
|
|
|
112
115
|
|
|
113
116
|
O plugin `syncJSON` irá automaticamente encapsular o JSON. Ele irá ler e escrever os arquivos JSON sem alterar a arquitetura do conteúdo.
|
|
114
117
|
|
|
115
|
-
Se você quiser fazer coexistir esse JSON com os arquivos de declaração de conteúdo do
|
|
118
|
+
Se você quiser fazer coexistir esse JSON com os arquivos de declaração de conteúdo do Intlayer (`.content` files), o Intlayer procederá da seguinte forma:
|
|
116
119
|
|
|
117
|
-
1. carregar tanto os arquivos JSON quanto os arquivos de declaração de conteúdo e transformá-los em um dicionário
|
|
118
|
-
2. se houver conflitos entre o JSON e os arquivos de declaração de conteúdo, o Intlayer
|
|
120
|
+
1. carregar tanto os arquivos JSON quanto os arquivos de declaração de conteúdo e transformá-los em um dicionário Intlayer.
|
|
121
|
+
2. se houver conflitos entre o JSON e os arquivos de declaração de conteúdo, o Intlayer realizará a mesclagem de todos esses dicionários. Isso dependerá da prioridade dos plugins e da prioridade do arquivo de declaração de conteúdo (tudo é configurável).
|
|
119
122
|
|
|
120
123
|
Se alterações forem feitas usando o CLI para traduzir o JSON, ou usando o CMS, o Intlayer atualizará o arquivo JSON com as novas traduções.
|
|
121
124
|
|
|
125
|
+
Para ver mais detalhes sobre o plugin `syncJSON`, por favor consulte a [documentação do plugin syncJSON](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/plugins/sync-json.md).
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### (Opcional) Passo 3: Implementar traduções JSON por componente
|
|
130
|
+
|
|
131
|
+
Por padrão, o Intlayer irá carregar, mesclar e sincronizar tanto os arquivos JSON quanto os arquivos de declaração de conteúdo. Veja [a documentação da declaração de conteúdo](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/content_file.md) para mais detalhes. Mas se preferir, usando um plugin do Intlayer, você também pode implementar o gerenciamento por componente de JSON localizado em qualquer lugar da sua base de código.
|
|
132
|
+
|
|
133
|
+
Para isso, você pode usar o plugin `loadJSON`.
|
|
134
|
+
|
|
135
|
+
```ts fileName="intlayer.config.ts"
|
|
136
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
137
|
+
import { loadJSON, syncJSON } from "@intlayer/sync-json-plugin";
|
|
138
|
+
|
|
139
|
+
const config: IntlayerConfig = {
|
|
140
|
+
internationalization: {
|
|
141
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
142
|
+
defaultLocale: Locales.ENGLISH,
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
// Mantenha seus arquivos JSON atuais sincronizados com os dicionários do Intlayer
|
|
146
|
+
plugins: [
|
|
147
|
+
/**
|
|
148
|
+
* Carregará todos os arquivos JSON na pasta src que correspondem ao padrão {key}.i18n.json
|
|
149
|
+
*/
|
|
150
|
+
loadJSON({
|
|
151
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
152
|
+
locale: Locales.ENGLISH,
|
|
153
|
+
priority: 1, // Garante que esses arquivos JSON tenham precedência sobre os arquivos em `./public/locales/en/${key}.json`
|
|
154
|
+
}),
|
|
155
|
+
/**
|
|
156
|
+
* Irá carregar e gravar a saída e as traduções de volta nos arquivos JSON no diretório de locales
|
|
157
|
+
*/
|
|
158
|
+
syncJSON({
|
|
159
|
+
source: ({ key, locale }) => `./public/locales/${locale}/${key}.json`,
|
|
160
|
+
priority: 0,
|
|
161
|
+
}),
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export default config;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Isso irá carregar todos os arquivos JSON no diretório `src` que correspondem ao padrão `{key}.i18n.json` e carregá-los como dicionários do Intlayer.
|
|
169
|
+
|
|
122
170
|
---
|
|
123
171
|
|
|
124
172
|
## Configuração do Git
|
|
@@ -131,12 +179,10 @@ Exclua arquivos gerados do controle de versão:
|
|
|
131
179
|
intl
|
|
132
180
|
```
|
|
133
181
|
|
|
134
|
-
Esses arquivos são automaticamente regenerados durante o processo de build e não precisam ser
|
|
182
|
+
Esses arquivos são automaticamente regenerados durante o processo de build e não precisam ser commitados no seu repositório.
|
|
135
183
|
|
|
136
184
|
### Extensão VS Code
|
|
137
185
|
|
|
138
|
-
Para uma melhor experiência
|
|
139
|
-
|
|
140
|
-
[Instalar no VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
186
|
+
Para uma melhor experiência do desenvolvedor, instale a extensão oficial **Intlayer para VS Code**:
|
|
141
187
|
|
|
142
|
-
[Instalar
|
|
188
|
+
[Instalar a partir do VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
@@ -7,14 +7,17 @@ slugs:
|
|
|
7
7
|
- blog
|
|
8
8
|
- intlayer-with-next-intl
|
|
9
9
|
history:
|
|
10
|
+
- version: 7.0.6
|
|
11
|
+
date: 2025-11-01
|
|
12
|
+
changes: Adicionado plugin loadJSON
|
|
10
13
|
- version: 7.0.0
|
|
11
14
|
date: 2025-10-29
|
|
12
|
-
changes:
|
|
15
|
+
changes: Alterado para plugin syncJSON
|
|
13
16
|
---
|
|
14
17
|
|
|
15
18
|
# Como automatizar suas traduções JSON do next-intl usando Intlayer
|
|
16
19
|
|
|
17
|
-
## O que é
|
|
20
|
+
## O que é Intlayer?
|
|
18
21
|
|
|
19
22
|
**Intlayer** é uma biblioteca inovadora e de código aberto para internacionalização, projetada para resolver as limitações das soluções tradicionais de i18n. Ela oferece uma abordagem moderna para o gerenciamento de conteúdo em aplicações Next.js.
|
|
20
23
|
|
|
@@ -22,15 +25,15 @@ Veja uma comparação concreta com next-intl em nosso post no blog [next-i18next
|
|
|
22
25
|
|
|
23
26
|
## Por que combinar Intlayer com next-intl?
|
|
24
27
|
|
|
25
|
-
Embora o Intlayer forneça uma excelente solução
|
|
28
|
+
Embora o Intlayer forneça uma excelente solução i18n independente (veja nosso [guia de integração com Next.js](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_with_nextjs_16.md)), você pode querer combiná-lo com next-intl por vários motivos:
|
|
26
29
|
|
|
27
|
-
1. **Base de código existente**: Você
|
|
30
|
+
1. **Base de código existente**: Você possui uma implementação estabelecida do next-intl e deseja migrar gradualmente para a melhor experiência de desenvolvedor do Intlayer.
|
|
28
31
|
2. **Requisitos legados**: Seu projeto requer compatibilidade com plugins ou fluxos de trabalho existentes do next-intl.
|
|
29
|
-
3. **Familiaridade da equipe**: Sua equipe está confortável com o next-intl, mas deseja
|
|
32
|
+
3. **Familiaridade da equipe**: Sua equipe está confortável com o next-intl, mas deseja uma melhor gestão de conteúdo.
|
|
30
33
|
|
|
31
|
-
**Para isso, o Intlayer pode ser implementado como um adaptador para o next-intl
|
|
34
|
+
**Para isso, o Intlayer pode ser implementado como um adaptador para o next-intl, ajudando a automatizar suas traduções JSON em pipelines CLI ou CI/CD, testar suas traduções e muito mais.**
|
|
32
35
|
|
|
33
|
-
Este guia mostra como aproveitar o sistema superior de declaração de conteúdo do Intlayer
|
|
36
|
+
Este guia mostra como aproveitar o sistema superior de declaração de conteúdo do Intlayer, mantendo a compatibilidade com o next-intl.
|
|
34
37
|
|
|
35
38
|
## Índice
|
|
36
39
|
|
|
@@ -54,12 +57,16 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
54
57
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
55
58
|
```
|
|
56
59
|
|
|
60
|
+
```bash packageManager="bun"
|
|
61
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
62
|
+
```
|
|
63
|
+
|
|
57
64
|
**Descrição dos pacotes:**
|
|
58
65
|
|
|
59
66
|
- **intlayer**: Biblioteca principal para gerenciamento de internacionalização, declaração de conteúdo e construção
|
|
60
67
|
- **@intlayer/sync-json-plugin**: Plugin para exportar declarações de conteúdo do Intlayer para o formato JSON compatível com next-intl
|
|
61
68
|
|
|
62
|
-
### Passo 2:
|
|
69
|
+
### Passo 2: Implemente o plugin Intlayer para encapsular o JSON
|
|
63
70
|
|
|
64
71
|
Crie um arquivo de configuração do Intlayer para definir os locais suportados:
|
|
65
72
|
|
|
@@ -93,6 +100,49 @@ Se você quiser fazer coexistir esse JSON com arquivos de declaração de conte
|
|
|
93
100
|
|
|
94
101
|
Se alterações forem feitas usando o CLI para traduzir o JSON, ou usando o CMS, o Intlayer atualizará o arquivo JSON com as novas traduções.
|
|
95
102
|
|
|
103
|
+
Para ver mais detalhes sobre o plugin `syncJSON`, por favor consulte a [documentação do plugin syncJSON](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/plugins/sync-json.md).
|
|
104
|
+
|
|
105
|
+
### (Opcional) Passo 3: Implementar traduções JSON por componente
|
|
106
|
+
|
|
107
|
+
Por padrão, o Intlayer carregará, mesclará e sincronizará tanto os arquivos JSON quanto os arquivos de declaração de conteúdo. Veja [a documentação de declaração de conteúdo](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/content_file.md) para mais detalhes. Mas, se preferir, usando um plugin do Intlayer, você também pode implementar o gerenciamento por componente de JSON localizado em qualquer lugar da sua base de código.
|
|
108
|
+
|
|
109
|
+
Para isso, você pode usar o plugin `loadJSON`.
|
|
110
|
+
|
|
111
|
+
```ts fileName="intlayer.config.ts"
|
|
112
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
113
|
+
import { loadJSON, syncJSON } from "@intlayer/sync-json-plugin";
|
|
114
|
+
|
|
115
|
+
const config: IntlayerConfig = {
|
|
116
|
+
internationalization: {
|
|
117
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
118
|
+
defaultLocale: Locales.ENGLISH,
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
// Mantenha seus arquivos JSON atuais sincronizados com os dicionários do Intlayer
|
|
122
|
+
plugins: [
|
|
123
|
+
/**
|
|
124
|
+
* Carregará todos os arquivos JSON na pasta src que correspondem ao padrão {key}.i18n.json
|
|
125
|
+
*/
|
|
126
|
+
loadJSON({
|
|
127
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
128
|
+
locale: Locales.ENGLISH,
|
|
129
|
+
priority: 1, // Garante que esses arquivos JSON tenham precedência sobre os arquivos em `./locales/en/${key}.json`
|
|
130
|
+
}),
|
|
131
|
+
/**
|
|
132
|
+
* Carregará e escreverá a saída e as traduções de volta nos arquivos JSON no diretório de locais
|
|
133
|
+
*/
|
|
134
|
+
syncJSON({
|
|
135
|
+
source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
|
|
136
|
+
priority: 0,
|
|
137
|
+
}),
|
|
138
|
+
],
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export default config;
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Isso carregará todos os arquivos JSON no diretório `src` que correspondem ao padrão `{key}.i18n.json` e os carregará como dicionários do Intlayer.
|
|
145
|
+
|
|
96
146
|
## Configuração do Git
|
|
97
147
|
|
|
98
148
|
É recomendado ignorar os arquivos gerados automaticamente pelo Intlayer:
|
|
@@ -102,10 +152,10 @@ Se alterações forem feitas usando o CLI para traduzir o JSON, ou usando o CMS,
|
|
|
102
152
|
.intlayer
|
|
103
153
|
```
|
|
104
154
|
|
|
105
|
-
Esses arquivos podem ser regenerados durante
|
|
155
|
+
Esses arquivos podem ser regenerados durante seu processo de build e não precisam ser commitados no controle de versão.
|
|
106
156
|
|
|
107
|
-
### Extensão VS Code
|
|
157
|
+
### Extensão do VS Code
|
|
108
158
|
|
|
109
|
-
Para
|
|
159
|
+
Para uma melhor experiência de desenvolvimento, instale a extensão oficial **Intlayer VS Code Extension**:
|
|
110
160
|
|
|
111
|
-
[Instalar
|
|
161
|
+
[Instalar no VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|