@intlayer/docs 7.3.11 → 7.3.13
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/generated/docs.entry.cjs +19 -0
- package/dist/cjs/generated/docs.entry.cjs.map +1 -1
- package/dist/esm/generated/docs.entry.mjs +19 -0
- package/dist/esm/generated/docs.entry.mjs.map +1 -1
- package/dist/types/generated/docs.entry.d.ts +1 -0
- package/dist/types/generated/docs.entry.d.ts.map +1 -1
- package/docs/ar/intlayer_with_nuxt.md +294 -438
- package/docs/ar/intlayer_with_react_router_v7.md +33 -4
- package/docs/ar/intlayer_with_react_router_v7_fs_routes.md +516 -0
- package/docs/ar/intlayer_with_tanstack.md +2 -12
- package/docs/ar/intlayer_with_vite+vue.md +1 -0
- package/docs/de/intlayer_with_nuxt.md +284 -410
- package/docs/de/intlayer_with_react_router_v7.md +33 -4
- package/docs/de/intlayer_with_react_router_v7_fs_routes.md +573 -0
- package/docs/de/intlayer_with_tanstack.md +1 -0
- package/docs/de/intlayer_with_vite+vue.md +1 -0
- package/docs/en/intlayer_with_nuxt.md +237 -341
- package/docs/en/intlayer_with_react_router_v7.md +24 -0
- package/docs/en/intlayer_with_react_router_v7_fs_routes.md +570 -0
- package/docs/en/intlayer_with_tanstack.md +2 -12
- package/docs/en/intlayer_with_vite+vue.md +49 -48
- package/docs/en-GB/intlayer_with_nuxt.md +254 -378
- package/docs/en-GB/intlayer_with_react_router_v7.md +33 -4
- package/docs/en-GB/intlayer_with_react_router_v7_fs_routes.md +513 -0
- package/docs/en-GB/intlayer_with_tanstack.md +2 -12
- package/docs/en-GB/intlayer_with_vite+vue.md +1 -0
- package/docs/es/intlayer_with_nuxt.md +271 -390
- package/docs/es/intlayer_with_react_router_v7.md +33 -4
- package/docs/es/intlayer_with_react_router_v7_fs_routes.md +575 -0
- package/docs/es/intlayer_with_tanstack.md +1 -0
- package/docs/es/intlayer_with_vite+vue.md +1 -2
- package/docs/fr/intlayer_with_nuxt.md +278 -405
- package/docs/fr/intlayer_with_react_router_v7.md +34 -5
- package/docs/fr/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/fr/intlayer_with_tanstack.md +1 -0
- package/docs/fr/intlayer_with_vite+vue.md +1 -0
- package/docs/hi/intlayer_with_nuxt.md +303 -447
- package/docs/hi/intlayer_with_react_router_v7.md +33 -4
- package/docs/hi/intlayer_with_react_router_v7_fs_routes.md +518 -0
- package/docs/hi/intlayer_with_tanstack.md +2 -12
- package/docs/hi/intlayer_with_vite+vue.md +1 -0
- package/docs/id/intlayer_with_nuxt.md +266 -395
- package/docs/id/intlayer_with_react_router_v7.md +29 -4
- package/docs/id/intlayer_with_react_router_v7_fs_routes.md +521 -0
- package/docs/id/intlayer_with_tanstack.md +2 -12
- package/docs/id/intlayer_with_vite+vue.md +1 -0
- package/docs/it/intlayer_with_nuxt.md +299 -423
- package/docs/it/intlayer_with_react_router_v7.md +33 -4
- package/docs/it/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/it/intlayer_with_tanstack.md +1 -0
- package/docs/ja/intlayer_with_nuxt.md +309 -432
- package/docs/ja/intlayer_with_react_router_v7.md +33 -4
- package/docs/ja/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/ja/intlayer_with_tanstack.md +2 -12
- package/docs/ja/intlayer_with_vite+vue.md +1 -0
- package/docs/ko/intlayer_with_nuxt.md +295 -422
- package/docs/ko/intlayer_with_react_router_v7.md +33 -4
- package/docs/ko/intlayer_with_react_router_v7_fs_routes.md +515 -0
- package/docs/ko/intlayer_with_tanstack.md +2 -12
- package/docs/ko/intlayer_with_vite+vue.md +1 -0
- package/docs/pl/intlayer_with_nuxt.md +273 -476
- package/docs/pl/intlayer_with_react_router_v7.md +32 -5
- package/docs/pl/intlayer_with_react_router_v7_fs_routes.md +615 -0
- package/docs/pl/intlayer_with_tanstack.md +2 -12
- package/docs/pl/intlayer_with_vite+vue.md +1 -0
- package/docs/pt/intlayer_with_nuxt.md +277 -420
- package/docs/pt/intlayer_with_react_router_v7.md +28 -0
- package/docs/pt/intlayer_with_tanstack.md +1 -0
- package/docs/ru/intlayer_with_nuxt.md +287 -425
- package/docs/ru/intlayer_with_react_router_v7.md +33 -4
- package/docs/ru/intlayer_with_react_router_v7_fs_routes.md +574 -0
- package/docs/ru/intlayer_with_tanstack.md +1 -0
- package/docs/ru/intlayer_with_vite+vue.md +1 -0
- package/docs/tr/intlayer_with_nuxt.md +313 -406
- package/docs/tr/intlayer_with_react_router_v7.md +33 -4
- package/docs/tr/intlayer_with_react_router_v7_fs_routes.md +572 -0
- package/docs/tr/intlayer_with_tanstack.md +2 -12
- package/docs/tr/intlayer_with_vite+vue.md +1 -0
- package/docs/vi/intlayer_with_nuxt.md +273 -418
- package/docs/vi/intlayer_with_react_router_v7.md +29 -4
- package/docs/vi/intlayer_with_react_router_v7_fs_routes.md +523 -0
- package/docs/vi/intlayer_with_tanstack.md +2 -12
- package/docs/vi/intlayer_with_vite+vue.md +1 -0
- package/docs/zh/intlayer_with_nuxt.md +300 -461
- package/docs/zh/intlayer_with_react_router_v7.md +33 -4
- package/docs/zh/intlayer_with_react_router_v7_fs_routes.md +516 -0
- package/docs/zh/intlayer_with_tanstack.md +2 -12
- package/docs/zh/intlayer_with_vite+vue.md +1 -0
- package/package.json +10 -11
- package/src/generated/docs.entry.ts +19 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-06-18
|
|
3
|
-
updatedAt: 2025-
|
|
4
|
-
title: Como traduzir
|
|
3
|
+
updatedAt: 2025-12-07
|
|
4
|
+
title: Como traduzir sua aplicação Nuxt e Vue – guia i18n 2025
|
|
5
5
|
description: Descubra como tornar seu site Nuxt e Vue multilíngue. Siga a documentação para internacionalizar (i18n) e traduzir.
|
|
6
6
|
keywords:
|
|
7
7
|
- Internacionalização
|
|
@@ -14,31 +14,58 @@ slugs:
|
|
|
14
14
|
- doc
|
|
15
15
|
- environment
|
|
16
16
|
- nuxt-and-vue
|
|
17
|
-
applicationTemplate: https://github.com/aymericzip/intlayer-nuxt-template
|
|
17
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-nuxt-4-template
|
|
18
|
+
youtubeVideo: https://www.youtube.com/watch?v=nhUcUAVQ6eQ
|
|
18
19
|
history:
|
|
20
|
+
- version: 7.3.11
|
|
21
|
+
date: 2025-12-07
|
|
22
|
+
changes: Atualização do LocaleSwitcher, SEO, metadados
|
|
19
23
|
- version: 5.5.10
|
|
20
24
|
date: 2025-06-29
|
|
21
25
|
changes: Histórico inicial
|
|
22
26
|
---
|
|
23
27
|
|
|
24
|
-
# Traduza seu Nuxt
|
|
28
|
+
# Traduza seu site Nuxt e Vue usando Intlayer | Internacionalização (i18n)
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
## Índice
|
|
31
|
+
|
|
32
|
+
<TOC/>
|
|
27
33
|
|
|
28
34
|
## O que é Intlayer?
|
|
29
35
|
|
|
30
|
-
**Intlayer** é uma biblioteca inovadora e de
|
|
36
|
+
**Intlayer** é uma biblioteca inovadora e open-source de internacionalização (i18n) projetada para simplificar o suporte multilíngue em aplicações web modernas.
|
|
31
37
|
|
|
32
38
|
Com o Intlayer, você pode:
|
|
33
39
|
|
|
34
40
|
- **Gerenciar traduções facilmente** usando dicionários declarativos no nível do componente.
|
|
35
41
|
- **Localizar dinamicamente metadados**, rotas e conteúdo.
|
|
36
42
|
- **Garantir suporte ao TypeScript** com tipos gerados automaticamente, melhorando o autocompletar e a detecção de erros.
|
|
37
|
-
- **Aproveitar recursos avançados**, como detecção e troca
|
|
43
|
+
- **Aproveitar recursos avançados**, como detecção dinâmica de locale e troca de idioma.
|
|
38
44
|
|
|
39
45
|
---
|
|
40
46
|
|
|
41
|
-
## Guia
|
|
47
|
+
## Guia passo a passo para configurar o Intlayer em uma aplicação Nuxt
|
|
48
|
+
|
|
49
|
+
<Tab defaultTab="video">
|
|
50
|
+
<TabItem label="Vídeo" value="video">
|
|
51
|
+
|
|
52
|
+
<iframe title="Como traduzir sua aplicação Nuxt e Vue usando Intlayer? Descubra o Intlayer" class="m-auto aspect-[16/9] w-full overflow-hidden rounded-lg border-0" allow="autoplay; gyroscope;" loading="lazy" width="1080" height="auto" src="https://www.youtube.com/embed/nhUcUAVQ6eQ?autoplay=0&origin=http://intlayer.org&controls=0&rel=1"/>
|
|
53
|
+
|
|
54
|
+
</TabItem>
|
|
55
|
+
<TabItem label="Código" value="code">
|
|
56
|
+
|
|
57
|
+
<iframe
|
|
58
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-4-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
59
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
60
|
+
title="Demo CodeSandbox - Como Internacionalizar sua aplicação usando Intlayer"
|
|
61
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
62
|
+
loading="lazy"
|
|
63
|
+
/>
|
|
64
|
+
|
|
65
|
+
</TabItem>
|
|
66
|
+
</Tab>
|
|
67
|
+
|
|
68
|
+
Veja o [Template da Aplicação](https://github.com/aymericzip/intlayer-nuxt-4-template) no GitHub.
|
|
42
69
|
|
|
43
70
|
### Passo 1: Instalar Dependências
|
|
44
71
|
|
|
@@ -61,13 +88,13 @@ yarn add --save-dev nuxt-intlayer
|
|
|
61
88
|
|
|
62
89
|
- **intlayer**
|
|
63
90
|
|
|
64
|
-
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/
|
|
91
|
+
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), transpiração e [comandos CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/cli/index.md).
|
|
65
92
|
|
|
66
93
|
- **vue-intlayer**
|
|
67
94
|
O pacote que integra o Intlayer com a aplicação Vue. Ele fornece os composables para os componentes Vue.
|
|
68
95
|
|
|
69
96
|
- **nuxt-intlayer**
|
|
70
|
-
O módulo Nuxt que integra o Intlayer com aplicações Nuxt. Ele fornece configuração automática, middleware para detecção de
|
|
97
|
+
O módulo Nuxt que integra o Intlayer com aplicações Nuxt. Ele fornece configuração automática, middleware para detecção de locale, gerenciamento de cookies e redirecionamento de URL.
|
|
71
98
|
|
|
72
99
|
### Passo 2: Configuração do seu projeto
|
|
73
100
|
|
|
@@ -82,13 +109,10 @@ const config: IntlayerConfig = {
|
|
|
82
109
|
Locales.ENGLISH,
|
|
83
110
|
Locales.FRENCH,
|
|
84
111
|
Locales.SPANISH,
|
|
85
|
-
// Seus outros
|
|
112
|
+
// Seus outros idiomas
|
|
86
113
|
],
|
|
87
114
|
defaultLocale: Locales.ENGLISH,
|
|
88
115
|
},
|
|
89
|
-
content: {
|
|
90
|
-
contentDir: ["."], // Porque por padrão o Intlayer irá monitorar arquivos de declaração de conteúdo do diretório `./src`
|
|
91
|
-
},
|
|
92
116
|
};
|
|
93
117
|
|
|
94
118
|
export default config;
|
|
@@ -98,20 +122,16 @@ export default config;
|
|
|
98
122
|
import { Locales } from "intlayer";
|
|
99
123
|
|
|
100
124
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
101
|
-
// Configuração do Intlayer para internacionalização e conteúdo
|
|
102
125
|
const config = {
|
|
103
126
|
internationalization: {
|
|
104
127
|
locales: [
|
|
105
128
|
Locales.ENGLISH,
|
|
106
129
|
Locales.FRENCH,
|
|
107
130
|
Locales.SPANISH,
|
|
108
|
-
// Seus outros
|
|
131
|
+
// Seus outros idiomas
|
|
109
132
|
],
|
|
110
133
|
defaultLocale: Locales.ENGLISH,
|
|
111
134
|
},
|
|
112
|
-
content: {
|
|
113
|
-
contentDir: ["."],
|
|
114
|
-
},
|
|
115
135
|
};
|
|
116
136
|
|
|
117
137
|
export default config;
|
|
@@ -121,26 +141,22 @@ export default config;
|
|
|
121
141
|
const { Locales } = require("intlayer");
|
|
122
142
|
|
|
123
143
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
124
|
-
// Configuração do Intlayer para internacionalização e conteúdo
|
|
125
144
|
const config = {
|
|
126
145
|
internationalization: {
|
|
127
146
|
locales: [
|
|
128
147
|
Locales.ENGLISH,
|
|
129
148
|
Locales.FRENCH,
|
|
130
149
|
Locales.SPANISH,
|
|
131
|
-
// Seus outros
|
|
150
|
+
// Seus outros idiomas
|
|
132
151
|
],
|
|
133
152
|
defaultLocale: Locales.ENGLISH,
|
|
134
153
|
},
|
|
135
|
-
content: {
|
|
136
|
-
contentDir: ["."],
|
|
137
|
-
},
|
|
138
154
|
};
|
|
139
155
|
|
|
140
156
|
module.exports = config;
|
|
141
157
|
```
|
|
142
158
|
|
|
143
|
-
> Através deste arquivo de configuração, você pode configurar URLs localizadas, redirecionamento via middleware, nomes de cookies, a localização e extensão das suas declarações de conteúdo, desabilitar logs do Intlayer no console, e
|
|
159
|
+
> Através deste arquivo de configuração, você pode configurar URLs localizadas, redirecionamento via middleware, nomes de cookies, a localização e extensão das suas declarações de conteúdo, desabilitar logs do Intlayer no console, e mais. Para uma lista completa dos parâmetros disponíveis, consulte a [documentação de configuração](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/configuration.md).
|
|
144
160
|
|
|
145
161
|
### Passo 3: Integre o Intlayer na sua Configuração Nuxt
|
|
146
162
|
|
|
@@ -155,238 +171,42 @@ export default defineNuxtConfig({
|
|
|
155
171
|
});
|
|
156
172
|
```
|
|
157
173
|
|
|
158
|
-
> O módulo `nuxt-intlayer` gerencia automaticamente a integração do Intlayer com o Nuxt. Ele configura a construção da declaração de conteúdo, monitora arquivos no modo de desenvolvimento, fornece middleware para detecção de
|
|
174
|
+
> O módulo `nuxt-intlayer` gerencia automaticamente a integração do Intlayer com o Nuxt. Ele configura a construção da declaração de conteúdo, monitora os arquivos no modo de desenvolvimento, fornece middleware para detecção de locale e gerencia o roteamento localizado.
|
|
159
175
|
|
|
160
176
|
### Passo 4: Declare Seu Conteúdo
|
|
161
177
|
|
|
162
178
|
Crie e gerencie suas declarações de conteúdo para armazenar traduções:
|
|
163
179
|
|
|
164
|
-
```tsx fileName="
|
|
165
|
-
import {
|
|
180
|
+
```tsx fileName="content/home-page.content.ts" contentDeclarationFormat="typescript"
|
|
181
|
+
import { type Dictionary, t } from "intlayer";
|
|
166
182
|
|
|
167
|
-
const
|
|
168
|
-
key: "
|
|
183
|
+
const content = {
|
|
184
|
+
key: "home-page",
|
|
169
185
|
content: {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
175
|
-
}),
|
|
176
|
-
checkOut: t({
|
|
177
|
-
pt: "Confira ",
|
|
178
|
-
en: "Check out ",
|
|
179
|
-
fr: "Vérifiez ",
|
|
180
|
-
es: "Compruebe ",
|
|
181
|
-
}),
|
|
182
|
-
nuxtIntlayer: t({
|
|
183
|
-
pt: "Documentação do Nuxt Intlayer",
|
|
184
|
-
en: "Nuxt Intlayer documentation",
|
|
185
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
186
|
-
es: "Documentación de Nuxt Intlayer",
|
|
187
|
-
}),
|
|
188
|
-
learnMore: t({
|
|
189
|
-
pt: "Saiba mais sobre Nuxt em ",
|
|
190
|
-
en: "Learn more about Nuxt in the ",
|
|
191
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
192
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
186
|
+
title: t({
|
|
187
|
+
en: "Hello world",
|
|
188
|
+
fr: "Bonjour le monde",
|
|
189
|
+
es: "Hola mundo",
|
|
193
190
|
}),
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
es: "Documentación de Nuxt",
|
|
191
|
+
metaTitle: t({
|
|
192
|
+
en: "Welcome | My Application",
|
|
193
|
+
fr: "Bienvenue | Mon Application",
|
|
194
|
+
es: "Bienvenido | Mi Aplicación",
|
|
199
195
|
}),
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
fr: "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
205
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
196
|
+
metaDescription: t({
|
|
197
|
+
en: "Discover your multilingual Nuxt app homepage powered by Intlayer.",
|
|
198
|
+
fr: "Découvrez la page d'accueil multilingue de votre application Nuxt propulsée par Intlayer.",
|
|
199
|
+
es: "Descubre la página de inicio multilingüe de tu aplicación Nuxt impulsada por Intlayer.",
|
|
206
200
|
}),
|
|
207
201
|
},
|
|
208
202
|
} satisfies Dictionary;
|
|
209
203
|
|
|
210
|
-
export default
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
```javascript fileName="components/helloWorld.content.mjs" contentDeclarationFormat="esm"
|
|
214
|
-
import { t } from "intlayer";
|
|
215
|
-
|
|
216
|
-
/** @type {import('intlayer').Dictionary} */
|
|
217
|
-
const helloWorldContent = {
|
|
218
|
-
key: "helloworld",
|
|
219
|
-
content: {
|
|
220
|
-
count: t({
|
|
221
|
-
pt: "a contagem é ",
|
|
222
|
-
en: "count is ",
|
|
223
|
-
fr: "le compte est ",
|
|
224
|
-
es: "el recuento es ",
|
|
225
|
-
}),
|
|
226
|
-
edit: t({
|
|
227
|
-
pt: "Edite <code>components/HelloWorld.vue</code> e salve para testar HMR",
|
|
228
|
-
en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
229
|
-
fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
230
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
231
|
-
}),
|
|
232
|
-
checkOut: t({
|
|
233
|
-
pt: "Confira ",
|
|
234
|
-
en: "Check out ",
|
|
235
|
-
fr: "Vérifiez ",
|
|
236
|
-
es: "Compruebe ",
|
|
237
|
-
}),
|
|
238
|
-
nuxtIntlayer: t({
|
|
239
|
-
pt: "Documentação do Nuxt Intlayer",
|
|
240
|
-
en: "Nuxt Intlayer documentation",
|
|
241
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
242
|
-
es: "Documentación de Nuxt Intlayer",
|
|
243
|
-
}),
|
|
244
|
-
learnMore: t({
|
|
245
|
-
pt: "Saiba mais sobre Nuxt em ",
|
|
246
|
-
en: "Learn more about Nuxt in the ",
|
|
247
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
248
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
249
|
-
}),
|
|
250
|
-
nuxtDocs: t({
|
|
251
|
-
pt: "Documentação do Nuxt",
|
|
252
|
-
en: "Nuxt Documentation",
|
|
253
|
-
fr: "Documentation Nuxt",
|
|
254
|
-
es: "Documentación de Nuxt",
|
|
255
|
-
}),
|
|
256
|
-
readTheDocs: t({
|
|
257
|
-
pt: "Clique no logotipo do Nuxt para saber mais",
|
|
258
|
-
en: "Click on the Nuxt logo to learn more",
|
|
259
|
-
fr: "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
260
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
261
|
-
}),
|
|
262
|
-
},
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
export default helloWorldContent;
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
```javascript fileName="components/helloWorld.content.cjs" contentDeclarationFormat="commonjs"
|
|
269
|
-
const { t } = require("intlayer");
|
|
270
|
-
|
|
271
|
-
/** @type {import('intlayer').Dictionary} */
|
|
272
|
-
const helloWorldContent = {
|
|
273
|
-
key: "helloworld",
|
|
274
|
-
content: {
|
|
275
|
-
count: t({ pt: "a contagem é ", en: "count is ", fr: "le compte est ", es: "el recuento es " }),
|
|
276
|
-
edit: t({
|
|
277
|
-
pt: "Edite <code>components/HelloWorld.vue</code> e salve para testar HMR",
|
|
278
|
-
en: "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
279
|
-
fr: "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
280
|
-
es: "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR",
|
|
281
|
-
}),
|
|
282
|
-
checkOut: t({ pt: "Confira ", en: "Check out ", fr: "Vérifiez ", es: "Compruebe " }),
|
|
283
|
-
nuxtIntlayer: t({
|
|
284
|
-
pt: "Documentação do Nuxt Intlayer",
|
|
285
|
-
en: "Nuxt Intlayer documentation",
|
|
286
|
-
fr: "Documentation de Nuxt Intlayer",
|
|
287
|
-
es: "Documentación de Nuxt Intlayer",
|
|
288
|
-
}),
|
|
289
|
-
pt: "Documentação do Nuxt Intlayer",
|
|
290
|
-
}),
|
|
291
|
-
learnMore: t({
|
|
292
|
-
pt: "Saiba mais sobre Nuxt em ",
|
|
293
|
-
en: "Learn more about Nuxt in the ",
|
|
294
|
-
fr: "En savoir plus sur Nuxt dans la ",
|
|
295
|
-
es: "Aprenda más sobre Nuxt en la ",
|
|
296
|
-
}),
|
|
297
|
-
nuxtDocs: t({
|
|
298
|
-
pt: "Documentação do Nuxt",
|
|
299
|
-
en: "Nuxt Documentation",
|
|
300
|
-
fr: "Documentation Nuxt",
|
|
301
|
-
es: "Documentación de Nuxt",
|
|
302
|
-
}),
|
|
303
|
-
readTheDocs: t({
|
|
304
|
-
pt: "Clique no logotipo do Nuxt para saber mais",
|
|
305
|
-
en: "Click on the Nuxt logo to learn more",
|
|
306
|
-
fr: "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
307
|
-
es: "Haga clic en el logotipo de Nuxt para obtener más información",
|
|
308
|
-
}),
|
|
309
|
-
},
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
module.exports = helloWorldContent;
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
```json fileName="components/helloWorld.content.json" contentDeclarationFormat="json"
|
|
316
|
-
{
|
|
317
|
-
"$schema": "https://intlayer.org/schema.json",
|
|
318
|
-
"key": "helloworld",
|
|
319
|
-
"content": {
|
|
320
|
-
"count": {
|
|
321
|
-
"nodeType": "translation",
|
|
322
|
-
"translation": {
|
|
323
|
-
"pt": "a contagem é ",
|
|
324
|
-
"en": "count is ",
|
|
325
|
-
"fr": "le compte est ",
|
|
326
|
-
"es": "el recuento es "
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
"edit": {
|
|
330
|
-
"nodeType": "translation",
|
|
331
|
-
"translation": {
|
|
332
|
-
"pt": "Edite <code>components/HelloWorld.vue</code> e salve para testar HMR",
|
|
333
|
-
"en": "Edit <code>components/HelloWorld.vue</code> and save to test HMR",
|
|
334
|
-
"fr": "Éditez <code>components/HelloWorld.vue</code> et enregistrez pour tester HMR",
|
|
335
|
-
"es": "Edita <code>components/HelloWorld.vue</code> y guarda para probar HMR"
|
|
336
|
-
}
|
|
337
|
-
},
|
|
338
|
-
"checkOut": {
|
|
339
|
-
"nodeType": "translation",
|
|
340
|
-
"translation": {
|
|
341
|
-
"pt": "Confira ",
|
|
342
|
-
"en": "Check out ",
|
|
343
|
-
"fr": "Vérifiez ",
|
|
344
|
-
"es": "Compruebe "
|
|
345
|
-
}
|
|
346
|
-
},
|
|
347
|
-
"nuxtIntlayer": {
|
|
348
|
-
"nodeType": "translation",
|
|
349
|
-
"translation": {
|
|
350
|
-
"pt": "Documentação do Nuxt Intlayer",
|
|
351
|
-
"en": "Nuxt Intlayer documentation",
|
|
352
|
-
"fr": "Documentation de Nuxt Intlayer",
|
|
353
|
-
"es": "Documentación de Nuxt Intlayer"
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
"learnMore": {
|
|
357
|
-
"nodeType": "translation",
|
|
358
|
-
"translation": {
|
|
359
|
-
"pt": "Saiba mais sobre Nuxt em ",
|
|
360
|
-
"en": "Learn more about Nuxt in the ",
|
|
361
|
-
"fr": "En savoir plus sur Nuxt dans la ",
|
|
362
|
-
"es": "Aprenda más sobre Nuxt en la "
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
"nuxtDocs": {
|
|
366
|
-
"nodeType": "translation",
|
|
367
|
-
"translation": {
|
|
368
|
-
"pt": "Documentação do Nuxt",
|
|
369
|
-
"en": "Nuxt Documentation",
|
|
370
|
-
"fr": "Documentation Nuxt",
|
|
371
|
-
"es": "Documentación de Nuxt"
|
|
372
|
-
}
|
|
373
|
-
},
|
|
374
|
-
"readTheDocs": {
|
|
375
|
-
"nodeType": "translation",
|
|
376
|
-
"translation": {
|
|
377
|
-
"pt": "Clique no logotipo do Nuxt para saber mais",
|
|
378
|
-
"en": "Click on the Nuxt logo to learn more",
|
|
379
|
-
"fr": "Cliquez sur le logo Nuxt pour en savoir plus",
|
|
380
|
-
"es": "Haga clic en el logotipo de Nuxt para obtener más información"
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
}
|
|
204
|
+
export default content;
|
|
385
205
|
```
|
|
386
206
|
|
|
387
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,mjx,cjs,cjx}`).
|
|
388
208
|
|
|
389
|
-
> Para mais detalhes, consulte a [documentação de declaração de conteúdo](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/
|
|
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).
|
|
390
210
|
|
|
391
211
|
### Passo 5: Utilize o Intlayer no Seu Código
|
|
392
212
|
|
|
@@ -444,81 +264,71 @@ const countRef = ref(0);
|
|
|
444
264
|
O Intlayer oferece diferentes APIs para acessar seu conteúdo:
|
|
445
265
|
|
|
446
266
|
- **Sintaxe baseada em componentes** (recomendada):
|
|
447
|
-
Use a sintaxe `<myContent
|
|
267
|
+
Use a sintaxe `<myContent />`, ou `<Component :is="myContent" />` para renderizar o conteúdo como um Nó Intlayer. Isso integra-se perfeitamente com o [Editor Visual](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_visual_editor.md) e o [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_CMS.md).
|
|
448
268
|
|
|
449
269
|
- **Sintaxe baseada em string**:
|
|
450
270
|
Use `{{ myContent }}` para renderizar o conteúdo como texto simples, sem suporte ao Editor Visual.
|
|
451
271
|
|
|
452
|
-
- **Sintaxe HTML
|
|
272
|
+
- **Sintaxe HTML bruto**:
|
|
453
273
|
Use `<div v-html="myContent" />` para renderizar o conteúdo como HTML bruto, sem suporte ao Editor Visual.
|
|
454
274
|
|
|
455
275
|
- **Sintaxe de desestruturação**:
|
|
456
276
|
O composable `useIntlayer` retorna um Proxy com o conteúdo. Esse proxy pode ser desestruturado para acessar o conteúdo mantendo a reatividade.
|
|
457
|
-
- Use `const content = useIntlayer("myContent");` e `{{ content.myContent }}` / `<content.myContent />`.
|
|
458
|
-
- Ou use `const { myContent } = useIntlayer("myContent");` e `{{ myContent
|
|
277
|
+
- Use `const content = useIntlayer("myContent");` e `{{ content.myContent }}` / `<content.myContent />`.
|
|
278
|
+
- Ou use `const { myContent } = useIntlayer("myContent");` e `{{ myContent}}` / `<myContent/>` para desestruturar o conteúdo.
|
|
459
279
|
|
|
460
280
|
### (Opcional) Passo 6: Alterar o idioma do seu conteúdo
|
|
461
281
|
|
|
462
282
|
Para alterar o idioma do seu conteúdo, você pode usar a função `setLocale` fornecida pelo composable `useLocale`. Essa função permite definir o locale da aplicação e atualizar o conteúdo de acordo.
|
|
463
283
|
|
|
464
|
-
Crie um componente para alternar entre idiomas:
|
|
284
|
+
Crie um componente para alternar entre idiomas usando `NuxtLink`. **Usar links em vez de botões para a troca de locale é uma boa prática para SEO e descoberta da página**, pois permite que os motores de busca rastreiem e indexem todas as versões localizadas das suas páginas:
|
|
465
285
|
|
|
466
286
|
```vue fileName="components/LocaleSwitcher.vue"
|
|
467
|
-
<template>
|
|
468
|
-
<div class="locale-switcher">
|
|
469
|
-
<select v-model="selectedLocale" @change="changeLocale">
|
|
470
|
-
<option v-for="loc in availableLocales" :key="loc" :value="loc">
|
|
471
|
-
{{ getLocaleName(loc) }}
|
|
472
|
-
</option>
|
|
473
|
-
</select>
|
|
474
|
-
</div>
|
|
475
|
-
</template>
|
|
476
|
-
|
|
477
287
|
<script setup lang="ts">
|
|
478
|
-
import {
|
|
479
|
-
import { getLocaleName } from "intlayer";
|
|
288
|
+
import { getLocaleName, getLocalizedUrl } from "intlayer";
|
|
480
289
|
import { useLocale } from "vue-intlayer";
|
|
481
290
|
|
|
482
|
-
//
|
|
291
|
+
// Nuxt importa automaticamente useRoute
|
|
292
|
+
const route = useRoute();
|
|
483
293
|
const { locale, availableLocales, setLocale } = useLocale();
|
|
484
|
-
|
|
485
|
-
// Rastrear a localidade selecionada com um ref
|
|
486
|
-
const selectedLocale = ref(locale.value);
|
|
487
|
-
|
|
488
|
-
// Atualizar a localidade quando a seleção mudar
|
|
489
|
-
const changeLocale = () => setLocale(selectedLocale.value);
|
|
490
|
-
|
|
491
|
-
// Manter selectedLocale sincronizado com a localidade global
|
|
492
|
-
watch(
|
|
493
|
-
() => locale.value,
|
|
494
|
-
(newLocale) => {
|
|
495
|
-
selectedLocale.value = newLocale;
|
|
496
|
-
}
|
|
497
|
-
);
|
|
498
294
|
</script>
|
|
295
|
+
|
|
296
|
+
<template>
|
|
297
|
+
<nav class="locale-switcher">
|
|
298
|
+
<NuxtLink
|
|
299
|
+
v-for="localeEl in availableLocales"
|
|
300
|
+
:key="localeEl"
|
|
301
|
+
:to="getLocalizedUrl(route.fullPath, localeEl)"
|
|
302
|
+
class="locale-link"
|
|
303
|
+
:class="{ 'active-locale': localeEl === locale }"
|
|
304
|
+
@click="setLocale(localeEl)"
|
|
305
|
+
>
|
|
306
|
+
{{ getLocaleName(localeEl) }}
|
|
307
|
+
</NuxtLink>
|
|
308
|
+
</nav>
|
|
499
309
|
</template>
|
|
310
|
+
```
|
|
500
311
|
|
|
501
|
-
|
|
502
|
-
.locale-switcher {
|
|
503
|
-
margin: 1rem 0;
|
|
504
|
-
}
|
|
312
|
+
> Usar `NuxtLink` com atributos `href` apropriados (via `getLocalizedUrl`) garante que os motores de busca possam descobrir todas as variantes de idioma das suas páginas. Isso é preferível à troca de idioma apenas via JavaScript, que os rastreadores de motores de busca podem não seguir.
|
|
505
313
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
314
|
+
Em seguida, configure seu `app.vue` para usar layouts:
|
|
315
|
+
|
|
316
|
+
```vue fileName="app.vue"
|
|
317
|
+
<template>
|
|
318
|
+
<NuxtLayout>
|
|
319
|
+
<NuxtPage />
|
|
320
|
+
</NuxtLayout>
|
|
321
|
+
</template>
|
|
512
322
|
```
|
|
513
323
|
|
|
514
|
-
|
|
324
|
+
### (Opcional) Passo 6b: Criar um Layout com Navegação
|
|
515
325
|
|
|
516
|
-
|
|
326
|
+
Os layouts do Nuxt permitem definir uma estrutura comum para suas páginas. Crie um layout padrão que inclua o seletor de idioma e a navegação:
|
|
327
|
+
|
|
328
|
+
```vue fileName="layouts/default.vue"
|
|
517
329
|
<script setup lang="ts">
|
|
518
|
-
import
|
|
330
|
+
import Links from "~/components/Links.vue";
|
|
519
331
|
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
520
|
-
|
|
521
|
-
const content = useIntlayer("app"); // Crie o arquivo de declaração intlayer relacionado
|
|
522
332
|
</script>
|
|
523
333
|
|
|
524
334
|
<template>
|
|
@@ -527,15 +337,20 @@ const content = useIntlayer("app"); // Crie o arquivo de declaração intlayer r
|
|
|
527
337
|
<LocaleSwitcher />
|
|
528
338
|
</header>
|
|
529
339
|
<main>
|
|
530
|
-
<
|
|
340
|
+
<slot />
|
|
531
341
|
</main>
|
|
342
|
+
|
|
343
|
+
<Links href="/">Início</Links>
|
|
344
|
+
<Links href="/about">Sobre</Links>
|
|
532
345
|
</div>
|
|
533
346
|
</template>
|
|
534
347
|
```
|
|
535
348
|
|
|
536
|
-
|
|
349
|
+
O componente `Links` (mostrado abaixo) garante que os links de navegação interna sejam automaticamente localizados.
|
|
537
350
|
|
|
538
|
-
|
|
351
|
+
### (Opcional) Passo 7: Adicionar Roteamento Localizado à sua aplicação
|
|
352
|
+
|
|
353
|
+
O Nuxt gerencia automaticamente o roteamento localizado ao usar o módulo `nuxt-intlayer`. Isso cria rotas para cada idioma automaticamente com base na estrutura do diretório das suas páginas.
|
|
539
354
|
|
|
540
355
|
Exemplo:
|
|
541
356
|
|
|
@@ -547,23 +362,58 @@ pages/
|
|
|
547
362
|
└── index.vue → /contact, /fr/contact, /es/contact
|
|
548
363
|
```
|
|
549
364
|
|
|
550
|
-
Para criar
|
|
365
|
+
Para criar páginas localizadas, basta criar seus arquivos Vue no diretório `pages/`. Aqui estão dois exemplos de páginas:
|
|
366
|
+
|
|
367
|
+
**Página inicial (`pages/index.vue`):**
|
|
368
|
+
|
|
369
|
+
```vue fileName="pages/index.vue"
|
|
370
|
+
<script setup lang="ts">
|
|
371
|
+
import { useIntlayer } from "vue-intlayer";
|
|
372
|
+
|
|
373
|
+
const content = useIntlayer("home-page");
|
|
374
|
+
|
|
375
|
+
useHead({
|
|
376
|
+
title: content.metaTitle.value,
|
|
377
|
+
meta: [
|
|
378
|
+
{
|
|
379
|
+
name: "description",
|
|
380
|
+
content: content.metaDescription.value,
|
|
381
|
+
},
|
|
382
|
+
],
|
|
383
|
+
});
|
|
384
|
+
</script>
|
|
385
|
+
|
|
386
|
+
<template>
|
|
387
|
+
<h1><content.title /></h1>
|
|
388
|
+
</template>
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
**Página Sobre (`pages/about.vue`):**
|
|
551
392
|
|
|
552
393
|
```vue fileName="pages/about.vue"
|
|
553
394
|
<script setup lang="ts">
|
|
554
395
|
import { useIntlayer } from "vue-intlayer";
|
|
555
396
|
|
|
556
|
-
const content = useIntlayer("about");
|
|
397
|
+
const content = useIntlayer("about-page");
|
|
398
|
+
|
|
399
|
+
useHead({
|
|
400
|
+
title: content.metaTitle.raw, // Use .raw para acesso a string primitiva
|
|
401
|
+
meta: [
|
|
402
|
+
{
|
|
403
|
+
name: "description",
|
|
404
|
+
content: content.metaDescription.raw, // Use .raw para acesso a string primitiva
|
|
405
|
+
},
|
|
406
|
+
],
|
|
407
|
+
});
|
|
557
408
|
</script>
|
|
558
409
|
|
|
559
410
|
<template>
|
|
560
|
-
<
|
|
561
|
-
<h1>{{ content.title }}</h1>
|
|
562
|
-
<p>{{ content.description }}</p>
|
|
563
|
-
</div>
|
|
411
|
+
<h1><content.title /></h1>
|
|
564
412
|
</template>
|
|
565
413
|
```
|
|
566
414
|
|
|
415
|
+
> Nota: `useHead` é importado automaticamente no Nuxt. Você pode acessar os valores do conteúdo usando `.value` (reativo) ou `.raw` (string primitiva), dependendo das suas necessidades.
|
|
416
|
+
|
|
567
417
|
O módulo `nuxt-intlayer` irá automaticamente:
|
|
568
418
|
|
|
569
419
|
- Detectar o idioma preferido do usuário
|
|
@@ -574,228 +424,237 @@ O módulo `nuxt-intlayer` irá automaticamente:
|
|
|
574
424
|
|
|
575
425
|
### (Opcional) Passo 8: Criando um Componente de Link Localizado
|
|
576
426
|
|
|
577
|
-
Para garantir que a navegação da sua aplicação respeite o idioma atual, você pode criar um componente personalizado `
|
|
578
|
-
|
|
579
|
-
```vue fileName="components/LocalizedLink.vue"
|
|
580
|
-
<template>
|
|
581
|
-
<NuxtLink :to="localizedHref" v-bind="$attrs">
|
|
582
|
-
<slot />
|
|
583
|
-
</NuxtLink>
|
|
584
|
-
</template>
|
|
427
|
+
Para garantir que a navegação da sua aplicação respeite o idioma atual, você pode criar um componente personalizado `Links`. Este componente adiciona automaticamente o prefixo do idioma atual às URLs internas, o que é essencial para **SEO e descoberta das páginas**.
|
|
585
428
|
|
|
429
|
+
```vue fileName="components/Links.vue"
|
|
586
430
|
<script setup lang="ts">
|
|
587
|
-
import { computed } from "vue";
|
|
588
431
|
import { getLocalizedUrl } from "intlayer";
|
|
589
432
|
import { useLocale } from "vue-intlayer";
|
|
590
433
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
434
|
+
interface Props {
|
|
435
|
+
href: string;
|
|
436
|
+
locale?: string;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const props = defineProps<Props>();
|
|
440
|
+
|
|
441
|
+
const { locale: currentLocale } = useLocale();
|
|
597
442
|
|
|
598
|
-
|
|
443
|
+
// Calcula o caminho final
|
|
444
|
+
const finalPath = computed(() => {
|
|
445
|
+
// 1. Verifica se o link é externo
|
|
446
|
+
const isExternal = /^https?:\/\//.test(props.href || "");
|
|
599
447
|
|
|
600
|
-
//
|
|
601
|
-
|
|
448
|
+
// 2. Se for externo, retorna como está (NuxtLink cuida da geração da tag <a>)
|
|
449
|
+
if (isExternal) return props.href;
|
|
602
450
|
|
|
603
|
-
//
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
);
|
|
451
|
+
// 3. Se for interno, localize a URL
|
|
452
|
+
const targetLocale = props.locale || currentLocale.value;
|
|
453
|
+
return getLocalizedUrl(props.href, targetLocale);
|
|
454
|
+
});
|
|
607
455
|
</script>
|
|
456
|
+
|
|
457
|
+
<template>
|
|
458
|
+
<NuxtLink :to="finalPath" v-bind="$attrs">
|
|
459
|
+
<slot />
|
|
460
|
+
</NuxtLink>
|
|
461
|
+
</template>
|
|
608
462
|
```
|
|
609
463
|
|
|
610
464
|
Então use este componente em toda a sua aplicação:
|
|
611
465
|
|
|
612
|
-
```vue fileName="
|
|
466
|
+
```vue fileName="layouts/default.vue"
|
|
467
|
+
<script setup lang="ts">
|
|
468
|
+
import Links from "~/components/Links.vue";
|
|
469
|
+
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
470
|
+
</script>
|
|
471
|
+
|
|
613
472
|
<template>
|
|
614
473
|
<div>
|
|
615
|
-
<
|
|
616
|
-
|
|
617
|
-
</
|
|
618
|
-
<
|
|
619
|
-
|
|
620
|
-
</
|
|
474
|
+
<header>
|
|
475
|
+
<LocaleSwitcher />
|
|
476
|
+
</header>
|
|
477
|
+
<main>
|
|
478
|
+
<slot />
|
|
479
|
+
</main>
|
|
480
|
+
|
|
481
|
+
<Links href="/">Início</Links>
|
|
482
|
+
<Links href="/about">Sobre</Links>
|
|
621
483
|
</div>
|
|
622
484
|
</template>
|
|
623
|
-
|
|
624
|
-
<script setup lang="ts">
|
|
625
|
-
import { useIntlayer } from "vue-intlayer";
|
|
626
|
-
import LocalizedLink from "~/components/LocalizedLink.vue";
|
|
627
|
-
|
|
628
|
-
const content = useIntlayer("home");
|
|
629
|
-
</script>
|
|
630
485
|
```
|
|
631
486
|
|
|
487
|
+
> Ao usar `NuxtLink` com caminhos localizados, você garante que:
|
|
488
|
+
>
|
|
489
|
+
> - Os motores de busca possam rastrear e indexar todas as versões linguísticas das suas páginas
|
|
490
|
+
> - Os usuários possam compartilhar URLs localizadas diretamente
|
|
491
|
+
> - O histórico do navegador funcione corretamente com URLs prefixadas pelo locale
|
|
492
|
+
|
|
632
493
|
### (Opcional) Passo 9: Gerenciar Metadados e SEO
|
|
633
494
|
|
|
634
|
-
O Nuxt oferece excelentes capacidades de SEO. Você pode usar o Intlayer para gerenciar metadados localizados:
|
|
495
|
+
O Nuxt oferece excelentes capacidades de SEO através do composable `useHead` (auto-importado). Você pode usar o Intlayer para gerenciar metadados localizados utilizando o acessador `.raw` ou `.value` para obter o valor primitivo da string:
|
|
635
496
|
|
|
636
497
|
```vue fileName="pages/about.vue"
|
|
637
498
|
<script setup lang="ts">
|
|
638
|
-
import {
|
|
639
|
-
import { getIntlayer } from "intlayer";
|
|
640
|
-
import { useLocale } from "vue-intlayer";
|
|
499
|
+
import { useIntlayer } from "vue-intlayer";
|
|
641
500
|
|
|
642
|
-
|
|
643
|
-
const content =
|
|
501
|
+
// useHead é auto-importado no Nuxt
|
|
502
|
+
const content = useIntlayer("about-page");
|
|
644
503
|
|
|
645
|
-
|
|
646
|
-
title: content.
|
|
647
|
-
|
|
504
|
+
useHead({
|
|
505
|
+
title: content.metaTitle.raw, // Use .raw para acesso ao valor primitivo da string
|
|
506
|
+
meta: [
|
|
507
|
+
{
|
|
508
|
+
name: "description",
|
|
509
|
+
content: content.metaDescription.raw, // Use .raw para acessar a string primitiva
|
|
510
|
+
},
|
|
511
|
+
],
|
|
648
512
|
});
|
|
649
513
|
</script>
|
|
650
514
|
|
|
651
515
|
<template>
|
|
652
|
-
<
|
|
653
|
-
<h1>{{ content.pageTitle }}</h1>
|
|
654
|
-
<p>{{ content.pageContent }}</p>
|
|
655
|
-
</div>
|
|
516
|
+
<h1><content.title /></h1>
|
|
656
517
|
</template>
|
|
657
518
|
```
|
|
658
519
|
|
|
520
|
+
> Alternativamente, você pode usar a função `import { getIntlayer } from "intlayer"` para obter o conteúdo sem reatividade do Vue.
|
|
521
|
+
|
|
522
|
+
> **Acessando valores do conteúdo:**
|
|
523
|
+
>
|
|
524
|
+
> - Use `.raw` para obter o valor primitivo da string (não reativo)
|
|
525
|
+
> - Use `.value` para obter o valor reativo
|
|
526
|
+
> - Use a sintaxe de componente `<content.key />` para suporte ao Visual Editor
|
|
527
|
+
|
|
659
528
|
Crie a declaração de conteúdo correspondente:
|
|
660
529
|
|
|
661
|
-
```ts fileName="pages/about-
|
|
530
|
+
```ts fileName="pages/about-page.content.ts" contentDeclarationFormat="typescript"
|
|
662
531
|
import { t, type Dictionary } from "intlayer";
|
|
663
|
-
import type { useSeoMeta } from "nuxt/app";
|
|
664
532
|
|
|
665
|
-
const
|
|
666
|
-
key: "about-
|
|
533
|
+
const aboutPageContent = {
|
|
534
|
+
key: "about-page",
|
|
667
535
|
content: {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
en: "About Us - My Company",
|
|
536
|
+
metaTitle: t({
|
|
537
|
+
en: "Sobre Nós - Minha Empresa",
|
|
671
538
|
fr: "À Propos - Ma Société",
|
|
672
539
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
673
540
|
}),
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
en: "Learn more about our company and our mission",
|
|
541
|
+
metaDescription: t({
|
|
542
|
+
en: "Saiba mais sobre nossa empresa e nossa missão",
|
|
677
543
|
fr: "En savoir plus sur notre société et notre mission",
|
|
678
544
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
679
545
|
}),
|
|
546
|
+
title: t({
|
|
547
|
+
en: "Sobre Nós",
|
|
548
|
+
fr: "À Propos",
|
|
549
|
+
es: "Acerca de Nosotros",
|
|
550
|
+
}),
|
|
680
551
|
},
|
|
681
|
-
} satisfies Dictionary
|
|
552
|
+
} satisfies Dictionary;
|
|
682
553
|
|
|
683
|
-
export default
|
|
554
|
+
export default aboutPageContent;
|
|
684
555
|
```
|
|
685
556
|
|
|
686
|
-
```
|
|
557
|
+
```javascript fileName="pages/about-page.content.mjs" contentDeclarationFormat="esm"
|
|
687
558
|
import { t } from "intlayer";
|
|
688
559
|
|
|
689
560
|
/** @type {import('intlayer').Dictionary} */
|
|
690
|
-
const
|
|
691
|
-
key: "about-
|
|
561
|
+
const aboutPageContent = {
|
|
562
|
+
key: "about-page",
|
|
692
563
|
content: {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
pt: "Sobre Nós - Minha Empresa",
|
|
696
|
-
en: "About Us - My Company",
|
|
564
|
+
metaTitle: t({
|
|
565
|
+
en: "Sobre Nós - Minha Empresa",
|
|
697
566
|
fr: "À Propos - Ma Société",
|
|
698
567
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
699
568
|
}),
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
pt: "Saiba mais sobre nossa empresa e nossa missão",
|
|
703
|
-
en: "Learn more about our company and our mission",
|
|
569
|
+
metaDescription: t({
|
|
570
|
+
en: "Saiba mais sobre nossa empresa e nossa missão",
|
|
704
571
|
fr: "En savoir plus sur notre société et notre mission",
|
|
705
572
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
706
573
|
}),
|
|
574
|
+
title: t({
|
|
575
|
+
en: "Sobre Nós",
|
|
576
|
+
fr: "À Propos",
|
|
577
|
+
es: "Acerca de Nosotros",
|
|
578
|
+
}),
|
|
707
579
|
},
|
|
708
580
|
};
|
|
709
581
|
|
|
710
|
-
export default
|
|
582
|
+
export default aboutPageContent;
|
|
711
583
|
```
|
|
712
584
|
|
|
713
|
-
```
|
|
585
|
+
```javascript fileName="pages/about-page.content.cjs" contentDeclarationFormat="commonjs"
|
|
714
586
|
const { t } = require("intlayer");
|
|
715
587
|
|
|
716
588
|
/** @type {import('intlayer').Dictionary} */
|
|
717
|
-
const
|
|
718
|
-
key: "about-
|
|
589
|
+
const aboutPageContent = {
|
|
590
|
+
key: "about-page",
|
|
719
591
|
content: {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
pt: "Sobre Nós - Minha Empresa",
|
|
723
|
-
en: "About Us - My Company",
|
|
592
|
+
metaTitle: t({
|
|
593
|
+
en: "Sobre Nós - Minha Empresa",
|
|
724
594
|
fr: "À Propos - Ma Société",
|
|
725
595
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
726
596
|
}),
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
en: "Learn more about our company and our mission",
|
|
597
|
+
metaDescription: t({
|
|
598
|
+
en: "Saiba mais sobre nossa empresa e nossa missão",
|
|
730
599
|
fr: "En savoir plus sur notre société et notre mission",
|
|
731
600
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
732
|
-
|
|
601
|
+
}),
|
|
602
|
+
title: t({
|
|
603
|
+
en: "Sobre Nós",
|
|
604
|
+
fr: "À Propos",
|
|
605
|
+
es: "Acerca de Nosotros",
|
|
733
606
|
}),
|
|
734
607
|
},
|
|
735
608
|
};
|
|
736
609
|
|
|
737
|
-
module.exports =
|
|
610
|
+
module.exports = aboutPageContent;
|
|
738
611
|
```
|
|
739
612
|
|
|
740
|
-
```json fileName="pages/about-
|
|
613
|
+
```json fileName="pages/about-page.content.json" contentDeclarationFormat="json"
|
|
741
614
|
{
|
|
742
|
-
"
|
|
615
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
616
|
+
"key": "about-page",
|
|
743
617
|
"content": {
|
|
744
|
-
"
|
|
618
|
+
"metaTitle": {
|
|
745
619
|
"nodeType": "translation",
|
|
746
|
-
"
|
|
747
|
-
"
|
|
748
|
-
"en": "About Us - My Company",
|
|
620
|
+
"translation": {
|
|
621
|
+
"en": "Sobre Nós - Minha Empresa",
|
|
749
622
|
"fr": "À Propos - Ma Société",
|
|
750
|
-
"es": "Acerca de Nosotros - Mi Empresa"
|
|
751
|
-
"pt": "Sobre Nós - Minha Empresa"
|
|
623
|
+
"es": "Acerca de Nosotros - Mi Empresa"
|
|
752
624
|
}
|
|
753
625
|
},
|
|
754
|
-
"
|
|
626
|
+
"metaDescription": {
|
|
755
627
|
"nodeType": "translation",
|
|
756
|
-
"
|
|
757
|
-
"
|
|
758
|
-
"en": "Learn more about our company and our mission",
|
|
628
|
+
"translation": {
|
|
629
|
+
"en": "Saiba mais sobre nossa empresa e nossa missão",
|
|
759
630
|
"fr": "En savoir plus sur notre société et notre mission",
|
|
760
631
|
"es": "Conozca más sobre nuestra empresa y nuestra misión"
|
|
761
632
|
}
|
|
633
|
+
},
|
|
634
|
+
"title": {
|
|
635
|
+
"nodeType": "translation",
|
|
636
|
+
"translation": {
|
|
637
|
+
"en": "Sobre Nós",
|
|
638
|
+
"fr": "À Propos",
|
|
639
|
+
"es": "Acerca de Nosotros"
|
|
640
|
+
}
|
|
762
641
|
}
|
|
763
642
|
}
|
|
764
643
|
}
|
|
765
644
|
```
|
|
766
645
|
|
|
767
|
-
### Configurar TypeScript
|
|
768
|
-
|
|
769
|
-
O Intlayer usa a ampliação de módulos para aproveitar os benefícios do TypeScript e tornar sua base de código mais robusta.
|
|
770
|
-
|
|
771
|
-

