feat(i18n): localize pt-BR exercise names

This commit is contained in:
mzspicoli committed 2026-08-24 18:02:29 +02:00
1 parent dc3fafc6ef
commit 448c66752f
21 files changed
+1615 -53

No files matched your search

+2 -2
View File
@@ -1,7 +1,7 @@
import { useState } from 'react'
import { imgSrc, gifSrc } from '../lib/exercises.js'
import { useStore } from '../store/useStore.js'
import { t } from '../lib/i18n.js'
import { t, exerciseNameFor } from '../lib/i18n.js'
import Icon from './Icon.jsx'
// Big autoplaying animation; tap toggles to the still frame. `compact` shrinks it (superset cards).
@@ -18,7 +18,7 @@ export default function Media({ ex, id, compact, minimizable }) {
const toggleSize = e => { e.stopPropagation(); update(s => { s.gifSize = mini ? 'full' : 'mini' }) }
return (
<div className={'exmedia' + (compact ? ' compact' : '') + (mini ? ' mini' : '')} id={id} onClick={() => setPlaying(p => !p)}>
<img decoding="async" src={playing ? gifSrc(ex) : imgSrc(ex)} alt={ex.n} />
<img decoding="async" src={playing ? gifSrc(ex) : imgSrc(ex)} alt={exerciseNameFor(ex)} />
{minimizable && (
<button className="giftoggle" onClick={toggleSize}>
<Icon name={mini ? 'expand' : 'minimize'} />{mini ? t('Expand') : t('Minimize')}
+2
View File
@@ -0,0 +1,2 @@
// generated by scripts/build-pt-br-exercise-names.mjs — edit scripts/exercise-name-sources/pt-BR.json
export default {"1000":"elevação de panturrilha invertida unilateral com faixa elástica","1001":"afundo estático unilateral com faixa elástica","1002":"elevação de pernas retas deitado com faixa elástica","1003":"agachamento com remada e faixa elástica","1004":"agachamento com faixa elástica","1005":"abdominal em pé com faixa elástica","1007":"abdominal rotacional em pé com faixa elástica","1008":"subida no step com faixa elástica","1009":"levantamento terra pernas semiestendidas com faixa elástica","1010":"levantamento terra pernas estendidas com faixa elástica","1011":"torção sentado com faixa elástica","1012":"desenvolvimento acima da cabeça com rotação e faixa elástica","1013":"puxada pegada supinada com faixa elástica","1014":"abdominal em v com faixa elástica","1015":"pallof press vertical com faixa elástica","1016":"rosca de punho com faixa elástica","1017":"elevação em y com faixa elástica","1018":"encolhimento de ombros com faixa elástica","1022":"remada para deltoide posterior em pé com faixa elástica","1023":"levantamento terra pernas semiestendidas com costas retas e faixa elástica","1160":"burpee","1167":"alongamento dinâmico de peitoral (masculino)","1201":"Burpee com halteres","1253":"elevação de panturrilha burro na máquina","1254":"supino com faixa elástica","1255":"pullover declinado com barra","1256":"supino declinado pegada supinada com barra","1257":"supino inclinado pegada supinada com barra","1258":"supino pegada aberta supinada com barra","1259":"alongamento de peitoral atrás da cabeça","1260":"supino declinado unilateral no cabo","1261":"supino declinado no cabo","1262":"crucifixo declinado unilateral no cabo","1263":"crucifixo unilateral na bola de exercício no cabo","1264":"crucifixo inclinado unilateral na bola de exercício no cabo","1265":"supino inclinado unilateral no cabo","1266":"supino inclinado unilateral na bola de exercício no cabo","1267":"supino unilateral na bola de exercício no cabo","1268":"supino na bola de exercício no cabo","1269":"crossover em pé ereto no cabo","1270":"crossover para peitoral superior no cabo","1271":"alongamento de peito e parte frontal do ombro","1272":"alongamento de peito com bola de exercício","1273":"flexão de braços com palma","1274":"flexão de braços profunda","1275":"flexão de braços com queda","1276":"Crucifixo declinado unilateral com halter","1277":"Crucifixo com halteres na bola de estabilidade","1278":"Crucifixo inclinado com halteres na bola de estabilidade","1279":"Crucifixo inclinado unilateral com halter","1280":"Crucifixo inclinado unilateral com halter na bola de estabilidade","1281":"Supino inclinado unilateral com halter","1282":"Supino inclinado unilateral com halter na bola de estabilidade","1283":"Supino inclinado com halteres na bola de estabilidade","1284":"Pullover deitado na bola de estabilidade com halter","1285":"Crucifixo unilateral no banco com halter","1286":"Crucifixo unilateral na bola de estabilidade com halter","1287":"Supino declinado unilateral com halter","1288":"Crucifixo unilateral na bola de estabilidade com halter","1289":"Supino inclinado unilateral com halter","1290":"Supino unilateral na bola de estabilidade com halter","1291":"Pullover unilateral na bola de estabilidade com halter","1292":"Crucifixo com uma perna na bola de estabilidade (halteres)","1293":"Supino na bola de estabilidade com halteres","1294":"Pullover com extensão de quadril na bola de estabilidade (halteres)","1295":"Pullover na bola de estabilidade com halteres","1296":"flexão de braços em pique na bola de estabilidade","1297":"contração isométrica de peitoral","1298":"supino unilateral com kettlebell no chão","1299":"supino inclinado na máquina","1300":"supino declinado na máquina","1301":"supino interno na máquina","1302":"passe de peito com bola medicinal","1303":"empurrão de peito com bola medicinal a partir de três apoios","1304":"empurrão de peito com bola medicinal (resposta múltipla)","1305":"empurrão de peito com bola medicinal (resposta única)","1306":"flexão de braços pliométrica","1307":"flexão de braços na bosu","1308":"supino pegada aberta na máquina Smith","1309":"supino declinado pegada aberta na máquina Smith","1310":"flexão de braços com queda e peso","1311":"flexão de braços com mãos afastadas","1312":"empurrão de peito com bola medicinal com saída em corrida","1313":"remada unilateral na máquina","1314":"extensão de tronco na bola de estabilidade","1316":"pullover com braços flexionados com barra","1317":"remada no banco inclinado pegada supinada com barra","1318":"remada no banco inclinado no cabo","1319":"remada com rotação da palma no cabo","1320":"remada sentada crossover com corda no cabo","1321":"remada sentada elevada com corda no cabo","1322":"remada no banco inclinado com extensão de corda no cabo","1323":"remada sentada com corda no cabo","1324":"remada superior no cabo","1325":"puxada atrás da nuca pegada abLine truncated
+25 -3
View File
@@ -1,5 +1,6 @@
// Runtime-agnostic core of the i18n module: state, constants and readers (t, dateLocale,
// instrFor, getLang). Plain Node-loadable — the browser-only pieces (import.meta.glob lazy
// instrFor, exerciseNameFor, getLang). Plain Node-loadable — the browser-only pieces
// (import.meta.glob lazy
// loads, the React subscription hook) live in i18n.js and re-export from here.
export const LANGS = {
@@ -9,6 +10,7 @@ export const LANGS = {
ko: '한국어', hi: 'हिन्दी'
}
export const INSTR_LANGS = ['en', 'es', 'fr', 'it', 'tr', 'ru', 'zh', 'hi', 'pl', 'ko', 'pt-BR']
export const EXERCISE_NAME_LANGS = ['pt-BR']
export const DATE_LOCALES = {
en: 'en-GB', de: 'de-DE', es: 'es-ES', fr: 'fr-FR', it: 'it-IT', pt: 'pt-PT', 'pt-BR': 'pt-BR',
pl: 'pl-PL', tr: 'tr-TR', ru: 'ru-RU', zh: 'zh-CN', ko: 'ko-KR', hi: 'hi-IN'
@@ -17,6 +19,7 @@ export const DATE_LOCALES = {
let lang = 'en' // set only by _setLangState, called from i18n.js setLang
let dict = {} // current locale pack (empty = English fallback)
let instr = null // { exId: [steps] } for the current language, null = English
let exerciseNames = null // { exId: translated name }, null = original catalogue name
let version = 0 // bumped on every setLang; drives the React subscription selector
export const getLang = () => lang
@@ -33,13 +36,32 @@ export function t(s, ...args) {
// Instructions for an exercise in the current language (English steps as fallback).
export const instrFor = ex => (instr && instr[ex.id]) || ex.st || []
// Built-in catalogue names are bilingual when a complete translated name pack is active.
// User-created exercises have no entry in the pack and keep their exact chosen name.
export const exerciseNameFor = ex => {
const translated = exerciseNames && ex && exerciseNames[ex.id]
if (!translated) return ex?.n || ''
// Some names (Burpee, Pilates, brand/model terms) are the established pt-BR term too.
// Repeating an identical loanword in parentheses adds noise rather than context.
return translated.toLocaleLowerCase('pt-BR') === ex.n.toLocaleLowerCase('en')
? translated
: `${translated} (${ex.n})`
}
// Search both the localized and canonical English title without changing persisted data.
export const exerciseNameSearchText = ex => {
const translated = exerciseNames && ex && exerciseNames[ex.id]
return translated ? `${translated} ${ex.n}` : (ex?.n || '')
}
// Called by i18n.js's setLang once the locale pack has been loaded — kept here rather than
// exported as setLang because loading packs requires import.meta.glob, which is Vite-only.
// Both `dict` and `instr` may be null to reset to English.
export function _setLangState(newLang, newDict, newInstr) {
// `dict`, `instr` and `exerciseNames` may be null to reset to their English fallbacks.
export function _setLangState(newLang, newDict, newInstr, newExerciseNames) {
lang = LANGS[newLang] ? newLang : 'en'
dict = lang === 'en' ? {} : (newDict || {})
instr = lang === 'en' || !INSTR_LANGS.includes(lang) ? null : (newInstr || null)
exerciseNames = lang === 'en' || !EXERCISE_NAME_LANGS.includes(lang) ? null : (newExerciseNames || null)
version++
return version
}
+17 -10
View File
@@ -5,16 +5,20 @@
import { useSyncExternalStore } from 'react'
import {
LANGS, INSTR_LANGS, DATE_LOCALES,
getLang, dateLocale, t, instrFor, getVersion, _setLangState
LANGS, INSTR_LANGS, EXERCISE_NAME_LANGS, DATE_LOCALES,
getLang, dateLocale, t, instrFor, exerciseNameFor, exerciseNameSearchText, getVersion, _setLangState
} from './i18n-core.js'
export { LANGS, INSTR_LANGS, DATE_LOCALES, getLang, dateLocale, t, instrFor }
export {
LANGS, INSTR_LANGS, EXERCISE_NAME_LANGS, DATE_LOCALES,
getLang, dateLocale, t, instrFor, exerciseNameFor, exerciseNameSearchText
}
// Vite code-splits each locale pack into its own chunk via import.meta.glob; instructions use
// the same mechanism in src/instr/. Both are lazy, so the production bundle ships English only.
// Vite code-splits locale, instruction and exercise-name packs via import.meta.glob. They are
// lazy, so the production bundle ships English only until another language is selected.
const localePacks = import.meta.glob('../locales/*.js')
const instrPacks = import.meta.glob('../instr/*.js')
const exerciseNamePacks = import.meta.glob('../exercise-names/*.js')
// React subscription bookkeeping — kept here, not in core, so core has zero React coupling.
const subs = new Set()
@@ -23,12 +27,15 @@ const notify = () => { subs.forEach(f => f()) }
export async function setLang(l) {
if (!LANGS[l]) l = 'en'
if (l === getLang() && getVersion() > 0) return
let dict = {}, instr = null
let dict = {}, instr = null, exerciseNames = null
try { dict = l === 'en' ? {} : (await localePacks['../locales/' + l + '.js']()).default } catch (e) { dict = {} }
try { instr = l === 'en' || !INSTR_LANGS.includes(l) ? null : (await instrPacks['../instr/' + l + '.js']()).default } catch (e) { instr = null }
try {
dict = l === 'en' ? {} : (await localePacks['../locales/' + l + '.js']()).default
instr = l === 'en' || !INSTR_LANGS.includes(l) ? null : (await instrPacks['../instr/' + l + '.js']()).default
} catch (e) { dict = {}; instr = null }
_setLangState(l, dict, instr)
exerciseNames = l === 'en' || !EXERCISE_NAME_LANGS.includes(l)
? null
: (await exerciseNamePacks['../exercise-names/' + l + '.js']()).default
} catch (e) { exerciseNames = null }
_setLangState(l, dict, instr, exerciseNames)
notify()
}
+2 -2
View File
@@ -11,7 +11,7 @@
import { EXIDX, isBodyweightEq } from './exercises.js'
import { modeOf, fmtSec, isBw, isPerSide, sideReps } from './history.js'
import { uid, todayISO, DAYN, fmtNum, exCount } from './format.js'
import { t } from './i18n-core.js'
import { t, exerciseNameFor } from './i18n-core.js'
const PLAN_FMT = 1
const WEEK_ORDER = [1, 2, 3, 4, 5, 6, 0] // Mon-first, matching the Plan screen
@@ -172,7 +172,7 @@ function routineHTML(r, unit) {
const rows = units(r.ex).map(u => {
const items = u.map(e => {
const ex = EXIDX[e.id]
const name = ex ? ex.n : t('Unknown exercise')
const name = ex ? exerciseNameFor(ex) : t('Unknown exercise')
const part = ex && ex.bp && ex.bp !== 'cardio' ? `<span class="part">${esc(ex.bp)}</span>` : ''
return `<div class="ex"><div class="ex-n">${esc(name)}${part}</div><div class="ex-s">${esc(scheme(e, unit))}</div></div>`
}).join('')
@@ -0,0 +1,61 @@
import { afterEach, describe, expect, test } from 'vitest'
import { readFileSync } from 'node:fs'
import ptBR from '../exercise-names/pt-BR.js'
import { EXDB } from './exercises-data.js'
import {
EXERCISE_NAME_LANGS, _setLangState, exerciseNameFor, exerciseNameSearchText
} from './i18n-core.js'
describe('Brazilian Portuguese exercise names', () => {
const source = JSON.parse(readFileSync(new URL('../../../scripts/exercise-name-sources/pt-BR.json', import.meta.url), 'utf8'))
afterEach(() => _setLangState('en', {}, null, null))
test('matches the curated source and covers the complete built-in catalogue', () => {
expect(Object.keys(ptBR)).toHaveLength(EXDB.length)
expect(ptBR).toEqual(source)
expect(EXERCISE_NAME_LANGS).toContain('pt-BR')
})
test('contains a non-empty translation for every known exercise', () => {
for (const exercise of EXDB) {
expect(ptBR[exercise.id]?.trim(), exercise.id).toBeTruthy()
expect(ptBR[exercise.id], exercise.id).not.toMatch(/(?:^|[^\p{L}])(?:abdómen|anca|gémeos|ecrã|ginásio|banda|piso|omoplata|pegada inversa|pegada invertida)(?=$|[^\p{L}])/iu)
}
})
test('preserves identity-changing qualifiers and equipment', () => {
const rules = [
[/assisted/iu, /assistid/iu],
[/weighted/iu, /(?:peso|carga|lastro|ponderad)/iu],
[/(?:^|[^\p{L}])male(?=$|[^\p{L}])/iu, /masculin/iu],
[/(?:^|[^\p{L}])female(?=$|[^\p{L}])/iu, /feminin/iu],
[/barbell/iu, /barra/iu],
[/dumbbell/iu, /halter/iu],
[/kettlebell/iu, /kettlebell/iu],
[/smith/iu, /smith/iu],
[/stability ball/iu, /bola de estabilidade/iu],
[/medicine ball/iu, /bola medicinal/iu],
]
for (const exercise of EXDB) {
for (const [english, portuguese] of rules) {
if (english.test(exercise.n)) expect(ptBR[exercise.id], `${exercise.id}: ${english}`).toMatch(portuguese)
}
}
})
test('shows Portuguese first and preserves the canonical English title', () => {
const exercise = EXDB[0]
_setLangState('pt-BR', {}, null, ptBR)
expect(exerciseNameFor(exercise)).toBe(`${ptBR[exercise.id]} (${exercise.n})`)
expect(exerciseNameSearchText(exercise)).toContain(ptBR[exercise.id])
expect(exerciseNameSearchText(exercise)).toContain(exercise.n)
})
test('never translates custom exercises or changes other languages', () => {
const custom = { id: 'custom-1', n: 'Meu exercício' }
_setLangState('pt-BR', {}, null, ptBR)
expect(exerciseNameFor(custom)).toBe('Meu exercício')
_setLangState('en', {}, null, null)
expect(exerciseNameFor(EXDB[0])).toBe(EXDB[0].n)
})
})
+5 -4
View File
@@ -11,6 +11,7 @@ import { STRENGTH_FULL_MS, STRENGTH_HALF_LIFE_MS, STRENGTH_FLOOR, halfLifeDecay
import { musclesOf } from './muscles.js'
import { EXIDX } from './exercises.js'
import { isWarmupRow } from './workout-model.js'
import { exerciseNameFor } from './i18n-core.js'
const round1 = value => Math.round(value * 10) / 10
@@ -61,11 +62,11 @@ export function primaryMuscleOf(entry) {
return best
}
function exerciseName(entry) {
function resolvedExerciseName(entry) {
// Imported history often has no name snapshot (entries are { id, sets, topW }) - the
// catalogue (or the registered custom) is the canonical name source.
const ex = entry && typeof entry === 'object' ? EXIDX[entry.id] : null
if (ex?.n) return ex.n
if (ex?.n) return exerciseNameFor(ex)
if (entry?.muscleSnapshot?.n) return entry.muscleSnapshot.n
return entry && typeof entry === 'object' && entry.n ? entry.n : null
}
@@ -97,7 +98,7 @@ export function strengthExerciseRows(S, now) {
const decay = lastAt == null ? STRENGTH_FLOOR : strengthFromAge(Number(now) - lastAt)
rows.push({
id,
name: exerciseName(entry) || id,
name: resolvedExerciseName(entry) || id,
est: best.est,
estDate: best.d,
primary: primaryMuscleOf(entry) ? primaryMuscleOf(entry).slug : null,
@@ -129,7 +130,7 @@ export function strengthExerciseRowsForMuscle(S, now, slug) {
const primary = primaryMuscleOf(entry)
seen.set(entry.id, {
id: entry.id,
name: exerciseName(entry) || entry.id,
name: resolvedExerciseName(entry) || entry.id,
weight,
primary: primary ? primary.slug : null,
est: best.est,
+12 -12
View File
@@ -5,7 +5,7 @@ import { EXDB, EXIDX, BODYPARTS, isCardio, isBodyweightEq, allExercises, equipme
import { fmtDate, fmtNum, fmtVol, fmtDur, durPart, todayISO, uid, exCount, DAYN, MONTHS_LONG, ACCENTS } from './lib/format.js'
import { lastEntryFor, bestWeightFor, buildSets, effectiveRoutineId, workoutVolume, setsDone, setsDoneActive, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf, effortOf, isBw, isPerSide, sideReps, workSetsDone } from './lib/history.js'
import { beep, vibrate } from './lib/sound.js'
import { t, instrFor, getLang, INSTR_LANGS } from './lib/i18n.js'
import { t, instrFor, exerciseNameFor, exerciseNameSearchText, getLang, INSTR_LANGS } from './lib/i18n.js'
import { nav } from './lib/nav.js'
import { starterRoutines } from './lib/starter.js'
import Media, { Thumb } from './components/Media.jsx'
@@ -287,7 +287,7 @@ function ExerciseDetail({ ex, close }) {
const last = lastEntryFor(st, ex.id)
const best = bestWeightFor(st, ex.id)
return <>
<h3 className="capitalize">{ex.n}</h3>
<h3 className="capitalize">{exerciseNameFor(ex)}</h3>
<Media ex={ex} />
<div className="row" style={{ gap: 6, flexWrap: 'wrap', margin: '10px 0' }}>
<span className="tag acc">{t(ex.bp)}</span>
@@ -321,12 +321,12 @@ function AddToRoutine({ ex, close }) {
if (r) r.ex.push({ id: ex.id, ...cfg })
})
const r = isNew ? S().routines[S().routines.length - 1] : st.routines.find(x => x.id === rid)
toast(t('“{0}” added to {1}', ex.n, r ? r.name : t('routine')))
toast(t('“{0}” added to {1}', exerciseNameFor(ex), r ? r.name : t('routine')))
if (isNew && r) nav('/plan/r/' + r.id)
}, null, isNew ? null : st.routines.find(x => x.id === rid))
}
return <>
<h3 className="capitalize">{t('Add “{0}”', ex.n)}</h3>
<h3 className="capitalize">{t('Add “{0}”', exerciseNameFor(ex))}</h3>
<div className="muted small" style={{ marginBottom: 12 }}>{t('Pick a routine — sets, reps & weight come next.')}</div>
<div className="list">
{st.routines.map(r => <div key={r.id} className="item" onClick={() => pick(r.id)}>
@@ -426,8 +426,8 @@ function ExercisePicker({ onPick, close }) {
const all = allExercises(st)
let base = all.filter(e =>
(bp === '★' ? usage[e.id] : (!bp || e.bp === bp)) &&
(!ql || e.n.toLowerCase().includes(ql) || e.tg.includes(ql) || e.eq.includes(ql) || (e.desc || '').toLowerCase().includes(ql)))
if (bp === '★') base = [...base].sort((a, b) => (usage[b.id] - usage[a.id]) || (a.n < b.n ? -1 : 1))
(!ql || exerciseNameSearchText(e).toLowerCase().includes(ql) || e.tg.includes(ql) || e.eq.includes(ql) || (e.desc || '').toLowerCase().includes(ql)))
if (bp === '★') base = [...base].sort((a, b) => (usage[b.id] - usage[a.id]) || exerciseNameFor(a).localeCompare(exerciseNameFor(b)))
const eqOpts = equipmentOf(base)
// Drop the equipment filter if the search narrowed it away, so you never hit a dead end.
const eqOn = eqOpts.includes(eq) ? eq : ''
@@ -452,7 +452,7 @@ function ExercisePicker({ onPick, close }) {
<div className="grow"><div className="tt">{t('Create your own exercise')}</div><div className="ss">{t('name + body part, no animation')}</div></div><Icon name="plus" className="chev" />
</div>}
{f.slice(0, shown).map(e => <div key={e.id} className="item" onClick={() => onPick(e)}>
<Thumb ex={e} /><div className="grow"><div className="tt capitalize">{e.n}</div><div className="ss capitalize">{t(e.tg || e.bp)} · {t(e.eq)}</div></div>
<Thumb ex={e} /><div className="grow"><div className="tt capitalize">{exerciseNameFor(e)}</div><div className="ss capitalize">{t(e.tg || e.bp)} · {t(e.eq)}</div></div>
{usage[e.id] && <span className="tag acc"><Icon name="starFill" /></span>}<Icon name="plus" className="chev" />
</div>)}
{f.length === 0 && bp === '★' && <div className="empty">{t('Nothing chosen yet — add exercises and they’ll show up here.')}</div>}
@@ -531,7 +531,7 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
}
}
return <>
<h3 className="capitalize">{ex.n}</h3>
<h3 className="capitalize">{exerciseNameFor(ex)}</h3>
<Media ex={ex} />
<div className="row" style={{ gap: 6, flexWrap: 'wrap', margin: '10px 0 14px' }}>
{cardio && <span className="tag acc"><Icon name="figureRun" />{t('Cardio')}</span>}
@@ -762,7 +762,7 @@ function WorkoutDetail({ w, close }) {
const ex = EXIDX[e.id]
return <div key={i} className="row" style={{ marginBottom: 12, alignItems: 'flex-start' }}>
{ex && <Thumb ex={ex} />}
<div className="grow"><div className="tt capitalize" style={{ fontWeight: 600 }}>{ex ? ex.n : (e.n || e.id)} {w.prs && w.prs.includes(e.id) && <span className="pr"><Icon name="trophy" />PR</span>}</div>
<div className="grow"><div className="tt capitalize" style={{ fontWeight: 600 }}>{ex ? exerciseNameFor(ex) : (e.n || e.id)} {w.prs && w.prs.includes(e.id) && <span className="pr"><Icon name="trophy" />PR</span>}</div>
<div className="ss">{e.sets.filter(s => s.done).map(s => setLabel(e.id, s, e.target)).join(' · ') || t('no sets')}</div></div>
</div>
})}
@@ -883,7 +883,7 @@ function TopWeight({ entryIdx, close }) {
} else toast(t('Tracked — next time starts at {0}', fmtNum(S().exWeights[entry.id].w) + ' ' + st.unit))
}
return <>
<h3 className="capitalize row" style={{ gap: 8 }}><Icon name="checkCircle" style={{ color: 'var(--acc)' }} />{t('{0} done', ex.n)}</h3>
<h3 className="capitalize row" style={{ gap: 8 }}><Icon name="checkCircle" style={{ color: 'var(--acc)' }} />{t('{0} done', exerciseNameFor(ex))}</h3>
<div className="muted small">{t('Confirm the weight you worked with — your highest becomes the default next time.')}{!unitDone && unit.length > 1 ? ' ' + t('Then finish the superset partner.') : ''}</div>
<WeightInput value={v} setValue={setV} unit={st.unit} />
<div style={{ height: 10 }} />
@@ -921,8 +921,8 @@ function FinishSummary({ w, prs, e1prs = [], close }) {
<div className="tile"><div className="l">{t('PRs')}</div><div className="v" style={{ fontSize: 20 }}>{prs.length || '—'}</div></div>
</div>
{(prs.length > 0 || e1prs.length > 0) && <div style={{ textAlign: 'left', marginBottom: 12 }}>
{prs.map(id => <div key={id} className="small accent capitalize row" style={{ gap: 5 }}><Icon name="trophy" style={{ fontSize: 13 }} />{t('New PR:')} {(EXIDX[id] || {}).n || id}</div>)}
{e1prs.map(p => <div key={p.id} className="small accent capitalize row" style={{ gap: 5 }}><Icon name="chartLine" style={{ fontSize: 13 }} />{t('Best estimated 1RM:')} {(EXIDX[p.id] || {}).n || p.id} · {fmtNum(p.est)} {st.unit}</div>)}
{prs.map(id => <div key={id} className="small accent capitalize row" style={{ gap: 5 }}><Icon name="trophy" style={{ fontSize: 13 }} />{t('New PR:')} {EXIDX[id] ? exerciseNameFor(EXIDX[id]) : id}</div>)}
{e1prs.map(p => <div key={p.id} className="small accent capitalize row" style={{ gap: 5 }}><Icon name="chartLine" style={{ fontSize: 13 }} />{t('Best estimated 1RM:')} {EXIDX[p.id] ? exerciseNameFor(EXIDX[p.id]) : p.id} · {fmtNum(p.est)} {st.unit}</div>)}
</div>}
<h4 className="sec" style={{ textAlign: 'left' }}>{t('What you just trained')}</h4>
<BodyMap load={loadOfWorkouts([w])} body={st.body} />
+3 -3
View File
@@ -3,7 +3,7 @@ import { useStore } from '../store/useStore.js'
import { EXDB, BODYPARTS, allExercises, equipmentOf } from '../lib/exercises.js'
import { bestWeightFor } from '../lib/history.js'
import { fmtNum } from '../lib/format.js'
import { t } from '../lib/i18n.js'
import { t, exerciseNameFor, exerciseNameSearchText } from '../lib/i18n.js'
import { Thumb } from '../components/Media.jsx'
import { exerciseDetailSheet, addToRoutineSheet, customExSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
@@ -16,7 +16,7 @@ export default function Library() {
const [eq, setEq] = useState('')
const [shown, setShown] = useState(40)
const ql = q.toLowerCase().trim()
const base = allExercises(S).filter(e => (!bp || e.bp === bp) && (!ql || e.n.toLowerCase().includes(ql) || e.tg.includes(ql) || e.eq.includes(ql) || (e.desc || '').toLowerCase().includes(ql)))
const base = allExercises(S).filter(e => (!bp || e.bp === bp) && (!ql || exerciseNameSearchText(e).toLowerCase().includes(ql) || e.tg.includes(ql) || e.eq.includes(ql) || (e.desc || '').toLowerCase().includes(ql)))
const eqOpts = equipmentOf(base)
// Drop the equipment filter if the search narrowed it away, so you never hit a dead end.
const eqOn = eqOpts.includes(eq) ? eq : ''
@@ -43,7 +43,7 @@ export default function Library() {
const best = bestWeightFor(S, e.id)
return <div key={e.id} className="item" onClick={() => exerciseDetailSheet(e)}>
<Thumb ex={e} />
<div className="grow"><div className="tt capitalize">{e.n}</div><div className="ss capitalize">{t(e.tg || e.bp)} · {t(e.eq)}</div></div>
<div className="grow"><div className="tt capitalize">{exerciseNameFor(e)}</div><div className="ss capitalize">{t(e.tg || e.bp)} · {t(e.eq)}</div></div>
{best > 0 && <span className="tag acc">{fmtNum(best)}</span>}
<Button size="sm" variant="tinted" icon="plus" onClick={ev => { ev.stopPropagation(); addToRoutineSheet(e) }}>{t('Plan')}</Button>
</div>
+2 -2
View File
@@ -3,7 +3,7 @@ import { useEffect } from 'react'
import { useStore } from '../store/useStore.js'
import { exOr } from '../lib/exercises.js'
import { uid } from '../lib/format.js'
import { t } from '../lib/i18n.js'
import { t, exerciseNameFor } from '../lib/i18n.js'
import { supersetUnits, cleanupSg, exLine } from '../lib/history.js'
import { Thumb } from '../components/Media.jsx'
import { glyphPicker, exercisePicker, exConfigSheet, confirmSheet } from '../sheets.jsx'
@@ -67,7 +67,7 @@ export default function RoutineEdit() {
exConfigSheet(ex, e, cfg => edit(x => { x[i] = { id: x[i].id, sg: x[i].sg, ...cfg } }), () => edit(x => { x.splice(i, 1); cleanupSg(x) }), r)
}}>
<Thumb ex={ex} />
<div className="grow"><div className="tt capitalize">{ex.n}</div><div className="ss">{exLine(e, S.unit)}</div></div>
<div className="grow"><div className="tt capitalize">{exerciseNameFor(ex)}</div><div className="ss">{exLine(e, S.unit)}</div></div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 2, flex: 'none', alignItems: 'center' }}>
{i > 0 && <button className={'iconbtn' + (linkedPrev ? ' on-ss' : '')} title={t('Superset with exercise above')} style={{ width: 32, height: 28, borderRadius: 8, fontSize: 15 }} onClick={ev => { ev.stopPropagation(); toggleLink(i) }}><Icon name="link" /></button>}
<div style={{ display: 'flex', gap: 2 }}>
+4 -3
View File
@@ -4,7 +4,7 @@ import { useStore } from '../store/useStore.js'
import { EXIDX } from '../lib/exercises.js'
import { lastBW, streakWeeks, setLabel, modeOf, effortOf, metricModeForEntry, metricRowsForEntry, bestWeightForEntry } from '../lib/history.js'
import { fmtNum, fmtDate, fmtVol, todayISO, weekKey } from '../lib/format.js'
import { t } from '../lib/i18n.js'
import { t, exerciseNameFor, getLang } from '../lib/i18n.js'
import { bwSheet, goalSheet, calendarSheet, workoutDetailSheet, WorkoutRow, bwDeltaColor } from '../sheets.jsx'
import LineChart from '../components/LineChart.jsx'
import Heatmap from '../components/Heatmap.jsx'
@@ -102,6 +102,7 @@ function MuscleBalance({ S }) {
const [hard, setHard] = useState(false)
const [sel, setSel] = useState(null)
const now = useNow()
const lang = getLang()
const workouts = S.workouts
// The user's own last registered bodyweight drives bodyweight-exercise tonnage.
const bodyweightKg = useMemo(() => {
@@ -113,7 +114,7 @@ function MuscleBalance({ S }) {
}, [S.bodyweight, S.unit])
const fatigue = useMemo(() => fatigueOf(workouts, now, { bodyweightKg, unit: S.unit }), [workouts, now, bodyweightKg, S.unit])
const strength = useMemo(() => strengthOf(workouts, now, { bodyweightKg, unit: S.unit }), [workouts, now, bodyweightKg, S.unit])
const muscleExercises = useMemo(() => (sel ? strengthExerciseRowsForMuscle(S, now, sel) : []), [S, now, sel])
const muscleExercises = useMemo(() => (sel ? strengthExerciseRowsForMuscle(S, now, sel) : []), [S, now, sel, lang])
const lastTrained = useMemo(() => latestMuscleTraining(workouts), [workouts])
const strengthHint = slug => {
if (lastTrained[slug] == null) return t('not trained')
@@ -290,7 +291,7 @@ export default function Stats() {
const workouts = S.workouts
const monthW = workouts.filter(w => String(w.d || '').slice(0, 7) === todayISO().slice(0, 7)).length
const nameOf = id => EXIDX[id]?.n || workouts.flatMap(w => w.entries).find(e => e.id === id)?.n || id
const nameOf = id => EXIDX[id] ? exerciseNameFor(EXIDX[id]) : (workouts.flatMap(w => w.entries).find(e => e.id === id)?.n || id)
const currentOf = id => {
for (let i = workouts.length - 1; i >= 0; i--) {
const en = workouts[i].entries.find(e => e.id === id)
+5 -5
View File
@@ -6,7 +6,7 @@ import { exOr } from '../lib/exercises.js'
import { effectiveRoutine, lastEntryFor, bestWeightFor, buildSets, freestyleConfig, defaultConfig, setsDoneActive, supersetUnits, unitOf, setLabel, modeOf, isBw, isPerSide, sideReps, repStep, EFFORT, effortOf, stepEffort, capEffort, cascadeWeight, insertWarmupRow, removeRowAt, pairAdjacent, unpairSuperset, cleanupSg } from '../lib/history.js'
import { fmtNum, fmtDate, todayISO, exCount, DAYN } from '../lib/format.js'
import { beep, vibrate } from '../lib/sound.js'
import { t } from '../lib/i18n.js'
import { t, exerciseNameFor } from '../lib/i18n.js'
import { api } from '../lib/api.js'
import { setProgressHighWater, supersetFlowStep } from '../lib/supersetFlow.js'
import Media from '../components/Media.jsx'
@@ -113,7 +113,7 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov
return <>
<Media ex={ex} key={entry.id} compact={compact} minimizable />
<div className="row between" style={{ marginBottom: 6 }}>
<div style={{ fontSize: compact ? 17 : 20, fontWeight: 600, letterSpacing: '-.02em', textTransform: 'capitalize', lineHeight: 1.2 }}>{ex.n}</div>
<div style={{ fontSize: compact ? 17 : 20, fontWeight: 600, letterSpacing: '-.02em', textTransform: 'capitalize', lineHeight: 1.2 }}>{exerciseNameFor(ex)}</div>
<button className="iconbtn" aria-label={t('Details')} onClick={() => exerciseDetailSheet(ex)}><Icon name="info" /></button>
</div>
{!compact && (onPairPrev || onPairNext) && <div className="row" style={{ gap: 6, flexWrap: 'wrap', marginBottom: 8 }}>
@@ -258,7 +258,7 @@ function ActiveWorkout() {
if (!e) return
const hasDone = (e.sets || []).some(s => s.done)
confirmSheet({
title: t('Remove {0}?', exOr(e.id).n),
title: t('Remove {0}?', exerciseNameFor(exOr(e.id))),
message: hasDone
? t('The sets you logged for this exercise in this session will be lost.')
: t('This removes the exercise from your current session.'),
@@ -273,7 +273,7 @@ function ActiveWorkout() {
<div className="muted small" style={{ marginBottom: 12 }}>{t('Which exercise in this superset do you want to remove?')}</div>
<div className="list">
{unit.map(idx => <div key={idx} className="item" onClick={() => { close(); confirmRemoveExercise(idx) }}>
<div className="grow"><div className="tt">{exOr(A.entries[idx]?.id).n}</div></div>
<div className="grow"><div className="tt">{exerciseNameFor(exOr(A.entries[idx]?.id))}</div></div>
<Icon name="chevronRight" />
</div>)}
</div>
@@ -288,7 +288,7 @@ function ActiveWorkout() {
// behave exactly as they do for a reps set.
const startTimed = (idx, i) => {
const e = A.entries[idx]
useUI.getState().startWork(e.sets[i].sec || 45, exOr(e.id).n, elapsed => {
useUI.getState().startWork(e.sets[i].sec || 45, exerciseNameFor(exOr(e.id)), elapsed => {
mutEntry(idx, en => { en.sets[i].sec = elapsed })
if (!useStore.getState().S.active.entries[idx].sets[i].done) toggle(idx, i)
})