From 4081ddac06cba273ba0167ee2972937e41964d81 Mon Sep 17 00:00:00 2001 From: mzspicoli Date: Wed, 19 Aug 2026 22:07:40 +0200 Subject: [PATCH] fix(i18n): close pt-BR review gaps --- README.md | 2 +- .../scripts/pt-br-inheritance-fingerprint.mjs | 17 +++++++++++++++++ frontend/src/lib/pt-br-locale.test.js | 13 ++++++++----- frontend/src/locales/pt-BR.js | 2 ++ 4 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 frontend/scripts/pt-br-inheritance-fingerprint.mjs diff --git a/README.md b/README.md index f1f3277..47a2f97 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ as a home-screen app, passkey sign-in, offline support, sync across your phone a - 🔑 **Passkeys, not passwords** — Face ID / Touch ID / fingerprint login; each profile keeps its own data, synced across devices. Sign-ins last 90 days by default (configurable), and “sign out everywhere” in Settings ends every session on every device at once - 🛠️ **Admin dashboard** (optional) — for whoever runs the instance: who's training right now, per-user history, disable accounts, invite-only signup, and an **activity log** of sign-ins, failed attempts and admin actions. Off by default, so a fresh instance stays open with no admin - 🎨 **Designed, not assembled** — light/dark themes and 8 accent colors saved to your profile, over a hand-drawn icon set instead of emoji, so it looks the same on every phone -- 🌍 **13 languages** — full UI translation (EN, DE, ES, FR, IT, Portuguese (Portugal), Portuguese (Brazil), PL, TR, RU, ZH, KO, HI); exercise instructions localized in 10 of them, loaded on demand so the app stays fast +- 🌍 **13 languages** — full UI translation (EN, DE, ES, FR, IT, PT (Portugal), PT (Brazil), PL, TR, RU, ZH, KO, HI); exercise instructions localized in 10 of them, loaded on demand so the app stays fast - 📥 **Bring your history with you** — import from **FitNotes** (Android and iOS), **Strong** and **Hevy**, or body weight straight out of an **Apple Health** export. Exercise names are matched against the library and anything unrecognised becomes one of your own exercises, so nothing in the file is dropped - 📦 **Yours to keep** — one-tap JSON export/import, guest mode, **no telemetry** - 🤖 **Ask an AI about your training** (optional) — an [MCP server](mcp/README.md) lets a client like Claude Desktop or Cursor read your history in your own words: *"what did I bench last week?"*. Read-only, spawned locally by the client, nothing leaves your box. Not in the Docker build — if you don't use an AI assistant, it isn't there diff --git a/frontend/scripts/pt-br-inheritance-fingerprint.mjs b/frontend/scripts/pt-br-inheritance-fingerprint.mjs new file mode 100644 index 0000000..53a61a1 --- /dev/null +++ b/frontend/scripts/pt-br-inheritance-fingerprint.mjs @@ -0,0 +1,17 @@ +#!/usr/bin/env node + +import { createHash } from 'node:crypto' +import pt from '../src/locales/pt.js' +import { PT_BR_OVERRIDES } from '../src/locales/pt-BR.js' + +const inherited = Object.entries(pt) + .filter(([key]) => !(key in PT_BR_OVERRIDES)) + .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)) +const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex') + +console.log(JSON.stringify({ + overrides: Object.keys(PT_BR_OVERRIDES).length, + inherited: inherited.length, + fingerprint, + ...(process.argv.includes('--list') ? { entries: inherited } : {}) +}, null, 2)) diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js index 7926dcc..e9693d3 100644 --- a/frontend/src/lib/pt-br-locale.test.js +++ b/frontend/src/lib/pt-br-locale.test.js @@ -5,6 +5,7 @@ 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() +const byCodeUnit = ([a], [b]) => (a < b ? -1 : a > b ? 1 : 0) describe('Brazilian Portuguese locale', () => { test('is a separately selectable locale with Brazilian date formatting', () => { @@ -23,17 +24,19 @@ describe('Brazilian Portuguese locale', () => { 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)) + .sort(byCodeUnit) 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') + expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(223) + expect(inherited).toHaveLength(431) + // If this fails, review the changed keys and wording before accepting a new hash. From + // frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list + expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('414a54d8e6e0941556ba90e4ec14c5a88dbd98666618d20f4c902b705fd0c47c') }) test('does not leak European Portuguese UI terms', () => { const text = Object.values(ptBR).join('\n') - 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 + 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|vê|vês)(?=$|[^\p{L}])/iu expect(text).not.toMatch(europeanPortuguese) expect(text).not.toMatch(/[«»]/u) expect(ptBR.Save).toBe('Salvar') diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js index 60a2673..acd3656 100644 --- a/frontend/src/locales/pt-BR.js +++ b/frontend/src/locales/pt-BR.js @@ -1,5 +1,6 @@ // Brazilian Portuguese overrides. Shared, region-neutral strings inherit from pt-PT. // Tests fingerprint every deliberately inherited entry so upstream changes require review. +// Some byte-identical overrides intentionally pin wording that must not drift with pt-PT. import pt from './pt.js' export const PT_BR_OVERRIDES = { @@ -130,6 +131,7 @@ export const PT_BR_OVERRIDES = { '{0} days already have data here and will be left alone.': '{0} dias já têm dados aqui e não serão alterados.', 'Not in the library — added as your own exercises': 'Não estão na biblioteca — foram adicionados como exercícios próprios', 'Could not read that file': 'Não foi possível ler esse arquivo', + 'That file\'s columns aren\'t recognised — see the docs for supported apps.': 'Colunas não reconhecidas — consulte a documentação dos aplicativos compatíveis.', 'That file is empty': 'Esse arquivo está vazio', 'Nothing to import from that file': 'Não há nada para importar desse arquivo', 'Your data': 'Seus dados',