Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
Follow-up to #290: the title-casing is decided per exercise, so an exercise the German pack does not cover shows as 'Push-Up' and not 'push-up'
Duarte Santos1e2cfc9b8d17
diff --git a/frontend/src/components/MuscleExplorer.jsx b/frontend/src/components/MuscleExplorer.jsxindex 8e4f64a4b..511afd065 100644--- a/frontend/src/components/MuscleExplorer.jsx+++ b/frontend/src/components/MuscleExplorer.jsx@@ -84,7 +84,7 @@ export default function MuscleExplorer({ onPick, onDetail, onPlan }) {const primary = musclesOf(e)[selected] === 1return <div key={e.id} className="item" {...tappable(() => choose(e))}><Thumb ex={e} />- <div className="grow"><div className={`tt ${exerciseNameClass()}`}>{isFav(S, e.id) && <Icon name="starFill" className="fav-star" />}{exerciseNameFor(e)}</div><div className="ss">{t(primary ? 'Primary target' : 'Also trains')} · <span className="capitalize">{t(MUSCLE_NAME[e.tg] || e.tg || e.bp)} · {t(e.eq)}</span></div></div>+ <div className="grow"><div className={`tt ${exerciseNameClass(e)}`}>{isFav(S, e.id) && <Icon name="starFill" className="fav-star" />}{exerciseNameFor(e)}</div><div className="ss">{t(primary ? 'Primary target' : 'Also trains')} · <span className="capitalize">{t(MUSCLE_NAME[e.tg] || e.tg || e.bp)} · {t(e.eq)}</span></div></div>{onPick ? <Icon name="plus" className="chev" /> : <>{best > 0 && <span className="tag acc">{fmtNum(best)}</span>}<Button size="sm" variant="tinted" icon="plus" onClick={ev => { ev.stopPropagation(); onPlan(e) }}>{t('Plan')}</Button>diff --git a/frontend/src/lib/i18n-core.js b/frontend/src/lib/i18n-core.jsindex afc05b976..03841eb20 100644--- a/frontend/src/lib/i18n-core.js+++ b/frontend/src/lib/i18n-core.js@@ -94,9 +94,13 @@ export const exerciseNameFor = ex => {// carries its own casing and must not be cased again on top: German lower-cases adjectives// ("Assistiertes hängendes Knieheben"), Hungarian lower-cases common nouns. So the class that// does the title-casing belongs on the element only while the English fallback is showing.-// Callers spread this onto the element that holds exerciseNameFor's output, nothing else —+// That is decided per exercise, not per language: German covers only part of the catalogue,+// and an exercise it has no entry for shows its lower-case English title, which still needs+// the casing ("push-up" would otherwise sit between "Bankdrücken" and "Kniebeuge"). A custom+// exercise has no pack entry either and keeps the casing it always had.+// Callers spread this onto the element that holds exerciseNameFor(ex)'s output, nothing else —// muscle and equipment labels next to it are t() strings and keep their own capitalize.-export const exerciseNameClass = () => (exerciseNames ? '' : 'capitalize')+export const exerciseNameClass = ex => (exerciseNames && ex && exerciseNames[ex.id] ? '' : 'capitalize')// Search both the localized and canonical English title without changing persisted data.export const exerciseNameSearchText = ex => {diff --git a/frontend/src/lib/i18n-core.test.js b/frontend/src/lib/i18n-core.test.jsindex 7302fc7de..d5bf15923 100644--- a/frontend/src/lib/i18n-core.test.js+++ b/frontend/src/lib/i18n-core.test.js@@ -104,14 +104,29 @@ describe('de-CH as a selectable language', () => {// brings its own casing, and applying capitalize on top of it produced "Bankdrücken Mit// Langhantel" in German and "Has" for Hungarian common nouns.describe('exerciseNameClass', () => {+ const bench = { id: '0025', n: 'barbell bench press' }+ const pushUp = { id: '0662', n: 'push-up' }+ const custom = { id: 'custom-1', n: 'my own press' }+it('title-cases only while the English fallback is showing', () => {_setLangState('en', {}, null, null)- expect(exerciseNameClass()).toBe('capitalize')+ expect(exerciseNameClass(bench)).toBe('capitalize')_setLangState('de', {}, null, null)- expect(exerciseNameClass()).toBe('capitalize')+ expect(exerciseNameClass(bench)).toBe('capitalize')+ _setLangState('de', {}, null, { '0025': 'Bankdrücken mit Langhantel' })+ expect(exerciseNameClass(bench)).toBe('')+ _setLangState('en', {}, null, null)+ expect(exerciseNameClass(bench)).toBe('capitalize')+ })++ // German covers the equipment exercises and not the body-weight ones: an exercise the pack+ // has no entry for shows its lower-case English title and still needs the casing.+ it('decides per exercise, so an untranslated one in a partial pack keeps its casing', () => {_setLangState('de', {}, null, { '0025': 'Bankdrücken mit Langhantel' })- expect(exerciseNameClass()).toBe('')+ expect(exerciseNameClass(bench)).toBe('')+ expect(exerciseNameClass(pushUp)).toBe('capitalize')+ expect(exerciseNameClass(custom)).toBe('capitalize')+ expect(exerciseNameClass(undefined)).toBe('capitalize')_setLangState('en', {}, null, null)- expect(exerciseNameClass()).toBe('capitalize')})})diff --git a/frontend/src/lib/plan-share.js b/frontend/src/lib/plan-share.jsindex 614af18f2..e4da29c64 100644--- a/frontend/src/lib/plan-share.js+++ b/frontend/src/lib/plan-share.js@@ -322,7 +322,7 @@ function routineHTML(r, unit) {const name = ex ? exerciseNameFor(ex) : t('Unknown exercise')const part = ex && ex.bp && ex.bp !== 'cardio' ? `<span class="part">${esc(ex.bp)}</span>` : ''const note = e.note ? `<div class="ex-note">${esc(e.note)}</div>` : ''- return `<div class="ex"><div class="ex-row"><div class="ex-n">${esc(name)}${part}</div><div class="ex-s">${esc(scheme(e, unit))}</div></div>${note}</div>`+ return `<div class="ex"><div class="ex-row"><div class="ex-n ${ex ? exerciseNameClass(ex) : ''}">${esc(name)}${part}</div><div class="ex-s">${esc(scheme(e, unit))}</div></div>${note}</div>`}).join('')return u.length > 1? `<div class="ss"><div class="ss-tag">${esc(t('Superset'))}</div><div class="ss-items">${items}</div></div>`@@ -390,7 +390,8 @@ export function planPrintHTML(S, owner) {.ex { display: flex; flex-direction: column; padding: 6px 0; break-inside: avoid; page-break-inside: avoid; }.ex + .ex, .ss + .ex, .ex + .ss { border-top: 1px solid #f2f3f6; }.ex-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }- .ex-n { text-transform: ${exerciseNameClass() ? 'capitalize' : 'none'}; font-weight: 500; }+ .ex-n { font-weight: 500; }+ .ex-n.capitalize { text-transform: capitalize; }.ex-n .part { text-transform: capitalize; color: #9aa0ae; font-weight: 400; font-size: 12px; margin-left: 8px; }.ex-s { color: #3d424e; white-space: nowrap; font-variant-numeric: tabular-nums; }.ex-note { color: #6a7080; font-size: 12px; margin-top: 2px; }diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsxindex 0d7608807..743b69857 100644--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@ -74,9 +74,11 @@ export function askAddDeviceData(extras) {// everything that is not a set you are about to log: the point of a single "more" button is// that the ten things you do once a session stop competing with the two you do every set.// items: [{ icon, label, sub, onClick, danger, disabled, on }] — `on` draws a check for toggles.-function MenuSheet({ title, subtitle, items, close }) {+// titleClass replaces the title's default title-casing, for a title that is an exercise name+// carrying its own casing from a translated pack (exerciseNameClass).+function MenuSheet({ title, titleClass = 'capitalize', subtitle, items, close }) {return <>- {title && <h3 className="capitalize" style={{ marginBottom: subtitle ? 2 : 10 }}>{title}</h3>}+ {title && <h3 className={titleClass || undefined} style={{ marginBottom: subtitle ? 2 : 10 }}>{title}</h3>}{subtitle && <div className="muted small" style={{ marginBottom: 10 }}>{subtitle}</div>}<div className="list menu-list">{items.filter(Boolean).map((it, i) => <div key={i}@@ -623,7 +625,7 @@ function BarWeightSheet({ exId, close }) {const ex = exOr(exId)return <><h3>{t('Bar weight')}</h3>- <div className={`muted small ${exerciseNameClass()}`} style={{ marginBottom: 12 }}>{exerciseNameFor(ex)}</div>+ <div className={`muted small ${exerciseNameClass(ex)}`} style={{ marginBottom: 12 }}>{exerciseNameFor(ex)}</div><BarWeightEditor ex={ex} extra={t('Applies to this exercise everywhere, not just this plan.')} /><Button variant="primary" onClick={close}>{t('Done')}</Button></>@@ -671,7 +673,7 @@ function ExerciseDetail({ ex, close }) {}return <><div className="row between" style={{ gap: 8, alignItems: 'flex-start' }}>- <h3 className={exerciseNameClass()}>{exerciseNameFor(ex)}</h3>+ <h3 className={exerciseNameClass(ex)}>{exerciseNameFor(ex)}</h3><button className={'iconbtn fav-btn' + (fav ? ' on' : '')} aria-pressed={fav}aria-label={fav ? t('Remove from favourites') : t('Add to favourites')} onClick={flipFav}><Icon name={fav ? 'starFill' : 'star'} />@@ -720,7 +722,7 @@ function ExerciseHistory({ exId }) {const unit = h.metric === 'weight' ? st.unit : h.metric === 'reps' ? t('reps') : h.metric === 'sec' ? 's' : t('min')const e1Best = useMemo(() => Math.max(0, ...h.e1rmPoints.map(p => p.y)), [h])if (!h.total) return <>- <h3 className={exerciseNameClass()}>{exerciseNameFor(ex)}</h3>+ <h3 className={exerciseNameClass(ex)}>{exerciseNameFor(ex)}</h3><div className="empty"><div className="ico"><Icon name="history" /></div>{t('No sessions logged yet')}</div></>const tail = s => [@@ -728,7 +730,7 @@ function ExerciseHistory({ exId }) {s.e1rm != null && t('Est. 1RM') + ' ' + fmtNum(s.e1rm) + ' ' + st.unit,].filter(Boolean).join(' · ')return <>- <h3 className={exerciseNameClass()} style={{ marginBottom: 2 }}>{exerciseNameFor(ex)}</h3>+ <h3 className={exerciseNameClass(ex)} style={{ marginBottom: 2 }}>{exerciseNameFor(ex)}</h3><div className="muted small" style={{ marginBottom: 10 }}>{t('Exercise history')} · {t(h.total === 1 ? '{0} session' : '{0} sessions', h.total)}</div>{/* Only reps work with a load produces an estimate, so the toggle is absent for the rest. */}{h.e1rmPoints.length > 0 && h.metric === 'weight' && <Segmented className="seg-range" value={curve} onChange={setCurve}@@ -768,12 +770,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}', exerciseNameClass() ? capWords(exerciseNameFor(ex)) : exerciseNameFor(ex), r ? r.name : t('routine')))+ toast(t('“{0}” added to {1}', exerciseNameClass(ex) ? capWords(exerciseNameFor(ex)) : 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={exerciseNameClass()}>{t('Add “{0}”', exerciseNameFor(ex))}</h3>+ <h3 className={exerciseNameClass(ex)}>{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" {...tappable(() => pick(r.id))}>@@ -986,7 +988,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" {...tappable(() => onPick(e))}>- <Thumb ex={e} /><div className="grow"><div className={`tt ${exerciseNameClass()}`}>{isFav(st, e.id) && <Icon name="starFill" className="fav-star" />}{exerciseNameFor(e)}</div><div className="ss capitalize">{t(MUSCLE_NAME[e.tg] || e.tg || e.bp)} · {t(e.eq)}</div></div>+ <Thumb ex={e} /><div className="grow"><div className={`tt ${exerciseNameClass(e)}`}>{isFav(st, e.id) && <Icon name="starFill" className="fav-star" />}{exerciseNameFor(e)}</div><div className="ss capitalize">{t(MUSCLE_NAME[e.tg] || e.tg || e.bp)} · {t(e.eq)}</div></div>{/* Accent tag = already in a routine/log ("Chosen"); the yellow star by the name = favourite. */}{usage[e.id] && <span className="tag acc"><Icon name="starFill" /></span>}{/* A "+" glyph reads as "add this now" — it used to just open the same detail sheet as@@ -1266,7 +1268,7 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {}}return <>- <h3 className={exerciseNameClass()}>{exerciseNameFor(ex)}</h3>+ <h3 className={exerciseNameClass(ex)}>{exerciseNameFor(ex)}</h3><Media ex={ex} />{/* The same tags the exercise detail sheet shows, secondaries included: choosing what goesinto a plan is exactly when "what else does this hit" matters, and until now that was@@ -1788,7 +1790,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 ${exerciseNameClass()}`} 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="grow"><div className={`tt ${exerciseNameClass(ex)}`} 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(hasCompletedWork).map(s => setLabel(e.id, s, e.target)).join(' · ') || t('no sets')}</div>{e.note && <div className="small dim" style={{ marginTop: 3 }}>{e.notePin && <Icon name="flag" style={{ fontSize: 12, marginRight: 4, verticalAlign: '-1px', color: 'var(--yellow)' }} />}{e.note}@@ -2120,7 +2122,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={`row ${exerciseNameClass()}`} style={{ gap: 8 }}><Icon name="checkCircle" style={{ color: 'var(--acc)' }} />{t('{0} done', exerciseNameFor(ex))}</h3>+ <h3 className={`row ${exerciseNameClass(ex)}`} 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 }} />@@ -2179,7 +2181,7 @@ function ExerciseNote({ entryIdx, close }) {}return <>- <h3 className={exerciseNameClass()}>{exerciseNameFor(ex)}</h3>+ <h3 className={exerciseNameClass(ex)}>{exerciseNameFor(ex)}</h3><div className="small muted" style={{ marginBottom: 6 }}>{t('This session')}</div><textarea ref={noteRef} className="input" rows={3} maxLength={NOTE_MAX} value={note}placeholder={t('How it went, what to change — kept with today’s workout.')}@@ -2330,8 +2332,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 row" style={{ gap: 5 }}><Icon name="trophy" style={{ fontSize: 13 }} />{t('New PR:')} <span className={exerciseNameClass()}>{EXIDX[id] ? exerciseNameFor(EXIDX[id]) : id}</span></div>)}- {e1prs.map(p => <div key={p.id} className="small accent row" style={{ gap: 5 }}><Icon name="chartLine" style={{ fontSize: 13 }} />{t('Best estimated 1RM:')} <span className={exerciseNameClass()}>{EXIDX[p.id] ? exerciseNameFor(EXIDX[p.id]) : p.id}</span> · {fmtNum(p.est)} {st.unit}</div>)}+ {prs.map(id => <div key={id} className="small accent row" style={{ gap: 5 }}><Icon name="trophy" style={{ fontSize: 13 }} />{t('New PR:')} <span className={exerciseNameClass(EXIDX[id])}>{EXIDX[id] ? exerciseNameFor(EXIDX[id]) : id}</span></div>)}+ {e1prs.map(p => <div key={p.id} className="small accent row" style={{ gap: 5 }}><Icon name="chartLine" style={{ fontSize: 13 }} />{t('Best estimated 1RM:')} <span className={exerciseNameClass(EXIDX[p.id])}>{EXIDX[p.id] ? exerciseNameFor(EXIDX[p.id]) : p.id}</span> · {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} />diff --git a/frontend/src/views/Library.jsx b/frontend/src/views/Library.jsxindex 7521823f5..315bc63bf 100644--- a/frontend/src/views/Library.jsx+++ b/frontend/src/views/Library.jsx@@ -67,7 +67,7 @@ export default function Library() {const best = bestWeightFor(S, e.id)return <div key={e.id} className="item" {...tappable(() => exerciseDetailSheet(e))}><Thumb ex={e} />- <div className="grow"><div className={`tt ${exerciseNameClass()}`}>{isFav(S, e.id) && <Icon name="starFill" className="fav-star" />}{exerciseNameFor(e)}</div><div className="ss capitalize">{t(MUSCLE_NAME[e.tg] || e.tg || e.bp)} · {t(e.eq)}</div></div>+ <div className="grow"><div className={`tt ${exerciseNameClass(e)}`}>{isFav(S, e.id) && <Icon name="starFill" className="fav-star" />}{exerciseNameFor(e)}</div><div className="ss capitalize">{t(MUSCLE_NAME[e.tg] || 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>diff --git a/frontend/src/views/RoutineEdit.jsx b/frontend/src/views/RoutineEdit.jsxindex 9fa748a15..3afa39779 100644--- a/frontend/src/views/RoutineEdit.jsx+++ b/frontend/src/views/RoutineEdit.jsx@@ -400,7 +400,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 ${exerciseNameClass()}`}>{exerciseNameFor(ex)}</div><div className="ss">{exLine(e, S.unit)}</div>+ <div className="grow"><div className={`tt ${exerciseNameClass(ex)}`}>{exerciseNameFor(ex)}</div><div className="ss">{exLine(e, S.unit)}</div>{e.note && <div className="small dim" style={{ marginTop: 2 }}>{e.note}</div>}</div>{noEquip && <span className="tag" style={{ color: 'var(--orange)', borderColor: 'var(--orange)' }} title={t('Needs {0} — not in your active profile', t(ex.eq))}><Icon name="warning" /></span>}<div style={{ display: 'flex', flexDirection: 'column', gap: 2, flex: 'none', alignItems: 'center' }}>diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex db3e33aea..329160c9b 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -246,6 +246,7 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi})() : nullconst openMore = () => menuSheet({title: exerciseNameFor(ex),+ titleClass: exerciseNameClass(ex),items: [{ icon: 'pencil', label: entry.note ? t('Edit note') : t('Add note'), sub: entry.note || undefined, onClick: () => exerciseNoteSheet(entryIdx) },{ icon: 'info', label: t('Details'), onClick: () => exerciseDetailSheet(ex) },@@ -398,7 +399,7 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSireturn <>{!dense && <Media ex={ex} key={entry.id} compact={compact} minimizable />}<div className="row between" style={{ marginBottom: 6 }}>- <div style={{ fontSize: (compact || dense) ? 17 : 20, fontWeight: 600, letterSpacing: '-.02em', lineHeight: 1.2 }} className={exerciseNameClass()}>{exerciseNameFor(ex)}</div>+ <div style={{ fontSize: (compact || dense) ? 17 : 20, fontWeight: 600, letterSpacing: '-.02em', lineHeight: 1.2 }} className={exerciseNameClass(ex)}>{exerciseNameFor(ex)}</div><div className="row" style={{ gap: 2, flex: 'none' }}>{entry.note && <button className="iconbtn" aria-label={t('Note')} title={t('Note')} style={{ color: 'var(--acc)' }}onClick={() => exerciseNoteSheet(entryIdx)}><Icon name="pencil" /></button>}@@ -1181,7 +1182,7 @@ function ActiveWorkout() {// button. Quick-add commits with the same default (or, freestyle, last-session) config// the sheet would have opened with; tapping the row still opens that sheet for anyone// who wants to set sets/reps first.- if (quick) { commit(seed || defaultConfig(ex.id)); useUI.getState().toast(t('“{0}” added to {1}', capWords(exerciseNameFor(ex)), routine ? routine.name : t('Freestyle'))) }+ if (quick) { commit(seed || defaultConfig(ex.id)); useUI.getState().toast(t('“{0}” added to {1}', exerciseNameClass(ex) ? capWords(exerciseNameFor(ex)) : exerciseNameFor(ex), routine ? routine.name : t('Freestyle'))) }else exConfigSheet(ex, null, commit, null, routine, seed)})} icon="plus">{t('Add exercise')}</Button>{wc.exerciseButtons && A.entries.length > 0 && <>