Skip to content

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.

Arabic: a per-side set on the last-time or best-set line reads in its own direction again, so each side word stays in front of its own numbers instead of behind them (#173)

Duarte Santos5bbefa646705
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index 3591e32c6..a0e309742 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -80,6 +80,11 @@ function Elapsed({ start }) {
// (cardio speed, stored in km/h) converts it for the screen.
const viewOf = (col, value) => (col.view && value != null && value !== '' ? col.view(value) : value)
+// Arabic and Hebrew letters, the presentation forms included. A set summary with one in it is a
+// per-side set in Arabic ("يسار 15×8 · يمين 15×7"): forced left to right, its side words stood
+// on the wrong side of their numbers and the numbers after them turned round (8×15).
+const RTL_LETTER = /[֐-ࣿיִ-﷿ﹰ-]/
+
/* ---------- one exercise block (reps: weight×reps · time: a held duration · cardio: duration+speed) ---------- */
// `compact` shrinks the block for a superset member; `dense` (compact view) goes further and
// drops everything that is not a set you are logging — media, tag chips, the note lines, the
@@ -210,8 +215,9 @@ function ExerciseBlock({ entryIdx, compact, dense, editing, onToggle, onToggleSi
title={refAction} aria-label={`${refText}. ${refAction}`}
onClick={() => update(s => { s.logRef = refBest ? 'last' : 'best' })}>
{/* Each set on its own left-to-right island. In Arabic the first one followed the label's
- direction and read 8×60, while those after a Latin "RIR" read 60×8. */}
- <span>{ref ? <>{refHead}{refSets.map((l, i) => <Fragment key={i}>{i ? ', ' : ''}<bdi dir="ltr">{l}</bdi></Fragment>)}</> : refText}</span>
+ direction and read 8×60, while those after a Latin "RIR" read 60×8. A set that carries
+ words of a right-to-left script keeps its own direction, still isolated (RTL_LETTER). */}
+ <span>{ref ? <>{refHead}{refSets.map((l, i) => <Fragment key={i}>{i ? ', ' : ''}<bdi dir={RTL_LETTER.test(l) ? 'auto' : 'ltr'}>{l}</bdi></Fragment>)}</> : refText}</span>
<Icon name="shuffle" />
</button> : null
// A bodyweight set has no weight to type, so the column is not there (issue #32) — one
diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsx
index d6dc7d14b..4fbff8178 100644
--- a/frontend/src/views/Workout.test.jsx
+++ b/frontend/src/views/Workout.test.jsx
@@ -1990,6 +1990,26 @@ describe('the reference line: last time or best set', () => {
expect(line().textContent).toMatch(/^Last time \(.+\): 60×8 \(RIR 3\), 60×8 \(RIR 2\)$/)
})
+ // A per-side set in Arabic carries its side words ("يسار 15×8 · يمين 15×7"). Forced left to
+ // right, each word stood on the wrong side of its numbers and the numbers after it turned
+ // round; isolated in its own direction it reads as before, next to sets that are forced.
+ it('leaves a set with right-to-left words in its own direction', async () => {
+ const { _setLangState } = await import('../lib/i18n-core.js')
+ const { default: ar } = await import('../locales/ar.js')
+ const side = r => ({ w: 15, r, done: true })
+ const sided = [{ d: '2026-08-26', start: Date.parse('2026-08-26T18:00:00'), routineIds: ['A'],
+ entries: [{ id: 'plain-bench', rid: 'A', target: { mode: 'reps', side: true, reps: 16, weight: 15, bodyweight: false },
+ sets: [{ w: 15, r: 15, done: true, sides: { L: side(8), R: side(7) } }] }] }]
+ _setLangState('ar', ar, null, null)
+ try {
+ await mount([exercise('plain-bench', [false], { rid: 'A' })], 0, { workouts: sided })
+ const sets = [...line().querySelectorAll('bdi')]
+ expect(sets.map(b => [b.getAttribute('dir'), b.textContent])).toEqual([['auto', `${ar.L} 15×8 · ${ar.R} 15×7`]])
+ } finally { _setLangState('en', null, null, null) }
+ await mount([exercise('plain-bench', [false], { rid: 'A' })], 0, { workouts: sided })
+ expect([...line().querySelectorAll('bdi')].map(b => [b.getAttribute('dir'), b.textContent])).toEqual([['ltr', 'L 15×8 · R 15×7']])
+ })
+
// The text is the reference; the name also says what a tap does, after the text it shows.
it('names the switch a tap makes', async () => {
await mount([exercise('plain-bench', [false], { rid: 'A' })], 0, { workouts: history })