@intlayer/docs 7.4.0 → 7.5.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blog/ar/intlayer_with_i18next.md +2 -0
- package/blog/ar/intlayer_with_next-i18next.md +2 -0
- package/blog/ar/intlayer_with_next-intl.md +2 -0
- package/blog/ar/intlayer_with_react-i18next.md +2 -0
- package/blog/ar/intlayer_with_react-intl.md +2 -0
- package/blog/ar/intlayer_with_vue-i18n.md +2 -0
- package/blog/de/intlayer_with_i18next.md +2 -0
- package/blog/de/intlayer_with_next-i18next.md +1 -0
- package/blog/de/intlayer_with_next-intl.md +2 -0
- package/blog/de/intlayer_with_react-i18next.md +2 -0
- package/blog/de/intlayer_with_react-intl.md +2 -0
- package/blog/de/intlayer_with_vue-i18n.md +2 -0
- package/blog/en/intlayer_with_i18next.md +6 -0
- package/blog/en/intlayer_with_next-i18next.md +3 -0
- package/blog/en/intlayer_with_next-intl.md +3 -0
- package/blog/en/intlayer_with_react-i18next.md +3 -0
- package/blog/en/intlayer_with_react-intl.md +3 -0
- package/blog/en/intlayer_with_vue-i18n.md +3 -0
- package/blog/en-GB/intlayer_with_i18next.md +2 -0
- package/blog/en-GB/intlayer_with_next-i18next.md +2 -0
- package/blog/en-GB/intlayer_with_next-intl.md +2 -0
- package/blog/en-GB/intlayer_with_react-i18next.md +2 -0
- package/blog/en-GB/intlayer_with_react-intl.md +2 -0
- package/blog/en-GB/intlayer_with_vue-i18n.md +2 -0
- package/blog/es/intlayer_with_i18next.md +2 -0
- package/blog/es/intlayer_with_next-i18next.md +2 -0
- package/blog/es/intlayer_with_next-intl.md +2 -0
- package/blog/es/intlayer_with_react-i18next.md +2 -0
- package/blog/es/intlayer_with_react-intl.md +2 -0
- package/blog/es/intlayer_with_vue-i18n.md +2 -0
- package/blog/fr/intlayer_with_i18next.md +2 -0
- package/blog/fr/intlayer_with_next-i18next.md +2 -0
- package/blog/fr/intlayer_with_next-intl.md +2 -0
- package/blog/fr/intlayer_with_react-i18next.md +2 -0
- package/blog/fr/intlayer_with_react-intl.md +2 -0
- package/blog/fr/intlayer_with_vue-i18n.md +2 -0
- package/blog/hi/intlayer_with_i18next.md +2 -0
- package/blog/hi/intlayer_with_next-i18next.md +2 -0
- package/blog/hi/intlayer_with_next-intl.md +2 -0
- package/blog/hi/intlayer_with_react-i18next.md +2 -0
- package/blog/hi/intlayer_with_react-intl.md +2 -0
- package/blog/hi/intlayer_with_vue-i18n.md +2 -0
- package/blog/id/intlayer_with_i18next.md +2 -0
- package/blog/id/intlayer_with_next-i18next.md +2 -0
- package/blog/id/intlayer_with_next-intl.md +2 -0
- package/blog/id/intlayer_with_react-i18next.md +2 -0
- package/blog/id/intlayer_with_react-intl.md +2 -0
- package/blog/id/intlayer_with_vue-i18n.md +2 -0
- package/blog/it/intlayer_with_i18next.md +2 -0
- package/blog/it/intlayer_with_next-i18next.md +2 -0
- package/blog/it/intlayer_with_next-intl.md +2 -0
- package/blog/it/intlayer_with_react-i18next.md +2 -0
- package/blog/it/intlayer_with_react-intl.md +2 -0
- package/blog/it/intlayer_with_vue-i18n.md +2 -0
- package/blog/ja/intlayer_with_i18next.md +2 -0
- package/blog/ja/intlayer_with_next-i18next.md +1 -0
- package/blog/ja/intlayer_with_next-intl.md +2 -0
- package/blog/ja/intlayer_with_react-i18next.md +2 -0
- package/blog/ja/intlayer_with_react-intl.md +2 -0
- package/blog/ja/intlayer_with_vue-i18n.md +2 -0
- package/blog/ko/intlayer_with_i18next.md +2 -0
- package/blog/ko/intlayer_with_next-i18next.md +2 -0
- package/blog/ko/intlayer_with_next-intl.md +2 -0
- package/blog/ko/intlayer_with_react-i18next.md +2 -0
- package/blog/ko/intlayer_with_react-intl.md +2 -0
- package/blog/ko/intlayer_with_vue-i18n.md +2 -0
- package/blog/pl/intlayer_with_i18next.md +2 -0
- package/blog/pl/intlayer_with_next-i18next.md +2 -0
- package/blog/pl/intlayer_with_next-intl.md +2 -0
- package/blog/pl/intlayer_with_react-i18next.md +2 -0
- package/blog/pl/intlayer_with_react-intl.md +2 -0
- package/blog/pl/intlayer_with_vue-i18n.md +2 -0
- package/blog/pt/intlayer_with_i18next.md +2 -0
- package/blog/pt/intlayer_with_next-i18next.md +2 -0
- package/blog/pt/intlayer_with_next-intl.md +2 -0
- package/blog/pt/intlayer_with_react-i18next.md +2 -0
- package/blog/pt/intlayer_with_react-intl.md +2 -0
- package/blog/pt/intlayer_with_vue-i18n.md +2 -0
- package/blog/ru/intlayer_with_i18next.md +2 -0
- package/blog/ru/intlayer_with_next-i18next.md +2 -0
- package/blog/ru/intlayer_with_next-intl.md +2 -0
- package/blog/ru/intlayer_with_react-i18next.md +2 -0
- package/blog/ru/intlayer_with_react-intl.md +2 -0
- package/blog/ru/intlayer_with_vue-i18n.md +2 -0
- package/blog/tr/intlayer_with_i18next.md +2 -0
- package/blog/tr/intlayer_with_next-i18next.md +2 -0
- package/blog/tr/intlayer_with_next-intl.md +2 -0
- package/blog/tr/intlayer_with_react-i18next.md +2 -0
- package/blog/tr/intlayer_with_react-intl.md +2 -0
- package/blog/tr/intlayer_with_vue-i18n.md +2 -0
- package/blog/vi/intlayer_with_i18next.md +2 -0
- package/blog/vi/intlayer_with_next-i18next.md +2 -0
- package/blog/vi/intlayer_with_next-intl.md +2 -0
- package/blog/vi/intlayer_with_react-i18next.md +2 -0
- package/blog/vi/intlayer_with_react-intl.md +2 -0
- package/blog/vi/intlayer_with_vue-i18n.md +2 -0
- package/blog/zh/intlayer_with_i18next.md +2 -0
- package/blog/zh/intlayer_with_next-i18next.md +2 -0
- package/blog/zh/intlayer_with_next-intl.md +2 -0
- package/blog/zh/intlayer_with_react-i18next.md +2 -0
- package/blog/zh/intlayer_with_react-intl.md +2 -0
- package/blog/zh/intlayer_with_vue-i18n.md +2 -0
- 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/cli/index.md +5 -0
- package/docs/ar/cli/login.md +157 -0
- package/docs/ar/configuration.md +12 -0
- package/docs/ar/dictionary/content_file.md +24 -1
- package/docs/ar/intlayer_with_astro.md +1 -1
- package/docs/ar/intlayer_with_express.md +1 -1
- package/docs/ar/intlayer_with_nestjs.md +1 -1
- package/docs/ar/intlayer_with_next-i18next.md +1 -0
- package/docs/ar/intlayer_with_next-intl.md +1 -0
- package/docs/ar/intlayer_with_tanstack.md +1 -12
- package/docs/ar/plugins/sync-json.md +27 -2
- package/docs/de/cli/index.md +5 -0
- package/docs/de/cli/login.md +160 -0
- package/docs/de/configuration.md +12 -0
- package/docs/de/dictionary/content_file.md +24 -1
- package/docs/de/intlayer_with_astro.md +1 -1
- package/docs/de/intlayer_with_express.md +1 -1
- package/docs/de/intlayer_with_nestjs.md +1 -1
- package/docs/de/intlayer_with_next-i18next.md +1 -0
- package/docs/de/intlayer_with_next-intl.md +1 -0
- package/docs/de/intlayer_with_tanstack.md +1 -12
- package/docs/de/plugins/sync-json.md +27 -2
- package/docs/en/cli/index.md +5 -0
- package/docs/en/cli/login.md +157 -0
- package/docs/en/configuration.md +13 -0
- package/docs/en/dictionary/content_file.md +24 -1
- package/docs/en/index.md +1 -0
- package/docs/en/intlayer_with_astro.md +1 -1
- package/docs/en/intlayer_with_express.md +1 -1
- package/docs/en/intlayer_with_nestjs.md +1 -2
- package/docs/en/intlayer_with_next-i18next.md +1 -0
- package/docs/en/intlayer_with_next-intl.md +1 -0
- package/docs/en/intlayer_with_tanstack.md +7 -17
- package/docs/en/plugins/sync-json.md +53 -2
- package/docs/en-GB/cli/index.md +5 -0
- package/docs/en-GB/cli/login.md +181 -0
- package/docs/en-GB/configuration.md +12 -0
- package/docs/en-GB/dictionary/content_file.md +24 -1
- package/docs/en-GB/intlayer_with_astro.md +1 -1
- package/docs/en-GB/intlayer_with_express.md +1 -1
- package/docs/en-GB/intlayer_with_nestjs.md +1 -1
- package/docs/en-GB/intlayer_with_next-i18next.md +1 -0
- package/docs/en-GB/intlayer_with_next-intl.md +1 -0
- package/docs/en-GB/intlayer_with_tanstack.md +1 -12
- package/docs/en-GB/plugins/sync-json.md +26 -1
- package/docs/es/cli/index.md +5 -0
- package/docs/es/cli/login.md +182 -0
- package/docs/es/configuration.md +12 -0
- package/docs/es/dictionary/content_file.md +24 -1
- package/docs/es/intlayer_with_astro.md +1 -1
- package/docs/es/intlayer_with_express.md +1 -1
- package/docs/es/intlayer_with_nestjs.md +1 -1
- package/docs/es/intlayer_with_next-i18next.md +1 -0
- package/docs/es/intlayer_with_next-intl.md +1 -0
- package/docs/es/intlayer_with_tanstack.md +1 -12
- package/docs/es/plugins/sync-json.md +27 -2
- package/docs/fr/cli/index.md +5 -0
- package/docs/fr/cli/login.md +185 -0
- package/docs/fr/configuration.md +12 -0
- package/docs/fr/dictionary/content_file.md +24 -1
- package/docs/fr/intlayer_with_astro.md +1 -1
- package/docs/fr/intlayer_with_express.md +1 -1
- package/docs/fr/intlayer_with_nestjs.md +1 -1
- package/docs/fr/intlayer_with_next-i18next.md +1 -0
- package/docs/fr/intlayer_with_next-intl.md +1 -0
- package/docs/fr/intlayer_with_tanstack.md +1 -12
- package/docs/fr/plugins/sync-json.md +27 -2
- package/docs/hi/cli/index.md +5 -0
- package/docs/hi/cli/login.md +181 -0
- package/docs/hi/configuration.md +12 -0
- package/docs/hi/dictionary/content_file.md +24 -1
- package/docs/hi/intlayer_with_astro.md +1 -1
- package/docs/hi/intlayer_with_express.md +1 -1
- package/docs/hi/intlayer_with_nestjs.md +1 -1
- package/docs/hi/intlayer_with_next-i18next.md +1 -0
- package/docs/hi/intlayer_with_next-intl.md +1 -0
- package/docs/hi/intlayer_with_tanstack.md +1 -12
- package/docs/hi/plugins/sync-json.md +27 -2
- package/docs/id/cli/index.md +5 -0
- package/docs/id/cli/login.md +157 -0
- package/docs/id/configuration.md +12 -0
- package/docs/id/dictionary/content_file.md +24 -1
- package/docs/id/intlayer_with_astro.md +1 -1
- package/docs/id/intlayer_with_express.md +1 -1
- package/docs/id/intlayer_with_nestjs.md +1 -1
- package/docs/id/intlayer_with_next-i18next.md +1 -0
- package/docs/id/intlayer_with_next-intl.md +1 -0
- package/docs/id/intlayer_with_tanstack.md +1 -12
- package/docs/id/plugins/sync-json.md +27 -2
- package/docs/it/cli/index.md +5 -0
- package/docs/it/cli/login.md +157 -0
- package/docs/it/configuration.md +12 -0
- package/docs/it/dictionary/content_file.md +24 -1
- package/docs/it/intlayer_with_astro.md +1 -1
- package/docs/it/intlayer_with_express.md +1 -1
- package/docs/it/intlayer_with_nestjs.md +1 -1
- package/docs/it/intlayer_with_next-i18next.md +1 -0
- package/docs/it/intlayer_with_next-intl.md +1 -0
- package/docs/it/intlayer_with_tanstack.md +1 -12
- package/docs/it/plugins/sync-json.md +27 -2
- package/docs/ja/cli/index.md +5 -0
- package/docs/ja/cli/login.md +159 -0
- package/docs/ja/configuration.md +12 -0
- package/docs/ja/dictionary/content_file.md +24 -1
- package/docs/ja/intlayer_with_astro.md +1 -1
- package/docs/ja/intlayer_with_express.md +1 -1
- package/docs/ja/intlayer_with_nestjs.md +1 -1
- package/docs/ja/intlayer_with_next-i18next.md +1 -0
- package/docs/ja/intlayer_with_next-intl.md +1 -0
- package/docs/ja/intlayer_with_tanstack.md +1 -12
- package/docs/ja/plugins/sync-json.md +27 -2
- package/docs/ko/cli/index.md +5 -0
- package/docs/ko/cli/login.md +188 -0
- package/docs/ko/configuration.md +12 -0
- package/docs/ko/dictionary/content_file.md +44 -1
- package/docs/ko/intlayer_with_astro.md +1 -1
- package/docs/ko/intlayer_with_express.md +1 -1
- package/docs/ko/intlayer_with_nestjs.md +1 -1
- package/docs/ko/intlayer_with_next-i18next.md +1 -0
- package/docs/ko/intlayer_with_next-intl.md +1 -0
- package/docs/ko/intlayer_with_tanstack.md +1 -12
- package/docs/ko/plugins/sync-json.md +27 -2
- package/docs/pl/cli/index.md +5 -0
- package/docs/pl/cli/login.md +187 -0
- package/docs/pl/configuration.md +12 -0
- package/docs/pl/dictionary/content_file.md +24 -1
- package/docs/pl/intlayer_with_astro.md +2 -2
- package/docs/pl/intlayer_with_express.md +1 -1
- package/docs/pl/intlayer_with_nestjs.md +1 -1
- package/docs/pl/intlayer_with_next-i18next.md +1 -0
- package/docs/pl/intlayer_with_next-intl.md +1 -0
- package/docs/pl/intlayer_with_tanstack.md +1 -12
- package/docs/pl/plugins/sync-json.md +24 -2
- package/docs/pt/cli/index.md +5 -0
- package/docs/pt/cli/login.md +186 -0
- package/docs/pt/configuration.md +12 -0
- package/docs/pt/dictionary/content_file.md +24 -1
- package/docs/pt/intlayer_with_astro.md +1 -1
- package/docs/pt/intlayer_with_express.md +1 -1
- package/docs/pt/intlayer_with_nestjs.md +1 -1
- package/docs/pt/intlayer_with_next-i18next.md +1 -0
- package/docs/pt/intlayer_with_next-intl.md +1 -0
- package/docs/pt/intlayer_with_react_router_v7_fs_routes.md +570 -0
- package/docs/pt/intlayer_with_tanstack.md +1 -12
- package/docs/pt/plugins/sync-json.md +27 -2
- package/docs/ru/cli/index.md +5 -0
- package/docs/ru/cli/login.md +181 -0
- package/docs/ru/configuration.md +12 -0
- package/docs/ru/dictionary/content_file.md +44 -1
- package/docs/ru/intlayer_with_astro.md +1 -1
- package/docs/ru/intlayer_with_express.md +1 -1
- package/docs/ru/intlayer_with_nestjs.md +1 -1
- package/docs/ru/intlayer_with_next-i18next.md +1 -0
- package/docs/ru/intlayer_with_next-intl.md +1 -0
- package/docs/ru/intlayer_with_tanstack.md +1 -12
- package/docs/ru/plugins/sync-json.md +27 -2
- package/docs/tr/cli/index.md +5 -0
- package/docs/tr/cli/login.md +171 -0
- package/docs/tr/configuration.md +12 -0
- package/docs/tr/dictionary/content_file.md +44 -1
- package/docs/tr/intlayer_with_astro.md +1 -1
- package/docs/tr/intlayer_with_express.md +1 -1
- package/docs/tr/intlayer_with_next-i18next.md +1 -0
- package/docs/tr/intlayer_with_next-intl.md +1 -0
- package/docs/tr/intlayer_with_tanstack.md +1 -12
- package/docs/tr/plugins/sync-json.md +27 -2
- package/docs/vi/cli/index.md +5 -0
- package/docs/vi/cli/login.md +186 -0
- package/docs/vi/configuration.md +12 -0
- package/docs/vi/dictionary/content_file.md +24 -1
- package/docs/vi/intlayer_with_astro.md +1 -1
- package/docs/vi/intlayer_with_express.md +1 -1
- package/docs/vi/intlayer_with_nestjs.md +1 -1
- package/docs/vi/intlayer_with_next-i18next.md +1 -0
- package/docs/vi/intlayer_with_next-intl.md +1 -0
- package/docs/vi/intlayer_with_tanstack.md +1 -12
- package/docs/vi/plugins/sync-json.md +27 -2
- package/docs/zh/cli/index.md +5 -0
- package/docs/zh/cli/login.md +182 -0
- package/docs/zh/configuration.md +12 -0
- package/docs/zh/dictionary/content_file.md +44 -1
- package/docs/zh/intlayer_with_astro.md +1 -1
- package/docs/zh/intlayer_with_express.md +1 -1
- package/docs/zh/intlayer_with_nestjs.md +1 -1
- package/docs/zh/intlayer_with_next-i18next.md +1 -0
- package/docs/zh/intlayer_with_next-intl.md +1 -0
- package/docs/zh/intlayer_with_tanstack.md +1 -12
- package/docs/zh/plugins/sync-json.md +27 -2
- package/package.json +9 -9
- package/src/generated/docs.entry.ts +19 -0
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
---
|
|
2
|
+
createdAt: 2025-12-07
|
|
3
|
+
updatedAt: 2025-12-07
|
|
4
|
+
title: Como traduzir sua aplicação React Router v7 (File-System Routes) – guia i18n 2025
|
|
5
|
+
description: Aprenda como adicionar internacionalização (i18n) à sua aplicação React Router v7 usando Intlayer com roteamento baseado em sistema de arquivos. Siga este guia completo para tornar sua aplicação multilíngue com roteamento consciente de localidade.
|
|
6
|
+
keywords:
|
|
7
|
+
- Internacionalização
|
|
8
|
+
- Documentação
|
|
9
|
+
- Intlayer
|
|
10
|
+
- React Router v7
|
|
11
|
+
- fs-routes
|
|
12
|
+
- File System Routes
|
|
13
|
+
- React
|
|
14
|
+
- i18n
|
|
15
|
+
- TypeScript
|
|
16
|
+
- Locale Routing
|
|
17
|
+
slugs:
|
|
18
|
+
- doc
|
|
19
|
+
- environment
|
|
20
|
+
- vite-and-react
|
|
21
|
+
- react-router-v7-fs-routes
|
|
22
|
+
applicationTemplate: https://github.com/aymericzip/intlayer-react-router-v7-fs-routes-template
|
|
23
|
+
youtubeVideo: https://www.youtube.com/watch?v=dS9L7uJeak4
|
|
24
|
+
history:
|
|
25
|
+
- version: 7.3.4
|
|
26
|
+
date: 2025-12-08
|
|
27
|
+
changes: Histórico inicial
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
# Traduza seu site React Router v7 (File-System Routes) usando Intlayer | Internacionalização (i18n)
|
|
31
|
+
|
|
32
|
+
Este guia demonstra como integrar o **Intlayer** para internacionalização perfeita em projetos React Router v7 usando **roteamento baseado em sistema de arquivos** (`@react-router/fs-routes`) com roteamento consciente de localidade, suporte a TypeScript e práticas modernas de desenvolvimento.
|
|
33
|
+
|
|
34
|
+
## Índice
|
|
35
|
+
|
|
36
|
+
<TOC/>
|
|
37
|
+
|
|
38
|
+
## O que é o Intlayer?
|
|
39
|
+
|
|
40
|
+
**Intlayer** é uma biblioteca de internacionalização (i18n) inovadora e de código aberto projetada para simplificar o suporte multilíngue em aplicações web modernas.
|
|
41
|
+
|
|
42
|
+
Com o Intlayer, você pode:
|
|
43
|
+
|
|
44
|
+
- **Gerenciar traduções facilmente** usando dicionários declarativos no nível do componente.
|
|
45
|
+
- **Localizar dinamicamente metadados**, rotas e conteúdo.
|
|
46
|
+
- **Garantir suporte ao TypeScript** com tipos autogerados, melhorando o preenchimento automático e a detecção de erros.
|
|
47
|
+
- **Aproveitar recursos avançados**, como detecção dinâmica de localidade e alternância de idioma.
|
|
48
|
+
- **Habilitar roteamento consciente de localidade** com o sistema de roteamento baseado em sistema de arquivos do React Router v7.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Guia Passo a Passo para Configurar o Intlayer em uma Aplicação React Router v7 com File-System Routes
|
|
53
|
+
|
|
54
|
+
<Tab defaultTab="video">
|
|
55
|
+
<TabItem label="Vídeo" value="video">
|
|
56
|
+
|
|
57
|
+
<iframe title="Como traduzir sua aplicação React Router v7 (File-System Routes) usando 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/dS9L7uJeak4?autoplay=0&origin=http://intlayer.org&controls=0&rel=1"/>
|
|
58
|
+
|
|
59
|
+
</TabItem>
|
|
60
|
+
<TabItem label="Código" value="code">
|
|
61
|
+
|
|
62
|
+
<iframe
|
|
63
|
+
src="https://stackblitz.com/github/aymericzip/intlayer-react-router-v7-fs-routes-template?embed=1&ctl=1&file=intlayer.config.ts"
|
|
64
|
+
className="m-auto overflow-hidden rounded-lg border-0 max-md:size-full max-md:h-[700px] md:aspect-16/9 md:w-full"
|
|
65
|
+
title="Demo CodeSandbox - Como internacionalizar sua aplicação usando Intlayer"
|
|
66
|
+
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
|
|
67
|
+
loading="lazy"
|
|
68
|
+
/>
|
|
69
|
+
|
|
70
|
+
</TabItem>
|
|
71
|
+
</Tab>
|
|
72
|
+
|
|
73
|
+
Veja o [Application Template](https://github.com/aymericzip/intlayer-react-router-v7-fs-routes-template) no GitHub.
|
|
74
|
+
|
|
75
|
+
### Passo 1: Instalar Dependências
|
|
76
|
+
|
|
77
|
+
Instale os pacotes necessários usando seu gerenciador de pacotes preferido:
|
|
78
|
+
|
|
79
|
+
```bash packageManager="npm"
|
|
80
|
+
npm install intlayer react-intlayer
|
|
81
|
+
npm install vite-intlayer --save-dev
|
|
82
|
+
npm install @react-router/fs-routes --save-dev
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```bash packageManager="pnpm"
|
|
86
|
+
pnpm add intlayer react-intlayer
|
|
87
|
+
pnpm add vite-intlayer --save-dev
|
|
88
|
+
pnpm add @react-router/fs-routes --save-dev
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
- **intlayer**
|
|
92
|
+
|
|
93
|
+
O pacote principal que fornece ferramentas de internacionalização para gerenciamento de configuração, tradução, [declaração de conteúdo](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/content_file.md), transpilação e [comandos CLI](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/cli/index.md).
|
|
94
|
+
|
|
95
|
+
- **react-intlayer**
|
|
96
|
+
O pacote que integra o Intlayer com aplicações React. Fornece providers de contexto e hooks para internacionalização em React.
|
|
97
|
+
|
|
98
|
+
- **vite-intlayer**
|
|
99
|
+
Inclui o plugin Vite para integrar o Intlayer com o [Vite bundler](https://vite.dev/guide/why.html#why-bundle-for-production), bem como middleware para detectar a localidade preferida do usuário, gerenciar cookies e lidar com redirecionamento de URL.
|
|
100
|
+
|
|
101
|
+
- **@react-router/fs-routes**
|
|
102
|
+
O pacote que habilita roteamento baseado em sistema de arquivos para React Router v7.
|
|
103
|
+
|
|
104
|
+
### Passo 2: Configuração do seu projeto
|
|
105
|
+
|
|
106
|
+
Crie um arquivo de configuração para configurar os idiomas da sua aplicação:
|
|
107
|
+
|
|
108
|
+
```typescript fileName="intlayer.config.ts" codeFormat="typescript"
|
|
109
|
+
import { type IntlayerConfig, Locales } from "intlayer";
|
|
110
|
+
|
|
111
|
+
const config: IntlayerConfig = {
|
|
112
|
+
internationalization: {
|
|
113
|
+
defaultLocale: Locales.ENGLISH,
|
|
114
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export default config;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
```javascript fileName="intlayer.config.mjs" codeFormat="esm"
|
|
122
|
+
import { Locales } from "intlayer";
|
|
123
|
+
|
|
124
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
125
|
+
const config = {
|
|
126
|
+
internationalization: {
|
|
127
|
+
defaultLocale: Locales.ENGLISH,
|
|
128
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export default config;
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```javascript fileName="intlayer.config.cjs" codeFormat="commonjs"
|
|
136
|
+
const { Locales } = require("intlayer");
|
|
137
|
+
|
|
138
|
+
/** @type {import('intlayer').IntlayerConfig} */
|
|
139
|
+
const config = {
|
|
140
|
+
internationalization: {
|
|
141
|
+
defaultLocale: Locales.ENGLISH,
|
|
142
|
+
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH],
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
module.exports = config;
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
> Através deste arquivo de configuração, você pode configurar URLs localizadas, redirecionamento de middleware, nomes de cookies, a localização e extensão das suas declarações de conteúdo, desabilitar os 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).
|
|
150
|
+
|
|
151
|
+
### Passo 3: Integrar o Intlayer na sua Configuração do Vite
|
|
152
|
+
|
|
153
|
+
Adicione o plugin intlayer na sua configuração:
|
|
154
|
+
|
|
155
|
+
```typescript fileName="vite.config.ts"
|
|
156
|
+
import { reactRouter } from "@react-router/dev/vite";
|
|
157
|
+
import { defineConfig } from "vite";
|
|
158
|
+
import { intlayer } from "vite-intlayer";
|
|
159
|
+
import tsconfigPaths from "vite-tsconfig-paths";
|
|
160
|
+
|
|
161
|
+
export default defineConfig({
|
|
162
|
+
plugins: [reactRouter(), tsconfigPaths(), intlayer()],
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
> O plugin Vite `intlayer()` é usado para integrar o Intlayer com o Vite. Ele garante a construção dos arquivos de declaração de conteúdo e os monitora em modo de desenvolvimento. Ele define variáveis de ambiente do Intlayer dentro da aplicação Vite. Além disso, fornece aliases para otimizar o desempenho.
|
|
167
|
+
|
|
168
|
+
### Passo 4: Configurar Rotas File-System do React Router v7
|
|
169
|
+
|
|
170
|
+
Configure sua configuração de rotas para usar rotas baseadas em sistema de arquivos com `flatRoutes`:
|
|
171
|
+
|
|
172
|
+
```typescript fileName="app/routes.ts"
|
|
173
|
+
import type { RouteConfig } from "@react-router/dev/routes";
|
|
174
|
+
import { flatRoutes } from "@react-router/fs-routes";
|
|
175
|
+
import { configuration } from "intlayer";
|
|
176
|
+
|
|
177
|
+
const routes: RouteConfig = flatRoutes({
|
|
178
|
+
// Ignorar arquivos de declaração de conteúdo para não serem tratados como rotas
|
|
179
|
+
ignoredRouteFiles: configuration.content.fileExtensions.map(
|
|
180
|
+
(fileExtension) => `**/*${fileExtension}`
|
|
181
|
+
),
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
export default routes;
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
> A função `flatRoutes` do `@react-router/fs-routes` habilita roteamento baseado em sistema de arquivos, onde a estrutura de arquivos no diretório `routes/` determina as rotas da sua aplicação. A opção `ignoredRouteFiles` garante que os arquivos de declaração de conteúdo do Intlayer (`.content.ts`, etc.) não sejam tratados como arquivos de rota.
|
|
188
|
+
|
|
189
|
+
### Passo 5: Criar Arquivos de Rota com Convenções File-System
|
|
190
|
+
|
|
191
|
+
Com roteamento baseado em sistema de arquivos, você usa uma convenção de nomenclatura plana onde pontos (`.`) representam segmentos de caminho e parênteses `()` denotam segmentos opcionais.
|
|
192
|
+
|
|
193
|
+
Crie os seguintes arquivos no seu diretório `app/routes/`:
|
|
194
|
+
|
|
195
|
+
#### Estrutura de Arquivos
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
app/routes/
|
|
199
|
+
├── ($locale)._layout.tsx # Wrapper de layout para rotas de locale
|
|
200
|
+
├── ($locale)._index.tsx # Página inicial (/:locale?)
|
|
201
|
+
├── ($locale)._index.content.ts # Conteúdo da página inicial
|
|
202
|
+
├── ($locale).about.tsx # Página About (/:locale?/about)
|
|
203
|
+
└── ($locale).about.content.ts # Conteúdo da página About
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
As convenções de nomenclatura:
|
|
207
|
+
|
|
208
|
+
- `($locale)` - Segmento dinâmico opcional para o parâmetro locale
|
|
209
|
+
- `_layout` - Rota de layout que envolve as rotas filhas
|
|
210
|
+
- `_index` - Rota index (renderiza no caminho pai)
|
|
211
|
+
- `.` (ponto) - Separa segmentos de caminho (ex.: `($locale).about` → `/:locale?/about`)
|
|
212
|
+
|
|
213
|
+
#### Componente de Layout
|
|
214
|
+
|
|
215
|
+
```tsx fileName="app/routes/($locale)._layout.tsx"
|
|
216
|
+
import { IntlayerProvider } from "react-intlayer";
|
|
217
|
+
import { Outlet } from "react-router";
|
|
218
|
+
|
|
219
|
+
import { useI18nHTMLAttributes } from "~/hooks/useI18nHTMLAttributes";
|
|
220
|
+
|
|
221
|
+
import type { Route } from "./+types/($locale)._layout";
|
|
222
|
+
|
|
223
|
+
export default function RootLayout({ params }: Route.ComponentProps) {
|
|
224
|
+
useI18nHTMLAttributes();
|
|
225
|
+
|
|
226
|
+
const { locale } = params;
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<IntlayerProvider locale={locale}>
|
|
230
|
+
<Outlet />
|
|
231
|
+
</IntlayerProvider>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
#### Página Index
|
|
237
|
+
|
|
238
|
+
```tsx fileName="app/routes/($locale)._index.tsx"
|
|
239
|
+
import { useIntlayer } from "react-intlayer";
|
|
240
|
+
import { LocalizedLink } from "~/components/localized-link";
|
|
241
|
+
|
|
242
|
+
import type { Route } from "./+types/($locale)._index";
|
|
243
|
+
|
|
244
|
+
export default function Page() {
|
|
245
|
+
const { title, description, aboutLink } = useIntlayer("page");
|
|
246
|
+
|
|
247
|
+
return (
|
|
248
|
+
<div>
|
|
249
|
+
<h1>{title}</h1>
|
|
250
|
+
<p>{description}</p>
|
|
251
|
+
<nav>
|
|
252
|
+
<LocalizedLink to="/about">{aboutLink}</LocalizedLink>
|
|
253
|
+
</nav>
|
|
254
|
+
</div>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
#### Página About
|
|
260
|
+
|
|
261
|
+
```tsx fileName="app/routes/($locale).about.tsx"
|
|
262
|
+
import { useIntlayer } from "react-intlayer";
|
|
263
|
+
import { LocalizedLink } from "~/components/localized-link";
|
|
264
|
+
|
|
265
|
+
import type { Route } from "./+types/($locale).about";
|
|
266
|
+
|
|
267
|
+
export default function AboutPage() {
|
|
268
|
+
const { title, content, homeLink } = useIntlayer("about");
|
|
269
|
+
|
|
270
|
+
return (
|
|
271
|
+
<div>
|
|
272
|
+
<h1>{title}</h1>
|
|
273
|
+
<p>{content}</p>
|
|
274
|
+
<nav>
|
|
275
|
+
<LocalizedLink to="/">{homeLink}</LocalizedLink>
|
|
276
|
+
</nav>
|
|
277
|
+
</div>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Passo 6: Declarar seu Conteúdo
|
|
283
|
+
|
|
284
|
+
Crie e gerencie suas declarações de conteúdo para armazenar traduções. Coloque os arquivos de conteúdo ao lado dos seus arquivos de rota:
|
|
285
|
+
|
|
286
|
+
```tsx fileName="app/routes/($locale)._index.content.ts"
|
|
287
|
+
import { t, type Dictionary } from "intlayer";
|
|
288
|
+
|
|
289
|
+
const pageContent = {
|
|
290
|
+
key: "page",
|
|
291
|
+
content: {
|
|
292
|
+
title: t({
|
|
293
|
+
en: "Welcome to React Router v7 + Intlayer",
|
|
294
|
+
es: "Bienvenido a React Router v7 + Intlayer",
|
|
295
|
+
fr: "Bienvenue sur React Router v7 + Intlayer",
|
|
296
|
+
}),
|
|
297
|
+
description: t({
|
|
298
|
+
en: "Build multilingual applications with ease using React Router v7 and Intlayer.",
|
|
299
|
+
es: "Cree aplicaciones multilingües fácilmente usando React Router v7 y Intlayer.",
|
|
300
|
+
fr: "Créez des applications multilingues facilement avec React Router v7 et Intlayer.",
|
|
301
|
+
}),
|
|
302
|
+
aboutLink: t({
|
|
303
|
+
en: "Learn About Us",
|
|
304
|
+
es: "Aprender Sobre Nosotros",
|
|
305
|
+
fr: "En savoir plus sur nous",
|
|
306
|
+
}),
|
|
307
|
+
},
|
|
308
|
+
} satisfies Dictionary;
|
|
309
|
+
|
|
310
|
+
export default pageContent;
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
```tsx fileName="app/routes/($locale).about.content.ts"
|
|
314
|
+
import { t, type Dictionary } from "intlayer";
|
|
315
|
+
|
|
316
|
+
const aboutContent = {
|
|
317
|
+
key: "about",
|
|
318
|
+
content: {
|
|
319
|
+
title: t({
|
|
320
|
+
en: "About Us",
|
|
321
|
+
es: "Sobre Nosotros",
|
|
322
|
+
fr: "À propos de nous",
|
|
323
|
+
}),
|
|
324
|
+
content: t({
|
|
325
|
+
en: "This is the about page content.",
|
|
326
|
+
es: "Este es el contenido de la página de información.",
|
|
327
|
+
fr: "Ceci est le contenu de la page à propos.",
|
|
328
|
+
}),
|
|
329
|
+
homeLink: t({
|
|
330
|
+
en: "Home",
|
|
331
|
+
es: "Inicio",
|
|
332
|
+
fr: "Accueil",
|
|
333
|
+
}),
|
|
334
|
+
},
|
|
335
|
+
} satisfies Dictionary;
|
|
336
|
+
|
|
337
|
+
export default aboutContent;
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
> Suas declarações de conteúdo podem ser definidas em qualquer lugar da sua aplicação, desde que sejam incluídas no diretório `contentDir` (por padrão, `./app`). E correspondam à extensão de arquivo de declaração de conteúdo (por padrão, `.content.{json,ts,tsx,js,jsx,mjs,mjx,cjs,cjx}`).
|
|
341
|
+
|
|
342
|
+
> 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).
|
|
343
|
+
|
|
344
|
+
### Passo 7: Criar Componentes Locale-Aware
|
|
345
|
+
|
|
346
|
+
Crie um componente `LocalizedLink` para navegação consciente de localidade:
|
|
347
|
+
|
|
348
|
+
```tsx fileName="app/components/localized-link.tsx"
|
|
349
|
+
import type { FC } from "react";
|
|
350
|
+
|
|
351
|
+
import { getLocalizedUrl, type LocalesValues } from "intlayer";
|
|
352
|
+
import { useLocale } from "react-intlayer";
|
|
353
|
+
import { Link, type LinkProps, type To } from "react-router";
|
|
354
|
+
|
|
355
|
+
const isExternalLink = (to: string) => /^(https?:)?\/\//.test(to);
|
|
356
|
+
|
|
357
|
+
export const locacalizeTo = (to: To, locale: LocalesValues): To => {
|
|
358
|
+
if (typeof to === "string") {
|
|
359
|
+
if (isExternalLink(to)) {
|
|
360
|
+
return to;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return getLocalizedUrl(to, locale);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (isExternalLink(to.pathname ?? "")) {
|
|
367
|
+
return to;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return {
|
|
371
|
+
...to,
|
|
372
|
+
pathname: getLocalizedUrl(to.pathname ?? "", locale),
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
export const LocalizedLink: FC<LinkProps> = (props) => {
|
|
377
|
+
const { locale } = useLocale();
|
|
378
|
+
|
|
379
|
+
return <Link {...props} to={locacalizeTo(props.to, locale)} />;
|
|
380
|
+
};
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
No caso de você querer navegar para as rotas localizadas, você pode usar o hook `useLocalizedNavigate`:
|
|
384
|
+
|
|
385
|
+
```tsx fileName="app/hooks/useLocalizedNavigate.ts"
|
|
386
|
+
import { useLocale } from "react-intlayer";
|
|
387
|
+
import { type NavigateOptions, type To, useNavigate } from "react-router";
|
|
388
|
+
|
|
389
|
+
import { locacalizeTo } from "~/components/localized-link";
|
|
390
|
+
|
|
391
|
+
export const useLocalizedNavigate = () => {
|
|
392
|
+
const navigate = useNavigate();
|
|
393
|
+
const { locale } = useLocale();
|
|
394
|
+
|
|
395
|
+
const localizedNavigate = (to: To, options?: NavigateOptions) => {
|
|
396
|
+
const localedTo = locacalizeTo(to, locale);
|
|
397
|
+
|
|
398
|
+
navigate(localedTo, options);
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
return localizedNavigate;
|
|
402
|
+
};
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Passo 8: Criar um Componente de Alternância de Locale
|
|
406
|
+
|
|
407
|
+
Crie um componente para permitir que os usuários alterem idiomas:
|
|
408
|
+
|
|
409
|
+
```tsx fileName="app/components/locale-switcher.tsx"
|
|
410
|
+
import type { FC } from "react";
|
|
411
|
+
|
|
412
|
+
import {
|
|
413
|
+
getHTMLTextDir,
|
|
414
|
+
getLocaleName,
|
|
415
|
+
getLocalizedUrl,
|
|
416
|
+
getPathWithoutLocale,
|
|
417
|
+
Locales,
|
|
418
|
+
} from "intlayer";
|
|
419
|
+
import { useIntlayer, useLocale } from "react-intlayer";
|
|
420
|
+
import { Link, useLocation } from "react-router";
|
|
421
|
+
|
|
422
|
+
export const LocaleSwitcher: FC = () => {
|
|
423
|
+
const { localeSwitcherLabel } = useIntlayer("locale-switcher");
|
|
424
|
+
const { pathname } = useLocation();
|
|
425
|
+
|
|
426
|
+
const { availableLocales, locale } = useLocale();
|
|
427
|
+
|
|
428
|
+
const pathWithoutLocale = getPathWithoutLocale(pathname);
|
|
429
|
+
|
|
430
|
+
return (
|
|
431
|
+
<ol>
|
|
432
|
+
{availableLocales.map((localeItem) => (
|
|
433
|
+
<li key={localeItem}>
|
|
434
|
+
<Link
|
|
435
|
+
aria-current={localeItem === locale ? "page" : undefined}
|
|
436
|
+
aria-label={`${localeSwitcherLabel.value} ${getLocaleName(localeItem)}`}
|
|
437
|
+
reloadDocument // Recarregar a página para aplicar o novo locale
|
|
438
|
+
to={getLocalizedUrl(pathWithoutLocale, localeItem)}
|
|
439
|
+
>
|
|
440
|
+
<span>
|
|
441
|
+
{/* Locale - ex.: FR */}
|
|
442
|
+
{localeItem}
|
|
443
|
+
</span>
|
|
444
|
+
<span>
|
|
445
|
+
{/* Idioma na sua própria Locale - ex.: Français */}
|
|
446
|
+
{getLocaleName(localeItem, locale)}
|
|
447
|
+
</span>
|
|
448
|
+
<span dir={getHTMLTextDir(localeItem)} lang={localeItem}>
|
|
449
|
+
{/* Idioma na Locale atual - ex.: Francés com a locale atual definida como Locales.SPANISH */}
|
|
450
|
+
{getLocaleName(localeItem)}
|
|
451
|
+
</span>
|
|
452
|
+
<span dir="ltr" lang={Locales.ENGLISH}>
|
|
453
|
+
{/* Idioma em inglês - ex.: French */}
|
|
454
|
+
{getLocaleName(localeItem, Locales.ENGLISH)}
|
|
455
|
+
</span>
|
|
456
|
+
</Link>
|
|
457
|
+
</li>
|
|
458
|
+
))}
|
|
459
|
+
</ol>
|
|
460
|
+
);
|
|
461
|
+
};
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
> Para saber mais sobre o hook `useLocale`, consulte a [documentação](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/packages/react-intlayer/useLocale.md).
|
|
465
|
+
|
|
466
|
+
### Passo 9: Adicionar Gerenciamento de Atributos HTML (Opcional)
|
|
467
|
+
|
|
468
|
+
Crie um hook para gerenciar os atributos HTML lang e dir:
|
|
469
|
+
|
|
470
|
+
```tsx fileName="app/hooks/useI18nHTMLAttributes.tsx"
|
|
471
|
+
import { getHTMLTextDir } from "intlayer";
|
|
472
|
+
import { useEffect } from "react";
|
|
473
|
+
import { useLocale } from "react-intlayer";
|
|
474
|
+
|
|
475
|
+
export const useI18nHTMLAttributes = () => {
|
|
476
|
+
const { locale } = useLocale();
|
|
477
|
+
|
|
478
|
+
useEffect(() => {
|
|
479
|
+
document.documentElement.lang = locale;
|
|
480
|
+
document.documentElement.dir = getHTMLTextDir(locale);
|
|
481
|
+
}, [locale]);
|
|
482
|
+
};
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
Este hook já é usado no componente de layout (`($locale)._layout.tsx`) mostrado no Passo 5.
|
|
486
|
+
|
|
487
|
+
### Passo 10: Adicionar middleware (Opcional)
|
|
488
|
+
|
|
489
|
+
Você também pode usar o `intlayerProxy` para adicionar roteamento do lado do servidor à sua aplicação. Este plugin detectará automaticamente a localidade atual com base na URL e definirá o cookie de localidade apropriado. Se nenhuma localidade for especificada, o plugin determinará a localidade mais adequada com base nas preferências de idioma do navegador do usuário. Se nenhuma localidade for detectada, ele redirecionará para a localidade padrão.
|
|
490
|
+
|
|
491
|
+
> Note que para usar o `intlayerProxy` em produção, você precisa mover o pacote `vite-intlayer` de `devDependencies` para `dependencies`.
|
|
492
|
+
|
|
493
|
+
```typescript {3,7} fileName="vite.config.ts"
|
|
494
|
+
import { reactRouter } from "@react-router/dev/vite";
|
|
495
|
+
import { defineConfig } from "vite";
|
|
496
|
+
import { intlayer, intlayerProxy } from "vite-intlayer";
|
|
497
|
+
import tsconfigPaths from "vite-tsconfig-paths";
|
|
498
|
+
|
|
499
|
+
export default defineConfig({
|
|
500
|
+
plugins: [reactRouter(), tsconfigPaths(), intlayer(), intlayerProxy()],
|
|
501
|
+
});
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
---
|
|
505
|
+
|
|
506
|
+
## Configurar TypeScript
|
|
507
|
+
|
|
508
|
+
O Intlayer usa module augmentation para aproveitar os benefícios do TypeScript e tornar sua codebase mais robusta.
|
|
509
|
+
|
|
510
|
+
Certifique-se de que sua configuração do TypeScript inclui os tipos autogerados:
|
|
511
|
+
|
|
512
|
+
```json5 fileName="tsconfig.json"
|
|
513
|
+
{
|
|
514
|
+
// ... suas configurações existentes
|
|
515
|
+
include: [
|
|
516
|
+
// ... seus includes existentes
|
|
517
|
+
".intlayer/**/*.ts", // Incluir os tipos autogerados
|
|
518
|
+
],
|
|
519
|
+
}
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
## Configuração do Git
|
|
525
|
+
|
|
526
|
+
É recomendado ignorar os arquivos gerados pelo Intlayer. Isso permite que você evite commitá-los no seu repositório Git.
|
|
527
|
+
|
|
528
|
+
Para fazer isso, você pode adicionar as seguintes instruções ao seu arquivo `.gitignore`:
|
|
529
|
+
|
|
530
|
+
```plaintext fileName=".gitignore"
|
|
531
|
+
# Ignorar os arquivos gerados pelo Intlayer
|
|
532
|
+
.intlayer
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
---
|
|
536
|
+
|
|
537
|
+
## Extensão do VS Code
|
|
538
|
+
|
|
539
|
+
Para melhorar sua experiência de desenvolvimento com o Intlayer, você pode instalar a extensão oficial **Intlayer VS Code Extension**.
|
|
540
|
+
|
|
541
|
+
[Instalar no VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=intlayer.intlayer-vs-code-extension)
|
|
542
|
+
|
|
543
|
+
Esta extensão fornece:
|
|
544
|
+
|
|
545
|
+
- **Autocompletar** para chaves de tradução.
|
|
546
|
+
- **Detecção de erros em tempo real** para traduções faltando.
|
|
547
|
+
- **Pré-visualizações inline** do conteúdo traduzido.
|
|
548
|
+
- **Ações rápidas** para criar e atualizar traduções facilmente.
|
|
549
|
+
|
|
550
|
+
Para mais detalhes sobre como usar a extensão, consulte a [documentação da Extensão Intlayer VS Code](https://intlayer.org/doc/vs-code-extension).
|
|
551
|
+
|
|
552
|
+
---
|
|
553
|
+
|
|
554
|
+
## Ir Além
|
|
555
|
+
|
|
556
|
+
Para ir além, você pode implementar o [editor visual](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_visual_editor.md) ou externalizar seu conteúdo usando o [CMS](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/intlayer_CMS.md).
|
|
557
|
+
|
|
558
|
+
---
|
|
559
|
+
|
|
560
|
+
## Referências da Documentação
|
|
561
|
+
|
|
562
|
+
- [Documentação do Intlayer](https://intlayer.org)
|
|
563
|
+
- [Documentação do React Router v7](https://reactrouter.com/)
|
|
564
|
+
- [Documentação do React Router fs-routes](https://reactrouter.com/how-to/file-route-conventions)
|
|
565
|
+
- [Hook useIntlayer](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/packages/react-intlayer/useIntlayer.md)
|
|
566
|
+
- [Hook useLocale](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/packages/react-intlayer/useLocale.md)
|
|
567
|
+
- [Declaração de Conteúdo](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/dictionary/content_file.md)
|
|
568
|
+
- [Configuração](https://github.com/aymericzip/intlayer/blob/main/docs/docs/pt/configuration.md)
|
|
569
|
+
|
|
570
|
+
Este guia completo fornece tudo o que você precisa para integrar o Intlayer com o React Router v7 usando roteamento baseado em sistema de arquivos para uma aplicação totalmente internacionalizada com roteamento consciente de localidade e suporte a TypeScript.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-09-09
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-12-11
|
|
4
4
|
title: Como traduzir seu Tanstack Start – guia i18n 2025
|
|
5
5
|
description: Aprenda como adicionar internacionalização (i18n) à sua aplicação Tanstack Start usando Intlayer. Siga este guia completo para tornar seu app multilíngue com roteamento sensível ao locale.
|
|
6
6
|
keywords:
|
|
@@ -646,17 +646,6 @@ export function NotFoundComponent() {
|
|
|
646
646
|
}
|
|
647
647
|
```
|
|
648
648
|
|
|
649
|
-
```tsx fileName="src/routes/__root.tsx"
|
|
650
|
-
import { createRootRoute } from "@tanstack/react-router";
|
|
651
|
-
|
|
652
|
-
// A rota raiz serve como o layout de nível superior
|
|
653
|
-
// Ela não trata 404s diretamente - isso é delegado às rotas filhas
|
|
654
|
-
// Isso mantém a raiz simples e permite que rotas conscientes de locale gerenciem sua própria lógica 404
|
|
655
|
-
export const Route = createRootRoute({
|
|
656
|
-
component: Outlet,
|
|
657
|
-
});
|
|
658
|
-
```
|
|
659
|
-
|
|
660
649
|
```tsx fileName="src/routes/{-$locale}/route.tsx"
|
|
661
650
|
import { createFileRoute, Outlet, redirect } from "@tanstack/react-router";
|
|
662
651
|
import { validatePrefix } from "intlayer";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-03-13
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-12-13
|
|
4
4
|
title: Plugin Sync JSON
|
|
5
5
|
description: Sincronize os dicionários Intlayer com arquivos JSON i18n de terceiros (i18next, next-intl, react-intl, vue-i18n e mais). Mantenha seu i18n existente enquanto usa o Intlayer para gerenciar, traduzir e testar suas mensagens.
|
|
6
6
|
keywords:
|
|
@@ -24,12 +24,15 @@ slugs:
|
|
|
24
24
|
- sync-json
|
|
25
25
|
youtubeVideo: https://www.youtube.com/watch?v=MpGMxniDHNg
|
|
26
26
|
history:
|
|
27
|
+
- version: 7.5.0
|
|
28
|
+
date: 2025-12-13
|
|
29
|
+
changes: Adicionado suporte para formatos ICU e i18next
|
|
27
30
|
- version: 6.1.6
|
|
28
31
|
date: 2025-10-05
|
|
29
32
|
changes: Documentação inicial do plugin Sync JSON
|
|
30
33
|
---
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
# Sync JSON (pontes i18n) - Sync JSON com suporte ICU / i18next
|
|
33
36
|
|
|
34
37
|
<iframe title="Como manter suas traduções JSON sincronizadas com 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/MpGMxniDHNg?autoplay=0&origin=http://intlayer.org&controls=0&rel=1"/>
|
|
35
38
|
|
|
@@ -105,9 +108,27 @@ syncJSON({
|
|
|
105
108
|
source: ({ key, locale }) => string, // obrigatório
|
|
106
109
|
location?: string, // rótulo opcional, padrão: "plugin"
|
|
107
110
|
priority?: number, // prioridade opcional para resolução de conflitos, padrão: 0
|
|
111
|
+
format?: 'intlayer' | 'icu' | 'i18next', // formatador opcional, padrão: 'intlayer'
|
|
108
112
|
});
|
|
109
113
|
```
|
|
110
114
|
|
|
115
|
+
#### `format` ('intlayer' | 'icu' | 'i18next')
|
|
116
|
+
|
|
117
|
+
Especifica o formatador a ser usado para o conteúdo do dicionário ao sincronizar arquivos JSON. Isso permite usar diferentes sintaxes de formatação de mensagens compatíveis com várias bibliotecas i18n.
|
|
118
|
+
|
|
119
|
+
- `'intlayer'`: O formatador Intlayer padrão (padrão).
|
|
120
|
+
- `'icu'`: Usa formatação de mensagens ICU (compatível com bibliotecas como react-intl, vue-i18n).
|
|
121
|
+
- `'i18next'`: Usa formatação de mensagens i18next (compatível com i18next, next-i18next, Solid-i18next).
|
|
122
|
+
|
|
123
|
+
**Exemplo:**
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
syncJSON({
|
|
127
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
128
|
+
format: "i18next", // Usar formatação i18next para compatibilidade
|
|
129
|
+
}),
|
|
130
|
+
```
|
|
131
|
+
|
|
111
132
|
## Múltiplas fontes JSON e prioridade
|
|
112
133
|
|
|
113
134
|
Você pode adicionar múltiplos plugins `syncJSON` para sincronizar diferentes fontes JSON. Isso é útil quando você tem múltiplas bibliotecas i18n ou diferentes estruturas JSON no seu projeto.
|
|
@@ -134,6 +155,7 @@ export default defineConfig({
|
|
|
134
155
|
plugins: [
|
|
135
156
|
// Fonte JSON principal (maior prioridade)
|
|
136
157
|
syncJSON({
|
|
158
|
+
format: "i18next",
|
|
137
159
|
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
138
160
|
location: "main-translations",
|
|
139
161
|
priority: 10,
|
|
@@ -141,6 +163,7 @@ export default defineConfig({
|
|
|
141
163
|
|
|
142
164
|
// Fonte JSON de fallback (prioridade menor)
|
|
143
165
|
syncJSON({
|
|
166
|
+
format: "i18next",
|
|
144
167
|
source: ({ locale }) => `./fallback-locales/${locale}.json`,
|
|
145
168
|
location: "fallback-translations",
|
|
146
169
|
priority: 5,
|
|
@@ -148,6 +171,7 @@ export default defineConfig({
|
|
|
148
171
|
|
|
149
172
|
// Fonte JSON legado (prioridade mais baixa)
|
|
150
173
|
syncJSON({
|
|
174
|
+
format: "i18next",
|
|
151
175
|
source: ({ locale }) => `/my/other/app/legacy/${locale}/messages.json`,
|
|
152
176
|
location: "legacy-translations",
|
|
153
177
|
priority: 1,
|
|
@@ -178,6 +202,7 @@ import { syncJSON } from "@intlayer/sync-json-plugin";
|
|
|
178
202
|
export default {
|
|
179
203
|
plugins: [
|
|
180
204
|
syncJSON({
|
|
205
|
+
format: "i18next",
|
|
181
206
|
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
182
207
|
}),
|
|
183
208
|
],
|