curated2: !69; Thai/Hungarian get the swap strings; pt-BR guard re-fingerprinted

This commit is contained in:
Duarte Santos committed 2026-08-30 13:40:58 +02:00
commit 148ef9fbbb
21 files changed
+145 -17

No files matched your search

+4 -2
View File
@@ -19,6 +19,7 @@
import { modeOf, repStep, rerampWarmups } from './history.js'
import { EXIDX } from './exercises.js'
import { isWarmupRow } from './workout-model.js'
import { normalizeRepRange } from './rep-range.js'
export const POLICIES = ['off', 'linear', 'greyskull', 'double', 'time']
@@ -214,8 +215,9 @@ export function nextPrescription(S, cfg, routine) {
return { policy, kind: 'up', weight: 0, reps: next, why: ['Bodyweight — every rep last time, so go for {0} this time.', next] }
}
if (policy === 'double') {
const top = cfg.reps || last.goal || 10
const bottom = Math.min(cfg.repsMin || Math.max(1, top - 2), top)
const range = normalizeRepRange(cfg.reps || last.goal || 10, cfg.repsMin, repStep(cfg))
const top = range.reps
const bottom = range.repsMin
if (last.ok) return { policy, kind: 'up', weight: snap(w + inc, inc), reps: bottom, why: ['Top of the rep range in every set — {0} {1} more, back to {2} reps.', inc, unit, bottom] }
if (stalls >= deloadAt) {
const dw = deloadTo(w, inc)
+7
View File
@@ -311,6 +311,13 @@ describe('double progression', () => {
expect(p.reps).toBe(8)
expect(p.weight).toBe(35) // 40 × 0.9 = 36 → nearest loadable 2.5 step
})
it('normalizes persisted per-side bounds before prescribing', () => {
const perSide = { ...cfg, reps: 13, repsMin: 7, side: true }
const p = nextPrescription(hist(LIFT, [[40, 12, 12, 12]], { sets: 3, reps: 13 }), perSide)
expect(p.kind).toBe('hold')
expect(p.reps).toBe(14)
})
})
describe('timed progression', () => {
+3 -3
View File
@@ -27,11 +27,11 @@ describe('Brazilian Portuguese locale', () => {
.sort(byCodeUnit)
const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(293)
expect(inherited).toHaveLength(449)
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(331)
expect(inherited).toHaveLength(448)
// 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('09c4fa5e04c8d3ea21916a6c07f074a35013b33d5d945ecfc13cd54cc8b7d41d')
expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('1f0f51af8e2e4b778db6d3d89cb7a6539091c9bc6e1cf0f864a590e586b03180')
})
test('does not leak European Portuguese UI terms', () => {
+19
View File
@@ -0,0 +1,19 @@
// Normalize the two bounds used by double progression.
// `reps` is the upper bound and `repsMin` is the lower bound in persisted configs.
export function normalizeRepRange(reps, repsMin, stride = 1) {
const step = Number.isInteger(stride) && stride > 0 ? stride : 1
const upper = align(positiveInt(reps, 10), step)
const lower = align(positiveInt(repsMin, Math.max(1, upper - 2)), step)
return lower >= upper
? { reps: lower + step, repsMin: lower }
: { reps: upper, repsMin: lower }
}
function align(value, stride) {
return Math.max(stride, Math.ceil(value / stride) * stride)
}
function positiveInt(value, fallback) {
const n = Number(value)
return Number.isFinite(n) && n > 0 ? Math.max(1, Math.round(n)) : fallback
}
+38
View File
@@ -0,0 +1,38 @@
import { describe, expect, it } from 'vitest'
import { normalizeRepRange } from './rep-range.js'
describe('normalizeRepRange', () => {
it('keeps valid positive integer bounds unchanged', () => {
expect(normalizeRepRange(12, 8)).toEqual({ reps: 12, repsMin: 8 })
})
it('rounds bounds to positive integers', () => {
expect(normalizeRepRange(12.4, 7.6)).toEqual({ reps: 12, repsMin: 8 })
expect(normalizeRepRange(0, -2)).toEqual({ reps: 10, repsMin: 8 })
})
it('raises the upper bound when the lower bound reaches it', () => {
expect(normalizeRepRange(8, 8)).toEqual({ reps: 9, repsMin: 8 })
})
it('raises the upper bound when the lower bound exceeds it', () => {
expect(normalizeRepRange(8, 12)).toEqual({ reps: 13, repsMin: 12 })
})
it('keeps the lower bound at least one below a lowered upper bound', () => {
expect(normalizeRepRange(6, 8)).toEqual({ reps: 9, repsMin: 8 })
})
it('supplies a usable default lower bound for a small upper bound', () => {
expect(normalizeRepRange(1, undefined)).toEqual({ reps: 2, repsMin: 1 })
})
it('aligns both bounds to an even stride', () => {
expect(normalizeRepRange(13, 7, 2)).toEqual({ reps: 14, repsMin: 8 })
})
it('keeps a valid gap when per-side bounds are invalid', () => {
expect(normalizeRepRange(8, 9, 2)).toEqual({ reps: 12, repsMin: 10 })
expect(normalizeRepRange(0, -2, 2)).toEqual({ reps: 10, repsMin: 8 })
})
})
+1
View File
@@ -573,6 +573,7 @@ export default {
'Step ({0})': 'Schritt ({0})',
'Step (seconds)': 'Schritt (Sekunden)',
'Reps from': 'Wdh. ab',
'Reps up to': 'Wdh. bis',
'No automatic progression': 'Keine automatische Progression',
'Exclude from automatic progression': 'Von der automatischen Progression ausschließen',
'Use for planned deloads. Workouts stay in history and statistics.': 'Für geplante Deloads. Workouts bleiben im Verlauf und in den Statistiken.',
+1
View File
@@ -555,6 +555,7 @@ export default {
'Step ({0})': 'Incremento ({0})',
'Step (seconds)': 'Incremento (segundos)',
'Reps from': 'Reps desde',
'Reps up to': 'Reps hasta',
'No automatic progression': 'Sin progresión automática',
'Exclude from automatic progression': 'Excluir de la progresión automática',
'Use for planned deloads. Workouts stay in history and statistics.': 'Úsalo para descargas planificadas. Los entrenamientos permanecen en el historial y las estadísticas.',
+1
View File
@@ -555,6 +555,7 @@ export default {
'Step ({0})': 'Palier ({0})',
'Step (seconds)': 'Palier (secondes)',
'Reps from': 'Reps à partir de',
'Reps up to': 'Reps jusqu’à',
'No automatic progression': 'Pas de progression automatique',
'Exclude from automatic progression': 'Exclure de la progression automatique',
'Use for planned deloads. Workouts stay in history and statistics.': 'À utiliser pour les semaines de décharge planifiées. Les séances restent dans l’historique et les statistiques.',
+1
View File
@@ -555,6 +555,7 @@ export default {
'Step ({0})': 'स्टेप ({0})',
'Step (seconds)': 'स्टेप (सेकंड)',
'Reps from': 'रेप्स से',
'Reps up to': 'रेप्स तक',
'No automatic progression': 'कोई स्वचालित प्रोग्रेशन नहीं',
'Exclude from automatic progression': 'स्वचालित प्रोग्रेशन से बाहर रखें',
'Use for planned deloads. Workouts stay in history and statistics.': 'योजनाबद्ध डीलोड के लिए उपयोग करें। वर्कआउट इतिहास और आँकड़ों में रहते हैं।',
+6
View File
@@ -683,4 +683,10 @@ export default {
'Showing all equipment': 'Minden eszköz megjelenítve',
'Move up': 'Feljebb',
'Move down': 'Lejjebb',
'Swap exercise': 'Gyakorlat cseréje',
'Swap exercise?': 'Cseréled a gyakorlatot?',
'Logged sets stay with the original exercise. Choose where the replacement belongs.': 'A naplózott sorozatok az eredeti gyakorlatnál maradnak. Válaszd ki, hová kerüljön a csere.',
'Keep replacement in this group': 'A csere maradjon ebben a csoportban',
'Insert after this group': 'Beszúrás a csoport után',
'Logged sets stay with the original exercise. The replacement will be inserted afterward.': 'A naplózott sorozatok az eredeti gyakorlatnál maradnak. A csere utána kerül beszúrásra.',
}
+1
View File
@@ -555,6 +555,7 @@ export default {
'Step ({0})': 'Incremento ({0})',
'Step (seconds)': 'Incremento (secondi)',
'Reps from': 'Rip. da',
'Reps up to': 'Rip. fino a',
'No automatic progression': 'Nessuna progressione automatica',
'Exclude from automatic progression': 'Escludi dalla progressione automatica',
'Use for planned deloads. Workouts stay in history and statistics.': 'Usa per gli scarichi programmati. Gli allenamenti restano nella cronologia e nelle statistiche.',
+1
View File
@@ -555,6 +555,7 @@ export default {
'Step ({0})': '증가폭 ({0})',
'Step (seconds)': '증가폭 (초)',
'Reps from': '최소 횟수',
'Reps up to': '최대 횟수',
'No automatic progression': '자동 증가 없음',
'Exclude from automatic progression': '자동 증가에서 제외',
'Use for planned deloads. Workouts stay in history and statistics.': '계획된 디로딩에 사용합니다. 운동은 기록과 통계에 남습니다.',
+1
View File
@@ -555,6 +555,7 @@ export default {
'Step ({0})': 'Skok ({0})',
'Step (seconds)': 'Skok (sekundy)',
'Reps from': 'Powt. od',
'Reps up to': 'Powt. do',
'No automatic progression': 'Bez automatycznej progresji',
'Exclude from automatic progression': 'Wyklucz z automatycznej progresji',
'Use for planned deloads. Workouts stay in history and statistics.': 'Użyj dla planowanych deloadów. Treningi pozostają w historii i statystykach.',
+1
View File
@@ -5,6 +5,7 @@ import pt from './pt.js'
export const PT_BR_OVERRIDES = {
'Press back again to exit': 'Pressione voltar novamente para sair',
'Reps up to': 'Reps até',
'Delete': 'Excluir',
'Save': 'Salvar',
'Log': 'Registrar',
+1
View File
@@ -555,6 +555,7 @@ export default {
'Step ({0})': 'Incremento ({0})',
'Step (seconds)': 'Incremento (segundos)',
'Reps from': 'Reps a partir de',
'Reps up to': 'Reps até',
'No automatic progression': 'Sem progressão automática',
'Exclude from automatic progression': 'Excluir da progressão automática',
'Use for planned deloads. Workouts stay in history and statistics.': 'Use para deloads planeados. Os treinos permanecem no histórico e nas estatísticas.',
+1
View File
@@ -555,6 +555,7 @@ export default {
'Step ({0})': 'Шаг ({0})',
'Step (seconds)': 'Шаг (секунды)',
'Reps from': 'Повт. от',
'Reps up to': 'Повт. до',
'No automatic progression': 'Без автопрогрессии',
'Exclude from automatic progression': 'Исключить из автоматической прогрессии',
'Use for planned deloads. Workouts stay in history and statistics.': 'Используйте для плановых разгрузок. Тренировки остаются в истории и статистике.',
+6
View File
@@ -691,4 +691,10 @@ export default {
'Rest-pause always trains as one warm-up set at this rep count, then one rest-pause work set — "Sets" is not used.': 'เรสต์-พอสจะฝึกเป็นเซ็ตวอร์มอัพหนึ่งเซ็ตที่จำนวนครั้งนี้ ตามด้วยเซ็ตหลักแบบเรสต์-พอสหนึ่งเซ็ตเสมอ — ไม่ใช้ค่า "เซ็ต"',
'Move up': 'เลื่อนขึ้น',
'Move down': 'เลื่อนลง',
'Swap exercise': 'สลับท่าออกกำลังกาย',
'Swap exercise?': 'สลับท่าออกกำลังกาย?',
'Logged sets stay with the original exercise. Choose where the replacement belongs.': 'เซ็ตที่บันทึกแล้วจะอยู่กับท่าเดิม เลือกว่าจะวางท่าใหม่ไว้ตรงไหน',
'Keep replacement in this group': 'เก็บท่าใหม่ไว้ในกลุ่มนี้',
'Insert after this group': 'แทรกหลังกลุ่มนี้',
'Logged sets stay with the original exercise. The replacement will be inserted afterward.': 'เซ็ตที่บันทึกแล้วจะอยู่กับท่าเดิม ท่าใหม่จะถูกแทรกไว้ถัดไป',
}
+1
View File
@@ -555,6 +555,7 @@ export default {
'Step ({0})': 'Artış ({0})',
'Step (seconds)': 'Artış (saniye)',
'Reps from': 'Tekrar en az',
'Reps up to': 'Tekrar en çok',
'No automatic progression': 'Otomatik ilerleme yok',
'Exclude from automatic progression': 'Otomatik ilerlemeden hariç tut',
'Use for planned deloads. Workouts stay in history and statistics.': 'Planlı deloadlar için kullanın. Antrenmanlar geçmişte ve istatistiklerde kalır.',
+1
View File
@@ -555,6 +555,7 @@ export default {
'Step ({0})': '加量({0})',
'Step (seconds)': '加量(秒)',
'Reps from': '次数下限',
'Reps up to': '次数上限',
'No automatic progression': '不自动进阶',
'Exclude from automatic progression': '不计入自动进阶',
'Use for planned deloads. Workouts stay in history and statistics.': '用于计划性减载。训练仍保留在历史记录和统计中。',
+48 -11
View File
@@ -21,6 +21,7 @@ import { importHevyData, HevyApiError, HEVY_DEV_SETTINGS, mergeHevyRoutines } fr
import { buildPlanBundle, parsePlan, mergePlan, printPlan } from './lib/plan-share.js'
import { estimate1RM, best1RM, is1RMRecord, REP_CAP } from './lib/onerm.js'
import { nextPrescription, applyPrescription, policyFor, defaultIncrement, POLICIES_FOR, POLICY_NAME, POLICY_DESC, MAX_BW_SETS } from './lib/progression.js'
import { normalizeRepRange } from './lib/rep-range.js'
import { MOBILE, shareExport } from './lib/mobile.js'
import { buildCompletedWorkout } from './lib/finish-workout.js'
import { isWarmupRow } from './lib/workout-model.js'
@@ -817,17 +818,25 @@ const progressionStepOf = (c, mode, ex, unit) =>
const progressionStepIsValid = (step, policy) =>
policy === 'off' || (Number.isFinite(step) && step > 0)
function ProgressionFields({ ex, mode, c, setC, routine, unit }) {
function ProgressionFields({ ex, mode, c, setC, routine, unit, perSide }) {
const options = POLICIES_FOR[mode] || ['off']
if (options.length < 2) return null
const inherited = policyFor({ id: ex.id }, routine, mode)
const active = policyFor({ ...c, id: ex.id }, routine, mode)
const inc = progressionStepOf(c, mode, ex, unit)
const invalid = !progressionStepIsValid(inc, active)
const stride = mode === 'reps' && perSide ? 2 : 1
const range = active === 'double' ? normalizeRepRange(c.reps, c.repsMin, stride) : null
const setRule = v => setC(x => {
const next = { ...x, prog: v || undefined }
return policyFor({ ...next, id: ex.id }, routine, mode) === 'double'
? { ...next, ...normalizeRepRange(next.reps, next.repsMin, stride) }
: next
})
return <>
<h4 className="sec">{t('Progression')}</h4>
<div className="sect-b" style={{ marginBottom: 8 }}>
<SelectRow title={t('Rule')} sheetTitle={t('Progression')} value={c.prog || ''} onChange={v => setC(x => ({ ...x, prog: v || undefined }))}
<SelectRow title={t('Rule')} sheetTitle={t('Progression')} value={c.prog || ''} onChange={setRule}
options={[{ value: '', label: t('Follow the routine ({0})', t(POLICY_NAME[inherited])) },
...options.map(p => ({ value: p, label: t(POLICY_NAME[p]) }))]} />
</div>
@@ -836,8 +845,12 @@ function ProgressionFields({ ex, mode, c, setC, routine, unit }) {
<Stepper label={mode === 'time' ? t('Step (seconds)') : t('Step ({0})', unit)} value={inc}
step={mode === 'time' ? 5 : 1.25} decimal={mode !== 'time'} invalid={invalid} className={invalid ? 'invalid' : ''}
onChange={v => setC(x => ({ ...x, inc: v }))} />
{active === 'double' && <Stepper label={t('Reps from')} value={c.repsMin || Math.max(1, (c.reps || 10) - 2)}
step={1} decimal={false} onChange={v => setC(x => ({ ...x, repsMin: v }))} />}
{active === 'double' && <>
<Stepper label={t('Reps from')} value={range.repsMin} step={stride} decimal={false}
onChange={v => setC(x => ({ ...x, ...normalizeRepRange(x.reps, v, stride) }))} />
<Stepper label={t('Reps up to')} value={range.reps} step={stride} decimal={false}
onChange={v => setC(x => ({ ...x, ...normalizeRepRange(v, x.repsMin, stride) }))} />
</>}
</div>}
{invalid && <div className="small" role="alert" style={{ color: 'var(--red)', marginTop: -10, marginBottom: 18 }}>
{t('Enter a positive step to use this progression rule.')}
@@ -848,7 +861,13 @@ function ProgressionFields({ ex, mode, c, setC, routine, unit }) {
function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
const st = useStore(s => s.S)
const cardio = isCardio(ex.id)
const [c, setC] = useState(existing || initial || defaultConfig(ex.id))
const seed = existing || initial || defaultConfig(ex.id)
const [c, setC] = useState(() => {
const cfg = { ...seed }
return policyFor({ ...cfg, id: ex.id }, routine, modeOf({ ...cfg, id: ex.id })) === 'double'
? { ...cfg, ...normalizeRepRange(cfg.reps, cfg.repsMin, isPerSide(cfg) ? 2 : 1) }
: cfg
})
// Cardio keeps its own duration+speed form; the reps/time choice (issue #16) is offered for
// everything else, which is where the gap was — planks, hangs, wall sits, loaded carries.
const mode = cardio ? 'cardio' : modeOf({ ...c, id: ex.id })
@@ -857,8 +876,15 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
const perSide = isPerSide(c)
const progressionPolicy = policyFor({ ...c, id: ex.id }, routine, mode)
const progressionStepInvalid = !progressionStepIsValid(progressionStepOf(c, mode, ex, st.unit), progressionPolicy)
const activePolicy = policyFor({ ...c, id: ex.id }, routine, mode)
const double = mode === 'reps' && activePolicy === 'double'
// Keep whatever the other mode already had (sets, weight) and fill only what is missing.
const setMode = m => setC(x => ({ ...defaultConfig(ex.id, m), ...x, mode: m }))
const setMode = m => setC(x => {
const next = { ...defaultConfig(ex.id, m), ...x, mode: m }
return m === 'reps' && policyFor({ ...next, id: ex.id }, routine, 'reps') === 'double'
? { ...next, ...normalizeRepRange(next.reps, next.repsMin, isPerSide(next) ? 2 : 1) }
: next
})
const save = () => {
if (progressionStepInvalid) return
close()
@@ -895,9 +921,15 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
// A unilateral target is stored even: the split has to divide, and a typed 15 would
// otherwise plan seven reps on one side and eight on the other, every session.
const typed = Math.max(1, Math.round(c.reps) || 10)
const reps = perSide ? Math.ceil(typed / 2) * 2 : typed
const stride = perSide ? 2 : 1
let reps = perSide ? Math.ceil(typed / stride) * stride : typed
let range = null
if (double) {
range = normalizeRepRange(reps, c.repsMin, stride)
reps = range.reps
}
const out = { sets, mode: 'reps', reps, weight: Math.max(0, c.weight || 0), ...flags, ...(perSide ? { side: true } : {}), ...prog, ...withNote, ...withWarmups, ...withRest }
if (policyFor({ ...c, id: ex.id }, routine, 'reps') === 'double') out.repsMin = Math.min(reps, Math.max(1, Math.round(c.repsMin) || Math.max(1, reps - 2)))
if (double) out.repsMin = range.repsMin
// A ceiling below the working reps would tell you to add a set on day one.
if (bw && !(out.weight > 0) && c.repsMax > 0) out.repsMax = Math.max(reps, Math.round(c.repsMax))
// Every set in this exercise becomes a drop-set/rest-pause (buildSets stamps the rows) —
@@ -937,7 +969,7 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
rest-pause work set — so "Sets" has nothing left to mean and only invites a mismatch. */}
{c.intensifier?.type !== 'restpause' &&
<Stepper label={t('Sets')} value={c.sets} step={1} decimal={false} onChange={v => setC(x => ({ ...x, sets: v }))} />}
<Stepper label={t('Reps')} value={c.reps} step={perSide ? 2 : 1} decimal={false} onChange={v => setC(x => ({ ...x, reps: v }))} />
{!double && <Stepper label={t('Reps')} value={c.reps} step={perSide ? 2 : 1} decimal={false} onChange={v => setC(x => ({ ...x, reps: v }))} />}
{/* On bodyweight work the weight stepper is the click #32 is about, so it is not here
until there is a belt to describe — see the added-weight row below. */}
{!bw && <Stepper label={t('Weight ({0})', st.unit)} value={c.weight} step={2.5} onChange={v => setC(x => ({ ...x, weight: v }))} />}
@@ -983,7 +1015,12 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
subtitle={perSide ? t('You still log the total: {0} is {1} per side.', c.reps || 0, fmtNum(sideReps(c.reps))) : t('For lunges, single-arm rows and the like.')}>
{/* Turning it on rounds the target up to an even number, since half of an odd
total is a rep one side does not get. */}
<Switch checked={perSide} onChange={v => setC(x => ({ ...x, side: v || undefined, reps: v ? Math.ceil((x.reps || 0) / 2) * 2 : x.reps }))} />
<Switch checked={perSide} onChange={v => setC(x => {
const next = { ...x, side: v || undefined, reps: v ? Math.ceil((x.reps || 0) / 2) * 2 : x.reps }
return policyFor({ ...next, id: ex.id }, routine, 'reps') === 'double'
? { ...next, ...normalizeRepRange(next.reps, next.repsMin, v ? 2 : 1) }
: next
})} />
</Row>}
</div>}
{/* A stepper is too wide to sit in a list row next to a label — it squeezes the text to
@@ -1045,7 +1082,7 @@ function ExConfig({ ex, existing, onSave, onDelete, close, routine, initial }) {
: t('Every set becomes rest-pause: {0} reps to start, then {1} more split into short bursts, {2}s rest before each, roughly halving each time.', c.reps || 0, c.intensifier.totalReps, c.intensifier.restSec)}
</div>}
</>}
<ProgressionFields ex={ex} mode={mode} c={c} setC={setC} routine={routine} unit={st.unit} />
<ProgressionFields ex={ex} mode={mode} c={c} setC={setC} routine={routine} unit={st.unit} perSide={perSide} />
<textarea className="input" rows={3} maxLength={500} style={{ marginBottom: 18 }}
placeholder={t('Note (optional) — loading cues, "bar only then +1 plate/side each set", anything worth remembering here')}
value={c.note || ''} onChange={e => setC(x => ({ ...x, note: e.target.value }))} />
+2 -1
View File
@@ -1,4 +1,5 @@
// @vitest-environment happy-dom
import { LANGS } from './lib/i18n-core.js'
import { act } from 'react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { swapActiveWorkoutExercise } from './sheets.jsx'
@@ -77,7 +78,7 @@ describe('active exercise swap locale coverage', () => {
const packs = import.meta.glob('./locales/*.js', { eager: true, import: 'default' })
it('defines every new prompt in all twelve locale packs', () => {
expect(Object.keys(packs)).toHaveLength(12)
expect(Object.keys(packs)).toHaveLength(Object.keys(LANGS).length - 1)
Object.entries(packs).forEach(([path, pack]) => {
required.forEach(key => expect(pack, `${path} is missing ${key}`).toHaveProperty(key))
})