FieldOps/apps/operator-pwa/next.config.ts
Pedro Gomes 35e7027881 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.
2026-05-30 16:46:07 +01:00

36 lines
1004 B
TypeScript

import type { NextConfig } from 'next';
import withPWAInit from '@ducanh2912/next-pwa';
import createNextIntlPlugin from 'next-intl/plugin';
import './env';
const withNextIntl = createNextIntlPlugin('./i18n/request.ts');
const withPWA = withPWAInit({
dest: 'public',
cacheOnFrontEndNav: true,
aggressiveFrontEndNavCaching: true,
reloadOnOnline: true,
// Keep SW enabled in dev so offline testing works in Chrome DevTools.
disable: false,
workboxOptions: {
// Precache app shell; skip SW self and large data files.
exclude: [/manifest\.webmanifest$/],
},
});
const nextConfig: NextConfig = {
transpilePackages: ['@repo/db', '@repo/api', '@repo/ui', '@repo/domain', '@repo/storage'],
reactStrictMode: true,
poweredByHeader: false,
serverExternalPackages: [
'pino',
'pino-pretty',
'@aws-sdk/client-s3',
'@aws-sdk/s3-request-presigner',
'@aws-sdk/lib-storage',
'@smithy/node-http-handler',
],
};
export default withPWA(withNextIntl(nextConfig));