@intlayer/docs 7.3.11 → 7.3.12
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 +305 -421
- 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 +296 -394
- 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 +242 -321
- 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 +262 -358
- 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 +284 -375
- 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 +288 -387
- 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 +318 -434
- 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 +275 -376
- 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 +312 -408
- 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 +319 -414
- 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 +307 -406
- 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 +282 -457
- 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 +288 -403
- 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 +300 -410
- 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 +327 -392
- 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 +282 -399
- 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 +311 -444
- 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 +6 -6
- 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,34 +14,69 @@ 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=IE3XWkZ6a5U
|
|
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
|
+
<iframe
|
|
50
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-4-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
51
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
52
|
+
title="Demo CodeSandbox - Como Internacionalizar sua aplicação usando Intlayer"
|
|
53
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
54
|
+
loading="lazy"
|
|
55
|
+
/>
|
|
42
56
|
|
|
43
57
|
### Passo 1: Instalar Dependências
|
|
44
58
|
|
|
59
|
+
<Tab defaultTab="video">
|
|
60
|
+
<TabItem label="Vídeo" value="video">
|
|
61
|
+
|
|
62
|
+
<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/IE3XWkZ6a5U?autoplay=0&origin=http://intlayer.org&controls=0&rel=1"/>
|
|
63
|
+
|
|
64
|
+
</TabItem>
|
|
65
|
+
<TabItem label="Código" value="code">
|
|
66
|
+
|
|
67
|
+
<iframe
|
|
68
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-nuxt-4-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
69
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
70
|
+
title="Demo CodeSandbox - Como Internacionalizar sua aplicação usando Intlayer"
|
|
71
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
72
|
+
loading="lazy"
|
|
73
|
+
/>
|
|
74
|
+
|
|
75
|
+
</TabItem>
|
|
76
|
+
</Tab>
|
|
77
|
+
|
|
78
|
+
Veja o [Template da Aplicação](https://github.com/aymericzip/intlayer-nuxt-4-template) no GitHub.
|
|
79
|
+
|
|
45
80
|
Instale os pacotes necessários usando npm:
|
|
46
81
|
|
|
47
82
|
```bash packageManager="npm"
|
|
@@ -61,13 +96,13 @@ yarn add --save-dev nuxt-intlayer
|
|
|
61
96
|
|
|
62
97
|
- **intlayer**
|
|
63
98
|
|
|
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/
|
|
99
|
+
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
100
|
|
|
66
101
|
- **vue-intlayer**
|
|
67
102
|
O pacote que integra o Intlayer com a aplicação Vue. Ele fornece os composables para os componentes Vue.
|
|
68
103
|
|
|
69
104
|
- **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
|
|
105
|
+
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
106
|
|
|
72
107
|
### Passo 2: Configuração do seu projeto
|
|
73
108
|
|
|
@@ -82,13 +117,10 @@ const config: IntlayerConfig = {
|
|
|
82
117
|
Locales.ENGLISH,
|
|
83
118
|
Locales.FRENCH,
|
|
84
119
|
Locales.SPANISH,
|
|
85
|
-
// Seus outros
|
|
120
|
+
// Seus outros idiomas
|
|
86
121
|
],
|
|
87
122
|
defaultLocale: Locales.ENGLISH,
|
|
88
123
|
},
|
|
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
124
|
};
|
|
93
125
|
|
|
94
126
|
export default config;
|
|
@@ -98,20 +130,16 @@ export default config;
|
|
|
98
130
|
import { Locales } from "intlayer";
|
|
99
131
|
|
|
100
132
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
101
|
-
// Configuração do Intlayer para internacionalização e conteúdo
|
|
102
133
|
const config = {
|
|
103
134
|
internationalization: {
|
|
104
135
|
locales: [
|
|
105
136
|
Locales.ENGLISH,
|
|
106
137
|
Locales.FRENCH,
|
|
107
138
|
Locales.SPANISH,
|
|
108
|
-
// Seus outros
|
|
139
|
+
// Seus outros idiomas
|
|
109
140
|
],
|
|
110
141
|
defaultLocale: Locales.ENGLISH,
|
|
111
142
|
},
|
|
112
|
-
content: {
|
|
113
|
-
contentDir: ["."],
|
|
114
|
-
},
|
|
115
143
|
};
|
|
116
144
|
|
|
117
145
|
export default config;
|
|
@@ -121,26 +149,22 @@ export default config;
|
|
|
121
149
|
const { Locales } = require("intlayer");
|
|
122
150
|
|
|
123
151
|
/** @type {import('intlayer').IntlayerConfig} */
|
|
124
|
-
// Configuração do Intlayer para internacionalização e conteúdo
|
|
125
152
|
const config = {
|
|
126
153
|
internationalization: {
|
|
127
154
|
locales: [
|
|
128
155
|
Locales.ENGLISH,
|
|
129
156
|
Locales.FRENCH,
|
|
130
157
|
Locales.SPANISH,
|
|
131
|
-
// Seus outros
|
|
158
|
+
// Seus outros idiomas
|
|
132
159
|
],
|
|
133
160
|
defaultLocale: Locales.ENGLISH,
|
|
134
161
|
},
|
|
135
|
-
content: {
|
|
136
|
-
contentDir: ["."],
|
|
137
|
-
},
|
|
138
162
|
};
|
|
139
163
|
|
|
140
164
|
module.exports = config;
|
|
141
165
|
```
|
|
142
166
|
|
|
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
|
|
167
|
+
> 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
168
|
|
|
145
169
|
### Passo 3: Integre o Intlayer na sua Configuração Nuxt
|
|
146
170
|
|
|
@@ -155,238 +179,42 @@ export default defineNuxtConfig({
|
|
|
155
179
|
});
|
|
156
180
|
```
|
|
157
181
|
|
|
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
|
|
182
|
+
> 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
183
|
|
|
160
184
|
### Passo 4: Declare Seu Conteúdo
|
|
161
185
|
|
|
162
186
|
Crie e gerencie suas declarações de conteúdo para armazenar traduções:
|
|
163
187
|
|
|
164
|
-
```tsx fileName="
|
|
165
|
-
import {
|
|
188
|
+
```tsx fileName="content/home-page.content.ts" contentDeclarationFormat="typescript"
|
|
189
|
+
import { type Dictionary, t } from "intlayer";
|
|
166
190
|
|
|
167
|
-
const
|
|
168
|
-
key: "
|
|
191
|
+
const content = {
|
|
192
|
+
key: "home-page",
|
|
169
193
|
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 ",
|
|
194
|
+
title: t({
|
|
195
|
+
en: "Hello world",
|
|
196
|
+
fr: "Bonjour le monde",
|
|
197
|
+
es: "Hola mundo",
|
|
193
198
|
}),
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
es: "Documentación de Nuxt",
|
|
199
|
+
metaTitle: t({
|
|
200
|
+
en: "Welcome | My Application",
|
|
201
|
+
fr: "Bienvenue | Mon Application",
|
|
202
|
+
es: "Bienvenido | Mi Aplicación",
|
|
199
203
|
}),
|
|
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",
|
|
204
|
+
metaDescription: t({
|
|
205
|
+
en: "Discover your multilingual Nuxt app homepage powered by Intlayer.",
|
|
206
|
+
fr: "Découvrez la page d'accueil multilingue de votre application Nuxt propulsée par Intlayer.",
|
|
207
|
+
es: "Descubre la página de inicio multilingüe de tu aplicación Nuxt impulsada por Intlayer.",
|
|
206
208
|
}),
|
|
207
209
|
},
|
|
208
210
|
} satisfies Dictionary;
|
|
209
211
|
|
|
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
|
-
}
|
|
212
|
+
export default content;
|
|
385
213
|
```
|
|
386
214
|
|
|
387
215
|
> 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
216
|
|
|
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/
|
|
217
|
+
> 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
218
|
|
|
391
219
|
### Passo 5: Utilize o Intlayer no Seu Código
|
|
392
220
|
|
|
@@ -444,81 +272,71 @@ const countRef = ref(0);
|
|
|
444
272
|
O Intlayer oferece diferentes APIs para acessar seu conteúdo:
|
|
445
273
|
|
|
446
274
|
- **Sintaxe baseada em componentes** (recomendada):
|
|
447
|
-
Use a sintaxe `<myContent
|
|
275
|
+
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
276
|
|
|
449
277
|
- **Sintaxe baseada em string**:
|
|
450
278
|
Use `{{ myContent }}` para renderizar o conteúdo como texto simples, sem suporte ao Editor Visual.
|
|
451
279
|
|
|
452
|
-
- **Sintaxe HTML
|
|
280
|
+
- **Sintaxe HTML bruto**:
|
|
453
281
|
Use `<div v-html="myContent" />` para renderizar o conteúdo como HTML bruto, sem suporte ao Editor Visual.
|
|
454
282
|
|
|
455
283
|
- **Sintaxe de desestruturação**:
|
|
456
284
|
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
|
|
285
|
+
- Use `const content = useIntlayer("myContent");` e `{{ content.myContent }}` / `<content.myContent />`.
|
|
286
|
+
- Ou use `const { myContent } = useIntlayer("myContent");` e `{{ myContent}}` / `<myContent/>` para desestruturar o conteúdo.
|
|
459
287
|
|
|
460
288
|
### (Opcional) Passo 6: Alterar o idioma do seu conteúdo
|
|
461
289
|
|
|
462
290
|
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
291
|
|
|
464
|
-
Crie um componente para alternar entre idiomas:
|
|
292
|
+
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
293
|
|
|
466
294
|
```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
295
|
<script setup lang="ts">
|
|
478
|
-
import {
|
|
479
|
-
import { getLocaleName } from "intlayer";
|
|
296
|
+
import { getLocaleName, getLocalizedUrl } from "intlayer";
|
|
480
297
|
import { useLocale } from "vue-intlayer";
|
|
481
298
|
|
|
482
|
-
//
|
|
299
|
+
// Nuxt importa automaticamente useRoute
|
|
300
|
+
const route = useRoute();
|
|
483
301
|
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
302
|
</script>
|
|
303
|
+
|
|
304
|
+
<template>
|
|
305
|
+
<nav class="locale-switcher">
|
|
306
|
+
<NuxtLink
|
|
307
|
+
v-for="localeEl in availableLocales"
|
|
308
|
+
:key="localeEl"
|
|
309
|
+
:to="getLocalizedUrl(route.fullPath, localeEl)"
|
|
310
|
+
class="locale-link"
|
|
311
|
+
:class="{ 'active-locale': localeEl === locale }"
|
|
312
|
+
@click="setLocale(localeEl)"
|
|
313
|
+
>
|
|
314
|
+
{{ getLocaleName(localeEl) }}
|
|
315
|
+
</NuxtLink>
|
|
316
|
+
</nav>
|
|
499
317
|
</template>
|
|
318
|
+
```
|
|
500
319
|
|
|
501
|
-
|
|
502
|
-
.locale-switcher {
|
|
503
|
-
margin: 1rem 0;
|
|
504
|
-
}
|
|
320
|
+
> 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
321
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
322
|
+
Em seguida, configure seu `app.vue` para usar layouts:
|
|
323
|
+
|
|
324
|
+
```vue fileName="app.vue"
|
|
325
|
+
<template>
|
|
326
|
+
<NuxtLayout>
|
|
327
|
+
<NuxtPage />
|
|
328
|
+
</NuxtLayout>
|
|
329
|
+
</template>
|
|
512
330
|
```
|
|
513
331
|
|
|
514
|
-
|
|
332
|
+
### (Opcional) Passo 6b: Criar um Layout com Navegação
|
|
515
333
|
|
|
516
|
-
|
|
334
|
+
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:
|
|
335
|
+
|
|
336
|
+
```vue fileName="layouts/default.vue"
|
|
517
337
|
<script setup lang="ts">
|
|
518
|
-
import
|
|
338
|
+
import Links from "~/components/Links.vue";
|
|
519
339
|
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
520
|
-
|
|
521
|
-
const content = useIntlayer("app"); // Crie o arquivo de declaração intlayer relacionado
|
|
522
340
|
</script>
|
|
523
341
|
|
|
524
342
|
<template>
|
|
@@ -527,15 +345,20 @@ const content = useIntlayer("app"); // Crie o arquivo de declaração intlayer r
|
|
|
527
345
|
<LocaleSwitcher />
|
|
528
346
|
</header>
|
|
529
347
|
<main>
|
|
530
|
-
<
|
|
348
|
+
<slot />
|
|
531
349
|
</main>
|
|
350
|
+
|
|
351
|
+
<Links href="/">Início</Links>
|
|
352
|
+
<Links href="/about">Sobre</Links>
|
|
532
353
|
</div>
|
|
533
354
|
</template>
|
|
534
355
|
```
|
|
535
356
|
|
|
536
|
-
|
|
357
|
+
O componente `Links` (mostrado abaixo) garante que os links de navegação interna sejam automaticamente localizados.
|
|
358
|
+
|
|
359
|
+
### (Opcional) Passo 7: Adicionar Roteamento Localizado à sua aplicação
|
|
537
360
|
|
|
538
|
-
O Nuxt
|
|
361
|
+
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
362
|
|
|
540
363
|
Exemplo:
|
|
541
364
|
|
|
@@ -547,23 +370,58 @@ pages/
|
|
|
547
370
|
└── index.vue → /contact, /fr/contact, /es/contact
|
|
548
371
|
```
|
|
549
372
|
|
|
550
|
-
Para criar
|
|
373
|
+
Para criar páginas localizadas, basta criar seus arquivos Vue no diretório `pages/`. Aqui estão dois exemplos de páginas:
|
|
374
|
+
|
|
375
|
+
**Página inicial (`pages/index.vue`):**
|
|
376
|
+
|
|
377
|
+
```vue fileName="pages/index.vue"
|
|
378
|
+
<script setup lang="ts">
|
|
379
|
+
import { useIntlayer } from "vue-intlayer";
|
|
380
|
+
|
|
381
|
+
const content = useIntlayer("home-page");
|
|
382
|
+
|
|
383
|
+
useHead({
|
|
384
|
+
title: content.metaTitle.value,
|
|
385
|
+
meta: [
|
|
386
|
+
{
|
|
387
|
+
name: "description",
|
|
388
|
+
content: content.metaDescription.value,
|
|
389
|
+
},
|
|
390
|
+
],
|
|
391
|
+
});
|
|
392
|
+
</script>
|
|
393
|
+
|
|
394
|
+
<template>
|
|
395
|
+
<h1><content.title /></h1>
|
|
396
|
+
</template>
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**Página Sobre (`pages/about.vue`):**
|
|
551
400
|
|
|
552
401
|
```vue fileName="pages/about.vue"
|
|
553
402
|
<script setup lang="ts">
|
|
554
403
|
import { useIntlayer } from "vue-intlayer";
|
|
555
404
|
|
|
556
|
-
const content = useIntlayer("about");
|
|
405
|
+
const content = useIntlayer("about-page");
|
|
406
|
+
|
|
407
|
+
useHead({
|
|
408
|
+
title: content.metaTitle.raw, // Use .raw para acesso a string primitiva
|
|
409
|
+
meta: [
|
|
410
|
+
{
|
|
411
|
+
name: "description",
|
|
412
|
+
content: content.metaDescription.raw, // Use .raw para acesso a string primitiva
|
|
413
|
+
},
|
|
414
|
+
],
|
|
415
|
+
});
|
|
557
416
|
</script>
|
|
558
417
|
|
|
559
418
|
<template>
|
|
560
|
-
<
|
|
561
|
-
<h1>{{ content.title }}</h1>
|
|
562
|
-
<p>{{ content.description }}</p>
|
|
563
|
-
</div>
|
|
419
|
+
<h1><content.title /></h1>
|
|
564
420
|
</template>
|
|
565
421
|
```
|
|
566
422
|
|
|
423
|
+
> 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.
|
|
424
|
+
|
|
567
425
|
O módulo `nuxt-intlayer` irá automaticamente:
|
|
568
426
|
|
|
569
427
|
- Detectar o idioma preferido do usuário
|
|
@@ -574,191 +432,220 @@ O módulo `nuxt-intlayer` irá automaticamente:
|
|
|
574
432
|
|
|
575
433
|
### (Opcional) Passo 8: Criando um Componente de Link Localizado
|
|
576
434
|
|
|
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>
|
|
435
|
+
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
436
|
|
|
437
|
+
```vue fileName="components/Links.vue"
|
|
586
438
|
<script setup lang="ts">
|
|
587
|
-
import { computed } from "vue";
|
|
588
439
|
import { getLocalizedUrl } from "intlayer";
|
|
589
440
|
import { useLocale } from "vue-intlayer";
|
|
590
441
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
},
|
|
596
|
-
});
|
|
442
|
+
interface Props {
|
|
443
|
+
href: string;
|
|
444
|
+
locale?: string;
|
|
445
|
+
}
|
|
597
446
|
|
|
598
|
-
const
|
|
447
|
+
const props = defineProps<Props>();
|
|
599
448
|
|
|
600
|
-
|
|
601
|
-
const isExternalLink = computed(() => /^https?:\/\//.test(props.to || ""));
|
|
449
|
+
const { locale: currentLocale } = useLocale();
|
|
602
450
|
|
|
603
|
-
//
|
|
604
|
-
const
|
|
605
|
-
|
|
606
|
-
);
|
|
451
|
+
// Calcula o caminho final
|
|
452
|
+
const finalPath = computed(() => {
|
|
453
|
+
// 1. Verifica se o link é externo
|
|
454
|
+
const isExternal = /^https?:\/\//.test(props.href || "");
|
|
455
|
+
|
|
456
|
+
// 2. Se for externo, retorna como está (NuxtLink cuida da geração da tag <a>)
|
|
457
|
+
if (isExternal) return props.href;
|
|
458
|
+
|
|
459
|
+
// 3. Se for interno, localize a URL
|
|
460
|
+
const targetLocale = props.locale || currentLocale.value;
|
|
461
|
+
return getLocalizedUrl(props.href, targetLocale);
|
|
462
|
+
});
|
|
607
463
|
</script>
|
|
464
|
+
|
|
465
|
+
<template>
|
|
466
|
+
<NuxtLink :to="finalPath" v-bind="$attrs">
|
|
467
|
+
<slot />
|
|
468
|
+
</NuxtLink>
|
|
469
|
+
</template>
|
|
608
470
|
```
|
|
609
471
|
|
|
610
472
|
Então use este componente em toda a sua aplicação:
|
|
611
473
|
|
|
612
|
-
```vue fileName="
|
|
474
|
+
```vue fileName="layouts/default.vue"
|
|
475
|
+
<script setup lang="ts">
|
|
476
|
+
import Links from "~/components/Links.vue";
|
|
477
|
+
import LocaleSwitcher from "~/components/LocaleSwitcher.vue";
|
|
478
|
+
</script>
|
|
479
|
+
|
|
613
480
|
<template>
|
|
614
481
|
<div>
|
|
615
|
-
<
|
|
616
|
-
|
|
617
|
-
</
|
|
618
|
-
<
|
|
619
|
-
|
|
620
|
-
</
|
|
482
|
+
<header>
|
|
483
|
+
<LocaleSwitcher />
|
|
484
|
+
</header>
|
|
485
|
+
<main>
|
|
486
|
+
<slot />
|
|
487
|
+
</main>
|
|
488
|
+
|
|
489
|
+
<Links href="/">Início</Links>
|
|
490
|
+
<Links href="/about">Sobre</Links>
|
|
621
491
|
</div>
|
|
622
492
|
</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
493
|
```
|
|
631
494
|
|
|
495
|
+
> Ao usar `NuxtLink` com caminhos localizados, você garante que:
|
|
496
|
+
>
|
|
497
|
+
> - Os motores de busca possam rastrear e indexar todas as versões linguísticas das suas páginas
|
|
498
|
+
> - Os usuários possam compartilhar URLs localizadas diretamente
|
|
499
|
+
> - O histórico do navegador funcione corretamente com URLs prefixadas pelo locale
|
|
500
|
+
|
|
632
501
|
### (Opcional) Passo 9: Gerenciar Metadados e SEO
|
|
633
502
|
|
|
634
|
-
O Nuxt oferece excelentes capacidades de SEO. Você pode usar o Intlayer para gerenciar metadados localizados:
|
|
503
|
+
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
504
|
|
|
636
505
|
```vue fileName="pages/about.vue"
|
|
637
506
|
<script setup lang="ts">
|
|
638
|
-
import {
|
|
639
|
-
import { getIntlayer } from "intlayer";
|
|
640
|
-
import { useLocale } from "vue-intlayer";
|
|
507
|
+
import { useIntlayer } from "vue-intlayer";
|
|
641
508
|
|
|
642
|
-
|
|
643
|
-
const content =
|
|
509
|
+
// useHead é auto-importado no Nuxt
|
|
510
|
+
const content = useIntlayer("about-page");
|
|
644
511
|
|
|
645
|
-
|
|
646
|
-
title: content.
|
|
647
|
-
|
|
512
|
+
useHead({
|
|
513
|
+
title: content.metaTitle.raw, // Use .raw para acesso ao valor primitivo da string
|
|
514
|
+
meta: [
|
|
515
|
+
{
|
|
516
|
+
name: "description",
|
|
517
|
+
content: content.metaDescription.raw, // Use .raw para acessar a string primitiva
|
|
518
|
+
},
|
|
519
|
+
],
|
|
648
520
|
});
|
|
649
521
|
</script>
|
|
650
522
|
|
|
651
523
|
<template>
|
|
652
|
-
<
|
|
653
|
-
<h1>{{ content.pageTitle }}</h1>
|
|
654
|
-
<p>{{ content.pageContent }}</p>
|
|
655
|
-
</div>
|
|
524
|
+
<h1><content.title /></h1>
|
|
656
525
|
</template>
|
|
657
526
|
```
|
|
658
527
|
|
|
528
|
+
> Alternativamente, você pode usar a função `import { getIntlayer } from "intlayer"` para obter o conteúdo sem reatividade do Vue.
|
|
529
|
+
|
|
530
|
+
> **Acessando valores do conteúdo:**
|
|
531
|
+
>
|
|
532
|
+
> - Use `.raw` para obter o valor primitivo da string (não reativo)
|
|
533
|
+
> - Use `.value` para obter o valor reativo
|
|
534
|
+
> - Use a sintaxe de componente `<content.key />` para suporte ao Visual Editor
|
|
535
|
+
|
|
659
536
|
Crie a declaração de conteúdo correspondente:
|
|
660
537
|
|
|
661
|
-
```ts fileName="pages/about-
|
|
538
|
+
```ts fileName="pages/about-page.content.ts" contentDeclarationFormat="typescript"
|
|
662
539
|
import { t, type Dictionary } from "intlayer";
|
|
663
|
-
import type { useSeoMeta } from "nuxt/app";
|
|
664
540
|
|
|
665
|
-
const
|
|
666
|
-
key: "about-
|
|
541
|
+
const aboutPageContent = {
|
|
542
|
+
key: "about-page",
|
|
667
543
|
content: {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
en: "About Us - My Company",
|
|
544
|
+
metaTitle: t({
|
|
545
|
+
en: "Sobre Nós - Minha Empresa",
|
|
671
546
|
fr: "À Propos - Ma Société",
|
|
672
547
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
673
548
|
}),
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
en: "Learn more about our company and our mission",
|
|
549
|
+
metaDescription: t({
|
|
550
|
+
en: "Saiba mais sobre nossa empresa e nossa missão",
|
|
677
551
|
fr: "En savoir plus sur notre société et notre mission",
|
|
678
552
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
679
553
|
}),
|
|
554
|
+
title: t({
|
|
555
|
+
en: "Sobre Nós",
|
|
556
|
+
fr: "À Propos",
|
|
557
|
+
es: "Acerca de Nosotros",
|
|
558
|
+
}),
|
|
680
559
|
},
|
|
681
|
-
} satisfies Dictionary
|
|
560
|
+
} satisfies Dictionary;
|
|
682
561
|
|
|
683
|
-
export default
|
|
562
|
+
export default aboutPageContent;
|
|
684
563
|
```
|
|
685
564
|
|
|
686
|
-
```
|
|
565
|
+
```javascript fileName="pages/about-page.content.mjs" contentDeclarationFormat="esm"
|
|
687
566
|
import { t } from "intlayer";
|
|
688
567
|
|
|
689
568
|
/** @type {import('intlayer').Dictionary} */
|
|
690
|
-
const
|
|
691
|
-
key: "about-
|
|
569
|
+
const aboutPageContent = {
|
|
570
|
+
key: "about-page",
|
|
692
571
|
content: {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
pt: "Sobre Nós - Minha Empresa",
|
|
696
|
-
en: "About Us - My Company",
|
|
572
|
+
metaTitle: t({
|
|
573
|
+
en: "Sobre Nós - Minha Empresa",
|
|
697
574
|
fr: "À Propos - Ma Société",
|
|
698
575
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
699
576
|
}),
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
pt: "Saiba mais sobre nossa empresa e nossa missão",
|
|
703
|
-
en: "Learn more about our company and our mission",
|
|
577
|
+
metaDescription: t({
|
|
578
|
+
en: "Saiba mais sobre nossa empresa e nossa missão",
|
|
704
579
|
fr: "En savoir plus sur notre société et notre mission",
|
|
705
580
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
706
581
|
}),
|
|
582
|
+
title: t({
|
|
583
|
+
en: "Sobre Nós",
|
|
584
|
+
fr: "À Propos",
|
|
585
|
+
es: "Acerca de Nosotros",
|
|
586
|
+
}),
|
|
707
587
|
},
|
|
708
588
|
};
|
|
709
589
|
|
|
710
|
-
export default
|
|
590
|
+
export default aboutPageContent;
|
|
711
591
|
```
|
|
712
592
|
|
|
713
|
-
```
|
|
593
|
+
```javascript fileName="pages/about-page.content.cjs" contentDeclarationFormat="commonjs"
|
|
714
594
|
const { t } = require("intlayer");
|
|
715
595
|
|
|
716
596
|
/** @type {import('intlayer').Dictionary} */
|
|
717
|
-
const
|
|
718
|
-
key: "about-
|
|
597
|
+
const aboutPageContent = {
|
|
598
|
+
key: "about-page",
|
|
719
599
|
content: {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
pt: "Sobre Nós - Minha Empresa",
|
|
723
|
-
en: "About Us - My Company",
|
|
600
|
+
metaTitle: t({
|
|
601
|
+
en: "Sobre Nós - Minha Empresa",
|
|
724
602
|
fr: "À Propos - Ma Société",
|
|
725
603
|
es: "Acerca de Nosotros - Mi Empresa",
|
|
726
604
|
}),
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
en: "Learn more about our company and our mission",
|
|
605
|
+
metaDescription: t({
|
|
606
|
+
en: "Saiba mais sobre nossa empresa e nossa missão",
|
|
730
607
|
fr: "En savoir plus sur notre société et notre mission",
|
|
731
608
|
es: "Conozca más sobre nuestra empresa y nuestra misión",
|
|
732
|
-
|
|
609
|
+
}),
|
|
610
|
+
title: t({
|
|
611
|
+
en: "Sobre Nós",
|
|
612
|
+
fr: "À Propos",
|
|
613
|
+
es: "Acerca de Nosotros",
|
|
733
614
|
}),
|
|
734
615
|
},
|
|
735
616
|
};
|
|
736
617
|
|
|
737
|
-
module.exports =
|
|
618
|
+
module.exports = aboutPageContent;
|
|
738
619
|
```
|
|
739
620
|
|
|
740
|
-
```json fileName="pages/about-
|
|
621
|
+
```json fileName="pages/about-page.content.json" contentDeclarationFormat="json"
|
|
741
622
|
{
|
|
742
|
-
"
|
|
623
|
+
"$schema": "https://intlayer.org/schema.json",
|
|
624
|
+
"key": "about-page",
|
|
743
625
|
"content": {
|
|
744
|
-
"
|
|
626
|
+
"metaTitle": {
|
|
745
627
|
"nodeType": "translation",
|
|
746
|
-
"
|
|
747
|
-
"
|
|
748
|
-
"en": "About Us - My Company",
|
|
628
|
+
"translation": {
|
|
629
|
+
"en": "Sobre Nós - Minha Empresa",
|
|
749
630
|
"fr": "À Propos - Ma Société",
|
|
750
|
-
"es": "Acerca de Nosotros - Mi Empresa"
|
|
751
|
-
"pt": "Sobre Nós - Minha Empresa"
|
|
631
|
+
"es": "Acerca de Nosotros - Mi Empresa"
|
|
752
632
|
}
|
|
753
633
|
},
|
|
754
|
-
"
|
|
634
|
+
"metaDescription": {
|
|
755
635
|
"nodeType": "translation",
|
|
756
|
-
"
|
|
757
|
-
"
|
|
758
|
-
"en": "Learn more about our company and our mission",
|
|
636
|
+
"translation": {
|
|
637
|
+
"en": "Saiba mais sobre nossa empresa e nossa missão",
|
|
759
638
|
"fr": "En savoir plus sur notre société et notre mission",
|
|
760
639
|
"es": "Conozca más sobre nuestra empresa y nuestra misión"
|
|
761
640
|
}
|
|
641
|
+
},
|
|
642
|
+
"title": {
|
|
643
|
+
"nodeType": "translation",
|
|
644
|
+
"translation": {
|
|
645
|
+
"en": "Sobre Nós",
|
|
646
|
+
"fr": "À Propos",
|
|
647
|
+
"es": "Acerca de Nosotros"
|
|
648
|
+
}
|
|
762
649
|
}
|
|
763
650
|
}
|
|
764
651
|
}
|
|
@@ -766,11 +653,11 @@ module.exports = aboutMetaContent;
|
|
|
766
653
|
|
|
767
654
|
### Configurar TypeScript
|
|
768
655
|
|
|
769
|
-
|
|
656
|
+
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
657
|
|
|
771
|
-

|
|
772
659
|
|
|
773
|
-

|
|
774
661
|
|
|
775
662
|
Certifique-se de que sua configuração do TypeScript inclua os tipos gerados automaticamente.
|
|
776
663
|
|
|
@@ -786,16 +673,16 @@ Certifique-se de que sua configuração do TypeScript inclua os tipos gerados au
|
|
|
786
673
|
|
|
787
674
|
### Configuração do Git
|
|
788
675
|
|
|
789
|
-
É recomendado ignorar os arquivos gerados pelo Intlayer. Isso permite
|
|
676
|
+
É recomendado ignorar os arquivos gerados pelo Intlayer. Isso permite que você evite comitá-los no seu repositório Git.
|
|
790
677
|
|
|
791
|
-
Para isso, você pode adicionar as seguintes instruções
|
|
678
|
+
Para isso, você pode adicionar as seguintes instruções ao seu arquivo `.gitignore`:
|
|
792
679
|
|
|
793
680
|
```plaintext fileName=".gitignore"
|
|
794
681
|
# Ignorar os arquivos gerados pelo Intlayer
|
|
795
682
|
.intlayer
|
|
796
683
|
```
|
|
797
684
|
|
|
798
|
-
### Extensão VS Code
|
|
685
|
+
### Extensão do VS Code
|
|
799
686
|
|
|
800
687
|
Para melhorar sua experiência de desenvolvimento com o Intlayer, você pode instalar a extensão oficial **Intlayer VS Code Extension**.
|
|
801
688
|
|
|
@@ -808,12 +695,10 @@ Esta extensão oferece:
|
|
|
808
695
|
- **Visualizações inline** do conteúdo traduzido.
|
|
809
696
|
- **Ações rápidas** para criar e atualizar traduções facilmente.
|
|
810
697
|
|
|
811
|
-
Para mais detalhes sobre como usar a extensão, consulte a [documentação da
|
|
698
|
+
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
699
|
|
|
813
700
|
---
|
|
814
701
|
|
|
815
702
|
### Ir Além
|
|
816
703
|
|
|
817
|
-
Para ir
|
|
818
|
-
|
|
819
|
-
---
|
|
704
|
+
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).
|