Merge merge request !16 (pt-BR exercise names and instructions)
Resolves against !13 and !1: the picker and library keep the multi-token search and the equipment-profile filter, and matchExercise now builds its haystack from exerciseNameSearchText, so a pt-BR profile finds an exercise by the name it actually sees as well as by the English one. The 'chosen' sort takes !16's locale-aware localeCompare. Adds regression tests for localized search and for cache invalidation on a language switch.
This commit is contained in:
commit
76973edad1
33 files changed
+12376
-52
No files matched your search
@@ -4,7 +4,7 @@ import { EXDB, BODYPARTS, allExercises, equipmentOf, matchExercise } from '../li
|
||||
import { activeProfile, exAvailable } from '../lib/equipment.js'
|
||||
import { bestWeightFor } from '../lib/history.js'
|
||||
import { fmtNum } from '../lib/format.js'
|
||||
import { t } from '../lib/i18n.js'
|
||||
import { t, exerciseNameFor } from '../lib/i18n.js'
|
||||
import { Thumb } from '../components/Media.jsx'
|
||||
import { exerciseDetailSheet, addToRoutineSheet, customExSheet } from '../sheets.jsx'
|
||||
import Icon from '../components/Icon.jsx'
|
||||
@@ -53,7 +53,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>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useStore } from '../store/useStore.js'
|
||||
import { exOr } from '../lib/exercises.js'
|
||||
import { activeProfile, exAvailable } from '../lib/equipment.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'
|
||||
@@ -78,7 +78,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 className="grow"><div className="tt capitalize">{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' }}>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 }}>
|
||||
@@ -259,7 +259,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.'),
|
||||
@@ -274,7 +274,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>
|
||||
@@ -289,7 +289,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)
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user