User: "quero que o usuário possa escolher o idioma na navbar, e então leia
o site todo em seu idioma."
The locale infrastructure already existed (cookie + getLocale() + every
page renders bilingual). The toggle only lived as a subtle floating
control bottom-left. This surfaces it in the navbars where users expect
it, and confirms whole-site language switching.
locale-toggle-client.tsx
- New variant="navbar": gold-amber pill matching the magazine theme
(PT | EN, active = solid gold). Retro green variant kept for the
floating fallback.
- Guard: clicking the already-active language is a no-op.
- aria-pressed on each button for a11y.
locale-toggle.tsx: LocaleToggle gains variant passthrough.
site-header.tsx: <LocaleToggle variant="navbar"> added to the main nav
(homepage + /sightings /witnesses /objects /locations /operations
/documents).
bureau-nav.tsx: optional `locale` prop renders the same toggle pushed
to the right (ml-auto) on /bureau, /c/[slug], /h/[id], /jobs/[id].
All four callers now pass locale (getLocale added to h + jobs pages).
Cookie-based: switching sets `locale` cookie + router.refresh(); the
server re-renders every component through getLocale(), so the entire
page — headers, hero, summaries, case narratives, entity cards — flips
language in one click. The floating bottom-left toggle stays as a global
fallback for pages without a navbar (/d, /e, /search, /graph).
Also this session: Sun-Tzu smoke succeeded on the refreshed
CLAUDE_CODE_OAUTH_TOKEN — brief B-0001 written for the green fireballs
("bolas de fogo verdes confinadas ao corredor nuclear... cor espectral
e trajetória quase horizontal que os próprios analistas consideraram
irreconciliáveis com meteoros naturais", 3 pillars). Bulk entity
enrichment resumed in the background.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
21 lines
635 B
TypeScript
21 lines
635 B
TypeScript
/**
|
|
* Language switcher — toggle EN ↔ pt-br using a cookie.
|
|
* Server reads the cookie in getLocale(); client component sets it.
|
|
*/
|
|
import { cookies } from "next/headers";
|
|
import { LocaleToggleClient } from "./locale-toggle-client";
|
|
|
|
export type Locale = "en" | "pt-br";
|
|
|
|
export async function getLocale(): Promise<Locale> {
|
|
const store = await cookies();
|
|
const v = store.get("locale")?.value;
|
|
return v === "en" ? "en" : "pt-br";
|
|
}
|
|
|
|
export function LocaleToggle({
|
|
current,
|
|
variant = "retro",
|
|
}: { current: Locale; variant?: "retro" | "navbar" }) {
|
|
return <LocaleToggleClient current={current} variant={variant} />;
|
|
}
|