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
Merge !36: i18n: Arabic locale pack and RTL layout (smsmy)
Duarte Santosf8a9d9979ad9
diff --cc frontend/src/components/Heatmap.jsxindex aa3297327,ecfafa24c..16d1f95f7--- a/frontend/src/components/Heatmap.jsx+++ b/frontend/src/components/Heatmap.jsx@@@ -76,10 -51,8 +76,10 @@@ export default function Heatmap({ S, on}return <>+ <Segmented value={metric} onChange={changeMetric}+ options={[{ value: 'time', label: t('Time') }, { value: 'vol', label: t('Volume') }]} /><div className="hm-wrap" ref={wrapRef}>- <div className="hm-months" style={{ marginLeft: 30 }}>{months}</div>+ <div className="hm-months" style={{ marginInlineStart: 30 }}>{months}</div><div className="hm-body"><div className="hm-days">{dayLabels.map((lbl, i) => <span key={i}>{lbl ? t(lbl) : ''}</span>)}</div><div className="hm-grid">{cols}</div>diff --cc frontend/src/index.cssindex 63d439b4c,ccffa4117..0939eff85--- a/frontend/src/index.css+++ b/frontend/src/index.css@@@ -1070,9 -1040,7 +1070,9 @@@ body.chips-dragging *{cursor:inherit#timer.rest .head{display:flex;align-items:center;gap:12px}#timer.rest .acts{display:flex;align-items:center;gap:8px}#timer.rest .acts .btn{padding-top:11px;padding-bottom:11px} /* sweaty hands, mid-set */- #timer.rest .acts .skip{margin-left:auto;min-width:84px}+ #timer.rest .acts .skip{margin-inline-start:auto;min-width:84px}+/* A paused rest reads as held: the clock and the bar step back until it runs again. */+#timer.rest.paused .t,#timer.rest.paused .bar{opacity:.5}/* work timer (issue #16): the same bar doing the opposite job — outlined and tinted so aglance tells "you are holding this" apart from "you are recovering". */#timer.working{border:var(--hair) solid var(--acc)}diff --cc frontend/src/lib/i18n-core.jsindex 9c82755a2,e21cf4fa2..0e0358647--- a/frontend/src/lib/i18n-core.js+++ b/frontend/src/lib/i18n-core.js@@@ -6,15 -6,17 +6,17 @@@export const LANGS = {en: 'English', de: 'Deutsch', 'de-CH': 'Deutsch (Schweiz)', es: 'Español', fr: 'Français',it: 'Italiano', pt: 'Português (Portugal)', 'pt-BR': 'Português (Brasil)', pl: 'Polski',- tr: 'Türkçe', ru: 'Русский', zh: '中文',+ tr: 'Türkçe', ru: 'Русский', uk: 'Українська', zh: '中文',- ko: '한국어', hi: 'हिन्दी', th: 'ไทย', hu: 'Magyar'+ ko: '한국어', hi: 'हिन्दी', th: 'ไทย', hu: 'Magyar', ar: 'العربية'}- export const INSTR_LANGS = ['en', 'es', 'fr', 'it', 'tr', 'ru', 'zh', 'hi', 'pl', 'ko', 'pt-BR', 'hu']+ export const INSTR_LANGS = ['en', 'es', 'fr', 'it', 'tr', 'ru', 'zh', 'hi', 'pl', 'ko', 'pt-BR', 'hu', 'ar']-export const EXERCISE_NAME_LANGS = ['pt-BR', 'hu']+export const EXERCISE_NAME_LANGS = ['pt-BR', 'hu', 'de', 'es', 'ru', 'it', 'fr']+ // Languages rendered right-to-left; i18n.js setLang applies the direction from this.+ export const RTL_LANGS = new Set(['ar'])export const DATE_LOCALES = {en: 'en-GB', de: 'de-DE', 'de-CH': 'de-CH', es: 'es-ES', fr: 'fr-FR', it: 'it-IT',pt: 'pt-PT', 'pt-BR': 'pt-BR',- pl: 'pl-PL', tr: 'tr-TR', ru: 'ru-RU', uk: 'uk-UA', zh: 'zh-CN', ko: 'ko-KR', hi: 'hi-IN', th: 'th-TH', hu: 'hu-HU'- pl: 'pl-PL', tr: 'tr-TR', ru: 'ru-RU', zh: 'zh-CN', ko: 'ko-KR', hi: 'hi-IN', th: 'th-TH', hu: 'hu-HU', ar: 'ar-u-nu-latn'++ pl: 'pl-PL', tr: 'tr-TR', ru: 'ru-RU', uk: 'uk-UA', zh: 'zh-CN', ko: 'ko-KR', hi: 'hi-IN', th: 'th-TH', hu: 'hu-HU', ar: 'ar-u-nu-latn'}// Locales derived from another language by a pure text transform rather than carried as theirdiff --cc frontend/src/lib/i18n.jsindex 53b1c4b0a,a6ed51e9d..bc473caca--- a/frontend/src/lib/i18n.js+++ b/frontend/src/lib/i18n.js@@@ -5,14 -5,14 +5,14 @@@import { useSyncExternalStore } from 'react'import {- LANGS, INSTR_LANGS, EXERCISE_NAME_LANGS, DATE_LOCALES, DERIVED_LOCALES,+ LANGS, INSTR_LANGS, EXERCISE_NAME_LANGS, DATE_LOCALES, DERIVED_LOCALES, RTL_LANGS,getLang, dateLocale, t, instrFor, exerciseNameFor, exerciseNameSearchText, getVersion,- baseLang, derivePack, _setLangState+ baseLang, derivePack, _setLangState, exerciseNameClass} from './i18n-core.js'export {- LANGS, INSTR_LANGS, EXERCISE_NAME_LANGS, DATE_LOCALES, DERIVED_LOCALES,+ LANGS, INSTR_LANGS, EXERCISE_NAME_LANGS, DATE_LOCALES, DERIVED_LOCALES, RTL_LANGS,- getLang, dateLocale, t, instrFor, exerciseNameFor, exerciseNameSearchText+ getLang, dateLocale, t, instrFor, exerciseNameFor, exerciseNameSearchText, exerciseNameClass, baseLang}// Vite code-splits locale, instruction and exercise-name packs via import.meta.glob. They are@@@ -48,7 -40,9 +48,9 @@@ export async function setLang(l, showEn? null: (await exerciseNamePacks['../exercise-names/' + base + '.js']()).default} catch (e) { exerciseNames = null }- _setLangState(l, derivePack(l, dict), derivePack(l, instr), derivePack(l, exerciseNames))+ _setLangState(l, derivePack(l, dict), derivePack(l, instr), derivePack(l, exerciseNames), show, only)+ document.documentElement.lang = l+ document.documentElement.dir = RTL_LANGS.has(l) ? 'rtl' : 'ltr'notify()}diff --cc frontend/src/lib/plan-share.jsindex e4da29c64,964c524e4..afda0f4b2--- a/frontend/src/lib/plan-share.js+++ b/frontend/src/lib/plan-share.js@@@ -12,7 -12,7 +12,7 @@@ import { EXIDX, isBodyweightEq } from 'import { modeOf, fmtSec, isBw, isPerSide, sideReps, MAX_PLANNED_WARMUPS } from './history.js'import { deriveSessionName } from './session-merge.js'import { uid, todayISO, DAYN, weekOrder, weekStartOf, fmtNum, exCount } from './format.js'- import { t, exerciseNameFor, exerciseNameClass } from './i18n-core.js'-import { t, exerciseNameFor, getLang, RTL_LANGS } from './i18n-core.js'++import { t, exerciseNameFor, exerciseNameClass, getLang, RTL_LANGS } from './i18n-core.js'import { convertWeight } from './units.js'import { MUSCLES, inMuscleOrder } from './muscles.js'@@@ -390,9 -390,8 +390,9 @@@ 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: capitalize; 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-n .part { text-transform: capitalize; color: #9aa0ae; font-weight: 400; font-size: 12px; margin-inline-start: 8px; }.ex-s { color: #3d424e; white-space: nowrap; font-variant-numeric: tabular-nums; }.ex-note { color: #6a7080; font-size: 12px; margin-top: 2px; }.ex.empty, .none { color: #a2a8b6; }diff --cc frontend/src/sheets.jsxindex 743b69857,2168c295a..eb7fbda6a--- a/frontend/src/sheets.jsx+++ b/frontend/src/sheets.jsx@@@ -1790,10 -1699,10 +1790,10 @@@ 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 capitalize" 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}+ {e.notePin && <Icon name="flag" style={{ fontSize: 12, marginInlineEnd: 4, verticalAlign: '-1px', color: 'var(--yellow)' }} />}{e.note}</div>}</div></div>}@@@ -2331,11 -2166,11 +2331,11 @@@ function FinishSummary({ w, prs, e1prs<div className="tile"><div className="l">{t('Sets')}</div><div className="v" style={{ fontSize: '1.1rem' }}>{t('{0} sets · {1} work', setsDone(w), workSetsDone(w))}</div></div><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.length > 0 || e1prs.length > 0) && <div style={{ textAlign: 'start', marginBottom: 12 }}>- {prs.map(id => <div key={id} className="small accent capitalize row" style={{ gap: 5 }}><Icon name="trophy" style={{ fontSize: 13 }} />{t('New PR:')} {EXIDX[id] ? exerciseNameFor(EXIDX[id]) : id}</div>)}- {e1prs.map(p => <div key={p.id} className="small accent capitalize row" style={{ gap: 5 }}><Icon name="chartLine" style={{ fontSize: 13 }} />{t('Best estimated 1RM:')} {EXIDX[p.id] ? exerciseNameFor(EXIDX[p.id]) : p.id} · {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>+ <h4 className="sec" style={{ textAlign: 'start' }}>{t('What you just trained')}</h4><BodyMap load={loadOfWorkouts([w])} body={st.body} /><div style={{ height: 14 }} /><Button variant="primary" onClick={() => { close(); nav('/home') }}>{t('Nice!')}</Button>diff --cc frontend/src/store/useStore.jsindex d7a30fe3f,5f5bdca4a..e144c35f3--- a/frontend/src/store/useStore.js+++ b/frontend/src/store/useStore.js@@@ -5,13 -5,11 +5,14 @@@ import { t } from '../lib/i18n.jsimport { registerCustom } from '../lib/exercises.js'import { DEMO, DEMO_SEEDED } from '../lib/demo.js'import { guestAllowed } from '../lib/guest.js'-import { MOBILE, initReminderSync, nativeLoad, nativeSave, onAppActive, syncReminder, writeAutoBackup } from '../lib/mobile.js'-import { mergeStates, localExtras } from '../lib/sync-merge.js'-import { loadRemote, chooseLocal, forgetRemote, connect } from '../lib/remote.js'+import { MOBILE, initReminderSync, nativeLoad, nativeSave, onAppActive, readJsonFile, syncReminder, writeAutoBackup, writeJsonFile } from '../lib/mobile.js'+import { mergeStates, localExtras, stampRoutines } from '../lib/sync-merge.js'+import { countChanges, syncFingerprint } from '../lib/sync-changes.js'+import { saveWorkoutEdit } from '../lib/session-edit.js'+import { appBase } from '../lib/app-base.js'+import { loadRemote, chooseLocal, forgetRemote, connect, normalizeServerUrl, renewToken } from '../lib/remote.js'import { loadCoachDevice, saveCoachDevice, coachDeviceSettings } from '../lib/coach-device.js'+ import { RTL_LANGS } from '../lib/i18n-core.js'import { WC_DEFAULT } from '../lib/workout-controls.js'diff --cc frontend/src/views/Admin.jsxindex 7af4e69f8,4f779d5e4..1b8906c6a--- a/frontend/src/views/Admin.jsx+++ b/frontend/src/views/Admin.jsx@@@ -246,8 -237,8 +246,8 @@@ export default function Admin()return <div className="narrow"><div className="hdr"><button className="iconbtn" onClick={() => nav('/settings')} aria-label="Back"><Icon name="chevronLeft" /></button>- <div style={{ flex: 1, marginLeft: 8 }}><h1 style={{ margin: 0 }}>Admin</h1>+ <div style={{ flex: 1, marginInlineStart: 8 }}><h1 style={{ margin: 0 }}>Admin</h1>- <div className="sub">{users ? users.length + ' users · ' + activeCount + ' active this week' : 'Loading…'}</div></div>+ <div className="sub">{users ? users.length + ' users · ' + activeCount + ' active this week' : usersErr ? 'Could not load' : 'Loading…'}</div></div><button className="iconbtn" onClick={() => { loadUsers(); loadInvites(); setTick(n => n + 1) }} aria-label="refresh">↻</button></div><div className="adm-intro">diff --cc frontend/src/views/Settings.jsxindex 6f78050d1,50c3dcabb..d670402f3--- a/frontend/src/views/Settings.jsx+++ b/frontend/src/views/Settings.jsx@@@ -196,27 -183,25 +196,27 @@@ export default function Settings()return <div className="narrow"><div className="hdr"><button className="iconbtn" onClick={() => nav('/home')} aria-label={t('Home')}><Icon name="chevronLeft" /></button>- <div style={{ flex: 1, marginLeft: 10 }}><h1>{t('Settings')}</h1></div>+ <div style={{ flex: 1, marginInlineStart: 10 }}><h1>{t('Settings')}</h1></div></div>- {/* ---------- account (demo and mobile builds have nothing to sign in to) ---------- */}- <Section title={MOBILE ? (user ? t('Your server') : t('Your data')) : DEMO ? t('Demo') : t('Account')}>- {MOBILE ? (user ? <>- <Row icon="personCircle" iconTint="var(--grey)" title={user.name} subtitle={t('Synced with your openGym server.')} />+ {/* ---------- the server: which one, which account, how that stands, "Sync now" ----------+ A paired phone's Admin and Disconnect sit in the same block; a browser's account rows+ follow in their own. */}+ {user && !DEMO && <ServerSyncSection>+ {MOBILE && <>{user.admin && <Row icon="wrench" iconTint="var(--indigo)" title={t('Admin dashboard')} accessory="chevron" onClick={() => nav('/admin')} />}- <Row icon="signOut" iconTint="var(--red)" title={t('Disconnect')} danger onClick={() => confirmSheet({- title: t('Disconnect from your server?'),- message: t('Your data is synced to your server first, then this device switches back to local-only.'),- confirmText: t('Disconnect'), danger: true,- onConfirm: async () => { await disconnectServer(); nav('/home'); toast(t('Disconnected — back to local-only')) },- })} />- </> : <>+ <Row icon="signOut" iconTint="var(--red)" title={t('Disconnect')} danger onClick={disconnect} />+ </>}+ </ServerSyncSection>}++ {/* ---------- account (demo and mobile builds have nothing to sign in to) ---------- */}+ {!(MOBILE && user) && <Section title={MOBILE ? t('Your data') : DEMO ? t('Demo') : t('Account')}>+ {MOBILE ? <><Row icon="lock" iconTint="var(--acc)" title={t('All data stays on this phone')} subtitle={t('No account, no cloud — back it up anytime with Export below.')} /><Row icon="link" iconTint="var(--indigo)" title={t('Connect to my server')} subtitle={t('Sync this device to your own self-hosted openGym instead.')} accessory="chevron"- onClick={() => useUI.getState().openSheet(close => <ConnectSheet close={close} />)} />- </>) : DEMO ? <>+ onClick={connectServer} />+ <KeptChangesRows />+ </> : DEMO ? <><Row icon="sparkles" iconTint="var(--acc)" title={t('You’re in the demo')} subtitle={t('Example data, stored only in this browser — change anything you like.')} /><Row icon="reset" iconTint="var(--blue)" title={t('Reset demo data')} accessory="chevron"onClick={() => confirmSheet({ title: t('Reset demo data?'), message: t('Puts the example plan, workouts and weigh-ins back the way they started.'), confirmText: t('Reset'), onConfirm: () => { resetDemo(); nav('/home'); toast(t('Demo data reset')) } })} />