feat(i18n): English localization (phase 3)
- 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:
1 parent
22b1f26aed
commit
c1bd2c7e11
61 files changed
+18182
-1225
No files matched your search
+39
-4
@@ -6,6 +6,8 @@
|
||||
* nascendo sem título próprio.
|
||||
*/
|
||||
|
||||
import { ENABLED_LOCALES, getLocalizedHref } from "@/i18n/links";
|
||||
|
||||
export const SITE = {
|
||||
url: "https://espdocs.cienciaembarcada.com.br",
|
||||
nome: "ESPDocs",
|
||||
@@ -28,16 +30,49 @@ export const SITE = {
|
||||
* Usar isto em vez de escrever o objeto à mão garante que nenhuma página fique
|
||||
* sem canonical ou sem og:title.
|
||||
*/
|
||||
export function paginaMeta({ titulo, descricao, caminho, keywords = [], tipo = "website" }) {
|
||||
const url = `${SITE.url}${caminho}`;
|
||||
export function paginaMeta({ titulo, descricao, caminho, keywords = [], tipo = "website", locale = "pt" }) {
|
||||
const currentLocale = locale || "pt";
|
||||
const basePath = caminho.startsWith("/") ? caminho : `/${caminho}`;
|
||||
const canonicalPath = getLocalizedHref(`/pt${basePath}`, currentLocale);
|
||||
const url = `${SITE.url}${canonicalPath}`;
|
||||
|
||||
const languages = {};
|
||||
for (const loc of ENABLED_LOCALES) {
|
||||
if (basePath === "/livro" && loc !== "pt") continue;
|
||||
const locHref = getLocalizedHref(`/pt${basePath}`, loc);
|
||||
const langKey = loc === "pt" ? "pt-BR" : loc;
|
||||
languages[langKey] = `${SITE.url}${locHref}`;
|
||||
}
|
||||
if (ENABLED_LOCALES.includes("en") && basePath !== "/livro") {
|
||||
languages["x-default"] = `${SITE.url}${getLocalizedHref(`/pt${basePath}`, "en")}`;
|
||||
}
|
||||
|
||||
const ogLocaleMap = {
|
||||
pt: "pt_BR",
|
||||
en: "en_US",
|
||||
es: "es_419",
|
||||
fr: "fr_FR",
|
||||
de: "de_DE",
|
||||
"zh-CN": "zh_CN",
|
||||
};
|
||||
|
||||
const alternateLocales = ENABLED_LOCALES
|
||||
.filter((l) => l !== currentLocale && (basePath !== "/livro" || l === "pt"))
|
||||
.map((l) => ogLocaleMap[l])
|
||||
.filter(Boolean);
|
||||
|
||||
return {
|
||||
title: titulo,
|
||||
description: descricao,
|
||||
keywords,
|
||||
alternates: { canonical: caminho },
|
||||
alternates: {
|
||||
canonical: canonicalPath,
|
||||
languages: Object.keys(languages).length > 1 ? languages : undefined,
|
||||
},
|
||||
openGraph: {
|
||||
type: tipo,
|
||||
locale: "pt_BR",
|
||||
locale: ogLocaleMap[currentLocale] || "pt_BR",
|
||||
alternateLocale: alternateLocales.length > 0 ? alternateLocales : undefined,
|
||||
url,
|
||||
siteName: SITE.nome,
|
||||
title: `${titulo} · ${SITE.nome}`,
|
||||
|
||||
Reference in new issue
Block a user