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:
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"metadata": {
|
||||
"title": "FieldOps — Operator",
|
||||
"description": "Industrial operator console.",
|
||||
"appName": "FieldOps Operator"
|
||||
},
|
||||
"common": {
|
||||
"enter": "Sign in",
|
||||
"entering": "Signing in…",
|
||||
"status": {
|
||||
"open": "Open",
|
||||
"claimed": "In progress",
|
||||
"resolved": "Resolved"
|
||||
}
|
||||
},
|
||||
"errors": {
|
||||
"title500": "500",
|
||||
"message500": "An unexpected error occurred.",
|
||||
"retry": "Try again",
|
||||
"title404": "404",
|
||||
"message404": "Page not found.",
|
||||
"backHome": "Back to home"
|
||||
},
|
||||
"auth": {
|
||||
"pickerTitle": "Who are you?",
|
||||
"pickerSubtitle": "Choose your profile to continue.",
|
||||
"noOperators": "No operators found. Run pnpm db:seed.",
|
||||
"back": "Back",
|
||||
"operatorSelected": "Selected operator",
|
||||
"invalidPin": "Incorrect PIN or account locked. Please try again.",
|
||||
"unexpectedError": "Unexpected error. Please try again.",
|
||||
"deleteDigit": "Delete",
|
||||
"switchOperator": "Switch"
|
||||
},
|
||||
"home": {
|
||||
"operator": "Operator",
|
||||
"myRequests": "My requests",
|
||||
"requestMaintenance": "Request maintenance",
|
||||
"noRequests": "No requests yet."
|
||||
},
|
||||
"sync": {
|
||||
"deadLetters": "{count, plural, one {# request failed — contact your supervisor.} other {# requests failed — contact your supervisor.}}",
|
||||
"pending": "{count, plural, one {# request pending} other {# requests pending}}",
|
||||
"synced": "All synced",
|
||||
"requestFailed": "Request {id}… failed — contact your supervisor.",
|
||||
"close": "Close"
|
||||
},
|
||||
"maintenance": {
|
||||
"newTitle": "New maintenance request",
|
||||
"workstationLabel": "Workstation",
|
||||
"workstationRequired": "*",
|
||||
"workstationLoading": "Loading workstations…",
|
||||
"workstationPlaceholder": "Select a workstation…",
|
||||
"photoLabel": "Photo (optional)",
|
||||
"photoPreview": "Preview",
|
||||
"photoButton": "Take / choose photo",
|
||||
"descriptionLabel": "Description",
|
||||
"descriptionRequired": "*",
|
||||
"descriptionPlaceholder": "Describe the problem…",
|
||||
"photoError": "Could not process the photo. Please try again.",
|
||||
"saveError": "Error saving request. Please try again.",
|
||||
"submit": "Submit request",
|
||||
"submitting": "Saving…",
|
||||
"sentTitle": "Request submitted",
|
||||
"pendingTitle": "Request queued",
|
||||
"sentMessage": "The maintenance team has been notified and will handle the issue.",
|
||||
"pendingMessage": "Will be sent as soon as the connection is restored.",
|
||||
"backHome": "Back to home"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"metadata": {
|
||||
"title": "FieldOps — Operador",
|
||||
"description": "Consola de operador industrial.",
|
||||
"appName": "FieldOps Operador"
|
||||
},
|
||||
"common": {
|
||||
"enter": "Entrar",
|
||||
"entering": "A entrar…",
|
||||
"status": {
|
||||
"open": "Aberto",
|
||||
"claimed": "Em curso",
|
||||
"resolved": "Resolvido"
|
||||
}
|
||||
},
|
||||
"errors": {
|
||||
"title500": "500",
|
||||
"message500": "Ocorreu um erro inesperado.",
|
||||
"retry": "Tentar novamente",
|
||||
"title404": "404",
|
||||
"message404": "Página não encontrada.",
|
||||
"backHome": "Voltar ao início"
|
||||
},
|
||||
"auth": {
|
||||
"pickerTitle": "Quem és tu?",
|
||||
"pickerSubtitle": "Escolhe o teu perfil para continuar.",
|
||||
"noOperators": "Nenhum operador encontrado. Execute pnpm db:seed.",
|
||||
"back": "Voltar",
|
||||
"operatorSelected": "Operador selecionado",
|
||||
"invalidPin": "PIN incorreto ou conta bloqueada. Tente novamente.",
|
||||
"unexpectedError": "Erro inesperado. Tente novamente.",
|
||||
"deleteDigit": "Apagar",
|
||||
"switchOperator": "Trocar"
|
||||
},
|
||||
"home": {
|
||||
"operator": "Operador",
|
||||
"myRequests": "Os meus pedidos",
|
||||
"requestMaintenance": "Pedir manutenção",
|
||||
"noRequests": "Nenhum pedido ainda."
|
||||
},
|
||||
"sync": {
|
||||
"deadLetters": "{count, plural, one {# pedido com erro — contacta o supervisor.} other {# pedidos com erro — contacta o supervisor.}}",
|
||||
"pending": "{count, plural, one {# pedido por enviar} other {# pedidos por enviar}}",
|
||||
"synced": "Tudo sincronizado",
|
||||
"requestFailed": "Pedido {id}… falhou — contacta o supervisor.",
|
||||
"close": "Fechar"
|
||||
},
|
||||
"maintenance": {
|
||||
"newTitle": "Novo pedido de manutenção",
|
||||
"workstationLabel": "Posto",
|
||||
"workstationRequired": "*",
|
||||
"workstationLoading": "A carregar postos…",
|
||||
"workstationPlaceholder": "Seleciona um posto…",
|
||||
"photoLabel": "Foto (opcional)",
|
||||
"photoPreview": "Pré-visualização",
|
||||
"photoButton": "Tirar / escolher foto",
|
||||
"descriptionLabel": "Descrição",
|
||||
"descriptionRequired": "*",
|
||||
"descriptionPlaceholder": "Descreve o problema…",
|
||||
"photoError": "Não foi possível processar a foto. Tenta de novo.",
|
||||
"saveError": "Erro ao guardar pedido. Tenta de novo.",
|
||||
"submit": "Enviar pedido",
|
||||
"submitting": "A guardar…",
|
||||
"sentTitle": "Pedido enviado",
|
||||
"pendingTitle": "Pedido em fila",
|
||||
"sentMessage": "A equipa de manutenção foi notificada e irá tratar do problema.",
|
||||
"pendingMessage": "Será enviado assim que a ligação for restabelecida.",
|
||||
"backHome": "Voltar ao início"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user