@intlayer/docs 7.3.15 → 7.5.0-canary.0
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/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 +122 -3
- package/docs/ar/plugins/sync-json.md +27 -2
- 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 +122 -3
- package/docs/de/plugins/sync-json.md +27 -2
- package/docs/en/dictionary/content_file.md +24 -1
- 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 +120 -1
- package/docs/en/plugins/sync-json.md +53 -2
- 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 +121 -2
- package/docs/en-GB/plugins/sync-json.md +26 -1
- 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 +122 -3
- package/docs/es/plugins/sync-json.md +27 -2
- 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 +122 -3
- package/docs/fr/plugins/sync-json.md +27 -2
- 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 +122 -3
- package/docs/hi/plugins/sync-json.md +27 -2
- 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 +122 -3
- package/docs/id/plugins/sync-json.md +27 -2
- 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 +122 -3
- package/docs/it/plugins/sync-json.md +27 -2
- 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 +122 -3
- package/docs/ja/plugins/sync-json.md +27 -2
- 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 +122 -3
- package/docs/ko/plugins/sync-json.md +27 -2
- 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 +122 -3
- package/docs/pl/plugins/sync-json.md +24 -2
- 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_tanstack.md +122 -3
- package/docs/pt/plugins/sync-json.md +27 -2
- 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 +122 -3
- package/docs/ru/plugins/sync-json.md +27 -2
- 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 +122 -3
- package/docs/tr/plugins/sync-json.md +27 -2
- 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 +122 -3
- package/docs/vi/plugins/sync-json.md +27 -2
- 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 +122 -3
- package/docs/zh/plugins/sync-json.md +27 -2
- package/package.json +6 -6
|
@@ -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:
|
|
@@ -19,9 +19,12 @@ slugs:
|
|
|
19
19
|
applicationTemplate: https://github.com/aymericzip/intlayer-tanstack-start-template
|
|
20
20
|
youtubeVideo: https://www.youtube.com/watch?v=_XTdKVWaeqg
|
|
21
21
|
history:
|
|
22
|
+
- version: 7.4.0
|
|
23
|
+
date: 2025-12-11
|
|
24
|
+
changes: Introduz validatePrefix e adiciona o passo 14: Tratamento de páginas 404 com rotas localizadas.
|
|
22
25
|
- version: 7.3.9
|
|
23
26
|
date: 2025-12-05
|
|
24
|
-
changes:
|
|
27
|
+
changes: Adiciona o passo 13: Recuperar o locale em suas server actions (Opcional)
|
|
25
28
|
- version: 5.8.1
|
|
26
29
|
date: 2025-09-09
|
|
27
30
|
changes: Adicionado para Tanstack Start
|
|
@@ -612,7 +615,123 @@ export const getLocaleServer = createServerFn().handler(async () => {
|
|
|
612
615
|
|
|
613
616
|
---
|
|
614
617
|
|
|
615
|
-
### Passo 14:
|
|
618
|
+
### Passo 14: Gerenciar páginas não encontradas (Opcional)
|
|
619
|
+
|
|
620
|
+
Quando um usuário visita uma página inexistente, você pode exibir uma página personalizada de não encontrada e o prefixo de locale pode afetar a forma como a página de não encontrada é acionada.
|
|
621
|
+
|
|
622
|
+
#### Entendendo o tratamento de 404 do TanStack Router com prefixos de locale
|
|
623
|
+
|
|
624
|
+
No TanStack Router, lidar com páginas 404 com rotas localizadas requer uma abordagem multicamadas:
|
|
625
|
+
|
|
626
|
+
1. **Rota 404 dedicada**: Uma rota específica para exibir a interface 404
|
|
627
|
+
2. **Validação no nível da rota**: Valida os prefixos de locale e redireciona os inválidos para 404
|
|
628
|
+
3. **Rota catch-all**: Captura todos os caminhos não correspondentes dentro do segmento de locale
|
|
629
|
+
|
|
630
|
+
```tsx fileName="src/routes/{-$locale}/404.tsx"
|
|
631
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
632
|
+
|
|
633
|
+
// Isso cria uma rota dedicada /[locale]/404
|
|
634
|
+
// É usada tanto como uma rota direta quanto importada como um componente em outros arquivos
|
|
635
|
+
export const Route = createFileRoute("/{-$locale}/404")({
|
|
636
|
+
component: NotFoundComponent,
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
// Exportado separadamente para que possa ser reutilizado em notFoundComponent e rotas catch-all
|
|
640
|
+
export function NotFoundComponent() {
|
|
641
|
+
return (
|
|
642
|
+
<div>
|
|
643
|
+
<h1>404</h1>
|
|
644
|
+
</div>
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
```tsx fileName="src/routes/{-$locale}/route.tsx"
|
|
650
|
+
import { createFileRoute, Outlet, redirect } from "@tanstack/react-router";
|
|
651
|
+
import { validatePrefix } from "intlayer";
|
|
652
|
+
import { IntlayerProvider, useLocale } from "react-intlayer";
|
|
653
|
+
|
|
654
|
+
import { LocaleSwitcher } from "@/components/locale-switcher";
|
|
655
|
+
import { NotFoundComponent } from "./404";
|
|
656
|
+
|
|
657
|
+
export const Route = createFileRoute("/{-$locale}")({
|
|
658
|
+
// beforeLoad executa antes da rota ser renderizada (tanto no servidor quanto no cliente)
|
|
659
|
+
// É o lugar ideal para validar o prefixo de locale
|
|
660
|
+
beforeLoad: ({ params }) => {
|
|
661
|
+
// Obter locale dos parâmetros da rota (não dos cabeçalhos do servidor, pois beforeLoad executa tanto no cliente quanto no servidor)
|
|
662
|
+
const localeParam = params.locale;
|
|
663
|
+
|
|
664
|
+
// validatePrefix verifica se o locale é válido de acordo com sua configuração intlayer
|
|
665
|
+
// Retorna: { isValid: boolean, localePrefix: string }
|
|
666
|
+
// - isValid: true se o prefixo corresponder a um locale configurado (ou estiver vazio quando o prefixo for opcional)
|
|
667
|
+
// - localePrefix: o prefixo validado ou o prefixo de locale padrão para redirecionamentos
|
|
668
|
+
const { isValid, localePrefix } = validatePrefix(localeParam);
|
|
669
|
+
|
|
670
|
+
if (isValid) {
|
|
671
|
+
// Locale é válido, permitir que a rota seja renderizada normalmente
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// Prefixo de locale inválido (por exemplo, /xyz/about onde "xyz" não é um locale válido)
|
|
676
|
+
// Redirecionar para a página 404 com um prefixo de locale válido
|
|
677
|
+
// Isso garante que a página 404 ainda esteja adequadamente localizada
|
|
678
|
+
throw redirect({
|
|
679
|
+
to: "/{-$locale}/404",
|
|
680
|
+
params: { locale: localePrefix },
|
|
681
|
+
});
|
|
682
|
+
},
|
|
683
|
+
component: RouteComponent,
|
|
684
|
+
// notFoundComponent é chamado quando uma rota filha não existe
|
|
685
|
+
// por exemplo, /en/pagina-inexistente dispara isso dentro do layout /en
|
|
686
|
+
notFoundComponent: NotFoundLayout,
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
function RouteComponent() {
|
|
690
|
+
const { defaultLocale } = useLocale();
|
|
691
|
+
const { locale } = Route.useParams();
|
|
692
|
+
|
|
693
|
+
return (
|
|
694
|
+
// Envolver todo o segmento de locale com IntlayerProvider
|
|
695
|
+
// Volta para defaultLocale quando o parâmetro locale é undefined (modo de prefixo opcional)
|
|
696
|
+
<IntlayerProvider locale={locale ?? defaultLocale}>
|
|
697
|
+
<Outlet />
|
|
698
|
+
</IntlayerProvider>
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// NotFoundLayout envolve o componente 404 com IntlayerProvider
|
|
703
|
+
// Isso garante que as traduções ainda funcionem na página 404
|
|
704
|
+
function NotFoundLayout() {
|
|
705
|
+
const { defaultLocale } = useLocale();
|
|
706
|
+
const { locale } = Route.useParams();
|
|
707
|
+
|
|
708
|
+
return (
|
|
709
|
+
<IntlayerProvider locale={locale ?? defaultLocale}>
|
|
710
|
+
<NotFoundComponent />
|
|
711
|
+
{/* Incluir LocaleSwitcher para que os usuários possam alterar o idioma mesmo em 404 */}
|
|
712
|
+
<LocaleSwitcher />
|
|
713
|
+
</IntlayerProvider>
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
```tsx fileName="src/routes/{-$locale}/$.tsx"
|
|
719
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
720
|
+
|
|
721
|
+
import { NotFoundComponent } from "./404";
|
|
722
|
+
|
|
723
|
+
// A rota $ (splat/catch-all) corresponde a qualquer caminho que não corresponda a outras rotas
|
|
724
|
+
// por exemplo, /en/algum/caminho/profundamente/aninhado/invalido
|
|
725
|
+
// Isso garante que TODOS os caminhos não correspondentes dentro de um locale mostrem a página 404
|
|
726
|
+
// Sem isso, caminhos profundos não correspondentes podem mostrar uma página em branco ou erro
|
|
727
|
+
export const Route = createFileRoute("/{-$locale}/$")({
|
|
728
|
+
component: NotFoundComponent,
|
|
729
|
+
});
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
---
|
|
733
|
+
|
|
734
|
+
### Passo 15: Configurar o TypeScript (Opcional)
|
|
616
735
|
|
|
617
736
|
O Intlayer utiliza a ampliação de módulos para aproveitar os benefícios do TypeScript e fortalecer sua base de código.
|
|
618
737
|
|
|
@@ -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
|
],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-02-07
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-12-13
|
|
4
4
|
title: Файл контента
|
|
5
5
|
description: Узнайте, как настраивать расширения для ваших файлов декларации контента. Следуйте этой документации, чтобы эффективно реализовывать условия в вашем проекте.
|
|
6
6
|
keywords:
|
|
@@ -12,6 +12,9 @@ slugs:
|
|
|
12
12
|
- concept
|
|
13
13
|
- content
|
|
14
14
|
history:
|
|
15
|
+
- version: 7.5.0
|
|
16
|
+
date: 2025-12-13
|
|
17
|
+
changes: Добавлена поддержка форматов ICU и i18next
|
|
15
18
|
- version: 6.0.0
|
|
16
19
|
date: 2025-09-20
|
|
17
20
|
changes: Добавлена документация по полям
|
|
@@ -386,6 +389,46 @@ Intlayer поддерживает различные типы содержимо
|
|
|
386
389
|
}
|
|
387
390
|
```
|
|
388
391
|
|
|
392
|
+
#### `format` ('intlayer' | 'icu' | 'i18next')
|
|
393
|
+
|
|
394
|
+
Указывает форматтер, который будет использоваться для содержимого словаря. Это позволяет использовать различные синтаксисы форматирования сообщений.
|
|
395
|
+
|
|
396
|
+
- `'intlayer'`: Форматтер Intlayer по умолчанию.
|
|
397
|
+
- `'icu'`: Использует форматирование сообщений ICU.
|
|
398
|
+
- `'i18next'`: Использует форматирование сообщений i18next.
|
|
399
|
+
|
|
400
|
+
**Пример:**
|
|
401
|
+
|
|
402
|
+
```typescript
|
|
403
|
+
{
|
|
404
|
+
key: "my-dictionary",
|
|
405
|
+
format: "icu",
|
|
406
|
+
content: {
|
|
407
|
+
message: "Hello {name}, you have {count, plural, one {# message} other {# messages}}"
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
#### `format` ('intlayer' | 'icu' | 'i18next')
|
|
413
|
+
|
|
414
|
+
Указывает форматтер для использования содержимого словаря. Это позволяет использовать различные синтаксисы форматирования сообщений.
|
|
415
|
+
|
|
416
|
+
- `'intlayer'`: Форматтер Intlayer по умолчанию.
|
|
417
|
+
- `'icu'`: Использует форматирование сообщений ICU.
|
|
418
|
+
- `'i18next'`: Использует форматирование сообщений i18next.
|
|
419
|
+
|
|
420
|
+
**Пример:**
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
{
|
|
424
|
+
key: "my-dictionary",
|
|
425
|
+
format: "icu",
|
|
426
|
+
content: {
|
|
427
|
+
message: "Hello {name}, you have {count, plural, one {# message} other {# messages}}"
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
```
|
|
431
|
+
|
|
389
432
|
#### `locale` (LocalesValues)
|
|
390
433
|
|
|
391
434
|
Преобразует словарь в словарь для каждого локаля, где каждое поле, объявленное в содержимом, автоматически преобразуется в узел перевода. Когда это свойство установлено:
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2024-03-07
|
|
3
3
|
updatedAt: 2025-10-03
|
|
4
4
|
title: Как перевести ваше Astro – руководство i18n 2025
|
|
5
|
-
description: Узнайте, как добавить интернационализацию (i18n)
|
|
5
|
+
description: Узнайте, как добавить интернационализацию (i18n) на ваш сайт Astro с помощью Intlayer. Следуйте этому руководству, чтобы сделать ваш сайт многоязычным.
|
|
6
6
|
keywords:
|
|
7
7
|
- Интернационализация
|
|
8
8
|
- Документация
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2024-08-11
|
|
3
3
|
updatedAt: 2025-06-29
|
|
4
4
|
title: Как перевести ваше Express backend – руководство i18n 2025
|
|
5
|
-
description: Узнайте, как сделать ваш backend
|
|
5
|
+
description: Узнайте, как сделать ваш backend Express многоязычным. Следуйте документации для интернационализации (i18n) и перевода.
|
|
6
6
|
keywords:
|
|
7
7
|
- Интернационализация
|
|
8
8
|
- Документация
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2025-09-09
|
|
3
3
|
updatedAt: 2025-09-09
|
|
4
4
|
title: Как перевести ваше Nest backend – руководство i18n 2025
|
|
5
|
-
description: Узнайте, как сделать ваш
|
|
5
|
+
description: Узнайте, как сделать ваш NestJS бэкенд многоязычным. Следуйте документации для интернационализации (i18n) и перевода.
|
|
6
6
|
keywords:
|
|
7
7
|
- Интернационализация
|
|
8
8
|
- Документация
|
|
@@ -421,6 +421,7 @@ const config: IntlayerConfig = {
|
|
|
421
421
|
plugins: [
|
|
422
422
|
// Синхронизируйте структуру папок по namespace с Intlayer
|
|
423
423
|
syncJSON({
|
|
424
|
+
format: "icu",
|
|
424
425
|
source: ({ key, locale }) => `./locales/${locale}/${key}.json`, // путь к JSON-файлам с переводами
|
|
425
426
|
}),
|
|
426
427
|
],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-09-09
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-12-11
|
|
4
4
|
title: Как перевести ваше Tanstack Start – руководство i18n 2025
|
|
5
5
|
description: Узнайте, как добавить интернационализацию (i18n) в ваше приложение Tanstack Start с помощью Intlayer. Следуйте этому подробному руководству, чтобы сделать ваше приложение многоязычным с маршрутизацией, учитывающей локаль.
|
|
6
6
|
keywords:
|
|
@@ -19,9 +19,12 @@ slugs:
|
|
|
19
19
|
applicationTemplate: https://github.com/aymericzip/intlayer-tanstack-start-template
|
|
20
20
|
youtubeVideo: https://www.youtube.com/watch?v=_XTdKVWaeqg
|
|
21
21
|
history:
|
|
22
|
+
- version: 7.4.0
|
|
23
|
+
date: 2025-12-11
|
|
24
|
+
changes: Внедрена validatePrefix и добавлен шаг 14: Обработка страниц 404 с локализованными маршрутами.
|
|
22
25
|
- version: 7.3.9
|
|
23
26
|
date: 2025-12-05
|
|
24
|
-
changes:
|
|
27
|
+
changes: Добавлен шаг 13: Получение текущей локали в ваших server actions (опционально)
|
|
25
28
|
- version: 5.8.1
|
|
26
29
|
date: 2025-09-09
|
|
27
30
|
changes: Добавлено для Tanstack Start
|
|
@@ -602,7 +605,123 @@ export const getLocaleServer = createServerFn().handler(async () => {
|
|
|
602
605
|
|
|
603
606
|
---
|
|
604
607
|
|
|
605
|
-
### Шаг 14:
|
|
608
|
+
### Шаг 14: Управление страницами "не найдено" (необязательно)
|
|
609
|
+
|
|
610
|
+
Когда пользователь посещает несуществующую страницу, вы можете отобразить пользовательскую страницу "не найдено", и префикс локали может повлиять на способ срабатывания страницы "не найдено".
|
|
611
|
+
|
|
612
|
+
#### Понимание обработки 404 в TanStack Router с префиксами локали
|
|
613
|
+
|
|
614
|
+
В TanStack Router обработка страниц 404 с локализованными маршрутами требует многоуровневого подхода:
|
|
615
|
+
|
|
616
|
+
1. **Выделенный маршрут 404**: Специфический маршрут для отображения интерфейса 404
|
|
617
|
+
2. **Проверка на уровне маршрута**: Проверяет префиксы локали и перенаправляет недействительные на 404
|
|
618
|
+
3. **Маршрут catch-all**: Перехватывает все несовпадающие пути в сегменте локали
|
|
619
|
+
|
|
620
|
+
```tsx fileName="src/routes/{-$locale}/404.tsx"
|
|
621
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
622
|
+
|
|
623
|
+
// Это создает выделенный маршрут /[locale]/404
|
|
624
|
+
// Он используется как прямой маршрут и импортируется как компонент в других файлах
|
|
625
|
+
export const Route = createFileRoute("/{-$locale}/404")({
|
|
626
|
+
component: NotFoundComponent,
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
// Экспортируется отдельно, чтобы можно было повторно использовать в notFoundComponent и catch-all маршрутах
|
|
630
|
+
export function NotFoundComponent() {
|
|
631
|
+
return (
|
|
632
|
+
<div>
|
|
633
|
+
<h1>404</h1>
|
|
634
|
+
</div>
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
```tsx fileName="src/routes/{-$locale}/route.tsx"
|
|
640
|
+
import { createFileRoute, Outlet, redirect } from "@tanstack/react-router";
|
|
641
|
+
import { validatePrefix } from "intlayer";
|
|
642
|
+
import { IntlayerProvider, useLocale } from "react-intlayer";
|
|
643
|
+
|
|
644
|
+
import { LocaleSwitcher } from "@/components/locale-switcher";
|
|
645
|
+
import { NotFoundComponent } from "./404";
|
|
646
|
+
|
|
647
|
+
export const Route = createFileRoute("/{-$locale}")({
|
|
648
|
+
// beforeLoad выполняется до рендеринга маршрута (как на сервере, так и на клиенте)
|
|
649
|
+
// Это идеальное место для проверки префикса локали
|
|
650
|
+
beforeLoad: ({ params }) => {
|
|
651
|
+
// Получить локаль из параметров маршрута (не из заголовков сервера, так как beforeLoad выполняется как на клиенте, так и на сервере)
|
|
652
|
+
const localeParam = params.locale;
|
|
653
|
+
|
|
654
|
+
// validatePrefix проверяет, является ли локаль действительной согласно вашей конфигурации intlayer
|
|
655
|
+
// Возвращает: { isValid: boolean, localePrefix: string }
|
|
656
|
+
// - isValid: true, если префикс соответствует настроенной локали (или пуст, когда префикс опционален)
|
|
657
|
+
// - localePrefix: проверенный префикс или префикс локали по умолчанию для редиректов
|
|
658
|
+
const { isValid, localePrefix } = validatePrefix(localeParam);
|
|
659
|
+
|
|
660
|
+
if (isValid) {
|
|
661
|
+
// Локаль действительна, разрешить маршруту рендериться нормально
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// Недействительный префикс локали (например, /xyz/about, где "xyz" не является действительной локалью)
|
|
666
|
+
// Перенаправить на страницу 404 с действительным префиксом локали
|
|
667
|
+
// Это гарантирует, что страница 404 все еще правильно локализована
|
|
668
|
+
throw redirect({
|
|
669
|
+
to: "/{-$locale}/404",
|
|
670
|
+
params: { locale: localePrefix },
|
|
671
|
+
});
|
|
672
|
+
},
|
|
673
|
+
component: RouteComponent,
|
|
674
|
+
// notFoundComponent вызывается, когда дочерний маршрут не существует
|
|
675
|
+
// например, /en/несуществующая-страница запускает это в макете /en
|
|
676
|
+
notFoundComponent: NotFoundLayout,
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
function RouteComponent() {
|
|
680
|
+
const { defaultLocale } = useLocale();
|
|
681
|
+
const { locale } = Route.useParams();
|
|
682
|
+
|
|
683
|
+
return (
|
|
684
|
+
// Обернуть весь сегмент локали в IntlayerProvider
|
|
685
|
+
// Возвращается к defaultLocale, когда параметр locale равен undefined (режим опционального префикса)
|
|
686
|
+
<IntlayerProvider locale={locale ?? defaultLocale}>
|
|
687
|
+
<Outlet />
|
|
688
|
+
</IntlayerProvider>
|
|
689
|
+
);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// NotFoundLayout оборачивает компонент 404 в IntlayerProvider
|
|
693
|
+
// Это гарантирует, что переводы все еще работают на странице 404
|
|
694
|
+
function NotFoundLayout() {
|
|
695
|
+
const { defaultLocale } = useLocale();
|
|
696
|
+
const { locale } = Route.useParams();
|
|
697
|
+
|
|
698
|
+
return (
|
|
699
|
+
<IntlayerProvider locale={locale ?? defaultLocale}>
|
|
700
|
+
<NotFoundComponent />
|
|
701
|
+
{/* Включить LocaleSwitcher, чтобы пользователи могли менять язык даже на 404 */}
|
|
702
|
+
<LocaleSwitcher />
|
|
703
|
+
</IntlayerProvider>
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
```tsx fileName="src/routes/{-$locale}/$.tsx"
|
|
709
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
710
|
+
|
|
711
|
+
import { NotFoundComponent } from "./404";
|
|
712
|
+
|
|
713
|
+
// Маршрут $ (splat/catch-all) соответствует любому пути, который не соответствует другим маршрутам
|
|
714
|
+
// например, /en/какой-то/глубоко/вложенный/недействительный/путь
|
|
715
|
+
// Это гарантирует, что ВСЕ несоответствующие пути в локали показывают страницу 404
|
|
716
|
+
// Без этого несоответствующие глубокие пути могут показать пустую страницу или ошибку
|
|
717
|
+
export const Route = createFileRoute("/{-$locale}/$")({
|
|
718
|
+
component: NotFoundComponent,
|
|
719
|
+
});
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
---
|
|
723
|
+
|
|
724
|
+
### Шаг 15: Настройка TypeScript (необязательно)
|
|
606
725
|
|
|
607
726
|
Intlayer использует расширение модулей (module augmentation), чтобы использовать преимущества TypeScript и сделать вашу кодовую базу более надежной.
|
|
608
727
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-03-13
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-12-13
|
|
4
4
|
title: Плагин синхронизации JSON
|
|
5
5
|
description: Синхронизируйте словари Intlayer с JSON-файлами сторонних i18n (i18next, next-intl, react-intl, vue-i18n и другими). Сохраняйте существующую i18n, используя Intlayer для управления, перевода и тестирования ваших сообщений.
|
|
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: Добавлена поддержка форматов ICU и i18next
|
|
27
30
|
- version: 6.1.6
|
|
28
31
|
date: 2025-10-05
|
|
29
32
|
changes: Начальная документация плагина синхронизации JSON
|
|
30
33
|
---
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
# Синхронизация JSON (мосты i18n) - Синхронизация JSON с поддержкой ICU / i18next
|
|
33
36
|
|
|
34
37
|
<iframe title="Как поддерживать синхронизацию ваших JSON-переводов с 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, // обязательно
|
|
106
109
|
location?: string, // необязательная метка, по умолчанию: "plugin"
|
|
107
110
|
priority?: number, // необязательный приоритет для разрешения конфликтов, по умолчанию: 0
|
|
111
|
+
format?: 'intlayer' | 'icu' | 'i18next', // необязательный форматтер, по умолчанию: 'intlayer'
|
|
108
112
|
});
|
|
109
113
|
```
|
|
110
114
|
|
|
115
|
+
#### `format` ('intlayer' | 'icu' | 'i18next')
|
|
116
|
+
|
|
117
|
+
Указывает форматтер, который будет использоваться для содержимого словаря при синхронизации JSON-файлов. Это позволяет использовать различные синтаксисы форматирования сообщений, совместимые с различными библиотеками i18n.
|
|
118
|
+
|
|
119
|
+
- `'intlayer'`: Форматтер Intlayer по умолчанию (по умолчанию).
|
|
120
|
+
- `'icu'`: Использует форматирование сообщений ICU (совместимо с библиотеками, такими как react-intl, vue-i18n).
|
|
121
|
+
- `'i18next'`: Использует форматирование сообщений i18next (совместимо с i18next, next-i18next, Solid-i18next).
|
|
122
|
+
|
|
123
|
+
**Пример:**
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
syncJSON({
|
|
127
|
+
source: ({ key, locale }) => `./locales/${locale}/${key}.json`,
|
|
128
|
+
format: "i18next", // Использовать форматирование i18next для совместимости
|
|
129
|
+
}),
|
|
130
|
+
```
|
|
131
|
+
|
|
111
132
|
## Несколько источников JSON и приоритет
|
|
112
133
|
|
|
113
134
|
Вы можете добавить несколько плагинов `syncJSON` для синхронизации разных источников JSON. Это полезно, если в вашем проекте используются несколько библиотек i18n или разные структуры JSON.
|
|
@@ -134,6 +155,7 @@ export default defineConfig({
|
|
|
134
155
|
plugins: [
|
|
135
156
|
// Основной источник JSON (наивысший приоритет)
|
|
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
|
// Резервный источник JSON (низший приоритет)
|
|
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
|
// Источник устаревших JSON (самый низкий приоритет)
|
|
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
|
],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
createdAt: 2025-02-07
|
|
3
|
-
updatedAt: 2025-
|
|
3
|
+
updatedAt: 2025-12-13
|
|
4
4
|
title: İçerik Dosyası
|
|
5
5
|
description: İçerik bildirim dosyalarınız için uzantıları nasıl özelleştireceğinizi öğrenin. Projenizde koşulları verimli bir şekilde uygulamak için bu dokümantasyonu takip edin.
|
|
6
6
|
keywords:
|
|
@@ -12,6 +12,9 @@ slugs:
|
|
|
12
12
|
- concept
|
|
13
13
|
- content
|
|
14
14
|
history:
|
|
15
|
+
- version: 7.5.0
|
|
16
|
+
date: 2025-12-13
|
|
17
|
+
changes: ICU ve i18next format desteği eklendi
|
|
15
18
|
- version: 6.0.0
|
|
16
19
|
date: 2025-09-20
|
|
17
20
|
changes: Alanlar dokümantasyonu eklendi
|
|
@@ -385,6 +388,46 @@ Sözlükleri kategorize etmek ve düzenlemek için kullanılan string dizisi. Et
|
|
|
385
388
|
}
|
|
386
389
|
```
|
|
387
390
|
|
|
391
|
+
#### `format` ('intlayer' | 'icu' | 'i18next')
|
|
392
|
+
|
|
393
|
+
Sözlük içeriği için kullanılacak formatlayıcıyı belirtir. Bu, farklı mesaj formatlama sözdizimlerini kullanmanıza olanak tanır.
|
|
394
|
+
|
|
395
|
+
- `'intlayer'`: Varsayılan Intlayer formatlayıcısı.
|
|
396
|
+
- `'icu'`: ICU mesaj formatlamasını kullanır.
|
|
397
|
+
- `'i18next'`: i18next mesaj formatlamasını kullanır.
|
|
398
|
+
|
|
399
|
+
**Örnek:**
|
|
400
|
+
|
|
401
|
+
```typescript
|
|
402
|
+
{
|
|
403
|
+
key: "my-dictionary",
|
|
404
|
+
format: "icu",
|
|
405
|
+
content: {
|
|
406
|
+
message: "Hello {name}, you have {count, plural, one {# message} other {# messages}}"
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
#### `format` ('intlayer' | 'icu' | 'i18next')
|
|
412
|
+
|
|
413
|
+
Sözlük içeriği için kullanılacak formatörü belirtir. Bu, farklı mesaj formatlama sözdizimlerini kullanmaya olanak tanır.
|
|
414
|
+
|
|
415
|
+
- `'intlayer'`: Varsayılan Intlayer formatörü.
|
|
416
|
+
- `'icu'`: ICU mesaj formatlamasını kullanır.
|
|
417
|
+
- `'i18next'`: i18next mesaj formatlamasını kullanır.
|
|
418
|
+
|
|
419
|
+
**Örnek:**
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
{
|
|
423
|
+
key: "my-dictionary",
|
|
424
|
+
format: "icu",
|
|
425
|
+
content: {
|
|
426
|
+
message: "Hello {name}, you have {count, plural, one {# message} other {# messages}}"
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
```
|
|
430
|
+
|
|
388
431
|
#### `locale` (LocalesValues)
|
|
389
432
|
|
|
390
433
|
Sözlüğü, içerikte bildirilen her alanın otomatik olarak bir çeviri düğümüne dönüştürüleceği yerel bazlı bir sözlüğe dönüştürür. Bu özellik ayarlandığında:
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2024-03-07
|
|
3
3
|
updatedAt: 2025-10-03
|
|
4
4
|
title: Astro uygulamanızı nasıl çevirirsiniz – i18n rehberi 2025
|
|
5
|
-
description: Intlayer kullanarak
|
|
5
|
+
description: Intlayer kullanarak Astro web sitenize uluslararasılaştırma (i18n) nasıl eklenir öğrenin. Sitenizi çok dilli yapmak için bu kılavuzu takip edin.
|
|
6
6
|
keywords:
|
|
7
7
|
- Uluslararasılaştırma
|
|
8
8
|
- Dokümantasyon
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
createdAt: 2025-09-07
|
|
3
3
|
updatedAt: 2025-09-07
|
|
4
4
|
title: Express backend uygulamanızı nasıl çevirirsiniz – i18n rehberi 2025
|
|
5
|
-
description:
|
|
5
|
+
description: Express arka ucunuzu çok dilli hale getirmeyi keşfedin. Dokümantasyonu takip ederek uluslararasılaştırma (i18n) yapın ve çevirin.
|
|
6
6
|
keywords:
|
|
7
7
|
- Uluslararasılaştırma
|
|
8
8
|
- Dokümantasyon
|