@intlayer/docs 7.0.4-canary.0 → 7.0.5
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 +68 -106
- package/blog/ar/intlayer_with_next-i18next.md +84 -288
- package/blog/ar/intlayer_with_next-intl.md +58 -337
- package/blog/ar/intlayer_with_react-i18next.md +68 -290
- package/blog/ar/intlayer_with_react-intl.md +63 -266
- package/blog/de/intlayer_with_i18next.md +77 -97
- package/blog/de/intlayer_with_next-i18next.md +69 -296
- package/blog/de/intlayer_with_next-intl.md +59 -340
- package/blog/de/intlayer_with_react-i18next.md +68 -290
- package/blog/de/intlayer_with_react-intl.md +62 -264
- package/blog/en/intlayer_with_i18next.md +36 -1638
- package/blog/en/intlayer_with_next-i18next.md +22 -847
- package/blog/en/intlayer_with_next-intl.md +32 -1053
- package/blog/en/intlayer_with_react-i18next.md +38 -764
- package/blog/en/intlayer_with_react-intl.md +42 -1018
- package/blog/en-GB/intlayer_with_i18next.md +67 -103
- package/blog/en-GB/intlayer_with_next-i18next.md +71 -292
- package/blog/en-GB/intlayer_with_next-intl.md +58 -337
- package/blog/en-GB/intlayer_with_react-i18next.md +67 -289
- package/blog/en-GB/intlayer_with_react-intl.md +61 -264
- package/blog/es/intlayer_with_i18next.md +67 -103
- package/blog/es/intlayer_with_next-i18next.md +71 -296
- package/blog/es/intlayer_with_next-intl.md +57 -338
- package/blog/es/intlayer_with_react-i18next.md +68 -290
- package/blog/es/intlayer_with_react-intl.md +62 -265
- package/blog/fr/intlayer_with_i18next.md +66 -104
- package/blog/fr/intlayer_with_next-i18next.md +82 -285
- package/blog/fr/intlayer_with_next-intl.md +57 -338
- package/blog/fr/intlayer_with_react-i18next.md +67 -289
- package/blog/fr/intlayer_with_react-intl.md +61 -264
- package/blog/hi/intlayer_with_i18next.md +68 -104
- package/blog/hi/intlayer_with_next-i18next.md +74 -299
- package/blog/hi/intlayer_with_next-intl.md +57 -239
- package/blog/hi/intlayer_with_react-i18next.md +69 -291
- package/blog/hi/intlayer_with_react-intl.md +65 -268
- package/blog/id/intlayer_with_i18next.md +126 -0
- package/blog/id/intlayer_with_next-i18next.md +142 -0
- package/blog/id/intlayer_with_next-intl.md +113 -0
- package/blog/id/intlayer_with_react-i18next.md +124 -0
- package/blog/id/intlayer_with_react-intl.md +122 -0
- package/blog/it/intlayer_with_i18next.md +67 -103
- package/blog/it/intlayer_with_next-i18next.md +71 -296
- package/blog/it/intlayer_with_next-intl.md +57 -338
- package/blog/it/intlayer_with_react-i18next.md +68 -290
- package/blog/it/intlayer_with_react-intl.md +62 -265
- package/blog/ja/intlayer_with_i18next.md +68 -103
- package/blog/ja/intlayer_with_next-i18next.md +85 -283
- package/blog/ja/intlayer_with_next-intl.md +58 -336
- package/blog/ja/intlayer_with_react-i18next.md +68 -290
- package/blog/ja/intlayer_with_react-intl.md +62 -264
- package/blog/ko/intlayer_with_i18next.md +80 -96
- package/blog/ko/intlayer_with_next-i18next.md +85 -287
- package/blog/ko/intlayer_with_next-intl.md +68 -327
- package/blog/ko/intlayer_with_react-i18next.md +68 -290
- package/blog/ko/intlayer_with_react-intl.md +64 -266
- package/blog/pl/intlayer_with_i18next.md +126 -0
- package/blog/pl/intlayer_with_next-i18next.md +142 -0
- package/blog/pl/intlayer_with_next-intl.md +111 -0
- package/blog/pl/intlayer_with_react-i18next.md +124 -0
- package/blog/pl/intlayer_with_react-intl.md +122 -0
- package/blog/pt/intlayer_with_i18next.md +67 -103
- package/blog/pt/intlayer_with_next-i18next.md +72 -293
- package/blog/pt/intlayer_with_next-intl.md +57 -256
- package/blog/pt/intlayer_with_react-i18next.md +104 -78
- package/blog/pt/intlayer_with_react-intl.md +62 -266
- package/blog/ru/intlayer_with_i18next.md +66 -104
- package/blog/ru/intlayer_with_next-i18next.md +71 -296
- package/blog/ru/intlayer_with_next-intl.md +58 -337
- package/blog/ru/intlayer_with_react-i18next.md +68 -290
- package/blog/ru/intlayer_with_react-intl.md +62 -265
- package/blog/tr/intlayer_with_i18next.md +71 -107
- package/blog/tr/intlayer_with_next-i18next.md +72 -297
- package/blog/tr/intlayer_with_next-intl.md +58 -339
- package/blog/tr/intlayer_with_react-i18next.md +69 -291
- package/blog/tr/intlayer_with_react-intl.md +63 -285
- package/blog/vi/intlayer_with_i18next.md +126 -0
- package/blog/vi/intlayer_with_next-i18next.md +142 -0
- package/blog/vi/intlayer_with_next-intl.md +111 -0
- package/blog/vi/intlayer_with_react-i18next.md +124 -0
- package/blog/vi/intlayer_with_react-intl.md +122 -0
- package/blog/zh/intlayer_with_i18next.md +67 -102
- package/blog/zh/intlayer_with_next-i18next.md +72 -296
- package/blog/zh/intlayer_with_next-intl.md +58 -336
- package/blog/zh/intlayer_with_react-i18next.md +68 -290
- package/blog/zh/intlayer_with_react-intl.md +63 -106
- package/docs/ar/plugins/sync-json.md +244 -0
- package/docs/de/plugins/sync-json.md +244 -0
- package/docs/en/intlayer_cli.md +25 -0
- package/docs/en/intlayer_with_nextjs_14.md +2 -0
- package/docs/en/intlayer_with_nextjs_15.md +2 -0
- package/docs/en/intlayer_with_nextjs_16.md +2 -0
- package/docs/en/plugins/sync-json.md +1 -1
- package/docs/en-GB/plugins/sync-json.md +244 -0
- package/docs/es/plugins/sync-json.md +244 -0
- package/docs/fr/plugins/sync-json.md +244 -0
- package/docs/hi/plugins/sync-json.md +244 -0
- package/docs/id/plugins/sync-json.md +244 -0
- package/docs/it/plugins/sync-json.md +244 -0
- package/docs/ja/plugins/sync-json.md +244 -0
- package/docs/ko/plugins/sync-json.md +244 -0
- package/docs/pl/plugins/sync-json.md +244 -0
- package/docs/pt/plugins/sync-json.md +244 -0
- package/docs/ru/plugins/sync-json.md +244 -0
- package/docs/tr/plugins/sync-json.md +245 -0
- package/docs/vi/plugins/sync-json.md +244 -0
- package/docs/zh/plugins/sync-json.md +244 -0
- package/package.json +14 -14
|
@@ -1,363 +1,142 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-08-23
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-10-29
|
|
4
4
|
title: Intlayer e next-i18next
|
|
5
|
-
description: Integre o Intlayer com
|
|
5
|
+
description: Integre o Intlayer com next-i18next para uma solução abrangente de internacionalização Next.js
|
|
6
6
|
keywords:
|
|
7
7
|
- i18next
|
|
8
8
|
- next-i18next
|
|
9
9
|
- Intlayer
|
|
10
10
|
- Internacionalização
|
|
11
|
-
-
|
|
11
|
+
- Blog
|
|
12
12
|
- Next.js
|
|
13
13
|
- JavaScript
|
|
14
14
|
- React
|
|
15
15
|
slugs:
|
|
16
16
|
- blog
|
|
17
17
|
- intlayer-with-next-i18next
|
|
18
|
+
history:
|
|
19
|
+
- version: 7.0.0
|
|
20
|
+
date: 2025-10-29
|
|
21
|
+
changes: Mudança para o plugin syncJSON e reescrita abrangente
|
|
18
22
|
---
|
|
19
23
|
|
|
20
|
-
#
|
|
24
|
+
# Internacionalização (i18n) Next.js com next-i18next e Intlayer
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
## Índice
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
<TOC/>
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
- Nomeado `resource` no caso do `i18next`, a declaração de conteúdo é um objeto JSON estruturado contendo pares chave-valor para traduções em um ou mais idiomas. Veja a [documentação do i18next](https://www.i18next.com/translation-function/essentials) para mais informações.
|
|
28
|
-
- Nomeada `content declaration file` no caso do `Intlayer`, a declaração de conteúdo pode ser um arquivo JSON, JS ou TS exportando os dados estruturados. Veja a [documentação do Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/doc/concept/content) para mais informações.
|
|
30
|
+
## O que é next-i18next?
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
**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.
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
No entanto, o next-i18next apresenta alguns desafios:
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
- **Configuração complexa**: Configurar o next-i18next requer múltiplos arquivos de configuração e uma configuração cuidadosa das instâncias i18n no lado do servidor e do cliente.
|
|
37
|
+
- **Traduções dispersas**: Os arquivos de tradução geralmente são armazenados em diretórios separados dos componentes, dificultando a manutenção da consistência.
|
|
38
|
+
- **Gerenciamento manual de namespaces**: Os desenvolvedores precisam gerenciar manualmente os namespaces e garantir o carregamento adequado dos recursos de tradução.
|
|
39
|
+
- **Segurança de tipos limitada**: O suporte ao TypeScript requer configuração adicional e não fornece geração automática de tipos para traduções.
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
## O que é o Intlayer?
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
**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.
|
|
39
44
|
|
|
40
|
-
|
|
45
|
+
Veja uma comparação concreta com o next-intl 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).
|
|
41
46
|
|
|
42
|
-
|
|
47
|
+
## Por que combinar o Intlayer com o next-i18next?
|
|
43
48
|
|
|
44
|
-
|
|
49
|
+
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 next-i18next por várias razões:
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
1. **Base de código existente**: Você possui uma implementação estabelecida do next-i18next e deseja migrar gradualmente para a melhor experiência de desenvolvedor do Intlayer.
|
|
52
|
+
2. **Requisitos legados**: Seu projeto requer compatibilidade com plugins ou fluxos de trabalho existentes do i18next.
|
|
53
|
+
3. **Familiaridade da equipe**: Sua equipe está confortável com o next-i18next, mas deseja um melhor gerenciamento de conteúdo.
|
|
47
54
|
|
|
48
|
-
|
|
49
|
-
.
|
|
50
|
-
└── src
|
|
51
|
-
└── components
|
|
52
|
-
└── MyComponent
|
|
53
|
-
├── index.content.ts # Arquivo de declaração de conteúdo
|
|
54
|
-
└── index.tsx
|
|
55
|
-
```
|
|
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.**
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
.
|
|
59
|
-
└── src
|
|
60
|
-
└── components
|
|
61
|
-
└── MyComponent
|
|
62
|
-
├── index.content.mjs # Arquivo de declaração de conteúdo
|
|
63
|
-
└── index.mjx
|
|
64
|
-
```
|
|
57
|
+
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.
|
|
65
58
|
|
|
66
|
-
|
|
67
|
-
.
|
|
68
|
-
└── src
|
|
69
|
-
└── components
|
|
70
|
-
└── MyComponent
|
|
71
|
-
├── index.content.cjs # Arquivo de declaração de conteúdo
|
|
72
|
-
└── index.cjx
|
|
73
|
-
```
|
|
59
|
+
---
|
|
74
60
|
|
|
75
|
-
|
|
76
|
-
.
|
|
77
|
-
└── src
|
|
78
|
-
└── components
|
|
79
|
-
└── MyComponent
|
|
80
|
-
├── index.content.json # Arquivo de declaração de conteúdo
|
|
81
|
-
└── index.jsx
|
|
82
|
-
```
|
|
61
|
+
## Guia Passo a Passo para Configurar o Intlayer com next-i18next
|
|
83
62
|
|
|
84
|
-
|
|
63
|
+
### Passo 1: Instalar Dependências
|
|
85
64
|
|
|
86
|
-
|
|
65
|
+
Instale os pacotes necessários usando seu gerenciador de pacotes preferido:
|
|
87
66
|
|
|
88
67
|
```bash packageManager="npm"
|
|
89
|
-
npm install intlayer
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
```bash packageManager="yarn"
|
|
93
|
-
yarn add intlayer i18next next-i18next i18next-resources-to-backend
|
|
68
|
+
npm install intlayer @intlayer/sync-json-plugin
|
|
94
69
|
```
|
|
95
70
|
|
|
96
71
|
```bash packageManager="pnpm"
|
|
97
|
-
pnpm add intlayer
|
|
72
|
+
pnpm add intlayer @intlayer/sync-json-plugin
|
|
98
73
|
```
|
|
99
74
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
Para exportar recursos do i18next, configure o Intlayer em um arquivo `intlayer.config.ts`. Configurações de exemplo:
|
|
105
|
-
|
|
106
|
-
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
107
|
-
import { Locales, type IntlayerConfig } from "intlayer";
|
|
75
|
+
```bash packageManager="yarn"
|
|
76
|
+
yarn add intlayer @intlayer/sync-json-plugin
|
|
77
|
+
```
|
|
108
78
|
|
|
109
|
-
|
|
110
|
-
internationalization: {
|
|
111
|
-
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
112
|
-
defaultLocale: Locales.ENGLISH,
|
|
113
|
-
},
|
|
114
|
-
content: {
|
|
115
|
-
dictionaryOutput: ["i18next"],
|
|
116
|
-
i18nextResourcesDir: "./i18next/resources",
|
|
117
|
-
},
|
|
118
|
-
};
|
|
79
|
+
**Explicações dos pacotes:**
|
|
119
80
|
|
|
120
|
-
|
|
121
|
-
|
|
81
|
+
- **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
|
+
- **@intlayer/sync-json-plugin**: Plugin para sincronizar declarações de conteúdo do Intlayer para o formato JSON do i18next
|
|
122
87
|
|
|
123
|
-
|
|
124
|
-
import { Locales } from "intlayer";
|
|
88
|
+
### Passo 2: Implemente o plugin Intlayer para encapsular o JSON
|
|
125
89
|
|
|
126
|
-
|
|
127
|
-
const config = {
|
|
128
|
-
internationalization: {
|
|
129
|
-
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
130
|
-
defaultLocale: Locales.ENGLISH,
|
|
131
|
-
},
|
|
132
|
-
content: {
|
|
133
|
-
dictionaryOutput: ["i18next"],
|
|
134
|
-
i18nextResourcesDir: "./i18next/resources",
|
|
135
|
-
},
|
|
136
|
-
};
|
|
90
|
+
Crie um arquivo de configuração do Intlayer para definir os locais suportados:
|
|
137
91
|
|
|
138
|
-
|
|
139
|
-
```
|
|
92
|
+
**Se você também quiser exportar dicionários JSON para o i18next**, adicione o plugin `syncJSON`:
|
|
140
93
|
|
|
141
|
-
```
|
|
142
|
-
|
|
94
|
+
```typescript fileName="intlayer.config.ts"
|
|
95
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
96
|
+
import { syncJSON } from "@intlayer/sync-json-plugin";
|
|
143
97
|
|
|
144
|
-
|
|
145
|
-
const config = {
|
|
98
|
+
const config: IntlayerConfig = {
|
|
146
99
|
internationalization: {
|
|
147
100
|
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
148
101
|
defaultLocale: Locales.ENGLISH,
|
|
149
102
|
},
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
module.exports = config;
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### Importando Dicionários na Sua Configuração do i18next
|
|
160
|
-
|
|
161
|
-
Para importar os recursos gerados em sua configuração do i18next, use `i18next-resources-to-backend`. Abaixo estão exemplos:
|
|
162
|
-
|
|
163
|
-
```typescript fileName="i18n/client.ts" codeFormat="typescript"
|
|
164
|
-
import i18next from "i18next";
|
|
165
|
-
import resourcesToBackend from "i18next-resources-to-backend";
|
|
166
|
-
|
|
167
|
-
i18next.use(
|
|
168
|
-
resourcesToBackend(
|
|
169
|
-
(language: string, namespace: string) =>
|
|
170
|
-
import(`../i18next/resources/${language}/${namespace}.json`)
|
|
171
|
-
)
|
|
172
|
-
);
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
```javascript fileName="i18n/client.mjs" codeFormat="esm"
|
|
176
|
-
import i18next from "i18next";
|
|
177
|
-
import resourcesToBackend from "i18next-resources-to-backend";
|
|
178
|
-
|
|
179
|
-
i18next.use(
|
|
180
|
-
resourcesToBackend(
|
|
181
|
-
(language, namespace) =>
|
|
182
|
-
import(`../i18next/resources/${language}/${namespace}.json`)
|
|
183
|
-
)
|
|
184
|
-
);
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
```javascript fileName="i18n/client.cjs" codeFormat="commonjs"
|
|
188
|
-
const i18next = require("i18next");
|
|
189
|
-
const resourcesToBackend = require("i18next-resources-to-backend");
|
|
190
|
-
|
|
191
|
-
i18next.use(
|
|
192
|
-
resourcesToBackend(
|
|
193
|
-
(language, namespace) =>
|
|
194
|
-
import(`../i18next/resources/${language}/${namespace}.json`)
|
|
195
|
-
)
|
|
196
|
-
);
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
### Declaração de Conteúdo
|
|
200
|
-
|
|
201
|
-
Exemplos de arquivos de declaração de conteúdo em vários formatos:
|
|
202
|
-
|
|
203
|
-
```typescript fileName="**/*.content.ts" contentDeclarationFormat="typescript"
|
|
204
|
-
import { t, type Dictionary } from "intlayer";
|
|
205
|
-
|
|
206
|
-
const content = {
|
|
207
|
-
key: "my-content",
|
|
208
|
-
content: {
|
|
209
|
-
myTranslatedContent: t({
|
|
210
|
-
en: "Hello World",
|
|
211
|
-
es: "Hola Mundo",
|
|
212
|
-
fr: "Bonjour le monde",
|
|
213
|
-
}),
|
|
214
|
-
},
|
|
215
|
-
} satisfies Dictionary;
|
|
216
|
-
|
|
217
|
-
export default content;
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
```javascript fileName="**/*.content.mjs" contentDeclarationFormat="esm"
|
|
221
|
-
import { t } from "intlayer";
|
|
222
|
-
|
|
223
|
-
/** @type {import('intlayer').Dictionary} */
|
|
224
|
-
const content = {
|
|
225
|
-
key: "my-content",
|
|
226
|
-
content: {
|
|
227
|
-
myTranslatedContent: t({
|
|
228
|
-
en: "Hello World",
|
|
229
|
-
es: "Hola Mundo",
|
|
230
|
-
fr: "Bonjour le monde",
|
|
231
|
-
}),
|
|
232
|
-
},
|
|
233
|
-
};
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
```javascript fileName="**/*.content.cjs" contentDeclarationFormat="commonjs"
|
|
237
|
-
const { t } = require("intlayer");
|
|
238
|
-
|
|
239
|
-
module.exports = {
|
|
240
|
-
key: "my-content",
|
|
241
|
-
content: {
|
|
242
|
-
myTranslatedContent: t({
|
|
243
|
-
en: "Hello World",
|
|
244
|
-
es: "Hola Mundo",
|
|
245
|
-
fr: "Bonjour le monde",
|
|
103
|
+
plugins: [
|
|
104
|
+
syncJSON({
|
|
105
|
+
source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
|
|
246
106
|
}),
|
|
247
|
-
|
|
107
|
+
],
|
|
248
108
|
};
|
|
249
|
-
```
|
|
250
109
|
|
|
251
|
-
|
|
252
|
-
{
|
|
253
|
-
"$schema": "https://intlayer.org/schema.json",
|
|
254
|
-
"key": "my-content",
|
|
255
|
-
"content": {
|
|
256
|
-
"myTranslatedContent": {
|
|
257
|
-
"nodeType": "translation",
|
|
258
|
-
"translation": {
|
|
259
|
-
"en": "Hello World",
|
|
260
|
-
"fr": "Bonjour le monde",
|
|
261
|
-
"es": "Hola Mundo"
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
### Construindo os Recursos do next-i18next
|
|
269
|
-
|
|
270
|
-
Para construir os recursos do next-i18next, execute o seguinte comando:
|
|
271
|
-
|
|
272
|
-
```bash packageManager="npm"
|
|
273
|
-
npx run intlayer build
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
```bash packageManager="yarn"
|
|
277
|
-
yarn intlayer build
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
```bash packageManager="pnpm"
|
|
281
|
-
pnpm intlayer build
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
Isso irá gerar recursos no diretório `./i18next/resources`. A saída esperada:
|
|
285
|
-
|
|
286
|
-
```bash
|
|
287
|
-
.
|
|
288
|
-
└── i18next
|
|
289
|
-
└── resources
|
|
290
|
-
└── en
|
|
291
|
-
└── my-content.json
|
|
292
|
-
└── fr
|
|
293
|
-
└── my-content.json
|
|
294
|
-
└── es
|
|
295
|
-
└── my-content.json
|
|
110
|
+
export default config;
|
|
296
111
|
```
|
|
297
112
|
|
|
298
|
-
|
|
113
|
+
O plugin `syncJSON` irá automaticamente encapsular o JSON. Ele irá ler e escrever os arquivos JSON sem alterar a arquitetura do conteúdo.
|
|
299
114
|
|
|
300
|
-
|
|
115
|
+
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:
|
|
301
116
|
|
|
302
|
-
|
|
117
|
+
1. carregar tanto os arquivos JSON quanto os arquivos de declaração de conteúdo e transformá-los em um dicionário do intlayer.
|
|
118
|
+
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).
|
|
303
119
|
|
|
304
|
-
|
|
305
|
-
import { withIntlayer } from "next-intlayer/server";
|
|
120
|
+
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.
|
|
306
121
|
|
|
307
|
-
|
|
308
|
-
const nextConfig = {};
|
|
309
|
-
|
|
310
|
-
export default withIntlayer(nextConfig);
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
### Usando Conteúdo nos Componentes do Next.js
|
|
314
|
-
|
|
315
|
-
Após implementar o plugin do Next.js, você pode usar o conteúdo em seus componentes:
|
|
316
|
-
|
|
317
|
-
```typescript fileName="src/components/myComponent/index.tsx" codeFormat="typescript"
|
|
318
|
-
import type { FC } from "react";
|
|
319
|
-
import { useTranslation } from "react-i18next";
|
|
122
|
+
---
|
|
320
123
|
|
|
321
|
-
|
|
322
|
-
const { t } = useTranslation();
|
|
124
|
+
## Configuração do Git
|
|
323
125
|
|
|
324
|
-
|
|
325
|
-
<div>
|
|
326
|
-
<h1>{t("my-content.title")}</h1>
|
|
327
|
-
<p>{t("my-content.description")}</p>
|
|
328
|
-
</div>
|
|
329
|
-
);
|
|
330
|
-
};
|
|
126
|
+
Exclua arquivos gerados do controle de versão:
|
|
331
127
|
|
|
332
|
-
|
|
128
|
+
```plaintext fileName=".gitignore"
|
|
129
|
+
# Ignorar arquivos gerados pelo Intlayer
|
|
130
|
+
.intlayer
|
|
131
|
+
intl
|
|
333
132
|
```
|
|
334
133
|
|
|
335
|
-
|
|
336
|
-
import { useTranslation } from "react-i18next";
|
|
134
|
+
Esses arquivos são automaticamente regenerados durante o processo de build e não precisam ser comitados no seu repositório.
|
|
337
135
|
|
|
338
|
-
|
|
339
|
-
const { t } = useTranslation();
|
|
136
|
+
### Extensão VS Code
|
|
340
137
|
|
|
341
|
-
|
|
342
|
-
<div>
|
|
343
|
-
<h1>{t("my-content.title")}</h1>
|
|
344
|
-
<p>{t("my-content.description")}</p>
|
|
345
|
-
</div>
|
|
346
|
-
);
|
|
347
|
-
};
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
```jsx fileName="src/components/myComponent/index.cjx" codeFormat="commonjs"
|
|
351
|
-
const { useTranslation } = require("react-i18next");
|
|
138
|
+
Para uma melhor experiência de desenvolvimento, instale a extensão oficial **Intlayer VS Code Extension**:
|
|
352
139
|
|
|
353
|
-
|
|
354
|
-
const { t } = useTranslation();
|
|
140
|
+
[Instalar no VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
355
141
|
|
|
356
|
-
|
|
357
|
-
<div>
|
|
358
|
-
<h1>{t("my-content.title")}</h1>
|
|
359
|
-
<p>{t("my-content.description")}</p>
|
|
360
|
-
</div>
|
|
361
|
-
);
|
|
362
|
-
};
|
|
363
|
-
```
|
|
142
|
+
[Instalar no Marketplace do VS Code](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|