localization support

O que mudou
Infra (por app):

i18n/locales.ts — lista de locales (pt, en), default pt, labels para o seletor
i18n/request.ts — lê o cookie NEXT_LOCALE, carrega as mensagens
messages/pt.json + messages/en.json — todas as strings extraídas
next.config.ts — envolvido com withNextIntl (operator-pwa: withPWA(withNextIntl(...)))
app/layout.tsx — <html lang={locale}> dinâmico, NextIntlClientProvider
app/language-switcher.tsx — seletor PT | EN (cookie + router.refresh())
23 ficheiros de UI atualizados — todos os textos visíveis agora usam t('...') ou getTranslations.

Datas no relatório passaram de toLocaleString('pt-PT') fixo para useFormatter() do next-intl — localizam-se automaticamente.

Plurais em ICU no sync-chip: {count, plural, one {# pedido...} other {# pedidos...}}.

Resultado dos testes:

pnpm test:e2e — 3/3 ✓
pnpm test:e2e:auth — 4/4 ✓
tsc --noEmit em ambas as apps — limpo ✓
Para adicionar uma língua futura: criar messages/<locale>.json + adicionar o locale a i18n/locales.ts em cada app. O seletor aparece automaticamente.
This commit is contained in:
2026-05-30 16:46:07 +01:00
parent 2093f12d0a
commit 35e7027881
41 changed files with 1549 additions and 259 deletions
+7 -8
View File
@@ -22,14 +22,13 @@ AUTH_SECRET="dev-secret-do-not-use-in-production-please-change-me"
# must consciously opt in by editing their .env. See README "Auth" section.
AUTH_DEV_AUTOLOGIN="false"
# Base URL Auth.js uses to build callback/redirect URLs. It MUST match the host
# of the app being served. This shared .env can hold only ONE value, set here to
# the operator-pwa (:3000). The admin-web (:3001) therefore needs its OWN
# AUTH_URL whenever autologin is OFF (real-login dev, or production) — otherwise
# Auth.js redirects admin users to :3000 and the admin login breaks.
# - Local with autologin ON: this value is harmless (middleware never redirects).
# - E2E real-login: e2e/playwright.auth.config.ts passes AUTH_URL=:3001 to admin.
# - Production: give EACH app its own AUTH_URL (per-app env), not this shared file.
# Base URL Auth.js uses to build callback/redirect URLs. Must match the host of
# the app being served. This shared .env holds ONE value — the operator-pwa
# (:3000). The admin-web (:3001) gets its own from apps/admin-web/.env.admin,
# which its `dev` script loads with precedence over this file — so admin login
# works with autologin OFF without any extra step.
# - Production: each app still gets its own AUTH_URL from the deploy env
# (a value already in the process wins over .env.admin).
NEXT_PUBLIC_APP_URL="http://localhost:3000"
AUTH_URL="http://localhost:3000"