@intlayer/docs 7.0.5 → 7.0.7
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
|
@@ -13,33 +13,37 @@ keywords:
|
|
|
13
13
|
- React
|
|
14
14
|
- JavaScript
|
|
15
15
|
- TypeScript
|
|
16
|
-
-
|
|
16
|
+
- Gerenciamento de Conteúdo
|
|
17
17
|
slugs:
|
|
18
18
|
- blog
|
|
19
19
|
- intlayer-with-react-i18next
|
|
20
20
|
history:
|
|
21
|
+
- version: 7.0.6
|
|
22
|
+
date: 2025-11-01
|
|
23
|
+
changes: Adicionado plugin loadJSON
|
|
21
24
|
- version: 7.0.0
|
|
22
25
|
date: 2025-10-29
|
|
23
|
-
changes:
|
|
26
|
+
changes: Alterado para plugin syncJSON
|
|
24
27
|
---
|
|
25
28
|
|
|
26
29
|
# Como automatizar suas traduções JSON do react-i18next usando Intlayer
|
|
27
30
|
|
|
28
31
|
## O que é o Intlayer?
|
|
29
32
|
|
|
30
|
-
**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
|
|
33
|
+
**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 React.
|
|
31
34
|
|
|
32
35
|
Veja uma comparação concreta com react-i18next em nosso post no blog [react-i18next vs. react-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/pt/react-i18next_vs_react-intl_vs_intlayer.md).
|
|
33
36
|
|
|
34
37
|
## Por que combinar Intlayer com react-i18next?
|
|
35
38
|
|
|
36
|
-
Embora o Intlayer forneça uma excelente solução de i18n independente (veja nosso [guia de integração com React](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_with_vite+react.md)), você pode querer combiná-lo com react-i18next por
|
|
39
|
+
Embora o Intlayer forneça uma excelente solução de i18n independente (veja nosso [guia de integração com React](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_with_vite+react.md)), você pode querer combiná-lo com react-i18next por várias razões:
|
|
37
40
|
|
|
38
|
-
1. **Base de código existente**: Você possui uma implementação estabelecida do react-i18next e deseja migrar gradualmente para a melhor experiência de desenvolvedor
|
|
39
|
-
2. **Requisitos legados**: Seu projeto
|
|
40
|
-
3. **Familiaridade da equipe**: Sua equipe está confortável com o react-i18next, mas deseja
|
|
41
|
+
1. **Base de código existente**: Você possui uma implementação estabelecida do react-i18next e deseja migrar gradualmente para a melhor experiência de desenvolvedor do Intlayer.
|
|
42
|
+
2. **Requisitos legados**: Seu projeto requer compatibilidade com plugins ou fluxos de trabalho existentes do react-i18next.
|
|
43
|
+
3. **Familiaridade da equipe**: Sua equipe está confortável com o react-i18next, mas deseja um melhor gerenciamento de conteúdo.
|
|
44
|
+
4. **Uso dos recursos do Intlayer**: Você quer usar recursos do Intlayer como declaração de conteúdo, automação de traduções, testes de traduções e mais.
|
|
41
45
|
|
|
42
|
-
**Para isso, o Intlayer pode ser implementado como um adaptador para o react-i18next
|
|
46
|
+
**Para isso, o Intlayer pode ser implementado como um adaptador para o react-i18next para ajudar na automação das suas traduções JSON em CLI ou pipelines CI/CD, testar suas traduções e muito mais.**
|
|
43
47
|
|
|
44
48
|
Este guia mostra como aproveitar o sistema superior de declaração de conteúdo do Intlayer enquanto mantém a compatibilidade com o react-i18next.
|
|
45
49
|
|
|
@@ -49,7 +53,7 @@ Este guia mostra como aproveitar o sistema superior de declaração de conteúdo
|
|
|
49
53
|
|
|
50
54
|
## Guia passo a passo para configurar o Intlayer com react-i18next
|
|
51
55
|
|
|
52
|
-
### Passo 1: Instalar
|
|
56
|
+
### Passo 1: Instalar dependências
|
|
53
57
|
|
|
54
58
|
Instale os pacotes necessários:
|
|
55
59
|
|
|
@@ -65,16 +69,20 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
65
69
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
66
70
|
```
|
|
67
71
|
|
|
72
|
+
```bash packageManager="bun"
|
|
73
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
74
|
+
```
|
|
75
|
+
|
|
68
76
|
**Descrição dos pacotes:**
|
|
69
77
|
|
|
70
78
|
- **intlayer**: Biblioteca principal para gerenciamento de internacionalização, declaração de conteúdo e construção
|
|
71
79
|
- **@intlayer/sync-json-plugin**: Plugin para exportar declarações de conteúdo do Intlayer para o formato JSON compatível com react-i18next
|
|
72
80
|
|
|
73
|
-
### Passo 2:
|
|
81
|
+
### Passo 2: Implemente o plugin Intlayer para envolver o JSON
|
|
74
82
|
|
|
75
83
|
Crie um arquivo de configuração do Intlayer para definir os seus locais suportados:
|
|
76
84
|
|
|
77
|
-
**Se você também quiser exportar dicionários JSON para
|
|
85
|
+
**Se você também quiser exportar dicionários JSON para react-i18next**, adicione o plugin `syncJSON`:
|
|
78
86
|
|
|
79
87
|
```typescript fileName="intlayer.config.ts"
|
|
80
88
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -87,7 +95,7 @@ const config: IntlayerConfig = {
|
|
|
87
95
|
},
|
|
88
96
|
plugins: [
|
|
89
97
|
syncJSON({
|
|
90
|
-
source: ({ key, locale }) => `./
|
|
98
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
91
99
|
}),
|
|
92
100
|
],
|
|
93
101
|
};
|
|
@@ -95,17 +103,58 @@ const config: IntlayerConfig = {
|
|
|
95
103
|
export default config;
|
|
96
104
|
```
|
|
97
105
|
|
|
98
|
-
O plugin `syncJSON` irá automaticamente
|
|
106
|
+
O plugin `syncJSON` irá automaticamente envolver o JSON. Ele irá ler e escrever os arquivos JSON sem alterar a arquitetura do conteúdo.
|
|
99
107
|
|
|
100
|
-
Se você quiser fazer coexistir esse JSON com arquivos de declaração de conteúdo do
|
|
108
|
+
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:
|
|
101
109
|
|
|
102
|
-
1. carregar tanto os arquivos JSON quanto os arquivos de declaração de conteúdo e transformá-los em um dicionário
|
|
103
|
-
2. se houver conflitos entre
|
|
110
|
+
1. carregar tanto os arquivos JSON quanto os arquivos de declaração de conteúdo e transformá-los em um dicionário do Intlayer.
|
|
111
|
+
2. se houver conflitos entre os arquivos JSON e os arquivos de declaração de conteúdo, o Intlayer irá processar a fusão de todos esses dicionários. Dependendo da prioridade dos plugins e da do arquivo de declaração de conteúdo (tudo é configurável).
|
|
104
112
|
|
|
105
113
|
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.
|
|
106
114
|
|
|
107
115
|
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).
|
|
108
116
|
|
|
117
|
+
### (Opcional) Passo 3: Implementar traduções JSON por componente
|
|
118
|
+
|
|
119
|
+
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.
|
|
120
|
+
|
|
121
|
+
Para isso, você pode usar o plugin `loadJSON`.
|
|
122
|
+
|
|
123
|
+
```ts fileName="intlayer.config.ts"
|
|
124
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
125
|
+
import { loadJSON, syncJSON } from "@intlayer/sync-json-plugin";
|
|
126
|
+
|
|
127
|
+
const config: IntlayerConfig = {
|
|
128
|
+
internationalization: {
|
|
129
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
130
|
+
defaultLocale: Locales.ENGLISH,
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
// Mantenha seus arquivos JSON atuais sincronizados com os dicionários do Intlayer
|
|
134
|
+
plugins: [
|
|
135
|
+
/**
|
|
136
|
+
* Carregará todos os arquivos JSON na pasta src que correspondem ao padrão {key}.i18n.json
|
|
137
|
+
*/
|
|
138
|
+
loadJSON({
|
|
139
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
140
|
+
locale: Locales.ENGLISH,
|
|
141
|
+
priority: 1, // Garante que esses arquivos JSON tenham precedência sobre os arquivos em `./locales/en/${key}.json`
|
|
142
|
+
}),
|
|
143
|
+
/**
|
|
144
|
+
* Carregará e escreverá a saída e as traduções de volta nos arquivos JSON no diretório de locais
|
|
145
|
+
*/
|
|
146
|
+
syncJSON({
|
|
147
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
148
|
+
priority: 0,
|
|
149
|
+
}),
|
|
150
|
+
],
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export default config;
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
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.
|
|
157
|
+
|
|
109
158
|
## Configuração do Git
|
|
110
159
|
|
|
111
160
|
É recomendado ignorar os arquivos gerados automaticamente pelo Intlayer:
|
|
@@ -115,10 +164,10 @@ Para ver mais detalhes sobre o plugin `syncJSON`, por favor consulte a [document
|
|
|
115
164
|
.intlayer
|
|
116
165
|
```
|
|
117
166
|
|
|
118
|
-
|
|
167
|
+
Esses arquivos podem ser regenerados durante seu processo de build e não precisam ser commitados no controle de versão.
|
|
119
168
|
|
|
120
169
|
### Extensão VS Code
|
|
121
170
|
|
|
122
|
-
Para uma melhor experiência de desenvolvimento, instale a
|
|
171
|
+
Para uma melhor experiência de desenvolvimento, instale a extensão oficial **Intlayer VS Code Extension**:
|
|
123
172
|
|
|
124
173
|
[Instalar no VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
@@ -16,13 +16,20 @@ slugs:
|
|
|
16
16
|
- blog
|
|
17
17
|
- intlayer-with-react-intl
|
|
18
18
|
history:
|
|
19
|
+
- version: 7.0.6
|
|
20
|
+
date: 2025-11-01
|
|
21
|
+
changes: Adicionar plugin loadJSON
|
|
19
22
|
- version: 7.0.0
|
|
20
23
|
date: 2025-10-29
|
|
21
|
-
changes:
|
|
24
|
+
changes: Alterar para plugin syncJSON
|
|
22
25
|
---
|
|
23
26
|
|
|
24
27
|
# Como automatizar suas traduções JSON do react-intl usando Intlayer
|
|
25
28
|
|
|
29
|
+
## Índice
|
|
30
|
+
|
|
31
|
+
<TOC/>
|
|
32
|
+
|
|
26
33
|
## O que é o Intlayer?
|
|
27
34
|
|
|
28
35
|
**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 React.
|
|
@@ -31,15 +38,16 @@ Veja uma comparação concreta com react-intl em nosso post no blog [react-i18ne
|
|
|
31
38
|
|
|
32
39
|
## Por que combinar Intlayer com react-intl?
|
|
33
40
|
|
|
34
|
-
Embora o Intlayer forneça uma excelente solução i18n independente (veja nosso [guia de integração com React](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_with_vite+react.md)), você pode querer combiná-lo com react-intl por várias razões:
|
|
41
|
+
Embora o Intlayer forneça uma excelente solução i18n independente (veja nosso [guia de integração com React](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_with_vite+react.md)), você pode querer combiná-lo com o react-intl por várias razões:
|
|
35
42
|
|
|
36
43
|
1. **Base de código existente**: Você possui uma implementação estabelecida do react-intl e deseja migrar gradualmente para a melhor experiência de desenvolvedor do Intlayer.
|
|
37
44
|
2. **Requisitos legados**: Seu projeto requer compatibilidade com plugins ou fluxos de trabalho existentes do react-intl.
|
|
38
45
|
3. **Familiaridade da equipe**: Sua equipe está confortável com o react-intl, 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, automação de traduções, testes de traduções e mais.
|
|
39
47
|
|
|
40
|
-
**Para isso, o Intlayer pode ser implementado como um adaptador para o react-intl
|
|
48
|
+
**Para isso, o Intlayer pode ser implementado como um adaptador para o react-intl para ajudar a automatizar suas traduções JSON em pipelines CLI ou CI/CD, testar suas traduções e muito mais.**
|
|
41
49
|
|
|
42
|
-
Este guia mostra como aproveitar o sistema superior de declaração de conteúdo do Intlayer
|
|
50
|
+
Este guia mostra como aproveitar o sistema superior de declaração de conteúdo do Intlayer enquanto mantém a compatibilidade com o react-intl.
|
|
43
51
|
|
|
44
52
|
## Índice
|
|
45
53
|
|
|
@@ -63,6 +71,10 @@ pnpm add intlayer @intlayer/sync-json-plugin
|
|
|
63
71
|
yarn add intlayer @intlayer/sync-json-plugin
|
|
64
72
|
```
|
|
65
73
|
|
|
74
|
+
```bash packageManager="bun"
|
|
75
|
+
bun add intlayer @intlayer/sync-json-plugin
|
|
76
|
+
```
|
|
77
|
+
|
|
66
78
|
**Descrição dos pacotes:**
|
|
67
79
|
|
|
68
80
|
- **intlayer**: Biblioteca principal para gerenciamento de internacionalização, declaração de conteúdo e construção
|
|
@@ -95,16 +107,56 @@ export default config;
|
|
|
95
107
|
|
|
96
108
|
O plugin `syncJSON` irá automaticamente encapsular o JSON. Ele irá ler e escrever os arquivos JSON sem alterar a arquitetura do conteúdo.
|
|
97
109
|
|
|
98
|
-
Se você quiser fazer coexistir esse JSON com arquivos de declaração de conteúdo do Intlayer (
|
|
110
|
+
Se você quiser fazer coexistir esse JSON com arquivos de declaração de conteúdo do Intlayer (`.content` files), o Intlayer procederá da seguinte forma:
|
|
99
111
|
|
|
100
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.
|
|
101
|
-
|
|
102
|
-
2. se houver conflitos entre o JSON e os arquivos de declaração de conteúdo, o Intlayer irá processar a 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).
|
|
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).
|
|
103
114
|
|
|
104
115
|
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.
|
|
105
116
|
|
|
106
117
|
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).
|
|
107
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 escreverá a saída e as traduções de volta nos arquivos JSON no diretório de locais
|
|
147
|
+
*/
|
|
148
|
+
syncJSON({
|
|
149
|
+
source: ({ key, locale }) => `./messages/${locale}/${key}.json`,
|
|
150
|
+
priority: 0,
|
|
151
|
+
}),
|
|
152
|
+
],
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export default config;
|
|
156
|
+
```
|
|
157
|
+
|
|
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.
|
|
159
|
+
|
|
108
160
|
## Configuração do Git
|
|
109
161
|
|
|
110
162
|
É recomendado ignorar os arquivos gerados automaticamente pelo Intlayer:
|
|
@@ -114,10 +166,10 @@ Para ver mais detalhes sobre o plugin `syncJSON`, por favor consulte a [document
|
|
|
114
166
|
.intlayer
|
|
115
167
|
```
|
|
116
168
|
|
|
117
|
-
Esses arquivos podem ser regenerados durante
|
|
169
|
+
Esses arquivos podem ser regenerados durante seu processo de build e não precisam ser commitados no controle de versão.
|
|
118
170
|
|
|
119
|
-
### Extensão VS Code
|
|
171
|
+
### Extensão do VS Code
|
|
120
172
|
|
|
121
|
-
Para uma melhor experiência de desenvolvimento, instale a
|
|
173
|
+
Para uma melhor experiência de desenvolvimento, instale a extensão oficial **Intlayer VS Code Extension**:
|
|
122
174
|
|
|
123
175
|
[Instalar no VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-08-23
|
|
3
|
+
updatedAt: 2025-10-29
|
|
4
|
+
title: Intlayer e vue-i18n
|
|
5
|
+
description: Integre o Intlayer com vue-i18n para uma solução abrangente de internacionalização em Vue.js
|
|
6
|
+
keywords:
|
|
7
|
+
- vue-i18n
|
|
8
|
+
- Intlayer
|
|
9
|
+
- Internacionalização
|
|
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: Adicionado plugin loadJSON
|
|
22
|
+
- version: 7.0.0
|
|
23
|
+
date: 2025-10-29
|
|
24
|
+
changes: Alterado para plugin syncJSON e reescrita completa
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
# Internacionalização (i18n) em Vue.js com vue-i18n e Intlayer
|
|
28
|
+
|
|
29
|
+
## Índice
|
|
30
|
+
|
|
31
|
+
<TOC/>
|
|
32
|
+
|
|
33
|
+
## O que é o Intlayer?
|
|
34
|
+
|
|
35
|
+
**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 Vue.js e Nuxt.
|
|
36
|
+
|
|
37
|
+
Veja uma comparação concreta com o vue-i18n em nosso post no blog [vue-i18n vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/pt/vue-i18n_vs_intlayer.md).
|
|
38
|
+
|
|
39
|
+
## Por que combinar o Intlayer com o vue-i18n?
|
|
40
|
+
|
|
41
|
+
Embora o Intlayer forneça uma excelente solução de i18n independente (veja nosso [guia de integração com Vue.js](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_with_vite+vue.md)), você pode querer combiná-lo com o vue-i18n por várias razões:
|
|
42
|
+
|
|
43
|
+
1. **Base de código existente**: Você possui uma implementação estabelecida do vue-i18n e deseja migrar gradualmente para a melhor experiência de desenvolvedor do Intlayer.
|
|
44
|
+
2. **Requisitos legados**: Seu projeto requer compatibilidade com plugins ou fluxos de trabalho existentes do vue-i18n.
|
|
45
|
+
3. **Familiaridade da equipe**: Sua equipe está confortável com o vue-i18n, 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, automação de traduções, testes de traduções e mais.
|
|
47
|
+
|
|
48
|
+
**Para isso, o Intlayer pode ser implementado como um adaptador para o vue-i18n para ajudar a automatizar suas traduções JSON em pipelines CLI ou CI/CD, testar suas traduções e muito mais.**
|
|
49
|
+
|
|
50
|
+
Este guia mostra como aproveitar o sistema superior de declaração de conteúdo do Intlayer enquanto mantém a compatibilidade com o vue-i18n.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Guia Passo a Passo para Configurar o Intlayer com vue-i18n
|
|
55
|
+
|
|
56
|
+
### Passo 1: Instalar Dependências
|
|
57
|
+
|
|
58
|
+
Instale os pacotes necessários usando seu gerenciador de pacotes preferido:
|
|
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
|
+
**Explicações dos pacotes:**
|
|
77
|
+
|
|
78
|
+
- **intlayer**: Biblioteca principal para declaração e gerenciamento de conteúdo
|
|
79
|
+
- **@intlayer/sync-json-plugin**: Plugin para sincronizar declarações de conteúdo do Intlayer para o formato JSON do vue-i18n
|
|
80
|
+
|
|
81
|
+
### Passo 2: Implemente o plugin Intlayer para encapsular o JSON
|
|
82
|
+
|
|
83
|
+
Crie um arquivo de configuração do Intlayer para definir os seus locais suportados:
|
|
84
|
+
|
|
85
|
+
**Se você também quiser exportar dicionários JSON para o vue-i18n**, adicione o plugin `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
|
+
O plugin `syncJSON` irá automaticamente encapsular o JSON. Ele irá ler e escrever os arquivos JSON sem alterar a arquitetura do conteúdo.
|
|
107
|
+
|
|
108
|
+
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:
|
|
109
|
+
|
|
110
|
+
1. carregar tanto os arquivos JSON quanto os arquivos de declaração de conteúdo e transformá-los em um dicionário do Intlayer.
|
|
111
|
+
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).
|
|
112
|
+
|
|
113
|
+
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.
|
|
114
|
+
|
|
115
|
+
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).
|
|
116
|
+
|
|
117
|
+
---
|
|
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 escreverá a saída e as traduções de volta nos arquivos JSON no diretório de locais
|
|
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
|
+
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.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Configuração do Git
|
|
163
|
+
|
|
164
|
+
Exclua arquivos gerados do controle de versão:
|
|
165
|
+
|
|
166
|
+
```plaintext fileName=".gitignore"
|
|
167
|
+
# Ignorar arquivos gerados pelo Intlayer
|
|
168
|
+
.intlayer
|
|
169
|
+
intl
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Esses arquivos são automaticamente regenerados durante o processo de build e não precisam ser comitados no seu repositório.
|
|
173
|
+
|
|
174
|
+
### Extensão VS Code
|
|
175
|
+
|
|
176
|
+
Para uma melhor experiência de desenvolvimento, instale a extensão oficial **Intlayer VS Code Extension**:
|
|
177
|
+
|
|
178
|
+
[Instalar no Marketplace do 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: Как автоматизировать ваши JSON-переводы i18next с помощью Intlayer
|
|
5
5
|
description: Автоматизируйте ваши JSON-переводы с помощью Intlayer и i18next для улучшенной интернационализации в JavaScript-приложениях.
|
|
6
6
|
keywords:
|
|
@@ -20,30 +20,34 @@ slugs:
|
|
|
20
20
|
- blog
|
|
21
21
|
- intlayer-with-i18next
|
|
22
22
|
history:
|
|
23
|
+
- version: 7.0.6
|
|
24
|
+
date: 2025-11-01
|
|
25
|
+
changes: Добавлен плагин loadJSON
|
|
23
26
|
- version: 7.0.0
|
|
24
27
|
date: 2025-10-29
|
|
25
|
-
changes:
|
|
28
|
+
changes: Изменение на плагин syncJSON
|
|
26
29
|
---
|
|
27
30
|
|
|
28
31
|
# Как автоматизировать ваши JSON-переводы i18next с помощью Intlayer
|
|
29
32
|
|
|
30
33
|
## Что такое Intlayer?
|
|
31
34
|
|
|
32
|
-
**Intlayer** — это инновационная, открытая библиотека
|
|
35
|
+
**Intlayer** — это инновационная, открытая библиотека интернационализации, созданная для устранения недостатков традиционных решений i18n. Она предлагает современный подход к управлению контентом в JavaScript-приложениях.
|
|
33
36
|
|
|
34
37
|
Смотрите конкретное сравнение с i18next в нашем блоге [next-i18next vs. next-intl vs. Intlayer](https://github.com/aymericzip/intlayer/blob/main/docs/blog/ru/next-i18next_vs_next-intl_vs_intlayer.md).
|
|
35
38
|
|
|
36
39
|
## Почему стоит сочетать Intlayer с i18next?
|
|
37
40
|
|
|
38
|
-
Хотя Intlayer предоставляет отличное самостоятельное решение для i18n (см. наше руководство по интеграции с Next.js
|
|
41
|
+
Хотя Intlayer предоставляет отличное самостоятельное решение для i18n (см. наше [руководство по интеграции с Next.js](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ru/intlayer_with_nextjs_16.md)), вы можете захотеть объединить его с i18next по нескольким причинам:
|
|
39
42
|
|
|
40
|
-
1. **Существующая кодовая база**: У вас уже есть реализованная система i18next, и вы хотите постепенно перейти на улучшенный опыт
|
|
43
|
+
1. **Существующая кодовая база**: У вас уже есть реализованная система i18next, и вы хотите постепенно перейти на улучшенный опыт разработчика с Intlayer.
|
|
41
44
|
2. **Требования наследия**: Ваш проект требует совместимости с существующими плагинами или рабочими процессами i18next.
|
|
42
45
|
3. **Знакомство команды**: Ваша команда привыкла к i18next, но хочет улучшить управление контентом.
|
|
46
|
+
4. **Использование возможностей Intlayer**: Вы хотите использовать функции Intlayer, такие как декларация контента, управление ключами переводов, статус переводов и многое другое.
|
|
43
47
|
|
|
44
48
|
**Для этого Intlayer может быть реализован как адаптер для i18next, чтобы помочь автоматизировать ваши JSON-переводы в CLI или CI/CD пайплайнах, тестировать переводы и многое другое.**
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
Это руководство показывает, как использовать превосходную систему декларации контента Intlayer, сохраняя при этом совместимость с i18next.
|
|
47
51
|
|
|
48
52
|
## Содержание
|
|
49
53
|
|
|
@@ -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
|
**Описание пакетов:**
|
|
71
79
|
|
|
72
80
|
- **intlayer**: Основная библиотека для управления интернационализацией, декларации контента и сборки
|
|
@@ -76,7 +84,7 @@ yarn add intlayer @intlayer/sync-json-plugin
|
|
|
76
84
|
|
|
77
85
|
Создайте файл конфигурации Intlayer для определения поддерживаемых локалей:
|
|
78
86
|
|
|
79
|
-
**Если вы хотите
|
|
87
|
+
**Если вы также хотите экспортировать JSON-словари для i18next**, добавьте плагин `syncJSON`:
|
|
80
88
|
|
|
81
89
|
```typescript fileName="intlayer.config.ts"
|
|
82
90
|
import { Locales, type IntlayerConfig } from "intlayer";
|
|
@@ -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
|
};
|
|
@@ -97,14 +105,59 @@ const config: IntlayerConfig = {
|
|
|
97
105
|
export default config;
|
|
98
106
|
```
|
|
99
107
|
|
|
100
|
-
Плагин `syncJSON` автоматически обернет JSON. Он будет читать и записывать JSON-файлы без изменения архитектуры
|
|
108
|
+
Плагин `syncJSON` автоматически обернет JSON. Он будет читать и записывать JSON-файлы без изменения архитектуры содержимого.
|
|
109
|
+
|
|
110
|
+
Если вы хотите, чтобы JSON сосуществовал с файлами деклараций контента Intlayer (`.content` файлы), Intlayer будет работать следующим образом:
|
|
111
|
+
|
|
112
|
+
1. загрузит как JSON, так и файлы деклараций контента и преобразует их в словарь Intlayer.
|
|
113
|
+
2. если возникнут конфликты между JSON и файлами деклараций контента, Intlayer выполнит слияние всех этих словарей. В зависимости от приоритета плагинов и приоритета файла декларации контента (все настраивается).
|
|
114
|
+
|
|
115
|
+
Если изменения вносятся с помощью CLI для перевода JSON или с помощью CMS, Intlayer обновит JSON-файл с новыми переводами.
|
|
116
|
+
|
|
117
|
+
Чтобы узнать больше подробностей о плагине `syncJSON`, пожалуйста, обратитесь к [документации плагина syncJSON](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ru/plugins/sync-json.md).
|
|
118
|
+
|
|
119
|
+
### (Необязательно) Шаг 3: Реализация перевода JSON по компонентам
|
|
101
120
|
|
|
102
|
-
|
|
121
|
+
По умолчанию Intlayer загрузит, объединит и синхронизирует как JSON, так и файлы деклараций контента. Подробнее смотрите в [документации по декларации контента](https://github.com/aymericzip/intlayer/blob/main/docs/docs/ru/dictionary/content_file.md). Но если вы предпочитаете, используя плагин Intlayer, вы также можете реализовать управление локализованным JSON по компонентам в любом месте вашей кодовой базы.
|
|
103
122
|
|
|
104
|
-
|
|
105
|
-
2. если возникают конфликты между JSON и файлами декларации контента, Intlayer выполнит слияние всех словарей. В зависимости от приоритета плагинов и файла декларации контента (все настраивается).
|
|
123
|
+
Для этого вы можете использовать плагин `loadJSON`.
|
|
106
124
|
|
|
107
|
-
|
|
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
|
+
// Поддерживайте актуальность ваших текущих JSON файлов в соответствии со словарями Intlayer
|
|
136
|
+
plugins: [
|
|
137
|
+
/**
|
|
138
|
+
* Загрузит все JSON файлы в папке src, которые соответствуют шаблону {key}.i18n.json
|
|
139
|
+
*/
|
|
140
|
+
loadJSON({
|
|
141
|
+
source: ({ key }) => `./src/**/${key}.i18n.json`,
|
|
142
|
+
locale: Locales.ENGLISH,
|
|
143
|
+
priority: 1, // Обеспечивает приоритет этих JSON файлов над файлами в `./locales/en/${key}.json`
|
|
144
|
+
}),
|
|
145
|
+
/**
|
|
146
|
+
* Загрузит и запишет результат и переводы обратно в JSON файлы в директории locales
|
|
147
|
+
*/
|
|
148
|
+
syncJSON({
|
|
149
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
150
|
+
priority: 0,
|
|
151
|
+
}),
|
|
152
|
+
],
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export default config;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Это загрузит все JSON файлы в директории `src`, которые соответствуют шаблону `{key}.i18n.json`, и загрузит их как словари Intlayer.
|
|
159
|
+
|
|
160
|
+
---
|
|
108
161
|
|
|
109
162
|
## Конфигурация Git
|
|
110
163
|
|
|
@@ -115,10 +168,10 @@ export default config;
|
|
|
115
168
|
.intlayer
|
|
116
169
|
```
|
|
117
170
|
|
|
118
|
-
Эти файлы могут быть
|
|
171
|
+
Эти файлы могут быть воссозданы в процессе сборки и не требуют добавления в систему контроля версий.
|
|
119
172
|
|
|
120
173
|
### Расширение VS Code
|
|
121
174
|
|
|
122
175
|
Для улучшения опыта разработчика установите официальное **расширение Intlayer для VS Code**:
|
|
123
176
|
|
|
124
|
-
[Установить из
|
|
177
|
+
[Установить из VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|