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
Settings search: finds translated choices (Dunkel, Feste Woche) and matches English words from their start only
Duarte Santos220f6f5ac146
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.jsindex d536de3ce..eb2e78468 100644--- a/frontend/src/lib/pt-br-locale.test.js+++ b/frontend/src/lib/pt-br-locale.test.js@@ -41,7 +41,7 @@ describe('Brazilian Portuguese locale', () => {// has to be taught is a number nobody reads. What the numbers stood for is asserted above.// If the hash fails, review the changed keys and wording before accepting a new one. From// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list- expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('12899354b2d8c1a864ebc5aaf65747ca9d5ab8b9cd00e8ad591c5af457085c8b')+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('4da56efa8354bfc0964ccfaeb7f69d760b00f83ce86853545e8b6b6a90b18b63')})test('does not leak European Portuguese UI terms', () => {diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex 74e633e59..1d0a9eeb8 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -1936,4 +1936,5 @@ export default {'Delete {0}': 'حذف {0}','Move {0}': 'نقل {0}','Build your loop in Plan': 'أنشئ دورتك في الخطة',+ 'week start': 'بداية الأسبوع',}diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex cd2d6335d..08afb1979 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -1903,4 +1903,5 @@ export default {'Delete {0}': '{0} löschen','Move {0}': '{0} verschieben','Build your loop in Plan': 'Kreislauf im Plan erstellen',+ 'week start': 'Wochenstart',}diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex af554bb97..63c4b6840 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -1883,4 +1883,5 @@ export default {'Delete {0}': 'Eliminar {0}','Move {0}': 'Mover {0}','Build your loop in Plan': 'Crea tu bucle en Plan',+ 'week start': 'inicio de semana',}diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 73a4c866f..bd33dfc0d 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -1883,4 +1883,5 @@ export default {'Delete {0}': 'Supprimer {0}','Move {0}': 'Déplacer {0}','Build your loop in Plan': 'Crée ta boucle dans Plan',+ 'week start': 'début de semaine',}diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex 2b4654a14..c02440d85 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -1883,4 +1883,5 @@ export default {'Delete {0}': '{0} मिटाएँ','Move {0}': '{0} खिसकाएँ','Build your loop in Plan': 'योजना में अपना चक्र बनाएं',+ 'week start': 'सप्ताह की शुरुआत',}diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 61085566e..43e73aee2 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -1886,4 +1886,5 @@ export default {'Delete {0}': '{0} törlése','Move {0}': '{0} áthelyezése','Build your loop in Plan': 'Állítsd össze a köröd a Tervben',+ 'week start': 'hét kezdete',}diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 8fbdb0402..167cd3c47 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -1883,4 +1883,5 @@ export default {'Delete {0}': 'Elimina {0}','Move {0}': 'Sposta {0}','Build your loop in Plan': 'Crea il tuo ciclo in Piano',+ 'week start': 'inizio settimana',}diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 5b2d6c264..d14b447e8 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -1883,4 +1883,5 @@ export default {'Delete {0}': '{0} 삭제','Move {0}': '{0} 이동','Build your loop in Plan': '계획에서 순환 만들기',+ 'week start': '주 시작',}diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex 74775564a..38beb0f0e 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -1883,4 +1883,5 @@ export default {'Delete {0}': 'Usuń {0}','Move {0}': 'Przenieś {0}','Build your loop in Plan': 'Zbuduj pętlę w Planie',+ 'week start': 'początek tygodnia',}diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 1ccb37b05..541d49e3d 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -1883,4 +1883,5 @@ export default {'Delete {0}': 'Eliminar {0}','Move {0}': 'Mover {0}','Build your loop in Plan': 'Crie o seu ciclo no Plano',+ 'week start': 'início da semana',}diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 74ccb3995..742fd8370 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -1887,4 +1887,5 @@ export default {'Delete {0}': 'Удалить {0}','Move {0}': 'Переместить {0}','Build your loop in Plan': 'Собери круг в Плане',+ 'week start': 'начало недели',}diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 19e102e33..8ccff505a 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -1894,4 +1894,5 @@ export default {'Delete {0}': 'ลบ {0}','Move {0}': 'ย้าย {0}','Build your loop in Plan': 'สร้างการวนรอบในแผน',+ 'week start': 'วันเริ่มสัปดาห์',}diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 1d27f0320..3fabcb317 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -1883,4 +1883,5 @@ export default {'Delete {0}': '{0} sil','Move {0}': '{0} taşı','Build your loop in Plan': 'Döngünü Plan\'da oluştur',+ 'week start': 'hafta başlangıcı',}diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex 45488f214..510aea9d5 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -1880,4 +1880,5 @@ export default {'Delete {0}': 'Видалити {0}','Move {0}': 'Перемістити {0}','Build your loop in Plan': 'Збери коло в Плані',+ 'week start': 'початок тижня',}diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.jsindex fb5d1d011..b5e621879 100644--- a/frontend/src/locales/zh-TW.js+++ b/frontend/src/locales/zh-TW.js@@ -1876,4 +1876,5 @@ export default {'Delete {0}': '刪除 {0}','Move {0}': '移動 {0}','Build your loop in Plan': '在計畫中建立循環',+ 'week start': '每週開始',}diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex 935fc565f..7503b45e1 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -1883,4 +1883,5 @@ export default {'Delete {0}': '删除 {0}','Move {0}': '移动 {0}','Build your loop in Plan': '在计划中创建循环',+ 'week start': '每周开始',}diff --git a/frontend/src/views/settings-pages.js b/frontend/src/views/settings-pages.jsindex 56152b483..27b282e09 100644--- a/frontend/src/views/settings-pages.js+++ b/frontend/src/views/settings-pages.js@@ -6,6 +6,7 @@// by the same text and flash it (views/Settings.jsx). settings-pages.test.jsx renders every page// and checks that each entry below really is a row there.import { t } from '../lib/i18n.js'+import { ACCENT_NAMES } from '../lib/format.js'export const PAGES = {workout: { title: 'Workout', icon: 'play', tint: 'var(--green)' },@@ -38,7 +39,9 @@ export function pageVisible(page, ctx) {}// One entry per row. `kw` is extra words people search for (English; the translated title and-// page name are searched too). `when` repeats the row's own visibility rule, so a search never+// page name are searched too). `opts` are the English labels of a segmented or picker row's+// choices, searched in both languages, so "Dunkel" finds Theme; `tkw` is a word in the app's own+// language for a row whose title does not say it ("Wochenstart"). `when` repeats the row's own visibility rule, so a search never// offers a row the page would not show. The one rule a search cannot know in advance is whether// this browser's push subscription is on (the server is asked when the page opens): those rows// name `via`, the row the hit flashes instead when they turn out not to be there.@@ -50,15 +53,15 @@ export const SEARCH = [// Workout{ page: 'workout', title: 'Rest timer', icon: 'timer', tint: 'var(--orange)', kw: 'rest pause break seconds minutes timer countdown' },{ page: 'workout', title: 'Rest-pause rest', icon: 'bolt', tint: 'var(--orange)', kw: 'burst cluster rest pause' },- { page: 'workout', title: 'Effort per set', icon: 'gauge', tint: 'var(--purple)', kw: 'rir rpe effort reps in reserve difficulty' },- { page: 'workout', title: 'Shown under each exercise', icon: 'history', tint: 'var(--blue)', kw: 'last time best set reference previous' },- { page: 'workout', title: 'Layout', icon: 'layout', tint: 'var(--blue)', kw: 'workout view cards list compact' },+ { page: 'workout', title: 'Effort per set', icon: 'gauge', tint: 'var(--purple)', kw: 'rir rpe effort reps in reserve difficulty', opts: ['RIR', 'RPE'] },+ { page: 'workout', title: 'Shown under each exercise', icon: 'history', tint: 'var(--blue)', kw: 'last time best set reference previous', opts: ['Last time', 'Best set'] },+ { page: 'workout', title: 'Layout', icon: 'layout', tint: 'var(--blue)', kw: 'workout view cards list compact', opts: ['Cards', 'List', 'Compact'] },{ page: 'workout', title: 'Weigh in before workouts', icon: 'scale', tint: 'var(--green)', kw: 'body weight weigh scale start' },{ page: 'workout', title: 'Keep screen awake', icon: 'phoneScreen', tint: 'var(--yellow)', kw: 'wake lock screen sleep display on', when: c => c.wakeOK || !c.mobile },- { page: 'workout', title: 'Exercise animations', icon: 'image', tint: 'var(--teal)', kw: 'gif animation video media pictures images' },+ { page: 'workout', title: 'Exercise animations', icon: 'image', tint: 'var(--teal)', kw: 'gif animation video media pictures images', opts: ['Full', 'Small', 'Hidden'] },{ page: 'workout', title: 'Fine-tuning', icon: 'wrench', tint: 'var(--grey)', kw: 'advanced more options' },// Fine-tuning- { page: 'advanced', title: 'Planned sessions start from', icon: 'clipboard', tint: 'var(--green)', kw: 'start from plan last session reps carry over' },+ { page: 'advanced', title: 'Planned sessions start from', icon: 'clipboard', tint: 'var(--green)', kw: 'start from plan last session reps carry over', opts: ['Your plan', 'Your last session'] },{ page: 'advanced', title: 'Keep timing after target', icon: 'stopwatch', tint: 'var(--orange)', kw: 'timed set overtime hold duration' },{ page: 'advanced', title: 'Weight and reps buttons', icon: 'plusCircle', tint: 'var(--green)', kw: 'steppers plus minus buttons workout controls' },{ page: 'advanced', title: 'Drop and burst shortcuts on every set', icon: 'bolt', tint: 'var(--orange)', kw: 'drop set burst shortcuts workout controls' },@@ -66,7 +69,7 @@ export const SEARCH = [{ page: 'advanced', title: 'Move, swap and remove buttons below the exercise', icon: 'swap', tint: 'var(--teal)', kw: 'move swap remove replace workout controls' },// Timer alerts{ page: 'alerts', title: 'Play a sound', icon: 'speaker', tint: 'var(--pink)', kw: 'sound sounds audio beep chime volume' },- { page: 'alerts', title: 'Sound', icon: 'bell', tint: 'var(--pink)', kw: 'classic timer sound beep chime tone', when: c => c.sound },+ { page: 'alerts', title: 'Sound', icon: 'bell', tint: 'var(--pink)', kw: 'classic timer sound beep chime tone', opts: ['Chime (louder)', 'Classic beeps'], when: c => c.sound },{ page: 'alerts', title: 'Play even on silent', icon: 'speaker', tint: 'var(--orange)', kw: 'silent mute ring switch iphone music', when: c => c.sound && c.playOnSilent },{ page: 'alerts', title: 'Vibrate', icon: 'vibrate', tint: 'var(--indigo)', kw: 'vibrate vibration haptic haptics buzz' },{ page: 'alerts', title: 'Vibrate on silent too', icon: 'vibrate', tint: 'var(--indigo)', kw: 'alarm silent vibrate android', when: c => c.mobile && c.android && c.canVibrate && c.vibrate },@@ -76,11 +79,11 @@ export const SEARCH = [{ page: 'reminders', title: 'Workout day reminder', icon: 'calendar', tint: 'var(--orange)', kw: 'reminder notification remind', when: remind, via: PUSH },{ page: 'reminders', title: 'Reminder time', icon: 'clock', tint: 'var(--purple)', kw: 'reminder time clock hour when', when: c => remind(c) && c.reminderOn, via: PUSH },{ page: 'reminders', title: 'Nudge me when I skip a planned workout', icon: 'bell', tint: 'var(--red)', kw: 'nudge skip missed motivation', when: c => remind(c) && c.reminderOn, via: PUSH },- { page: 'reminders', title: 'Nudge tone', icon: 'chat', tint: 'var(--blue)', kw: 'nudge tone friendly guilt drill sergeant', when: c => remind(c) && c.reminderOn && c.nudge, via: PUSH },+ { page: 'reminders', title: 'Nudge tone', icon: 'chat', tint: 'var(--blue)', kw: 'nudge tone friendly guilt drill sergeant', opts: ['Friendly', 'Guilt trip', 'Drill sergeant'], when: c => remind(c) && c.reminderOn && c.nudge, via: PUSH },{ page: 'reminders', title: 'Send test notification', icon: 'bell', tint: 'var(--red)', kw: 'test push notification try', when: c => !c.mobile && c.pushOK, via: PUSH },// Plan & schedule- { page: 'plan', title: 'How you train', icon: 'repeat', tint: 'var(--orange)', kw: 'scheduling schedule rotation fixed week split' },- { page: 'plan', title: 'Week starts on', icon: 'calendar', tint: 'var(--orange)', kw: 'monday sunday first day week' },+ { page: 'plan', title: 'How you train', icon: 'repeat', tint: 'var(--orange)', kw: 'scheduling schedule rotation fixed week split', opts: ['Fixed Week', 'Rotation'] },+ { page: 'plan', title: 'Week starts on', icon: 'calendar', tint: 'var(--orange)', kw: 'monday sunday first day week', opts: ['Monday', 'Sunday'], tkw: () => t('week start') },{ page: 'plan', title: 'Load starter plan', icon: 'clipboard', tint: 'var(--green)', kw: 'starter template beginner program routine' },// Units & language{ page: 'units', title: 'Language', icon: 'globe', tint: 'var(--blue)', kw: 'language translation idioma sprache langue lingua' },@@ -95,9 +98,9 @@ export const SEARCH = [{ page: 'equipment', title: 'Active profile', icon: 'house', tint: 'var(--blue)', kw: 'equipment profile home gym', when: c => c.profiles },{ page: 'equipment', title: 'Add equipment profile', icon: 'plusCircle', tint: 'var(--green)', kw: 'equipment profile home gym hotel' },// Look & Home- { page: 'look', title: 'Theme', icon: 'moon', tint: 'var(--indigo)', kw: 'dark mode light mode theme appearance night' },- { page: 'look', title: 'Accent color', icon: 'palette', tint: 'var(--purple)', kw: 'color colour accent tint' },- { page: 'look', title: 'Body diagram', icon: 'figureStrength', tint: 'var(--teal)', kw: 'muscle map body male female' },+ { page: 'look', title: 'Theme', icon: 'moon', tint: 'var(--indigo)', kw: 'dark mode light mode theme appearance night', opts: ['Dark', 'Light', 'System'] },+ { page: 'look', title: 'Accent color', icon: 'palette', tint: 'var(--purple)', kw: 'color colour accent tint', opts: Object.values(ACCENT_NAMES) },+ { page: 'look', title: 'Body diagram', icon: 'figureStrength', tint: 'var(--teal)', kw: 'muscle map body male female', opts: ['Male', 'Female'] },{ page: 'look', title: 'Gym check-in', icon: 'qr', tint: 'var(--blue)', kw: 'qr code membership card check in barcode' },{ page: 'look', title: 'Body weight', icon: 'scale', tint: 'var(--green)', kw: 'weight card home' },{ page: 'look', title: 'Show connection status', icon: 'cloud', tint: 'var(--blue)', kw: 'sync offline banner bar connection', when: c => !c.demo },@@ -138,6 +141,12 @@ export const SEARCH = [// Lower case, accents and other marks dropped, so "théme", "Thème" and "theme" meet.export const fold = s => String(s || '').normalize('NFD').replace(/\p{M}/gu, '').toLowerCase()+const WORD_CHAR = /[\p{L}\p{N}]/u+const atWordStart = (hay, w) => {+ for (let i = hay.indexOf(w); i !== -1; i = hay.indexOf(w, i + 1)) if (i === 0 || !WORD_CHAR.test(hay[i - 1])) return true+ return false+}+/** The trail a hit names under its title: "Workout" or "Workout › Fine-tuning". */export function pageTrail(page, tr = t) {const p = PAGES[page]@@ -158,8 +167,14 @@ export function searchSettings(query, ctx, tr = t) {const hits = []const consider = (entry, isPage) => {const title = tr(entry.title)- const hay = fold([title, entry.title, entry.kw || '', isPage ? '' : pageTrail(entry.page, tr), isPage ? '' : PAGES[entry.page]?.title].join(' '))- if (!words.every(w => hay.includes(w))) return+ const opts = entry.opts || []+ // What the screen says, in the app's language: anywhere in a word, since German and others+ // build long compounds ("Wochenstart", "Pausentimer").+ const own = fold([title, ...opts.map(o => tr(o)), entry.tkw ? entry.tkw() : '', isPage ? '' : pageTrail(entry.page, tr)].join(' '))+ // The English words behind it: only from the start of a word, so a "ton" typed in German+ // does not find "buttons".+ const en = fold([entry.title, entry.kw || '', ...opts, isPage ? '' : PAGES[entry.page]?.title].join(' '))+ if (!words.every(w => own.includes(w) || atWordStart(en, w))) returnconst ft = fold(title)const rank = ft.startsWith(q) ? 0 : ft.includes(q) ? 1 : isPage ? 2 : 3hits.push({ ...entry, label: title, trail: isPage ? tr('Settings') : pageTrail(entry.page, tr), isPage, rank })diff --git a/frontend/src/views/settings-pages.test.jsx b/frontend/src/views/settings-pages.test.jsxindex 3074a24ed..15c5d84f8 100644--- a/frontend/src/views/settings-pages.test.jsx+++ b/frontend/src/views/settings-pages.test.jsx@@ -369,6 +369,32 @@ describe('searchSettings', () => {const hits = searchSettings('vibration', guestWeb, s => de[s] || s)expect(hits[0]).toMatchObject({ title: 'Vibrate', label: 'Vibration', trail: 'Timer-Hinweise' })})++ it('finds the translated choices of a row, and words of its own language', async () => {+ const { setLang, t } = await import('../lib/i18n.js')+ try {+ await setLang('de')+ const first = q => searchSettings(q, guestWeb, t)[0]?.title+ expect(first('Dunkel')).toBe('Theme')+ expect(first('Feste Woche')).toBe('How you train')+ expect(first('Wochenstart')).toBe('Week starts on')+ expect(first('kompakt')).toBe('Layout')+ await setLang('ar')+ expect(searchSettings('تناوب', guestWeb, t).map(h => h.title)).toContain('How you train')+ } finally { await setLang('en') }+ })++ it('English words match from the start of a word only, so "ton" never finds "buttons"', async () => {+ const { setLang, t } = await import('../lib/i18n.js')+ try {+ await setLang('de')+ const titles = searchSettings('ton', guestWeb, t).map(h => h.title)+ expect(titles).not.toContain('Weight and reps buttons')+ expect(titles).not.toContain('Superset buttons in the exercise header')+ } finally { await setLang('en') }+ expect(searchSettings('tone', { ...guestWeb, user: { id: 'u' }, pushOK: true, reminderOn: true, nudge: true }, s => s).map(h => h.title)).toContain('Nudge tone')+ expect(searchSettings('json', guestWeb, s => s).map(h => h.title)).toContain('Export backup (JSON)')+ })})describe('translations', () => {