From 45c4756cd023126c36c878e6edcf70653c177c5a Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Tue, 1 Sep 2026 14:11:51 +0200 Subject: [PATCH 1/8] Stangengewicht: Scheiben-Rechnung pro Seite, pro Uebung einstellbar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wer an der Stange arbeitet, rechnet vor jedem Satz dasselbe im Kopf: was muss pro Seite drauf. Die App kennt beide Zahlen laengst — das Gesamtgewicht steht im Satz, der Stangentyp in der Uebung — und hat sie nie zusammengebracht. Neu: lib/bar.js mit den ueblichen Stangen (Olympia 20 kg, EZ 10, Multipresse 9, Trap 25) und den Markierungen, die ein lb-Profil wirklich im Rack hat (45, 25, 20, 55) — keine umgerechneten 44,1 lb, die auf keiner Stange stehen. Das Stangengewicht liegt in S.barWeights pro Uebung und in der Profil-Einheit, wie jedes andere Gewicht im State: ein Einheitenwechsel beschriftet um und rechnet nicht, sonst waere die Stange die eine Zahl, die unter dem Nutzer wegrutscht, waehrend die Totale drumherum stehen bleiben. Eingetragen wird weiterhin das Gesamtgewicht. Historie, Progression und 1RM bedeuten exakt das, was sie vorher bedeutet haben — die Stange ist reine Anzeige-Metadatei und speist nur die Rechnung "(Total − Stange) / 2". Im Workout haengt der Chip "Stange 20 kg · 30 kg pro Seite" am Satz, der als naechstes dran ist (erster offener; ist alles abgehakt, der schwerste). Ein Tipp darauf oeffnet dieselbe Stepper-Zeile, die auch in Uebungsdetail und Konfiguration steht — auf 0 gestellt faellt die Uebung auf den Standard ihres Stangentyps zurueck, dieselbe "0 loescht den Schluessel"-Form wie bei den nullbaren Satzfeldern. Strings in allen vierzehn Sprachen; der pt-BR-Vererbungs-Fingerabdruck ist nachgezogen (4 Overrides, 3 geerbt). --- frontend/src/lib/bar.js | 56 ++++++++++++++++ frontend/src/lib/bar.test.js | 94 +++++++++++++++++++++++++++ frontend/src/lib/pt-br-locale.test.js | 6 +- frontend/src/locales/de.js | 8 +++ frontend/src/locales/es.js | 8 +++ frontend/src/locales/fr.js | 8 +++ frontend/src/locales/hi.js | 8 +++ frontend/src/locales/hu.js | 8 +++ frontend/src/locales/it.js | 8 +++ frontend/src/locales/ko.js | 8 +++ frontend/src/locales/pl.js | 8 +++ frontend/src/locales/pt-BR.js | 5 ++ frontend/src/locales/pt.js | 8 +++ frontend/src/locales/ru.js | 8 +++ frontend/src/locales/th.js | 8 +++ frontend/src/locales/tr.js | 8 +++ frontend/src/locales/zh.js | 8 +++ frontend/src/sheets.jsx | 49 ++++++++++++++ frontend/src/store/useStore.js | 4 ++ frontend/src/views/Workout.jsx | 20 +++++- 20 files changed, 334 insertions(+), 4 deletions(-) create mode 100644 frontend/src/lib/bar.js create mode 100644 frontend/src/lib/bar.test.js diff --git a/frontend/src/lib/bar.js b/frontend/src/lib/bar.js new file mode 100644 index 0000000..fa75348 --- /dev/null +++ b/frontend/src/lib/bar.js @@ -0,0 +1,56 @@ +// Per-exercise bar weight (issue: plate math for barbell work). Logged weights stay the +// TOTAL on the bar — history, progression and 1RM keep meaning exactly what they always +// did. The bar weight is display metadata: it feeds the "X per side" plate math and +// nothing else. +// +// Unit: stored in the profile unit (S.unit), like every other weight in state — set +// weights, exWeights, bodyweight are all written in whatever unit the profile logs and a +// unit switch re-labels them without converting. A canonical-kg bar would be the one +// number that shifts under the user on a unit switch while the totals around it stay +// put, so the override follows the same rule. The equipment *defaults* therefore exist +// per unit too: a kg profile gets the 20 kg olympic bar, a lb profile the 45 lb bar its +// gym actually racks — not a 44.1 lb conversion no bar is stamped with. + +import { EXIDX } from './exercises.js' + +/** Equipment values (e.eq) that put a bar in your hands. */ +export const BAR_EQ = new Set(['barbell', 'olympic barbell', 'ez barbell', 'smith machine', 'trap bar']) + +/** Typical bar weights per equipment type, for a kg profile. */ +export const DEFAULT_BAR_KG = { barbell: 20, 'olympic barbell': 20, 'ez barbell': 10, 'smith machine': 9, 'trap bar': 25 } +/** The same bars as a lb profile knows them — real markings, not converted kg. */ +export const DEFAULT_BAR_LB = { barbell: 45, 'olympic barbell': 45, 'ez barbell': 25, 'smith machine': 20, 'trap bar': 55 } + +const exOf = exOrId => (typeof exOrId === 'string' ? EXIDX[exOrId] : exOrId) + +/** Whether this exercise (object or id) is done with a bar. */ +export const usesBar = exOrId => BAR_EQ.has(exOf(exOrId)?.eq) + +/** The default bar weight for an equipment type, in the given unit. null off the list. */ +export const defaultBarWeight = (eq, unit) => + (unit === 'lb' ? DEFAULT_BAR_LB : DEFAULT_BAR_KG)[eq] ?? null + +/** True when the user has set their own bar weight for this exercise. */ +export const hasBarOverride = (S, exId) => ((S?.barWeights || {})[exId] || 0) > 0 + +/** + * Effective bar weight for one exercise, in the profile unit: the explicit + * S.barWeights[exId] if set, else the default for the bar type. null for anything + * that is not a bar exercise. + */ +export function barWeightFor(S, exOrId) { + const ex = exOf(exOrId) + if (!BAR_EQ.has(ex?.eq)) return null + const own = (S?.barWeights || {})[ex.id] + if (own > 0) return own + return defaultBarWeight(ex.eq, S?.unit) +} + +/** + * Plates per side: (total − bar) / 2, rounded to 2 decimals. null when there is nothing + * sensible to show — a missing number, or a total at or below the bar itself. + */ +export function plateSplit(total, bar) { + if (!(total > 0) || !(bar > 0) || total <= bar) return null + return Math.round(((total - bar) / 2) * 100) / 100 +} diff --git a/frontend/src/lib/bar.test.js b/frontend/src/lib/bar.test.js new file mode 100644 index 0000000..e8a94e6 --- /dev/null +++ b/frontend/src/lib/bar.test.js @@ -0,0 +1,94 @@ +import { describe, expect, test } from 'vitest' +import { BAR_EQ, DEFAULT_BAR_KG, DEFAULT_BAR_LB, usesBar, defaultBarWeight, barWeightFor, hasBarOverride, plateSplit } from './bar.js' +import { EXDB } from './exercises-data.js' + +const idOf = eq => EXDB.find(e => e.eq === eq).id + +describe('bar equipment', () => { + test('covers the five bar types and the 228 catalogue exercises they carry', () => { + expect([...BAR_EQ].sort()).toEqual(['barbell', 'ez barbell', 'olympic barbell', 'smith machine', 'trap bar']) + expect(EXDB.filter(e => BAR_EQ.has(e.eq)).length).toBe(228) + }) + + test('usesBar answers for ids and exercise objects alike', () => { + for (const eq of BAR_EQ) { + expect(usesBar(idOf(eq)), eq).toBe(true) + expect(usesBar({ eq }), eq).toBe(true) + } + expect(usesBar({ eq: 'dumbbell' })).toBe(false) + expect(usesBar({ eq: 'body weight' })).toBe(false) + expect(usesBar('no-such-id')).toBe(false) + expect(usesBar(null)).toBe(false) + }) +}) + +describe('per-unit defaults', () => { + test('every bar type has a default in both units', () => { + for (const eq of BAR_EQ) { + expect(DEFAULT_BAR_KG[eq], eq).toBeGreaterThan(0) + expect(DEFAULT_BAR_LB[eq], eq).toBeGreaterThan(0) + } + expect(defaultBarWeight('ez barbell', 'kg')).toBe(10) + expect(defaultBarWeight('ez barbell', 'lb')).toBe(25) + expect(defaultBarWeight('olympic barbell', 'kg')).toBe(20) + // A lb profile gets the bar its gym actually racks, not a 44.1 lb conversion. + expect(defaultBarWeight('barbell', 'lb')).toBe(45) + expect(defaultBarWeight('dumbbell', 'kg')).toBeNull() + }) +}) + +describe('barWeightFor', () => { + const barbell = idOf('barbell') + const ez = idOf('ez barbell') + + test('falls back to the equipment default in the profile unit', () => { + expect(barWeightFor({ unit: 'kg', barWeights: {} }, barbell)).toBe(20) + expect(barWeightFor({ unit: 'lb', barWeights: {} }, barbell)).toBe(45) + expect(barWeightFor({ unit: 'kg' }, ez)).toBe(10) + }) + + test('an explicit override wins over the default', () => { + const S = { unit: 'kg', barWeights: { [ez]: 7.5 } } + expect(barWeightFor(S, ez)).toBe(7.5) + expect(hasBarOverride(S, ez)).toBe(true) + expect(barWeightFor(S, barbell)).toBe(20) // other exercises keep their default + expect(hasBarOverride(S, barbell)).toBe(false) + }) + + test('a cleared (deleted or zeroed) override falls back to the default', () => { + const S = { unit: 'kg', barWeights: { [ez]: 12.5 } } + delete S.barWeights[ez] + expect(barWeightFor(S, ez)).toBe(10) + expect(barWeightFor({ unit: 'kg', barWeights: { [ez]: 0 } }, ez)).toBe(10) + expect(hasBarOverride({ unit: 'kg', barWeights: { [ez]: 0 } }, ez)).toBe(false) + }) + + test('is null for anything without a bar', () => { + const dumbbell = EXDB.find(e => e.eq === 'dumbbell') + expect(barWeightFor({ unit: 'kg', barWeights: {} }, dumbbell.id)).toBeNull() + expect(barWeightFor({ unit: 'kg', barWeights: {} }, 'no-such-id')).toBeNull() + }) +}) + +describe('plateSplit', () => { + test('splits what is beyond the bar evenly per side', () => { + expect(plateSplit(62.5, 20)).toBe(21.25) + expect(plateSplit(100, 20)).toBe(40) + expect(plateSplit(30, 10)).toBe(10) + }) + + test('rounds to 2 decimals', () => { + expect(plateSplit(65.55, 20)).toBe(22.78) + expect(plateSplit(21.2, 20)).toBe(0.6) + }) + + test('is null when there is nothing sensible to show', () => { + expect(plateSplit(20, 20)).toBe(null) // bar only + expect(plateSplit(15, 20)).toBe(null) // below the bar + expect(plateSplit(0, 20)).toBe(null) + expect(plateSplit(100, 0)).toBe(null) + expect(plateSplit(null, 20)).toBe(null) + expect(plateSplit(100, null)).toBe(null) + expect(plateSplit(undefined, undefined)).toBe(null) + }) +}) diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js index 2212b37..f02491f 100644 --- a/frontend/src/lib/pt-br-locale.test.js +++ b/frontend/src/lib/pt-br-locale.test.js @@ -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(338) - expect(inherited).toHaveLength(458) + expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(342) + expect(inherited).toHaveLength(461) // 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('67edc754880ed2a392eee8839549a36bd8bf55b16f889b655b40fc6c493fc6dd') + expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('1b6f52ab4152f95d7fca75fb79f12f582be228f6388b292b75932bfd09b427b2') }) test('does not leak European Portuguese UI terms', () => { diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js index 461da9f..78217f7 100644 --- a/frontend/src/locales/de.js +++ b/frontend/src/locales/de.js @@ -750,4 +750,12 @@ export default { 'Add as second workout': 'Als zweites Training hinzufügen', 'Finish the current workout first.': 'Beende zuerst das laufende Training.', 'Logging a past workout — no rest timers.': 'Vergangenes Training — keine Pausen-Timer.', + // --- bar weight (plate math) --- + 'Bar weight': 'Stangengewicht', + 'Bar ({0})': 'Stange ({0})', + 'Bar {0}': 'Stange {0}', + 'Default for this bar type.': 'Standard für diesen Stangentyp.', + 'Set to 0 to go back to the default ({0}).': 'Auf 0 stellen, um zum Standard ({0}) zurückzukehren.', + 'Applies to this exercise everywhere, not just this plan.': 'Gilt überall für diese Übung, nicht nur in diesem Plan.', + 'You still log the total weight — the bar only feeds the per-side plate math.': 'Eingetragen wird weiterhin das Gesamtgewicht — die Stange zählt nur für die Scheiben-Rechnung pro Seite.', } diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js index a8f5e82..6eb0450 100644 --- a/frontend/src/locales/es.js +++ b/frontend/src/locales/es.js @@ -733,4 +733,12 @@ export default { 'Add as second workout': 'Añadir como segundo entrenamiento', 'Finish the current workout first.': 'Termina primero el entrenamiento actual.', 'Logging a past workout — no rest timers.': 'Registrando un entrenamiento pasado — sin temporizadores de descanso.', + // --- bar weight (plate math) --- + 'Bar weight': 'Peso de la barra', + 'Bar ({0})': 'Barra ({0})', + 'Bar {0}': 'Barra {0}', + 'Default for this bar type.': 'Valor por defecto para este tipo de barra.', + 'Set to 0 to go back to the default ({0}).': 'Pon 0 para volver al valor por defecto ({0}).', + 'Applies to this exercise everywhere, not just this plan.': 'Se aplica a este ejercicio en todas partes, no solo en este plan.', + 'You still log the total weight — the bar only feeds the per-side plate math.': 'Sigues registrando el peso total — la barra solo se usa para calcular los discos por lado.', } diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js index ac9e96e..6521500 100644 --- a/frontend/src/locales/fr.js +++ b/frontend/src/locales/fr.js @@ -733,4 +733,12 @@ export default { 'Add as second workout': 'Ajouter comme deuxième séance', 'Finish the current workout first.': 'Termine d’abord la séance en cours.', 'Logging a past workout — no rest timers.': 'Séance passée — pas de minuteurs de repos.', + // --- bar weight (plate math) --- + 'Bar weight': 'Poids de la barre', + 'Bar ({0})': 'Barre ({0})', + 'Bar {0}': 'Barre {0}', + 'Default for this bar type.': 'Valeur par défaut pour ce type de barre.', + 'Set to 0 to go back to the default ({0}).': 'Mets 0 pour revenir à la valeur par défaut ({0}).', + 'Applies to this exercise everywhere, not just this plan.': 'S’applique à cet exercice partout, pas seulement dans ce plan.', + 'You still log the total weight — the bar only feeds the per-side plate math.': 'Tu enregistres toujours le poids total — la barre ne sert qu’au calcul des disques par côté.', } diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js index 8908a32..46715c8 100644 --- a/frontend/src/locales/hi.js +++ b/frontend/src/locales/hi.js @@ -733,4 +733,12 @@ export default { 'Add as second workout': 'दूसरे वर्कआउट के रूप में जोड़ें', 'Finish the current workout first.': 'पहले मौजूदा वर्कआउट पूरा करें।', 'Logging a past workout — no rest timers.': 'पिछला वर्कआउट दर्ज हो रहा है — कोई रेस्ट टाइमर नहीं।', + // --- bar weight (plate math) --- + 'Bar weight': 'बार का वज़न', + 'Bar ({0})': 'बार ({0})', + 'Bar {0}': 'बार {0}', + 'Default for this bar type.': 'इस तरह की बार का डिफ़ॉल्ट मान।', + 'Set to 0 to go back to the default ({0}).': 'डिफ़ॉल्ट ({0}) पर लौटने के लिए 0 सेट करें।', + 'Applies to this exercise everywhere, not just this plan.': 'यह इस एक्सरसाइज़ पर हर जगह लागू होता है, सिर्फ़ इसी प्लान पर नहीं।', + 'You still log the total weight — the bar only feeds the per-side plate math.': 'आप अब भी कुल वज़न ही दर्ज करते हैं — बार सिर्फ़ हर तरफ़ की प्लेट गिनती में काम आता है।', } diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js index bda6db8..e5891e0 100644 --- a/frontend/src/locales/hu.js +++ b/frontend/src/locales/hu.js @@ -738,4 +738,12 @@ export default { 'Add as second workout': 'Hozzáadás második edzésként', 'Finish the current workout first.': 'Előbb fejezd be a folyó edzést.', 'Logging a past workout — no rest timers.': 'Korábbi edzés rögzítése — nincs pihenőidőzítő.', + // --- bar weight (plate math) --- + 'Bar weight': 'Rúd súlya', + 'Bar ({0})': 'Rúd ({0})', + 'Bar {0}': 'Rúd {0}', + 'Default for this bar type.': 'Alapérték ehhez a rúdtípushoz.', + 'Set to 0 to go back to the default ({0}).': 'Állítsd 0-ra az alapérték ({0}) visszaállításához.', + 'Applies to this exercise everywhere, not just this plan.': 'Mindenhol érvényes erre a gyakorlatra, nem csak ebben a tervben.', + 'You still log the total weight — the bar only feeds the per-side plate math.': 'Továbbra is a teljes súlyt rögzíted — a rúd csak az oldalankénti tárcsaszámításhoz kell.', } diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js index 23ae58f..75ed6da 100644 --- a/frontend/src/locales/it.js +++ b/frontend/src/locales/it.js @@ -733,4 +733,12 @@ export default { 'Add as second workout': 'Aggiungi come secondo allenamento', 'Finish the current workout first.': 'Termina prima l’allenamento in corso.', 'Logging a past workout — no rest timers.': 'Allenamento passato — nessun timer di recupero.', + // --- bar weight (plate math) --- + 'Bar weight': 'Peso del bilanciere', + 'Bar ({0})': 'Bilanciere ({0})', + 'Bar {0}': 'Bilanciere {0}', + 'Default for this bar type.': 'Valore predefinito per questo tipo di bilanciere.', + 'Set to 0 to go back to the default ({0}).': 'Imposta 0 per tornare al valore predefinito ({0}).', + 'Applies to this exercise everywhere, not just this plan.': 'Vale per questo esercizio ovunque, non solo in questo piano.', + 'You still log the total weight — the bar only feeds the per-side plate math.': 'Registri comunque il peso totale — il bilanciere serve solo al calcolo dei dischi per lato.', } diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js index 3efbca0..dd6b957 100644 --- a/frontend/src/locales/ko.js +++ b/frontend/src/locales/ko.js @@ -733,4 +733,12 @@ export default { 'Add as second workout': '두 번째 운동으로 추가', 'Finish the current workout first.': '먼저 진행 중인 운동을 마치세요.', 'Logging a past workout — no rest timers.': '지난 운동 기록 중 — 휴식 타이머 없음.', + // --- bar weight (plate math) --- + 'Bar weight': '바 무게', + 'Bar ({0})': '바 ({0})', + 'Bar {0}': '바 {0}', + 'Default for this bar type.': '이 바 종류의 기본값입니다.', + 'Set to 0 to go back to the default ({0}).': '0으로 두면 기본값({0})으로 돌아갑니다.', + 'Applies to this exercise everywhere, not just this plan.': '이 플랜만이 아니라 어디서든 이 운동에 적용됩니다.', + 'You still log the total weight — the bar only feeds the per-side plate math.': '기록은 여전히 총 무게입니다 — 바 무게는 한쪽에 끼울 원판 계산에만 쓰입니다.', } diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js index ec6d21f..c5db41f 100644 --- a/frontend/src/locales/pl.js +++ b/frontend/src/locales/pl.js @@ -733,4 +733,12 @@ export default { 'Add as second workout': 'Dodaj jako drugi trening', 'Finish the current workout first.': 'Najpierw zakończ bieżący trening.', 'Logging a past workout — no rest timers.': 'Zapisywanie minionego treningu — bez minutników przerw.', + // --- bar weight (plate math) --- + 'Bar weight': 'Ciężar gryfu', + 'Bar ({0})': 'Gryf ({0})', + 'Bar {0}': 'Gryf {0}', + 'Default for this bar type.': 'Wartość domyślna dla tego typu gryfu.', + 'Set to 0 to go back to the default ({0}).': 'Ustaw 0, aby wrócić do wartości domyślnej ({0}).', + 'Applies to this exercise everywhere, not just this plan.': 'Dotyczy tego ćwiczenia wszędzie, nie tylko w tym planie.', + 'You still log the total weight — the bar only feeds the per-side plate math.': 'Nadal zapisujesz ciężar całkowity — gryf służy tylko do wyliczenia talerzy na stronę.', } diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js index cf6072e..f57f794 100644 --- a/frontend/src/locales/pt-BR.js +++ b/frontend/src/locales/pt-BR.js @@ -353,6 +353,11 @@ export const PT_BR_OVERRIDES = { 'Pick a day up to today': 'Escolha um dia até hoje', 'Finish the current workout first.': 'Termine primeiro o treino atual.', 'Logging a past workout — no rest timers.': 'Registrando um treino passado — sem temporizadores de descanso.', + // --- bar weight (plate math) --- ('Peso da barra', 'Barra ({0})', 'Barra {0}' inherit) + 'Default for this bar type.': 'Padrão para este tipo de barra.', + 'Set to 0 to go back to the default ({0}).': 'Defina 0 para voltar ao padrão ({0}).', + 'Applies to this exercise everywhere, not just this plan.': 'Vale para este exercício em todos os lugares, não só neste plano.', + 'You still log the total weight — the bar only feeds the per-side plate math.': 'Você continua registrando o peso total — a barra só entra no cálculo das anilhas por lado.' } export default { ...pt, ...PT_BR_OVERRIDES } diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js index 8c9dccc..dd2ae30 100644 --- a/frontend/src/locales/pt.js +++ b/frontend/src/locales/pt.js @@ -733,4 +733,12 @@ export default { 'Add as second workout': 'Adicionar como segundo treino', 'Finish the current workout first.': 'Termina primeiro o treino em curso.', 'Logging a past workout — no rest timers.': 'A registar um treino passado — sem temporizadores de descanso.', + // --- bar weight (plate math) --- + 'Bar weight': 'Peso da barra', + 'Bar ({0})': 'Barra ({0})', + 'Bar {0}': 'Barra {0}', + 'Default for this bar type.': 'Predefinição para este tipo de barra.', + 'Set to 0 to go back to the default ({0}).': 'Coloca 0 para voltar à predefinição ({0}).', + 'Applies to this exercise everywhere, not just this plan.': 'Aplica-se a este exercício em todo o lado, não só neste plano.', + 'You still log the total weight — the bar only feeds the per-side plate math.': 'Continuas a registar o peso total — a barra só conta para o cálculo dos discos por lado.', } diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js index 27a6056..9b69a06 100644 --- a/frontend/src/locales/ru.js +++ b/frontend/src/locales/ru.js @@ -733,4 +733,12 @@ export default { 'Add as second workout': 'Добавить как вторую тренировку', 'Finish the current workout first.': 'Сначала заверши текущую тренировку.', 'Logging a past workout — no rest timers.': 'Запись прошлой тренировки — без таймеров отдыха.', + // --- bar weight (plate math) --- + 'Bar weight': 'Вес грифа', + 'Bar ({0})': 'Гриф ({0})', + 'Bar {0}': 'Гриф {0}', + 'Default for this bar type.': 'Значение по умолчанию для этого типа грифа.', + 'Set to 0 to go back to the default ({0}).': 'Поставь 0, чтобы вернуться к значению по умолчанию ({0}).', + 'Applies to this exercise everywhere, not just this plan.': 'Действует для этого упражнения везде, а не только в этом плане.', + 'You still log the total weight — the bar only feeds the per-side plate math.': 'Записывается по-прежнему общий вес — гриф нужен только для расчёта блинов на сторону.', } diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js index f0baac5..caad79d 100644 --- a/frontend/src/locales/th.js +++ b/frontend/src/locales/th.js @@ -746,4 +746,12 @@ export default { 'Add as second workout': 'เพิ่มเป็นการฝึกครั้งที่สอง', 'Finish the current workout first.': 'จบการฝึกปัจจุบันก่อน', 'Logging a past workout — no rest timers.': 'กำลังบันทึกการฝึกย้อนหลัง — ไม่มีตัวจับเวลาพัก', + // --- bar weight (plate math) --- + 'Bar weight': 'น้ำหนักบาร์', + 'Bar ({0})': 'บาร์ ({0})', + 'Bar {0}': 'บาร์ {0}', + 'Default for this bar type.': 'ค่าเริ่มต้นสำหรับบาร์ชนิดนี้', + 'Set to 0 to go back to the default ({0}).': 'ตั้งเป็น 0 เพื่อกลับไปใช้ค่าเริ่มต้น ({0})', + 'Applies to this exercise everywhere, not just this plan.': 'มีผลกับท่านี้ทุกที่ ไม่ใช่เฉพาะในแผนนี้', + 'You still log the total weight — the bar only feeds the per-side plate math.': 'คุณยังบันทึกน้ำหนักรวมเหมือนเดิม — บาร์ใช้สำหรับคำนวณแผ่นน้ำหนักต่อข้างเท่านั้น', } diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js index 9ed9311..6ad2974 100644 --- a/frontend/src/locales/tr.js +++ b/frontend/src/locales/tr.js @@ -733,4 +733,12 @@ export default { 'Add as second workout': 'İkinci antrenman olarak ekle', 'Finish the current workout first.': 'Önce mevcut antrenmanı bitir.', 'Logging a past workout — no rest timers.': 'Geçmiş antrenman kaydediliyor — dinlenme zamanlayıcısı yok.', + // --- bar weight (plate math) --- + 'Bar weight': 'Bar ağırlığı', + 'Bar ({0})': 'Bar ({0})', + 'Bar {0}': 'Bar {0}', + 'Default for this bar type.': 'Bu bar türü için varsayılan.', + 'Set to 0 to go back to the default ({0}).': 'Varsayılana ({0}) dönmek için 0 yap.', + 'Applies to this exercise everywhere, not just this plan.': 'Yalnızca bu planda değil, bu egzersiz için her yerde geçerli.', + 'You still log the total weight — the bar only feeds the per-side plate math.': 'Yine de toplam ağırlığı kaydedersin — bar yalnızca taraf başına plaka hesabına girer.', } diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js index 4cf4465..cba254c 100644 --- a/frontend/src/locales/zh.js +++ b/frontend/src/locales/zh.js @@ -733,4 +733,12 @@ export default { 'Add as second workout': '添加为第二次训练', 'Finish the current workout first.': '请先完成当前训练。', 'Logging a past workout — no rest timers.': '正在补记过去的训练 — 没有休息计时器。', + // --- bar weight (plate math) --- + 'Bar weight': '杠铃杆重量', + 'Bar ({0})': '杆 ({0})', + 'Bar {0}': '杆 {0}', + 'Default for this bar type.': '此类杠铃杆的默认值。', + 'Set to 0 to go back to the default ({0}).': '设为 0 即恢复默认值({0})。', + 'Applies to this exercise everywhere, not just this plan.': '对这个动作处处生效,不只在此计划中。', + 'You still log the total weight — the bar only feeds the per-side plate math.': '记录的仍是总重量——杆重只用于每侧杠铃片的计算。', } diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx index 94ee1d4..037348b 100644 --- a/frontend/src/sheets.jsx +++ b/frontend/src/sheets.jsx @@ -5,6 +5,7 @@ import { EXDB, EXIDX, BODYPARTS, isCardio, isBodyweightEq, allExercises, equipme import { activeProfile, exAvailable, ALL_EQUIPMENT, newProfile } from './lib/equipment.js' import { fmtDate, fmtNum, fmtVol, fmtDur, durPart, todayISO, isoOf, 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, applyIntensifierPlan, MAX_PLANNED_WARMUPS, NOTE_MAX } from './lib/history.js' +import { usesBar, barWeightFor, defaultBarWeight, hasBarOverride } from './lib/bar.js' import { beep, vibrate } from './lib/sound.js' import { t, instrFor, exerciseNameFor, getLang, INSTR_LANGS } from './lib/i18n.js' import { nav } from './lib/nav.js' @@ -470,6 +471,44 @@ function GoalSheet({ close }) { } export const goalSheet = () => ui().openSheet(close => ) +/* ============================ bar weight ============================ */ +// One editor for every place the bar weight shows up (exercise detail, exercise config, +// mid-workout sheet): a stepper over the effective value. What it saves is per exercise +// and lives in S.barWeights, in the profile unit (see lib/bar.js) — stepping or typing +// down to 0 clears the override and the field falls back to the default for the bar +// type, the same "0 drops the key" shape a nullable set field has. +function BarWeightEditor({ ex, extra }) { + const st = useStore(s => s.S) + const explicit = hasBarOverride(st, ex.id) + const def = defaultBarWeight(ex.eq, st.unit) + const setBar = v => update(s => { + s.barWeights = s.barWeights || {} + const n = Math.max(0, Math.round((v || 0) * 100) / 100) + if (n > 0) s.barWeights[ex.id] = n; else delete s.barWeights[ex.id] + }) + return <> +
+ +
+
+ {explicit ? t('Set to 0 to go back to the default ({0}).', fmtNum(def) + ' ' + st.unit) : t('Default for this bar type.')} + {extra ? ' ' + extra : ''} +
+ +} + +// Tiny mid-workout sheet behind the "Bar … · … per side" chip — same value, same editor. +function BarWeightSheet({ exId, close }) { + const ex = exOr(exId) + return <> +

{t('Bar weight')}

+
{exerciseNameFor(ex)}
+ + + +} +export const barWeightSheet = exId => ui().openSheet(close => ) + /* ============================ exercise detail ============================ */ // Estimated 1RM for one exercise (issue #18): what the log already implies, plus a calculator // for a set you have not done — so the number is reachable before there is any history. @@ -519,6 +558,10 @@ function ExerciseDetail({ ex, close }) { } + {usesBar(ex) && <> +

{t('Bar weight')}

+ + } {!isCardio(ex) && } {instrFor(ex).length > 0 &&<>

{t('How to')}{!INSTR_LANGS.includes(getLang()) && · {t('instructions in English')}}

    {instrFor(ex).map((s, i) =>
  1. {s}
  2. )}
} @@ -1105,6 +1148,12 @@ 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)} } } + {/* The bar's own weight, for the plate math — per exercise, not per plan, so it sits + apart from the config fields above and writes straight to S.barWeights. */} + {usesBar(ex) && <> +

{t('Bar weight')}

+ + }