feat(i18n): English localization (phase 3)
CI / Lint e auditorias (push) Successful in 1m51s
CI / Trivy (dependências e segredos) (push) Successful in 15s
CI / Imagem Docker (linux/arm64) (push) Successful in 2m41s

- Translate content to English across messages/en.json, data/en, lib/data/en, and public/exemplos/en
- Implement localized routing, slugs, and language negotiation with fallback to en
- Build dedicated search index for English with strict book exclusion
- Update components and pages to dynamically render localized strings and datasets
- Verify full structural parity and exact 1:1 match on Portuguese pages via comparator

Co-Authored-By: Antigravity <noreply@google.com>
This commit is contained in:
Lucas RayanandAntigravity committed 2026-11-01 14:17:13 -03:00
1 parent 22b1f26aed
commit c1bd2c7e11
61 files changed
+18182 -1225

No files matched your search

+8 -6
View File
@@ -1,7 +1,7 @@
import createMiddleware from "next-intl/middleware";
import { NextResponse } from "next/server";
import { routing } from "./i18n/routing";
import { ALL_LOCALE_CODES, ENABLED_LOCALES, getPtPath } from "./i18n/links";
import { ALL_LOCALE_CODES, ENABLED_LOCALES, getLocalizedHref } from "./i18n/links";
const intlMiddleware = createMiddleware(routing);
@@ -76,18 +76,20 @@ export default function middleware(request) {
return response;
}
// 2. Idiomas INATIVOS: prefixos (/en, /es, /fr, /de, /zh-CN e qualquer subcaminho)
// Redirecionam com 307 para o mesmo caminho em /pt quando o slug existir lá; se não souber mapear o slug, para /pt.
// O 404 do livro fora de pt não se aplica a inativos (redirecionam para /pt/livro aqui).
// 2. Idiomas INATIVOS: prefixos (/es, /fr, /de, /zh-CN etc.)
// Redirecionam com 307 para o mesmo caminho no idioma fallback (en se ativo, senão pt) quando o slug existir lá.
const inactiveLocales = ALL_LOCALE_CODES.filter((l) => !ENABLED_LOCALES.includes(l));
if (inactiveLocales.length > 0) {
const isInactive = inactiveLocales.some(
(loc) => pathname === `/${loc}` || pathname.startsWith(`/${loc}/`)
);
if (isInactive) {
const targetPath = getPtPath(pathname);
const fallbackLocale = ENABLED_LOCALES.includes("en") ? "en" : "pt";
const targetPath = getLocalizedHref(pathname, fallbackLocale);
const url = new URL(targetPath, request.url);
url.search = search;
if (search && !targetPath.includes("?")) {
url.search = search;
}
return NextResponse.redirect(url, 307);
}
}