|
|
772
|
-
|
|
773
|
-

|
|
774
|
-
|
|
775
|
-
Certifique-se de que sua configuração do TypeScript inclua os tipos gerados automaticamente.
|
|
776
|
-
|
|
777
|
-
```json5 fileName="tsconfig.json"
|
|
778
|
-
{
|
|
779
|
-
// ... Suas configurações existentes do TypeScript
|
|
780
|
-
"include": [
|
|
781
|
-
// ... Suas configurações existentes do TypeScript
|
|
782
|
-
".intlayer/**/*.ts", // Inclua os tipos gerados automaticamente
|
|
783
|
-
],
|
|
784
|
-
}
|
|
785
|
-
```
|
|
786
|
-
|
|
787
646
|
### Configuração do Git
|
|
788
647
|
|
|
789
|
-
É recomendado ignorar os arquivos gerados pelo Intlayer. Isso permite
|
|
648
|
+
É recomendado ignorar os arquivos gerados pelo Intlayer. Isso permite que você evite comitá-los no seu repositório Git.
|
|
790
649
|
|
|
791
|
-
Para isso, você pode adicionar as seguintes instruções
|
|
650
|
+
Para isso, você pode adicionar as seguintes instruções ao seu arquivo `.gitignore`:
|
|
792
651
|
|
|
793
652
|
```plaintext fileName=".gitignore"
|
|
794
653
|
# Ignorar os arquivos gerados pelo Intlayer
|
|
795
654
|
.intlayer
|
|
796
655
|
```
|
|
797
656
|
|
|
798
|
-
### Extensão VS Code
|
|
657
|
+
### Extensão do VS Code
|
|
799
658
|
|
|
800
659
|
Para melhorar sua experiência de desenvolvimento com o Intlayer, você pode instalar a extensão oficial **Intlayer VS Code Extension**.
|
|
801
660
|
|
|
@@ -808,12 +667,10 @@ Esta extensão oferece:
|
|
|
808
667
|
- **Visualizações inline** do conteúdo traduzido.
|
|
809
668
|
- **Ações rápidas** para criar e atualizar traduções facilmente.
|
|
810
669
|
|
|
811
|
-
Para mais detalhes sobre como usar a extensão, consulte a [documentação da
|
|
670
|
+
Para mais detalhes sobre como usar a extensão, consulte a [documentação da Intlayer VS Code Extension](https://intlayer.org/doc/vs-code-extension).
|
|
812
671
|
|
|
813
672
|
---
|
|
814
673
|
|
|
815
674
|
### Ir Além
|
|
816
675
|
|
|
817
|
-
Para ir
|
|
818
|
-
|
|
819
|
-
---
|
|
676
|
+
Para ir mais longe, 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).
|