fix(i18n): harden Brazilian Portuguese locale
This commit is contained in:
1 parent
00ba71d4df
commit
9f913055d7
5 files changed
+92
-16
No files matched your search
@@ -4,7 +4,8 @@
|
||||
|
||||
export const LANGS = {
|
||||
en: 'English', de: 'Deutsch', es: 'Español', fr: 'Français', it: 'Italiano',
|
||||
pt: 'Português (Portugal)', 'pt-BR': 'Português (Brasil)', pl: 'Polski', tr: 'Türkçe', ru: 'Русский', zh: '中文',
|
||||
pt: 'Português (Portugal)', 'pt-BR': 'Português (Brasil)', pl: 'Polski',
|
||||
tr: 'Türkçe', ru: 'Русский', zh: '中文',
|
||||
ko: '한국어', hi: 'हिन्दी'
|
||||
}
|
||||
export const INSTR_LANGS = ['en', 'es', 'fr', 'it', 'tr', 'ru', 'zh', 'hi', 'pl', 'ko']
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, test } from 'vitest'
|
||||
import { createHash } from 'node:crypto'
|
||||
import pt from '../locales/pt.js'
|
||||
import ptBR from '../locales/pt-BR.js'
|
||||
import ptBR, { PT_BR_OVERRIDES } from '../locales/pt-BR.js'
|
||||
import { DATE_LOCALES, LANGS } from './i18n-core.js'
|
||||
|
||||
const placeholders = value => [...String(value).matchAll(/\{\d+\}/g)].map(match => match[0]).sort()
|
||||
@@ -12,18 +13,34 @@ describe('Brazilian Portuguese locale', () => {
|
||||
expect(DATE_LOCALES['pt-BR']).toBe('pt-BR')
|
||||
})
|
||||
|
||||
test('has the complete key set and preserves interpolation placeholders', () => {
|
||||
test('matches the source key set and preserves interpolation placeholders', () => {
|
||||
expect(Object.keys(ptBR).sort()).toEqual(Object.keys(pt).sort())
|
||||
for (const [source, translated] of Object.entries(ptBR)) {
|
||||
expect(placeholders(translated), source).toEqual(placeholders(source))
|
||||
}
|
||||
})
|
||||
|
||||
test('does not leak the most visible European Portuguese UI terms', () => {
|
||||
test('makes every inherited pt-PT value an explicit reviewed snapshot', () => {
|
||||
const inherited = Object.entries(pt)
|
||||
.filter(([key]) => !(key in PT_BR_OVERRIDES))
|
||||
.sort(([a], [b]) => a.localeCompare(b))
|
||||
const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')
|
||||
|
||||
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(222)
|
||||
expect(inherited).toHaveLength(432)
|
||||
expect(fingerprint).toBe('ed0546448785eef2e75ef23523c192f6e19e878b9e920a64a77009c662e731a6')
|
||||
})
|
||||
|
||||
test('does not leak European Portuguese UI terms', () => {
|
||||
const text = Object.values(ptBR).join('\n')
|
||||
expect(text).not.toMatch(/\b(ficheiro\w*|telemóvel\w*|ecrã\w*|regist(?:ar|ado|ada|ados|adas|o|os)|eliminar|definições)\b/i)
|
||||
const europeanPortuguese = /(?:^|[^\p{L}])(?:ficheiro\p{L}*|telemóvel\p{L}*|ecrã\p{L}*|regist(?:o|am|ado|ada|ados|adas)|eliminad\p{L}*|definições|cronómetro|detetad\p{L}*|gémeos|abdómen|anca|coifa dos rotadores|escadora|completaste|acabaste|aguentas|definires|completares|aguenta|aguentaste|ficaste|viajares)(?=$|[^\p{L}])/iu
|
||||
expect(text).not.toMatch(europeanPortuguese)
|
||||
expect(text).not.toMatch(/[«»]/u)
|
||||
expect(ptBR.Save).toBe('Salvar')
|
||||
expect(ptBR.Settings).toBe('Configurações')
|
||||
expect(ptBR['Delete workout']).toBe('Excluir treino')
|
||||
expect(ptBR.Superset).toBe('Superset')
|
||||
expect(ptBR['Guest mode — data lives only in this browser.']).toContain('visitante')
|
||||
expect(ptBR['Sign in with passkey']).toContain('chave de acesso')
|
||||
})
|
||||
})
|
||||
@@ -1,10 +1,9 @@
|
||||
// Brazilian Portuguese overrides. Shared, region-neutral strings inherit from pt-PT so new
|
||||
// source keys keep a Portuguese fallback; every wording that differs in Brazil is explicit here.
|
||||
// Brazilian Portuguese overrides. Shared, region-neutral strings inherit from pt-PT.
|
||||
// Tests fingerprint every deliberately inherited entry so upstream changes require review.
|
||||
import pt from './pt.js'
|
||||
|
||||
export default {
|
||||
...pt,
|
||||
'Press back again to exit': 'Pressione novamente para sair',
|
||||
export const PT_BR_OVERRIDES = {
|
||||
'Press back again to exit': 'Pressione voltar novamente para sair',
|
||||
'Delete': 'Excluir',
|
||||
'Save': 'Salvar',
|
||||
'Log': 'Registrar',
|
||||
@@ -51,13 +50,13 @@ export default {
|
||||
'The sets you logged in this session will be lost.': 'As séries registradas nesta sessão serão perdidas.',
|
||||
'Superset · do these back-to-back, rest when done': 'Superset · faça estes exercícios em sequência e descanse ao terminar',
|
||||
'Freestyle workout — add your first exercise.': 'Treino livre — adicione seu primeiro exercício.',
|
||||
'Set up your weekly routine to get going — or load a ready-made Push / Pull / Legs plan.': 'Configure sua rotina semanal para começar ou carregue um plano pronto de Empurrar / Puxar / Pernas.',
|
||||
'Set up your weekly routine to get going — or load a ready-made Push / Pull / Legs plan.': 'Configure sua rotina semanal para começar ou carregue um plano pronto de Push / Pull / Legs.',
|
||||
'Load starter plan (PPL)': 'Carregar plano inicial (PPL)',
|
||||
'Build my own plan': 'Criar meu próprio plano',
|
||||
'Finish your first workout to see progress curves here.': 'Finalize seu primeiro treino para ver os gráficos de progresso aqui.',
|
||||
'Your weekly routine': 'Sua rotina semanal',
|
||||
'Create one or load the starter plan.': 'Crie uma ou carregue o plano inicial.',
|
||||
'Load starter plan (Push / Pull / Legs)': 'Carregar plano inicial (Empurrar / Puxar / Pernas)',
|
||||
'Load starter plan (Push / Pull / Legs)': 'Carregar plano inicial (Push / Pull / Legs)',
|
||||
'No exercises yet — add your first one.': 'Ainda não há exercícios — adicione o primeiro.',
|
||||
'Tap the link button on an exercise to superset it with the one above — you’ll do them back-to-back.': 'Toque no botão de vínculo de um exercício para combiná-lo em um superset com o exercício acima — eles serão feitos em sequência.',
|
||||
'Delete routine?': 'Excluir rotina?',
|
||||
@@ -121,7 +120,7 @@ export default {
|
||||
'Finish your current workout first': 'Finalize o treino atual primeiro',
|
||||
'Delete exercise': 'Excluir exercício',
|
||||
'Edit or delete this exercise': 'Editar ou excluir este exercício',
|
||||
'This app is invite-only — enter the code you were given.': 'Este aplicativo é exclusivo para convidados — informe o código que você recebeu.',
|
||||
'This app is invite-only — enter the code you were given.': 'Este aplicativo é somente para convidados — informe o código que você recebeu.',
|
||||
'Passkeys use {0} — no passwords.': 'As chaves de acesso usam {0} — sem senhas.',
|
||||
'Strength shows retained muscle strength. Train again to reset it.': 'A força mostra quanto da força muscular foi mantida. Treine novamente para redefinir o valor.',
|
||||
'Added as your own': 'Adicionados como seus',
|
||||
@@ -150,7 +149,7 @@ export default {
|
||||
'These are added as new routines — nothing you already have is changed.': 'Elas serão adicionadas como novas rotinas — nada do que você já tem será alterado.',
|
||||
'{0} exercise in the file isn’t in your library and was left out.': '{0} exercício do arquivo não está na sua biblioteca e foi ignorado.',
|
||||
'{0} exercises in the file aren’t in your library and were left out.': '{0} exercícios do arquivo não estão na sua biblioteca e foram ignorados.',
|
||||
'Replaces your current Mon–Sun assignments.': 'Substitui suas atribuições atuais de seg. a dom.',
|
||||
'Replaces your current Mon–Sun assignments.': 'Substitui os dias definidos de segunda a domingo.',
|
||||
'Added {0} routines to your plan': '{0} rotinas adicionadas ao seu plano',
|
||||
'this isn’t an openGym plan file': 'este não é um arquivo de plano do openGym',
|
||||
'This screen could not be drawn. Your data is safe on this device.': 'Não foi possível exibir esta tela. Seus dados estão seguros neste dispositivo.',
|
||||
@@ -175,5 +174,59 @@ export default {
|
||||
'{0} reps in every set — add a set and go back to {1}.': '{0} repetições em todas as séries — adicione uma série e volte para {1}.',
|
||||
'You still log the total: {0} is {1} per side.': 'Você ainda registra o total: {0} corresponde a {1} de cada lado.',
|
||||
'Two straight sets plus a final set taken to failure. Beat the target on that set and the weight goes up — double if you double the reps. One failure resets 10 %.': 'Duas séries normais mais uma série final até a falha. Se você superar a meta nessa série, o peso aumenta — em dobro se você dobrar as repetições. Uma falha reduz 10%.',
|
||||
'Reps climb to {0}, then a set is added and the reps start over. At {1} sets it asks you to add weight instead.': 'As repetições aumentam até {0}; depois, uma série é adicionada e as repetições recomeçam. Ao chegar a {1} séries, o app sugere adicionar peso.'
|
||||
'Reps climb to {0}, then a set is added and the reps start over. At {1} sets it asks you to add weight instead.': 'As repetições aumentam até {0}; depois, uma série é adicionada e as repetições recomeçam. Ao chegar a {1} séries, o app sugere adicionar peso.',
|
||||
|
||||
// Regional wording inherited from pt-PT would otherwise leak into pt-BR.
|
||||
'Skip': 'Pular',
|
||||
'Rest / skip this day': 'Descansar / pular este dia',
|
||||
'Workout deleted': 'Treino excluído',
|
||||
'Last time you hit all reps — try {0}': 'Na última vez você concluiu todas as repetições — tente {0}',
|
||||
'{0} — in progress': '{0} — em andamento',
|
||||
'“{0}” and its exercises will be removed.': '“{0}” e seus exercícios serão removidos.',
|
||||
'Sign-in failed': 'Falha ao entrar',
|
||||
"This browser doesn't support passkeys, and this instance requires an account. Try a browser or device with passkey support.": 'Este navegador não oferece suporte a chaves de acesso e este servidor exige uma conta. Tente usar outro navegador ou dispositivo compatível.',
|
||||
'Keep screen awake': 'Manter a tela ligada',
|
||||
'All data reset': 'Todos os dados redefinidos',
|
||||
'to install openGym as a full-screen app.': 'para instalar o openGym como aplicativo em tela cheia.',
|
||||
'Timezone: {0} (auto-detected, updates if you travel).': 'Fuso horário: {0} (detectado automaticamente e atualizado se você viajar).',
|
||||
'lower legs': 'panturrilhas',
|
||||
'waist': 'abdômen',
|
||||
'stepmill machine': 'simulador de escada',
|
||||
'upper body ergometer': 'ergômetro de braços',
|
||||
'calves': 'panturrilhas',
|
||||
'levator scapulae': 'levantador da escápula',
|
||||
'hip flexors': 'flexores do quadril',
|
||||
'rotator cuff': 'manguito rotador',
|
||||
'“{0}” already exists': '“{0}” já existe',
|
||||
'“{0}” created': '“{0}” criado',
|
||||
'Cardio exercises log time + speed instead of weight × reps.': 'Exercícios de cardio registram tempo e velocidade em vez de peso × repetições.',
|
||||
'Exercise deleted': 'Exercício excluído',
|
||||
'What you just trained': 'O que você acabou de treinar',
|
||||
'Import “{0}”': 'Importar “{0}”',
|
||||
'Something went wrong': 'Algo deu errado',
|
||||
'Discard the running workout': 'Descartar o treino em andamento',
|
||||
'A timer runs while you hold the set. Leave the weight at 0 for bodyweight holds.': 'Um cronômetro funciona enquanto você mantém a posição. Deixe o peso em 0 para isometrias com o peso do corpo.',
|
||||
'Targets stay where you set them.': 'As metas permanecem como você definir.',
|
||||
'Hit every rep in every set and the weight goes up. Repeated misses trigger a deload.': 'Conclua todas as repetições de todas as séries para aumentar o peso. Falhas repetidas acionam uma redução de carga.',
|
||||
'Hold every set for the full duration and the target goes up.': 'Mantenha todas as séries pela duração completa para aumentar a meta.',
|
||||
'Held every set for the full time — target up by {0}s.': 'Você manteve todas as séries pelo tempo completo — meta aumentada em {0} s.',
|
||||
'Last time came up short — same target again.': 'Na última vez você ficou abaixo da meta — repita a mesma meta.',
|
||||
'Same weight — aim for {0} reps this time.': 'Mesmo peso — desta vez, tente fazer {0} repetições.',
|
||||
'Nothing left — went to failure': 'Sem repetições restantes — até a falha',
|
||||
'Tap a muscle to see its exercises.': 'Toque em um músculo para ver seus exercícios.',
|
||||
'Superset': 'Superset',
|
||||
'Superset {0} / {1}': 'Superset {0} / {1}',
|
||||
'Superset with exercise above': 'Superset com o exercício acima',
|
||||
'Guest mode — data lives only in this browser.': 'Modo visitante — os dados ficam somente neste navegador.',
|
||||
'Sign in with passkey': 'Entrar com chave de acesso',
|
||||
'Passkeys not supported in this browser.': 'Chaves de acesso não são compatíveis com este navegador.',
|
||||
'Su': 'D',
|
||||
'Mo': 'S',
|
||||
'Tu': 'T',
|
||||
'We': 'Q',
|
||||
'Th': 'Q',
|
||||
'Fr': 'S',
|
||||
'Sa': 'S'
|
||||
}
|
||||
|
||||
export default { ...pt, ...PT_BR_OVERRIDES }
|
||||
Reference in new issue
Block a user