@intlayer/docs 8.0.4 → 8.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/dist/cjs/blog.cjs +1 -0
- package/dist/cjs/blog.cjs.map +1 -1
- package/dist/cjs/common.cjs +1 -0
- package/dist/cjs/common.cjs.map +1 -1
- package/dist/cjs/doc.cjs +1 -0
- package/dist/cjs/doc.cjs.map +1 -1
- package/dist/cjs/frequentQuestions.cjs +1 -0
- package/dist/cjs/frequentQuestions.cjs.map +1 -1
- package/dist/cjs/generated/blog.entry.cjs +1 -0
- package/dist/cjs/generated/blog.entry.cjs.map +1 -1
- package/dist/cjs/generated/docs.entry.cjs +21 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/cjs/generated/frequentQuestions.entry.cjs +1 -0
- package/dist/cjs/generated/frequentQuestions.entry.cjs.map +1 -1
- package/dist/cjs/generated/legal.entry.cjs +1 -0
- package/dist/cjs/generated/legal.entry.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/legal.cjs +1 -0
- package/dist/cjs/legal.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +20 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/cli/doc-translate.md +1 -0
- package/docs/ar/cli/fill.md +1 -0
- package/docs/ar/configuration.md +10 -0
- package/docs/ar/intlayer_with_analog.md +371 -0
- package/docs/ar/intlayer_with_angular.md +12 -14
- package/docs/ar/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/de/agent_skills.md +53 -0
- package/docs/de/cli/doc-translate.md +1 -0
- package/docs/de/cli/fill.md +1 -0
- package/docs/de/configuration.md +10 -0
- package/docs/de/intlayer_with_analog.md +369 -0
- package/docs/de/intlayer_with_angular.md +11 -16
- package/docs/de/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/en/agent_skills.md +53 -0
- package/docs/en/cli/doc-translate.md +1 -0
- package/docs/en/cli/fill.md +1 -0
- package/docs/en/configuration.md +21 -1
- package/docs/en/intlayer_with_analog.md +4 -12
- package/docs/en/intlayer_with_angular.md +13 -15
- package/docs/en/packages/react-intlayer/useIntlayer.md +1 -1
- package/docs/en/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/en-GB/cli/doc-translate.md +1 -0
- package/docs/en-GB/cli/fill.md +1 -0
- package/docs/en-GB/configuration.md +10 -0
- package/docs/en-GB/intlayer_with_analog.md +369 -0
- package/docs/en-GB/intlayer_with_angular.md +12 -14
- package/docs/en-GB/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/es/agent_skills.md +53 -0
- package/docs/es/cli/doc-translate.md +1 -0
- package/docs/es/cli/fill.md +1 -0
- package/docs/es/configuration.md +10 -0
- package/docs/es/intlayer_with_analog.md +369 -0
- package/docs/es/intlayer_with_angular.md +11 -16
- package/docs/es/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/fr/agent_skills.md +53 -0
- package/docs/fr/cli/doc-translate.md +1 -0
- package/docs/fr/cli/fill.md +1 -0
- package/docs/fr/configuration.md +10 -0
- package/docs/fr/intlayer_with_analog.md +369 -0
- package/docs/fr/intlayer_with_angular.md +11 -16
- package/docs/fr/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/hi/cli/doc-translate.md +1 -0
- package/docs/hi/cli/fill.md +1 -0
- package/docs/hi/configuration.md +10 -0
- package/docs/hi/intlayer_with_analog.md +371 -0
- package/docs/hi/intlayer_with_angular.md +12 -14
- package/docs/hi/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/id/cli/doc-translate.md +1 -0
- package/docs/id/cli/fill.md +1 -0
- package/docs/id/configuration.md +10 -0
- package/docs/id/intlayer_with_analog.md +371 -0
- package/docs/id/intlayer_with_angular.md +12 -14
- package/docs/id/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/it/agent_skills.md +53 -0
- package/docs/it/cli/doc-translate.md +1 -0
- package/docs/it/cli/fill.md +1 -0
- package/docs/it/configuration.md +10 -0
- package/docs/it/intlayer_with_analog.md +371 -0
- package/docs/it/intlayer_with_angular.md +12 -14
- package/docs/it/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/ja/agent_skills.md +53 -0
- package/docs/ja/cli/doc-translate.md +1 -0
- package/docs/ja/cli/fill.md +1 -0
- package/docs/ja/configuration.md +10 -0
- package/docs/ja/intlayer_with_analog.md +365 -0
- package/docs/ja/intlayer_with_angular.md +12 -14
- package/docs/ja/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/ko/agent_skills.md +53 -0
- package/docs/ko/cli/doc-translate.md +1 -0
- package/docs/ko/cli/fill.md +1 -0
- package/docs/ko/configuration.md +10 -0
- package/docs/ko/intlayer_with_analog.md +365 -0
- package/docs/ko/intlayer_with_angular.md +12 -14
- package/docs/ko/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/pl/cli/doc-translate.md +1 -0
- package/docs/pl/cli/fill.md +1 -0
- package/docs/pl/configuration.md +10 -0
- package/docs/pl/intlayer_with_analog.md +371 -0
- package/docs/pl/intlayer_with_angular.md +12 -14
- package/docs/pl/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/pt/agent_skills.md +53 -0
- package/docs/pt/cli/doc-translate.md +1 -0
- package/docs/pt/cli/fill.md +1 -0
- package/docs/pt/configuration.md +10 -0
- package/docs/pt/intlayer_with_analog.md +371 -0
- package/docs/pt/intlayer_with_angular.md +12 -14
- package/docs/pt/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/ru/cli/doc-translate.md +1 -0
- package/docs/ru/cli/fill.md +1 -0
- package/docs/ru/configuration.md +18 -0
- package/docs/ru/intlayer_with_analog.md +371 -0
- package/docs/ru/intlayer_with_angular.md +12 -14
- package/docs/ru/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/tr/cli/doc-translate.md +1 -0
- package/docs/tr/cli/fill.md +1 -0
- package/docs/tr/configuration.md +10 -0
- package/docs/tr/intlayer_with_analog.md +365 -0
- package/docs/tr/intlayer_with_angular.md +12 -14
- package/docs/tr/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/uk/cli/doc-translate.md +1 -0
- package/docs/uk/cli/fill.md +1 -0
- package/docs/uk/configuration.md +10 -0
- package/docs/uk/intlayer_with_analog.md +365 -0
- package/docs/uk/intlayer_with_angular.md +12 -14
- package/docs/uk/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/vi/configuration.md +10 -0
- package/docs/vi/intlayer_with_analog.md +365 -0
- package/docs/vi/intlayer_with_angular.md +12 -14
- package/docs/vi/packages/solid-intlayer/useIntlayer.md +1 -1
- package/docs/zh/agent_skills.md +53 -0
- package/docs/zh/configuration.md +10 -0
- package/docs/zh/intlayer_with_analog.md +365 -0
- package/docs/zh/intlayer_with_angular.md +12 -14
- package/docs/zh/packages/solid-intlayer/useIntlayer.md +1 -1
- package/package.json +8 -8
- package/src/generated/docs.entry.ts +20 -0
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-04-18
|
|
3
|
+
updatedAt: 2025-12-30
|
|
4
|
+
title: Analog i18n - Como traduzir sua aplicação Analog – guia 2026
|
|
5
|
+
description: Descubra como tornar sua aplicação Analog multilíngue. Siga a documentação para internacionalizar (i18n) e traduzi-la.
|
|
6
|
+
keywords:
|
|
7
|
+
- Internacionalização
|
|
8
|
+
- Documentação
|
|
9
|
+
- Intlayer
|
|
10
|
+
- Analog
|
|
11
|
+
- Angular
|
|
12
|
+
- JavaScript
|
|
13
|
+
slugs:
|
|
14
|
+
- doc
|
|
15
|
+
- environment
|
|
16
|
+
- analog
|
|
17
|
+
applicationTemplate: https://github.com/aymericzip/intlayer/tree/main/examples/analog-app-template
|
|
18
|
+
history:
|
|
19
|
+
- version: 8.0.4
|
|
20
|
+
date: 2026-01-26
|
|
21
|
+
changes: Iniciar histórico
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
# Traduza sua aplicação Analog (Angular) usando Intlayer | Internacionalização (i18n)
|
|
25
|
+
|
|
26
|
+
## Sumário
|
|
27
|
+
|
|
28
|
+
<TOC/>
|
|
29
|
+
|
|
30
|
+
## O que é Intlayer?
|
|
31
|
+
|
|
32
|
+
**Intlayer** é uma biblioteca de internacionalização (i18n) inovadora e de código aberto, projetada para simplificar o suporte multilíngue em aplicações web modernas.
|
|
33
|
+
|
|
34
|
+
Com o Intlayer, você pode:
|
|
35
|
+
|
|
36
|
+
- **Gerenciar traduções facilmente** usando dicionários declarativos ao nível do componente.
|
|
37
|
+
- **Localizar metadados, rotas e conteúdo dinamicamente**.
|
|
38
|
+
- **Garantir suporte ao TypeScript** com tipos autogerados, melhorando o autocompletar e a detecção de erros.
|
|
39
|
+
- **Beneficiar-se de recursos avançados**, como detecção e troca dinâmica de idioma (locale).
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Guia Passo a Passo para Configurar o Intlayer em uma Aplicação Analog
|
|
44
|
+
|
|
45
|
+
<Tabs defaultTab="code">
|
|
46
|
+
<Tab label="Código" value="code">
|
|
47
|
+
|
|
48
|
+
<iframe
|
|
49
|
+
src="https://stackblitz.com/github/aymericzip/intlayer/tree/main/examples/vite-analog-app?embed=1&ctl=1&file=intlayer.config.ts"
|
|
50
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
51
|
+
title="Demo CodeSandbox - Como Internacionalizar sua aplicação usando Intlayer"
|
|
52
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
53
|
+
loading="lazy"
|
|
54
|
+
/>
|
|
55
|
+
|
|
56
|
+
</Tab>
|
|
57
|
+
</Tabs>
|
|
58
|
+
|
|
59
|
+
Veja o [Modelo de Aplicação](https://github.com/aymericzip/intlayer/tree/main/examples/analog-app-template) no GitHub.
|
|
60
|
+
|
|
61
|
+
### Passo 1: Instalar Dependências
|
|
62
|
+
|
|
63
|
+
Instale os pacotes necessários usando npm:
|
|
64
|
+
|
|
65
|
+
```bash packageManager="npm"
|
|
66
|
+
npm install intlayer angular-intlayer vite-intlayer
|
|
67
|
+
npx intlayer init
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```bash packageManager="pnpm"
|
|
71
|
+
pnpm add intlayer angular-intlayer vite-intlayer
|
|
72
|
+
pnpm intlayer init
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```bash packageManager="yarn"
|
|
76
|
+
yarn add intlayer angular-intlayer vite-intlayer
|
|
77
|
+
yarn intlayer init
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```bash packageManager="bun"
|
|
81
|
+
bun add intlayer angular-intlayer vite-intlayer
|
|
82
|
+
bunx intlayer init
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- **intlayer**
|
|
86
|
+
|
|
87
|
+
O pacote principal que fornece ferramentas de internacionalização para gerenciamento de configuração, tradução, [declaração de conteúdo](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/content_file.md), transpilação e [comandos CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/cli/index.md).
|
|
88
|
+
|
|
89
|
+
- **angular-intlayer**
|
|
90
|
+
O pacote que integra o Intlayer com aplicações Angular. Ele fornece provedores de contexto e hooks para internacionalização Angular.
|
|
91
|
+
|
|
92
|
+
- **vite-intlayer**
|
|
93
|
+
O pacote que integra o Intlayer com o Vite. Ele fornece um plugin para lidar com arquivos de declaração de conteúdo e configura aliases para um desempenho ideal.
|
|
94
|
+
|
|
95
|
+
### Passo 2: Configuração do seu projeto
|
|
96
|
+
|
|
97
|
+
Crie um arquivo de configuração para configurar os idiomas da sua aplicação:
|
|
98
|
+
|
|
99
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
100
|
+
import { Locales, type IntlayerConfig } from "intlayer";
|
|
101
|
+
|
|
102
|
+
const config: IntlayerConfig = {
|
|
103
|
+
internationalization: {
|
|
104
|
+
locales: [
|
|
105
|
+
Locales.ENGLISH,
|
|
106
|
+
Locales.FRENCH,
|
|
107
|
+
Locales.SPANISH,
|
|
108
|
+
// Seus outros idiomas
|
|
109
|
+
],
|
|
110
|
+
defaultLocale: Locales.ENGLISH,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default config;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
118
|
+
import { Locales } from "intlayer";
|
|
119
|
+
|
|
120
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
121
|
+
const config = {
|
|
122
|
+
internationalization: {
|
|
123
|
+
locales: [
|
|
124
|
+
Locales.ENGLISH,
|
|
125
|
+
Locales.FRENCH,
|
|
126
|
+
Locales.SPANISH,
|
|
127
|
+
// Seus outros idiomas
|
|
128
|
+
],
|
|
129
|
+
defaultLocale: Locales.ENGLISH,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export default config;
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
137
|
+
const { Locales } = require("intlayer");
|
|
138
|
+
|
|
139
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
140
|
+
const config = {
|
|
141
|
+
internationalization: {
|
|
142
|
+
locales: [
|
|
143
|
+
Locales.ENGLISH,
|
|
144
|
+
Locales.FRENCH,
|
|
145
|
+
Locales.SPANISH,
|
|
146
|
+
// Seus outros idiomas
|
|
147
|
+
],
|
|
148
|
+
defaultLocale: Locales.ENGLISH,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
module.exports = config;
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
> Através deste arquivo de configuração, você pode configurar URLs localizadas, redirecionamento de middleware, nomes de cookies, a localização e extensão das suas declarações de conteúdo, desativar os logs do Intlayer no console e muito mais. Para uma lista completa de parâmetros disponíveis, consulte a [documentação de configuração](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/configuration.md).
|
|
156
|
+
|
|
157
|
+
### Passo 3: Integrar o Intlayer na sua Configuração do Vite
|
|
158
|
+
|
|
159
|
+
Para integrar o Intlayer com o Analog, você precisa usar o plugin `vite-intlayer`.
|
|
160
|
+
|
|
161
|
+
Modifique seu arquivo `vite.config.ts`:
|
|
162
|
+
|
|
163
|
+
```typescript fileName="vite.config.ts"
|
|
164
|
+
import { defineConfig } from "vite";
|
|
165
|
+
import { intlayer } from "vite-intlayer";
|
|
166
|
+
import analog from "@analogjs/platform";
|
|
167
|
+
|
|
168
|
+
// https://vitejs.dev/config/
|
|
169
|
+
export default defineConfig(() => ({
|
|
170
|
+
plugins: [
|
|
171
|
+
analog(),
|
|
172
|
+
intlayer(), // Adicione o plugin Intlayer
|
|
173
|
+
],
|
|
174
|
+
}));
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
> O plugin `intlayer()` configura o Vite com o Intlayer. Ele lida com arquivos de declaração de conteúdo e configura aliases para um desempenho ideal.
|
|
178
|
+
|
|
179
|
+
### Passo 4: Declarar seu Conteúdo
|
|
180
|
+
|
|
181
|
+
Crie e gerencie suas declarações de conteúdo para armazenar traduções:
|
|
182
|
+
|
|
183
|
+
```tsx fileName="src/app/app.content.ts" contentDeclarationFormat="typescript"
|
|
184
|
+
import { t, type Dictionary } from "intlayer";
|
|
185
|
+
|
|
186
|
+
const appContent = {
|
|
187
|
+
key: "app",
|
|
188
|
+
content: {
|
|
189
|
+
title: t({
|
|
190
|
+
en: "Hello",
|
|
191
|
+
fr: "Bonjour",
|
|
192
|
+
es: "Hola",
|
|
193
|
+
pt: "Olá",
|
|
194
|
+
}),
|
|
195
|
+
congratulations: t({
|
|
196
|
+
en: "Congratulations! Your app is running. 🎉",
|
|
197
|
+
fr: "Félicitations! Votre application est en cours d'exécution. 🎉",
|
|
198
|
+
es: "¡Felicidades! Tu aplicación está en ejecución. 🎉",
|
|
199
|
+
pt: "Parabéns! Sua aplicação está funcionando. 🎉",
|
|
200
|
+
}),
|
|
201
|
+
},
|
|
202
|
+
} satisfies Dictionary;
|
|
203
|
+
|
|
204
|
+
export default appContent;
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
> Suas declarações de conteúdo podem ser definidas em qualquer lugar da sua aplicação, desde que estejam incluídas no diretório `contentDir` (por padrão, `./src`) e correspondam à extensão do arquivo de declaração de conteúdo (por padrão, `.content.{json,ts,tsx,js,jsx,mjs,cjs}`).
|
|
208
|
+
|
|
209
|
+
> Para mais detalhes, consulte a [documentação de declaração de conteúdo](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/content_file.md).
|
|
210
|
+
|
|
211
|
+
### Passo 5: Utilizar o Intlayer em seu Código
|
|
212
|
+
|
|
213
|
+
Para utilizar os recursos de internacionalização do Intlayer em toda a sua aplicação Analog, você precisa fornecer o Intlayer na configuração da sua aplicação.
|
|
214
|
+
|
|
215
|
+
```typescript fileName="src/app/app.config.ts"
|
|
216
|
+
import { ApplicationConfig } from "@angular/core";
|
|
217
|
+
import { provideIntlayer } from "angular-intlayer";
|
|
218
|
+
|
|
219
|
+
export const appConfig: ApplicationConfig = {
|
|
220
|
+
providers: [
|
|
221
|
+
provideIntlayer(), // Adicione o provedor Intlayer aqui
|
|
222
|
+
],
|
|
223
|
+
};
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Então, você pode usar a função `useIntlayer` dentro de qualquer componente.
|
|
227
|
+
|
|
228
|
+
```typescript fileName="src/app/pages/index.page.ts"
|
|
229
|
+
import { Component } from "@angular/core";
|
|
230
|
+
import { useIntlayer } from "angular-intlayer";
|
|
231
|
+
|
|
232
|
+
@Component({
|
|
233
|
+
selector: "app-home",
|
|
234
|
+
standalone: true,
|
|
235
|
+
template: `
|
|
236
|
+
<div class="content">
|
|
237
|
+
<h1>{{ content().title }}</h1>
|
|
238
|
+
<p>{{ content().congratulations }}</p>
|
|
239
|
+
</div>
|
|
240
|
+
`,
|
|
241
|
+
})
|
|
242
|
+
export default class HomeComponent {
|
|
243
|
+
content = useIntlayer("app");
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
O conteúdo do Intlayer é retornado como um `Signal`, então você acessa os valores chamando o sinal: `content().title`.
|
|
248
|
+
|
|
249
|
+
### (Opcional) Passo 6: Alterar o idioma do seu conteúdo
|
|
250
|
+
|
|
251
|
+
Para alterar o idioma do seu conteúdo, você pode usar a função `setLocale` fornecida pela função `useLocale`. Isso permite que você defina o idioma da aplicação e atualize o conteúdo adequadamente.
|
|
252
|
+
|
|
253
|
+
Crie um componente para alternar entre idiomas:
|
|
254
|
+
|
|
255
|
+
```typescript fileName="src/app/locale-switcher.component.ts"
|
|
256
|
+
import { Component } from "@angular/core";
|
|
257
|
+
import { CommonModule } from "@angular/common";
|
|
258
|
+
import { useLocale } from "angular-intlayer";
|
|
259
|
+
|
|
260
|
+
@Component({
|
|
261
|
+
selector: "app-locale-switcher",
|
|
262
|
+
standalone: true,
|
|
263
|
+
imports: [CommonModule],
|
|
264
|
+
template: `
|
|
265
|
+
<div class="locale-switcher">
|
|
266
|
+
<select
|
|
267
|
+
[value]="locale()"
|
|
268
|
+
(change)="setLocale($any($event.target).value)"
|
|
269
|
+
>
|
|
270
|
+
@for (loc of availableLocales; track loc) {
|
|
271
|
+
<option [value]="loc">{{ loc }}</option>
|
|
272
|
+
}
|
|
273
|
+
</select>
|
|
274
|
+
</div>
|
|
275
|
+
`,
|
|
276
|
+
styles: [
|
|
277
|
+
`
|
|
278
|
+
.locale-switcher {
|
|
279
|
+
margin: 1rem;
|
|
280
|
+
padding: 0.5rem;
|
|
281
|
+
border: 1px solid #ccc;
|
|
282
|
+
border-radius: 4px;
|
|
283
|
+
width: fit-content;
|
|
284
|
+
}
|
|
285
|
+
`,
|
|
286
|
+
],
|
|
287
|
+
})
|
|
288
|
+
export class LocaleSwitcherComponent {
|
|
289
|
+
localeCtx = useLocale();
|
|
290
|
+
|
|
291
|
+
locale = this.localeCtx.locale;
|
|
292
|
+
availableLocales = this.localeCtx.availableLocales;
|
|
293
|
+
setLocale = this.localeCtx.setLocale;
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Então, use este componente em suas páginas:
|
|
298
|
+
|
|
299
|
+
```typescript fileName="src/app/pages/index.page.ts"
|
|
300
|
+
import { Component } from "@angular/core";
|
|
301
|
+
import { useIntlayer } from "angular-intlayer";
|
|
302
|
+
import { LocaleSwitcherComponent } from "../locale-switcher.component";
|
|
303
|
+
|
|
304
|
+
@Component({
|
|
305
|
+
selector: "app-home",
|
|
306
|
+
standalone: true,
|
|
307
|
+
imports: [LocaleSwitcherComponent],
|
|
308
|
+
template: `
|
|
309
|
+
<app-locale-switcher></app-locale-switcher>
|
|
310
|
+
<div class="content">
|
|
311
|
+
<h1>{{ content().title }}</h1>
|
|
312
|
+
<p>{{ content().congratulations }}</p>
|
|
313
|
+
</div>
|
|
314
|
+
`,
|
|
315
|
+
})
|
|
316
|
+
export default class HomeComponent {
|
|
317
|
+
content = useIntlayer("app");
|
|
318
|
+
}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Configurar TypeScript
|
|
322
|
+
|
|
323
|
+
O Intlayer usa o aumento de módulo (module augmentation) para obter benefícios do TypeScript e tornar sua base de código mais robusta.
|
|
324
|
+
|
|
325
|
+

|
|
326
|
+
|
|
327
|
+

|
|
328
|
+
|
|
329
|
+
Certifique-se de que sua configuração do TypeScript inclua os tipos autogerados.
|
|
330
|
+
|
|
331
|
+
```json5 fileName="tsconfig.json"
|
|
332
|
+
{
|
|
333
|
+
// ... Suas configurações existentes do TypeScript
|
|
334
|
+
"include": [
|
|
335
|
+
// ... Suas configurações existentes do TypeScript
|
|
336
|
+
".intlayer/**/*.ts", // Incluir os tipos autogerados
|
|
337
|
+
],
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### Configuração do Git
|
|
342
|
+
|
|
343
|
+
Recomenda-se ignorar os arquivos gerados pelo Intlayer. Isso permite que você evite commitá-los no seu repositório Git.
|
|
344
|
+
|
|
345
|
+
Para fazer isso, você pode adicionar as seguintes instruções ao seu arquivo `.gitignore`:
|
|
346
|
+
|
|
347
|
+
```plaintext
|
|
348
|
+
# Ignorar os arquivos gerados pelo Intlayer
|
|
349
|
+
.intlayer
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Extensão do VS Code
|
|
353
|
+
|
|
354
|
+
Para melhorar sua experiência de desenvolvimento com o Intlayer, você pode instalar a **Extensão oficial do Intlayer para o VS Code**.
|
|
355
|
+
|
|
356
|
+
[Instalar a partir do VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
357
|
+
|
|
358
|
+
Esta extensão fornece:
|
|
359
|
+
|
|
360
|
+
- **Autocompletar** para chaves de tradução.
|
|
361
|
+
- **Detecção de erros em tempo real** para traduções ausentes.
|
|
362
|
+
- **Visualizações inline** do conteúdo traduzido.
|
|
363
|
+
- **Ações rápidas** para criar e atualizar traduções facilmente.
|
|
364
|
+
|
|
365
|
+
Para mais detalhes sobre como usar a extensão, consulte a [documentação da Extensão Intlayer para o VS Code](https://intlayer.org/doc/vs-code-extension).
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
### Indo Além
|
|
370
|
+
|
|
371
|
+
Para ir além, você pode implementar o [editor visual](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_visual_editor.md) ou externalizar seu conteúdo usando o [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_CMS.md).
|
|
@@ -166,30 +166,28 @@ Para integrar o Intlayer com o Angular CLI, você precisa usar um builder person
|
|
|
166
166
|
|
|
167
167
|
Primeiro, modifique seu `angular.json` para usar o builder personalizado do Webpack. Atualize as configurações de `build` e `serve`:
|
|
168
168
|
|
|
169
|
-
```
|
|
169
|
+
```json5 fileName="angular.json"
|
|
170
170
|
{
|
|
171
171
|
"projects": {
|
|
172
172
|
"your-app-name": {
|
|
173
173
|
"architect": {
|
|
174
174
|
"build": {
|
|
175
|
-
"builder": "@angular-builders/custom-webpack:browser",
|
|
175
|
+
"builder": "@angular-builders/custom-webpack:browser", // replace "@angular-devkit/build-angular:application",
|
|
176
176
|
"options": {
|
|
177
177
|
"customWebpackConfig": {
|
|
178
|
-
"path": "./webpack.config.ts"
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
"path": "./webpack.config.ts",
|
|
179
|
+
"mergeStrategies": { "module.rules": "prepend" },
|
|
180
|
+
},
|
|
181
|
+
"main": "src/main.ts", // replace "browser": "src/main.ts",
|
|
182
|
+
// ...
|
|
183
|
+
},
|
|
181
184
|
},
|
|
182
185
|
"serve": {
|
|
183
186
|
"builder": "@angular-builders/custom-webpack:dev-server",
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
},
|
|
193
191
|
}
|
|
194
192
|
```
|
|
195
193
|
|
|
@@ -33,7 +33,7 @@ O hook `useIntlayer` permite recuperar conteúdo localizado de um dicionário us
|
|
|
33
33
|
import { useIntlayer } from "solid-intlayer";
|
|
34
34
|
|
|
35
35
|
const MyComponent = () => {
|
|
36
|
-
const content = useIntlayer("
|
|
36
|
+
const content = useIntlayer("my-dictionary-key");
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
39
|
<div>
|
|
@@ -86,6 +86,7 @@ npx intlayer doc translate
|
|
|
86
86
|
- **`--temperature [temperature]`**: Параметр температуры для модели ИИ.
|
|
87
87
|
- **`--api-key [apiKey]`**: Предоставьте свой собственный API-ключ для сервиса ИИ.
|
|
88
88
|
- **`--application-context [applicationContext]`**: Предоставьте дополнительный контекст для перевода ИИ.
|
|
89
|
+
- **`--data-serialization [dataSerialization]`**: Формат сериализации данных для использования в функциях ИИ Intlayer. Опции: `json` (стандартный, надежный), `toon` (меньше токенов, менее стабильный).
|
|
89
90
|
- **`--custom-prompt [prompt]`**: Настройка базового запроса, используемого для перевода. (Примечание: для большинства случаев рекомендуется использовать опцию `--custom-instructions`, так как она обеспечивает лучший контроль над поведением перевода.)
|
|
90
91
|
|
|
91
92
|
> Пример: `npx intlayer doc translate --model deepseek-chat --provider deepseek --temperature 0.5 --api-key sk-1234567890 --application-context "Мое приложение — магазин для кошек"`
|
package/docs/ru/cli/fill.md
CHANGED
|
@@ -126,6 +126,7 @@ Affected dictionary keys for processing: app, comp-test, hello-world, lang-switc
|
|
|
126
126
|
- **`--api-key [apiKey]`**: Предоставить собственный API-ключ для сервиса ИИ.
|
|
127
127
|
- **`--custom-prompt [prompt]`**: Предоставить пользовательский запрос для инструкций по переводу.
|
|
128
128
|
- **`--application-context [applicationContext]`**: Предоставить дополнительный контекст для перевода ИИ.
|
|
129
|
+
- **`--data-serialization [dataSerialization]`**: Формат сериализации данных для использования в функциях ИИ Intlayer. Опции: `json` (стандартный, надежный), `toon` (меньше токенов, менее стабильный).
|
|
129
130
|
|
|
130
131
|
> Пример: `npx intlayer fill --model gpt-3.5-turbo --provider openai --temperature 0.5 --api-key sk-1234567890 --application-context "Моё приложение — магазин для кошек"`
|
|
131
132
|
|
package/docs/ru/configuration.md
CHANGED
|
@@ -14,6 +14,9 @@ slugs:
|
|
|
14
14
|
- concept
|
|
15
15
|
- configuration
|
|
16
16
|
history:
|
|
17
|
+
- version: 8.0.5
|
|
18
|
+
date: 2026-02-06
|
|
19
|
+
changes: Добавление `dataSerialization` в конфигурацию ИИ
|
|
17
20
|
- version: 8.0.0
|
|
18
21
|
date: 2026-01-22
|
|
19
22
|
changes: Move `importMode` build configuration to `dictionary` configuration.
|
|
@@ -311,6 +314,14 @@ const config: IntlayerConfig = {
|
|
|
311
314
|
* Base URL for the AI API.
|
|
312
315
|
*/
|
|
313
316
|
baseURL: "http://localhost:3000",
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Data serialization format to use for the AI features of Intlayer.
|
|
320
|
+
* - "json": The industry standard. Highly reliable and structured, but consumes more tokens.
|
|
321
|
+
* - "toon": An optimized format designed to reduce token consumption (cost-effective). However, it may slightly increase the risk of output inconsistency compared to standard JSON
|
|
322
|
+
* Default: "json"
|
|
323
|
+
*/
|
|
324
|
+
dataSerialization: "json",
|
|
314
325
|
},
|
|
315
326
|
|
|
316
327
|
/**
|
|
@@ -892,6 +903,13 @@ Intlayer поддерживает несколько провайдеров ИИ
|
|
|
892
903
|
- _Пример_: `'https://api.openai.com/v1'`
|
|
893
904
|
- _Примечание_: Может использоваться для указания локальной или пользовательской конечной точки API ИИ.
|
|
894
905
|
|
|
906
|
+
- **dataSerialization**:
|
|
907
|
+
- _Тип_: `'json' | 'toon'`
|
|
908
|
+
- _По умолчанию_: `'json'`
|
|
909
|
+
- _Описание_: Формат сериализации данных для использования в функциях ИИ Intlayer.
|
|
910
|
+
- _Пример_: `'toon'`
|
|
911
|
+
- _Примечание_: `json`: Стандартный, надежный; использует больше токенов. `toon`: Меньше токенов, менее стабильный, чем JSON.
|
|
912
|
+
|
|
895
913
|
### Конфигурация сборки
|
|
896
914
|
|
|
897
915
|
Настройки, которые контролируют, как Intlayer оптимизирует и собирает интернационализацию вашего приложения.
|