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
Stangengewicht: Scheiben-Rechnung pro Seite, pro Uebung einstellbar
Duarte Santos45c4756cd023
diff --git a/frontend/src/lib/bar.js b/frontend/src/lib/bar.jsnew file mode 100644index 000000000..fa75348c6--- /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.jsnew file mode 100644index 000000000..e8a94e6a4--- /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.jsindex 2212b37f9..f02491f29 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.jsindex 461da9fa4..78217f7ac 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.jsindex a8f5e82d7..6eb045042 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.jsindex ac9e96eef..65215003f 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.jsindex 8908a3258..46715c89f 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.jsindex bda6db8bb..e5891e0ed 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.jsindex 23ae58f6c..75ed6da5f 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.jsindex 3efbca09c..dd6b957c5 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.jsindex ec6d21f13..c5db41f52 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.jsindex cf6072e8a..f57f794a0 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.jsindex 8c9dccc6d..dd2ae30e8 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.jsindex 27a6056ca..9b69a0659 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.jsindex f0baac53a..caad79df6 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.jsindex 9ed931174..6ad297496 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.jsindex 4cf4465a8..cba254c09 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.jsxindex 94ee1d47d..037348b23 100644--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@ -5,6 +5,7 @@ import { EXDB, EXIDX, BODYPARTS, isCardio, isBodyweightEq, allExercises, equipmeimport { 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 => <GoalSheet close={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 <>+ <div className="row cfgrow" style={{ marginBottom: 6 }}>+ <Stepper label={t('Bar ({0})', st.unit)} value={barWeightFor(st, ex) || 0} step={2.5} onChange={setBar} />+ </div>+ <div className="small dim" style={{ marginBottom: 18 }}>+ {explicit ? t('Set to 0 to go back to the default ({0}).', fmtNum(def) + ' ' + st.unit) : t('Default for this bar type.')}+ {extra ? ' ' + extra : ''}+ </div>+ </>+}++// Tiny mid-workout sheet behind the "Bar … · … per side" chip — same value, same editor.+function BarWeightSheet({ exId, close }) {+ const ex = exOr(exId)+ return <>+ <h3>{t('Bar weight')}</h3>+ <div className="muted small capitalize" 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>+ </>+}+export const barWeightSheet = exId => ui().openSheet(close => <BarWeightSheet exId={exId} close={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 }) {<Button icon="pencil" style={{ flex: 1 }} onClick={() => { close(); customExSheet(ex) }}>{t('Edit')}</Button><Button variant="danger" icon="trash" style={{ flex: 1 }} onClick={() => deleteCustomEx(ex, close)}>{t('Delete')}</Button></div>}+ {usesBar(ex) && <>+ <h4 className="sec">{t('Bar weight')}</h4>+ <BarWeightEditor ex={ex} extra={t('You still log the total weight — the bar only feeds the per-side plate math.')} />+ </>}{!isCardio(ex) && <OneRM ex={ex} />}{instrFor(ex).length > 0 &&<><h4 className="sec">{t('How to')}{!INSTR_LANGS.includes(getLang()) && <span className="dim" style={{ textTransform: 'none', letterSpacing: 0 }}> · {t('instructions in English')}</span>}</h4><ol className="steps-list">{instrFor(ex).map((s, i) => <li key={i}>{s}</li>)}</ol></>}</>@@ -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)}</div>}</>}+ {/* 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) && <>+ <h4 className="sec">{t('Bar weight')}</h4>+ <BarWeightEditor ex={ex} extra={t('Applies to this exercise everywhere, not just this plan.')} />+ </>}<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')}diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.jsindex b1f9e3416..028f766b8 100644--- a/frontend/src/store/useStore.js+++ b/frontend/src/store/useStore.js@@ -21,6 +21,10 @@ export const DEF = {// Equipment profiles (issue: filter Library/picker/routines by what you actually own —// e.g. "Home" vs "Gym" — building on the session-only equipment filter from issue #6).equipProfiles: [], activeEquipId: null, equipFilterOn: false,+ // Per-exercise bar weight overrides, keyed by exercise id, in the profile unit (see+ // lib/bar.js). Personal equipment, so it syncs with the account but never travels in a+ // shared plan. Logged weights stay the total — this only feeds the plate math.+ barWeights: {},}const clone = o => JSON.parse(JSON.stringify(o))diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsxindex fafab2613..a71bfc005 100644--- a/frontend/src/views/Workout.jsx+++ b/frontend/src/views/Workout.jsx@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom'import { useStore } from '../store/useStore.js'import { useUI } from '../store/useUI.js'import { exOr } from '../lib/exercises.js'+import { usesBar, barWeightFor, plateSplit } from '../lib/bar.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, applyIntensifierPlan, pinnedNoteFor, exNoteFor } from '../lib/history.js'import { fmtNum, fmtDate, todayISO, exCount, DAYN } from '../lib/format.js'import { beep, vibrate } from '../lib/sound.js'@@ -10,7 +11,7 @@ import { t, exerciseNameFor } from '../lib/i18n.js'import { api } from '../lib/api.js'import { insertionIndexAfterCurrentUnit, nextUnfinishedUnit, setProgressHighWater, supersetFlowStep, restAfterSet, restOnRecheck, restSecFor } from '../lib/supersetFlow.js'import Media from '../components/Media.jsx'-import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet, confirmSheet, exerciseNoteSheet, sessionNoteSheet, swapActiveWorkoutExercise } from '../sheets.jsx'+import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet, confirmSheet, exerciseNoteSheet, sessionNoteSheet, swapActiveWorkoutExercise, barWeightSheet } from '../sheets.jsx'import Icon from '../components/Icon.jsx'import { Button, Check, NumberField } from '../components/ui.jsx'import { nextPrescription, applyPrescription, defaultIncrement } from '../lib/progression.js'@@ -197,6 +198,23 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onAddSet, onRemov</div>}{entry.note && <div className="exnote">{entry.note}</div>}{last && <div className="small dim" style={{ marginBottom: 4 }}>{t('Last time')} ({fmtDate(last.d)}): {last.sets.map(s => setLabel(entry.id, s, last.target)).join(', ')}</div>}+ {/* Bar + plates for barbell work: what to load per side for the set in front of you+ (first undone set; the heaviest row once everything is checked). The logged number+ stays the total — this chip is the split, and tapping it edits the bar's own weight+ (S.barWeights, per exercise) mid-workout. Weight ≤ bar leaves just the bar. */}+ {!cardio && !(bw && !added) && usesBar(ex) && (() => {+ const bar = barWeightFor(S, entry.id)+ if (!(bar > 0)) return null+ const nextW = entry.sets.find(s => !s.done)?.w+ const refW = nextW > 0 ? nextW : Math.max(0, ...entry.sets.map(s => s.w || 0))+ const split = plateSplit(refW, bar)+ return <div style={{ marginBottom: 6 }}>+ <button className="chip nocap" style={{ display: 'inline-flex', alignItems: 'center', gap: 5 }} onClick={() => barWeightSheet(entry.id)}>+ <Icon name="dumbbell" style={{ fontSize: 12 }} />+ {t('Bar {0}', fmtNum(bar) + ' ' + S.unit)}{split != null ? ' · ' + t('{0} per side', fmtNum(split) + ' ' + S.unit) : ''}+ </button>+ </div>+ })()}{guidance && <button type="button" className={'progline' + (plan.kind === 'deload' ? ' warn' : '')}aria-label={t('Open progression settings')} onClick={onProgressionSettings}><Icon name={plan.kind === 'up' ? 'arrowUp' : plan.kind === 'deload' ? 'arrowDown' : 'lightbulb'} />