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.

Exercises: other names behind an "Add another name" line, Swedish, imports in place (#624)

Duarte Santos3d455e66762c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index afd011079..3893857b7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -32,6 +32,10 @@ per muscle. Settings → Workout → Fine-tuning turns it off.
- **The AI Coach is one tap away for admins** (#683, thanks TheBlackSide243). On a server that
offers the Coach, admins now find an AI Coach row in Settings, right next to Look, that opens
the admin dashboard straight at the Coach card.
+- **Call an exercise what you call it** (#624, thanks Space-Hermes). "Add another name" under an
+ exercise's tags (or in your own exercise's form) gives it other names, like OHP for the overhead
+ press, and the search finds it by those too. They sync between your devices and travel with
+ your own exercises in shared plans.
- **Discard means discard, on the Apple Watch too** (#776). Discarding a workout on the phone
while the watch follows it used to save it to Apple Health anyway, calories and all. Now the
watch drops it and Apple Health never hears about it.
diff --git a/frontend/src/components/ExerciseAliases.jsx b/frontend/src/components/ExerciseAliases.jsx
index ef4dedf1a..8e47bab27 100644
--- a/frontend/src/components/ExerciseAliases.jsx
+++ b/frontend/src/components/ExerciseAliases.jsx
@@ -4,24 +4,36 @@ import { exerciseAliases, normalizeAliases } from '../lib/exercise-aliases.js'
import { isCustomEx } from '../lib/exercises.js'
import { t } from '../lib/i18n.js'
import { Button } from './ui.jsx'
+import Icon from './Icon.jsx'
-export function ExerciseAliasesField({ value, onChange }) {
+// Other names an exercise is found by (#624). A power feature, so it stays one quiet line until
+// someone asks for it: "Add another name", or the names already given, and only a tap opens the field.
+export function ExerciseAliasesField({ value, onChange, autoFocus }) {
const id = useId()
return <div style={{ marginTop: 12 }}>
- <label className="small muted" htmlFor={id}>{t('Aliases')}</label>
- <input id={id} className="input" value={value} onChange={e => onChange(e.target.value)}
+ <label className="small muted" htmlFor={id}>{t('Other names')}</label>
+ <input id={id} className="input" value={value} onChange={e => onChange(e.target.value)} autoFocus={autoFocus}
maxLength={1640} aria-describedby={id + '-help'} />
- <div id={id + '-help'} className="small dim">{t('Alternative names for search. Separate with commas.')}</div>
+ <div id={id + '-help'} className="small dim">{t('The search finds it by these too. Separate them with commas.')}</div>
</div>
}
+/** The closed state of the field: what it is called besides its name, or the offer to add one. */
+export function ExerciseAliasesLink({ names, onOpen }) {
+ return <button type="button" className="small dim exfix-link exalias-link" onClick={onOpen}>
+ <Icon name={names.length ? 'pencil' : 'plus'} /> {names.length ? t('Also called {0}', names.join(', ')) : t('Add another name')}
+ </button>
+}
+
export default function ExerciseAliasesEditor({ ex }) {
const st = useStore(s => s.S)
const update = useStore(s => s.update)
const current = isCustomEx(ex) ? st.customEx?.find(c => c.id === ex.id) || ex : ex
const saved = exerciseAliases(current, st.exAliases)
- const [value, setValue] = useState(() => saved.join(', '))
+ const [open, setOpen] = useState(false)
+ const [value, setValue] = useState('')
const aliases = normalizeAliases(value)
+ if (!open) return <ExerciseAliasesLink names={saved} onOpen={() => { setValue(saved.join(', ')); setOpen(true) }} />
const save = () => {
update(s => {
if (isCustomEx(ex)) {
@@ -29,10 +41,10 @@ export default function ExerciseAliasesEditor({ ex }) {
if (c) c.aliases = aliases
} else s.exAliases = { ...s.exAliases, [ex.id]: aliases }
})
- setValue(aliases.join(', '))
+ setOpen(false)
}
return <>
- <ExerciseAliasesField value={value} onChange={setValue} />
- <Button onClick={save} disabled={JSON.stringify(aliases) === JSON.stringify(saved)} style={{ marginTop: 8 }}>{t('Save aliases')}</Button>
+ <ExerciseAliasesField value={value} onChange={setValue} autoFocus />
+ <Button onClick={save} disabled={JSON.stringify(aliases) === JSON.stringify(saved)} style={{ marginTop: 8 }}>{t('Save names')}</Button>
</>
}
diff --git a/frontend/src/lib/exercises.js b/frontend/src/lib/exercises.js
index 5ab4a0310..0462d44aa 100644
--- a/frontend/src/lib/exercises.js
+++ b/frontend/src/lib/exercises.js
@@ -1,8 +1,8 @@
-import { exerciseAliases, aliasSnapshot } from './exercise-aliases.js'
import { EXDB, EXALIAS } from './exercises-data.js'
import MUSCLE_MAP from './exercise-muscle-map.json' with { type: 'json' }
import V13_IDS from './catalogue-v13-ids.json' with { type: 'json' }
import { t, getVersion, exerciseNameSearchText } from './i18n-core.js'
+import { exerciseAliases, aliasSnapshot } from './exercise-aliases.js'
export { EXDB }
diff --git a/frontend/src/lib/plan-share.js b/frontend/src/lib/plan-share.js
index 2f47c8edf..4ae289a40 100644
--- a/frontend/src/lib/plan-share.js
+++ b/frontend/src/lib/plan-share.js
@@ -1,4 +1,3 @@
-import { normalizeAliases } from './exercise-aliases.js'
// Share a weekly plan.
//
// Two jobs:
@@ -26,6 +25,7 @@ import { clampIncline, hasIncline } from './incline.js'
import { MUSCLES, inMuscleOrder } from './muscles.js'
import { SG_NAME_MAX } from './superset-meta.js'
import { esc, printShell, printDocument, probeMarks } from './print-doc.js'
+import { normalizeAliases } from './exercise-aliases.js'
const PLAN_FMT = 1
const WEEK_DAYS = [1, 2, 3, 4, 5, 6, 0] // every getDay() index; only the reader's own
diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js
index 520b04aa8..f2422b5dd 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('bd12d28e6831c52457fafb4a0839dcd525f1a855a87735c56f7b6eb7bed47684')
+ expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('be751d61beddb8ba099effdfc15b9e416f8b74556838c9c03be644ca276905d2')
})
// pt-PT labelled Unpair 'Desfazer': Undo, in Portuguese (it is pt-BR's Undo), on the button that
diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.js
index 64e5d2eca..a7e7e8be3 100644
--- a/frontend/src/locales/ar.js
+++ b/frontend/src/locales/ar.js
@@ -1,8 +1,5 @@
// Arabic UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "أسماء بديلة",
- "Alternative names for search. Separate with commas.": "أسماء بديلة للبحث. افصل بينها بفواصل.",
- "Save aliases": "حفظ الأسماء البديلة",
'Confirm': 'تأكيد',
'Cancel': 'إلغاء',
'Press back again to exit': 'اضغط زر الرجوع مرة أخرى للخروج',
@@ -437,6 +434,11 @@ export default {
'Create your own exercise': 'أنشئ تمرينك الخاص',
'Edit custom exercise': 'تعديل تمرين مخصص',
'Exercise name': 'اسم التمرين',
+ 'Other names': 'أسماء أخرى',
+ 'The search finds it by these too. Separate them with commas.': 'يجده البحث بهذه الأسماء أيضًا. افصل بينها بفواصل.',
+ 'Add another name': 'أضف اسمًا آخر',
+ 'Also called {0}': 'يُعرف أيضًا باسم {0}',
+ 'Save names': 'حفظ الأسماء',
'Create exercise': 'إنشاء تمرين',
'Give it a name': 'أعطه اسماً',
'Pick a body part': 'اختر عضلة',
diff --git a/frontend/src/locales/bn.js b/frontend/src/locales/bn.js
index 05d00326a..033c13bc9 100644
--- a/frontend/src/locales/bn.js
+++ b/frontend/src/locales/bn.js
@@ -1,8 +1,5 @@
// Bengali UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "বিকল্প নাম",
- "Alternative names for search. Separate with commas.": "অনুসন্ধানের জন্য বিকল্প নাম। কমা দিয়ে আলাদা করুন।",
- "Save aliases": "বিকল্প নাম সংরক্ষণ করুন",
'Confirm': 'নিশ্চিত করুন',
'Cancel': 'বাতিল',
'Press back again to exit': 'বের হতে আবার ব্যাক চাপুন',
@@ -616,6 +613,11 @@ export default {
'Create your own exercise': 'নিজের ব্যায়াম তৈরি করুন',
'Edit custom exercise': 'কাস্টম ব্যায়াম সম্পাদনা করুন',
'Exercise name': 'ব্যায়ামের নাম',
+ 'Other names': 'অন্য নাম',
+ 'The search finds it by these too. Separate them with commas.': 'এই নামগুলো দিয়েও সার্চে এটা পাওয়া যাবে। কমা দিয়ে আলাদা করুন।',
+ 'Add another name': 'আরেকটি নাম যোগ করুন',
+ 'Also called {0}': 'একে {0}-ও বলা হয়',
+ 'Save names': 'নামগুলো সেভ করুন',
'Create exercise': 'ব্যায়াম তৈরি করুন',
'Give it a name': 'একটি নাম দিন',
'Pick a body part': 'শরীরের অংশ বেছে নিন',
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index 0251c21fa..d22bec1cb 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -1,8 +1,5 @@
// German UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "Alternative Namen",
- "Alternative names for search. Separate with commas.": "Alternative Namen für die Suche. Mit Kommas trennen.",
- "Save aliases": "Alternative Namen speichern",
// --- generic ---
'Confirm': 'Bestätigen',
'Cancel': 'Abbrechen',
@@ -549,6 +546,11 @@ export default {
'Create your own exercise': 'Eigene Übung erstellen',
'Edit custom exercise': 'Eigene Übung bearbeiten',
'Exercise name': 'Übungsname',
+ 'Other names': 'Andere Namen',
+ 'The search finds it by these too. Separate them with commas.': 'Die Suche findet sie auch darunter. Mit Kommas trennen.',
+ 'Add another name': 'Weiteren Namen hinzufügen',
+ 'Also called {0}': 'Auch genannt: {0}',
+ 'Save names': 'Namen speichern',
'Create exercise': 'Übung erstellen',
'Give it a name': 'Gib ihr einen Namen',
'Pick a body part': 'Wähle eine Körperpartie',
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index 6f1e57818..e5ed22d4a 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -1,8 +1,5 @@
// Spanish UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "Alias",
- "Alternative names for search. Separate with commas.": "Nombres alternativos para buscar. Sepáralos con comas.",
- "Save aliases": "Guardar alias",
'Confirm': 'Confirmar',
'Cancel': 'Cancelar',
'Press back again to exit': 'Pulsa atrás otra vez para salir',
@@ -530,6 +527,11 @@ export default {
'Create your own exercise': 'Crea tu propio ejercicio',
'Edit custom exercise': 'Editar ejercicio propio',
'Exercise name': 'Nombre del ejercicio',
+ 'Other names': 'Otros nombres',
+ 'The search finds it by these too. Separate them with commas.': 'La búsqueda también lo encuentra por estos. Sepáralos con comas.',
+ 'Add another name': 'Añadir otro nombre',
+ 'Also called {0}': 'También llamado {0}',
+ 'Save names': 'Guardar nombres',
'Create exercise': 'Crear ejercicio',
'Give it a name': 'Ponle un nombre',
'Pick a body part': 'Elige una parte del cuerpo',
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index f00a659d1..17e33ccb3 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -1,8 +1,5 @@
// French UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "Autres noms",
- "Alternative names for search. Separate with commas.": "Autres noms pour la recherche. Sépare-les par des virgules.",
- "Save aliases": "Enregistrer les autres noms",
'Confirm': 'Confirmer',
'Cancel': 'Annuler',
'Press back again to exit': 'Appuie de nouveau pour quitter',
@@ -530,6 +527,11 @@ export default {
'Create your own exercise': 'Créer ton propre exercice',
'Edit custom exercise': 'Modifier l’exercice personnalisé',
'Exercise name': 'Nom de l’exercice',
+ 'Other names': 'Autres noms',
+ 'The search finds it by these too. Separate them with commas.': 'La recherche le trouve aussi avec ces noms. Sépare-les par des virgules.',
+ 'Add another name': 'Ajouter un autre nom',
+ 'Also called {0}': 'Aussi appelé {0}',
+ 'Save names': 'Enregistrer les noms',
'Create exercise': 'Créer l’exercice',
'Give it a name': 'Donne-lui un nom',
'Pick a body part': 'Choisis une partie du corps',
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index 057492a9a..da47d026a 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -1,8 +1,5 @@
// Hindi UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "वैकल्पिक नाम",
- "Alternative names for search. Separate with commas.": "खोज के लिए वैकल्पिक नाम। कॉमा से अलग करें।",
- "Save aliases": "वैकल्पिक नाम सहेजें",
'Confirm': 'पुष्टि करें',
'Cancel': 'रद्द करें',
'Press back again to exit': 'बाहर निकलने के लिए फिर से बैक दबाएँ',
@@ -530,6 +527,11 @@ export default {
'Create your own exercise': 'अपनी एक्सरसाइज़ बनाएं',
'Edit custom exercise': 'कस्टम एक्सरसाइज़ संपादित करें',
'Exercise name': 'एक्सरसाइज़ का नाम',
+ 'Other names': 'दूसरे नाम',
+ 'The search finds it by these too. Separate them with commas.': 'खोज इन नामों से भी इसे ढूंढ लेती है। इन्हें कॉमा से अलग करें।',
+ 'Add another name': 'एक और नाम जोड़ें',
+ 'Also called {0}': 'इसे {0} भी कहते हैं',
+ 'Save names': 'नाम सेव करें',
'Create exercise': 'एक्सरसाइज़ बनाएं',
'Give it a name': 'कोई नाम दें',
'Pick a body part': 'एक बॉडी पार्ट चुनें',
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index 7b4bf950d..ff3891c01 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -1,8 +1,5 @@
// Hungarian UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "Más elnevezések",
- "Alternative names for search. Separate with commas.": "Alternatív nevek a kereséshez. Vesszővel válaszd el őket.",
- "Save aliases": "Elnevezések mentése",
// --- generic ---
'Confirm': 'Megerősítés',
'Cancel': 'Mégse',
@@ -534,6 +531,11 @@ export default {
'Create your own exercise': 'Saját gyakorlat létrehozása',
'Edit custom exercise': 'Egyéni gyakorlat szerkesztése',
'Exercise name': 'Gyakorlat neve',
+ 'Other names': 'Más nevek',
+ 'The search finds it by these too. Separate them with commas.': 'A keresés ezeken a neveken is megtalálja. Vesszővel válaszd el őket.',
+ 'Add another name': 'Másik név hozzáadása',
+ 'Also called {0}': 'Más néven: {0}',
+ 'Save names': 'Nevek mentése',
'Create exercise': 'Gyakorlat létrehozása',
'Give it a name': 'Adj neki egy nevet',
'Pick a body part': 'Válassz testrészt',
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index abb821037..d9586f6a9 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -1,8 +1,5 @@
// Italian UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "Nomi alternativi",
- "Alternative names for search. Separate with commas.": "Nomi alternativi per la ricerca. Separali con virgole.",
- "Save aliases": "Salva nomi alternativi",
'Confirm': 'Conferma',
'Cancel': 'Annulla',
'Press back again to exit': 'Premi di nuovo indietro per uscire',
@@ -530,6 +527,11 @@ export default {
'Create your own exercise': 'Crea il tuo esercizio',
'Edit custom exercise': 'Modifica esercizio personalizzato',
'Exercise name': 'Nome esercizio',
+ 'Other names': 'Altri nomi',
+ 'The search finds it by these too. Separate them with commas.': 'La ricerca lo trova anche con questi. Separali con virgole.',
+ 'Add another name': 'Aggiungi un altro nome',
+ 'Also called {0}': 'Detto anche {0}',
+ 'Save names': 'Salva i nomi',
'Create exercise': 'Crea esercizio',
'Give it a name': 'Dagli un nome',
'Pick a body part': 'Scegli una parte del corpo',
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index cf0fe4274..3ed61e60b 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -1,8 +1,5 @@
// Korean UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "다른 이름",
- "Alternative names for search. Separate with commas.": "검색에 사용할 다른 이름입니다. 쉼표로 구분하세요.",
- "Save aliases": "다른 이름 저장",
'Confirm': '확인',
'Cancel': '취소',
'Press back again to exit': '뒤로를 한 번 더 누르면 종료됩니다',
@@ -530,6 +527,11 @@ export default {
'Create your own exercise': '나만의 운동 만들기',
'Edit custom exercise': '커스텀 운동 편집',
'Exercise name': '운동 이름',
+ 'Other names': '다른 이름',
+ 'The search finds it by these too. Separate them with commas.': '검색에서 이 이름으로도 찾을 수 있어요. 쉼표로 구분하세요.',
+ 'Add another name': '다른 이름 추가',
+ 'Also called {0}': '다른 이름: {0}',
+ 'Save names': '이름 저장',
'Create exercise': '운동 만들기',
'Give it a name': '이름을 입력하세요',
'Pick a body part': '부위를 선택하세요',
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index 218ecd587..453e12717 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -1,8 +1,5 @@
// Polish UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "Alternatywne nazwy",
- "Alternative names for search. Separate with commas.": "Alternatywne nazwy do wyszukiwania. Oddziel je przecinkami.",
- "Save aliases": "Zapisz alternatywne nazwy",
'Confirm': 'Potwierdź',
'Cancel': 'Anuluj',
'Press back again to exit': 'Naciśnij wstecz ponownie, aby wyjść',
@@ -530,6 +527,11 @@ export default {
'Create your own exercise': 'Stwórz własne ćwiczenie',
'Edit custom exercise': 'Edytuj własne ćwiczenie',
'Exercise name': 'Nazwa ćwiczenia',
+ 'Other names': 'Inne nazwy',
+ 'The search finds it by these too. Separate them with commas.': 'Wyszukiwarka znajdzie je też po tych nazwach. Oddziel je przecinkami.',
+ 'Add another name': 'Dodaj inną nazwę',
+ 'Also called {0}': 'Znane też jako {0}',
+ 'Save names': 'Zapisz nazwy',
'Create exercise': 'Utwórz ćwiczenie',
'Give it a name': 'Nadaj mu nazwę',
'Pick a body part': 'Wybierz partię ciała',
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index e22c10b72..8bf6b7fc1 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -4,10 +4,9 @@
import pt from './pt.js'
export const PT_BR_OVERRIDES = {
+ 'The search finds it by these too. Separate them with commas.': 'A busca também encontra o exercício por estes. Separe com vírgulas.',
+ 'Save names': 'Salvar nomes',
'Handy when you compare with another app. Records ignore warm-ups either way.': 'Ajuda quando você compara com outro app. Os recordes ignoram o aquecimento de qualquer jeito.',
- 'Aliases': 'Nomes alternativos',
- 'Alternative names for search. Separate with commas.': 'Nomes alternativos para pesquisa. Separe com vírgulas.',
- 'Save aliases': 'Salvar nomes alternativos',
'{0} set brings an {1} with it. Switch on Effort per set in Settings to see it.': '{0} série traz um {1} junto. Ative “Esforço por série” nas Configurações para ver.',
'Add to this set': 'Adicionar a esta série',
'Copy this exercise’s warm-up sets, and the rest and note from its Exercise settings, into the routine. A note added for today stays with this workout. Your workout history is kept.': 'Copia para a rotina as séries de aquecimento deste exercício, e o descanso e a anotação das Configurações do exercício dele. Uma anotação adicionada para hoje fica com este treino. Seu histórico de treinos é mantido.',
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index abc1c5761..91e16dac8 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -1,8 +1,5 @@
// Portuguese UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "Nomes alternativos",
- "Alternative names for search. Separate with commas.": "Nomes alternativos para a pesquisa. Separa-os com vírgulas.",
- "Save aliases": "Guardar nomes alternativos",
'Confirm': 'Confirmar',
'Cancel': 'Cancelar',
'Press back again to exit': 'Prima novamente para sair',
@@ -530,6 +527,11 @@ export default {
'Create your own exercise': 'Cria o teu próprio exercício',
'Edit custom exercise': 'Editar exercício personalizado',
'Exercise name': 'Nome do exercício',
+ 'Other names': 'Outros nomes',
+ 'The search finds it by these too. Separate them with commas.': 'A pesquisa também o encontra por estes. Separa-os com vírgulas.',
+ 'Add another name': 'Adicionar outro nome',
+ 'Also called {0}': 'Também conhecido como {0}',
+ 'Save names': 'Guardar nomes',
'Create exercise': 'Criar exercício',
'Give it a name': 'Dá-lhe um nome',
'Pick a body part': 'Escolhe uma parte do corpo',
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index c0b8e9076..72ee9437d 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -1,8 +1,5 @@
// Russian UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "Другие названия",
- "Alternative names for search. Separate with commas.": "Другие названия для поиска. Разделяйте запятыми.",
- "Save aliases": "Сохранить названия",
'Confirm': 'Подтвердить',
'Cancel': 'Отмена',
'Press back again to exit': 'Нажмите «Назад» ещё раз, чтобы выйти',
@@ -520,6 +517,11 @@ export default {
'Create your own exercise': 'Создать своё упражнение',
'Edit custom exercise': 'Изменить своё упражнение',
'Exercise name': 'Название упражнения',
+ 'Other names': 'Другие названия',
+ 'The search finds it by these too. Separate them with commas.': 'Поиск найдёт упражнение и по ним. Разделяйте запятыми.',
+ 'Add another name': 'Добавить другое название',
+ 'Also called {0}': 'Также называют: {0}',
+ 'Save names': 'Сохранить названия',
'Create exercise': 'Создать упражнение',
'Give it a name': 'Задайте название',
'Pick a body part': 'Выберите часть тела',
diff --git a/frontend/src/locales/sv.js b/frontend/src/locales/sv.js
index 2bd857a29..bc6b590d3 100644
--- a/frontend/src/locales/sv.js
+++ b/frontend/src/locales/sv.js
@@ -547,6 +547,11 @@ export default {
'Create your own exercise': 'Skapa en egen övning',
'Edit custom exercise': 'Redigera egen övning',
'Exercise name': 'Övningens namn',
+ 'Other names': 'Andra namn',
+ 'The search finds it by these too. Separate them with commas.': 'Sökningen hittar den på de här också. Skilj dem åt med kommatecken.',
+ 'Add another name': 'Lägg till ett namn till',
+ 'Also called {0}': 'Kallas också {0}',
+ 'Save names': 'Spara namnen',
'Create exercise': 'Skapa övning',
'Give it a name': 'Ge den ett namn',
'Pick a body part': 'Välj en kroppsdel',
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index 303be5172..fe447a9f0 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -1,8 +1,5 @@
// Thai UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "ชื่ออื่น",
- "Alternative names for search. Separate with commas.": "ชื่ออื่นสำหรับการค้นหา คั่นด้วยเครื่องหมายจุลภาค",
- "Save aliases": "บันทึกชื่ออื่น",
// --- generic ---
'Confirm': 'ยืนยัน',
'Cancel': 'ยกเลิก',
@@ -534,6 +531,11 @@ export default {
'Create your own exercise': 'สร้างท่าออกกำลังกายของตัวเอง',
'Edit custom exercise': 'แก้ไขท่าที่สร้างเอง',
'Exercise name': 'ชื่อท่าออกกำลังกาย',
+ 'Other names': 'ชื่ออื่น',
+ 'The search finds it by these too. Separate them with commas.': 'ค้นหาด้วยชื่อเหล่านี้ก็เจอเหมือนกัน คั่นด้วยเครื่องหมายจุลภาค',
+ 'Add another name': 'เพิ่มชื่ออื่น',
+ 'Also called {0}': 'เรียกอีกอย่างว่า {0}',
+ 'Save names': 'บันทึกชื่อ',
'Create exercise': 'สร้างท่าออกกำลังกาย',
'Give it a name': 'ตั้งชื่อให้',
'Pick a body part': 'เลือกส่วนร่างกาย',
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index 137106b7b..0bc0b66f2 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -1,8 +1,5 @@
// Turkish UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "Alternatif adlar",
- "Alternative names for search. Separate with commas.": "Arama için alternatif adlar. Virgülle ayırın.",
- "Save aliases": "Alternatif adları kaydet",
'Confirm': 'Onayla',
'Cancel': 'İptal',
'Press back again to exit': 'Çıkmak için geri tuşuna tekrar basın',
@@ -530,6 +527,11 @@ export default {
'Create your own exercise': 'Kendi egzersizini oluştur',
'Edit custom exercise': 'Özel egzersizi düzenle',
'Exercise name': 'Egzersiz adı',
+ 'Other names': 'Diğer adlar',
+ 'The search finds it by these too. Separate them with commas.': 'Arama bunu bu adlarla da bulur. Virgülle ayır.',
+ 'Add another name': 'Başka bir ad ekle',
+ 'Also called {0}': 'Diğer adıyla {0}',
+ 'Save names': 'Adları kaydet',
'Create exercise': 'Egzersiz oluştur',
'Give it a name': 'Bir ad ver',
'Pick a body part': 'Bir vücut bölgesi seç',
diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.js
index 3d275b1c7..a974521e5 100644
--- a/frontend/src/locales/uk.js
+++ b/frontend/src/locales/uk.js
@@ -1,8 +1,5 @@
// Ukrainian UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "Інші назви",
- "Alternative names for search. Separate with commas.": "Інші назви для пошуку. Розділяйте комами.",
- "Save aliases": "Зберегти назви",
'Confirm': 'Підтвердити',
'Cancel': 'Скасувати',
'Press back again to exit': 'Натисни «Назад» ще раз, щоб вийти',
@@ -367,6 +364,11 @@ export default {
'Create your own exercise': 'Створити свою вправу',
'Edit custom exercise': 'Змінити свою вправу',
'Exercise name': 'Назва вправи',
+ 'Other names': 'Інші назви',
+ 'The search finds it by these too. Separate them with commas.': 'Пошук знайде вправу і за ними. Розділяйте комами.',
+ 'Add another name': 'Додати іншу назву',
+ 'Also called {0}': 'Також називають: {0}',
+ 'Save names': 'Зберегти назви',
'Create exercise': 'Створити вправу',
'Give it a name': 'Задай назву',
'Pick a body part': 'Вибери частину тіла',
diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.js
index 2ef99c347..03f45c498 100644
--- a/frontend/src/locales/zh-TW.js
+++ b/frontend/src/locales/zh-TW.js
@@ -1,7 +1,4 @@
export default {
- "Aliases": "別名",
- "Alternative names for search. Separate with commas.": "用於搜尋的其他名稱,請以逗號分隔。",
- "Save aliases": "儲存別名",
'Confirm': '確認',
'Cancel': '取消',
'Press back again to exit': '再按一次返回以退出',
@@ -525,6 +522,11 @@ export default {
'Create your own exercise': '自訂訓練動作',
'Edit custom exercise': '編輯自訂動作',
'Exercise name': '動作名稱',
+ 'Other names': '其他名稱',
+ 'The search finds it by these too. Separate them with commas.': '搜尋時也能用這些名稱找到它。用逗號分隔。',
+ 'Add another name': '新增別名',
+ 'Also called {0}': '也叫{0}',
+ 'Save names': '儲存名稱',
'Create exercise': '建立動作',
'Give it a name': '請輸入動作名稱',
'Pick a body part': '請選擇訓練部位',
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index 60bed647a..a8c6e2cf5 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -1,8 +1,5 @@
// Simplified Chinese UI strings. Keys are the English source strings (see lib/i18n.js).
export default {
- "Aliases": "别名",
- "Alternative names for search. Separate with commas.": "用于搜索的其他名称,请用逗号分隔。",
- "Save aliases": "保存别名",
'Confirm': '确认',
'Cancel': '取消',
'Press back again to exit': '再按一次返回退出',
@@ -530,6 +527,11 @@ export default {
'Create your own exercise': '创建自己的动作',
'Edit custom exercise': '编辑自定义动作',
'Exercise name': '动作名称',
+ 'Other names': '其他名称',
+ 'The search finds it by these too. Separate them with commas.': '搜索时也能用这些名称找到它。用逗号分隔。',
+ 'Add another name': '添加别名',
+ 'Also called {0}': '也叫{0}',
+ 'Save names': '保存名称',
'Create exercise': '创建动作',
'Give it a name': '请输入名称',
'Pick a body part': '请选择身体部位',
diff --git a/frontend/src/sheets.aliases.test.jsx b/frontend/src/sheets.aliases.test.jsx
index 853b9b504..e159f9666 100644
--- a/frontend/src/sheets.aliases.test.jsx
+++ b/frontend/src/sheets.aliases.test.jsx
@@ -28,32 +28,58 @@ const type = (el, value) => act(() => {
const field = () => host.querySelector('input[aria-describedby]')
const click = text => act(() => [...host.querySelectorAll('button')].find(b => b.textContent.trim() === text).click())
+const link = () => host.querySelector('.exalias-link')
+const openNames = () => act(() => link().click())
+
+it('stays one quiet line until asked: no field on the detail sheet, "Add another name" opens it (#624)', () => {
+ exerciseDetailSheet(CATALOGUE.find(e => e.id === '1162')); render()
+ expect(field()).toBeNull()
+ expect(link().textContent.trim()).toBe('Add another name')
+ openNames()
+ expect(host.querySelector('label[for="' + field().id + '"]').textContent).toBe('Other names')
+ expect(document.activeElement).toBe(field())
+})
it('saves, reopens and clears built-in aliases without creating a custom exercise or touching history', () => {
const ex = CATALOGUE.find(e => e.id === '1162')
const before = structuredClone(useStore.getState().S)
exerciseDetailSheet(ex); render()
- expect(host.querySelector('label[for="' + field().id + '"]').textContent).toBe('Aliases')
- type(field(), ' OHP, Military press, ohp '); click('Save aliases')
+ openNames()
+ type(field(), ' OHP, Military press, ohp '); click('Save names')
expect(useStore.getState().S.exAliases[ex.id]).toEqual(['OHP', 'Military press'])
expect(useStore.getState().S.customEx).toEqual([])
expect(useStore.getState().S.workouts).toEqual(before.workouts)
+ // Saved, it folds back into one line that says what it is called.
+ expect(field()).toBeNull()
+ expect(link().textContent.trim()).toBe('Also called OHP, Military press')
exerciseDetailSheet(ex); render()
+ openNames()
expect(field().value).toBe('OHP, Military press')
- type(field(), ''); click('Save aliases')
+ type(field(), ''); click('Save names')
expect(useStore.getState().S.exAliases[ex.id]).toEqual([])
})
it('edits custom aliases and preserves its media, name and identity', () => {
const ex = { id: 'c1', n: 'My press', bp: 'shoulders', eq: 'barbell', custom: true, aliases: ['Old name'], url: 'https://example.com/demo' }
useStore.setState(s => ({ S: { ...s.S, customEx: [ex] } })); registerCustom([ex])
customExSheet(ex); render()
+ expect(field()).toBeNull()
+ expect(link().textContent.trim()).toBe('Also called Old name')
+ openNames()
expect(field().value).toBe('Old name')
type(field(), 'Viking lift'); click('Save')
const saved = useStore.getState().S.customEx[0]
expect(saved).toMatchObject({ id: ex.id, n: ex.n, url: ex.url, aliases: ['Viking lift'] })
expect(searchExercises([saved], 'Viking lift')).toEqual([saved])
})
+it('a custom exercise saved without opening the field keeps the names it had', () => {
+ const ex = { id: 'c1', n: 'My press', bp: 'shoulders', eq: 'barbell', custom: true, aliases: ['Old name'] }
+ useStore.setState(s => ({ S: { ...s.S, customEx: [ex] } })); registerCustom([ex])
+ customExSheet(ex); render()
+ click('Save')
+ expect(useStore.getState().S.customEx[0].aliases).toEqual(['Old name'])
+})
it('leaves unsaved edits out of state', () => {
exerciseDetailSheet(CATALOGUE.find(e => e.id === '1162')); render()
+ openNames()
type(field(), 'Unsaved name')
expect(useStore.getState().S.exAliases).toEqual({})
})
diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx
index 552d88931..0a3e9b0d5 100644
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@ -1,5 +1,3 @@
-import ExerciseAliasesEditor, { ExerciseAliasesField } from './components/ExerciseAliases.jsx'
-import { normalizeAliases } from './lib/exercise-aliases.js'
import { useDeferredValue, useEffect, useMemo, useRef, useState } from 'react'
import { useStore } from './store/useStore.js'
import { useUI } from './store/useUI.js'
@@ -23,6 +21,8 @@ import LineChart from './components/LineChart.jsx'
import Stepper from './components/Stepper.jsx'
import { durationSheet } from './components/DurationWheel.jsx'
import { cleanBackups, withBackups, MAX_BACKUPS, backupSlotConfig } from './lib/routine-backups.js'
+import { normalizeAliases } from './lib/exercise-aliases.js'
+import ExerciseAliasesEditor, { ExerciseAliasesField, ExerciseAliasesLink } from './components/ExerciseAliases.jsx'
import { SG_NAME_MAX } from './lib/superset-meta.js'
import { REST_MAX, fmtRest, restWheelValue } from './lib/duration.js'
import Icon from './components/Icon.jsx'
@@ -1079,10 +1079,10 @@ function ExerciseDetail({ ex, close }) {
</button>
</div>
<Media ex={ex} />
- <ExerciseAliasesEditor key={ex.id} ex={ex} />
<div className="row" style={{ gap: 6, flexWrap: 'wrap', margin: '10px 0' }}>
{detailTags(ex).map(tg => <span key={tg.key} className={'tag' + (tg.acc ? ' acc' : '')}>{tg.icon && <Icon name={tg.icon} />}{tg.label}</span>)}
</div>
+ <ExerciseAliasesEditor key={ex.id} ex={ex} />
{descFor(ex) && <div className="exnote">{descFor(ex)}</div>}
{best > 0 && <div className="small row" style={{ marginBottom: 6, gap: 5 }}><Icon name="trophy" style={{ fontSize: 14, color: 'var(--yellow)' }} />{t('Best:')} <b className="accent" style={{ whiteSpace: 'nowrap' }}>{fmtNum(best)} {st.unit}</b>{last ? ` · ${t('last')} ${fmtDate(last.d)}: ${last.sets.map(s => setLabel(ex.id, s, last.target, speedUnitOf(st))).join(', ')}` : ''}</div>}
<Button variant="primary" icon="plus" style={{ margin: '10px 0 4px' }} onClick={() => addToRoutineSheet(ex)}>{t('Add to my plan')}</Button>
@@ -1209,6 +1209,7 @@ function CustomExForm({ existing, prefill, onDone, close }) {
const onNameFocus = useSheetKeyboard(nameRef)
const [n, setN] = useState(existing ? existing.n : (prefill || ''))
const [aliases, setAliases] = useState(() => normalizeAliases(existing?.aliases).join(', '))
+ const [aliasesOpen, setAliasesOpen] = useState(false)
const [bp, setBp] = useState(existing ? existing.bp : '')
const [eq, setEq] = useState(existing ? (existing.eq || '') : '')
const storedEq = existing && typeof existing.eq === 'string' && existing.eq && !ALL_EQUIPMENT.includes(existing.eq) ? existing.eq : null
@@ -1298,7 +1299,8 @@ function CustomExForm({ existing, prefill, onDone, close }) {
<h3>{existing ? t('Edit custom exercise') : t('Create your own exercise')}</h3>
<div className="muted small" style={{ marginBottom: 12 }}>{t('Name it and pick a body part. It works just like any other exercise.')}</div>
<input ref={nameRef} className="input" placeholder={t('Exercise name')} maxLength={80} value={n} onFocus={onNameFocus} onChange={e => setN(e.target.value)} />
- <ExerciseAliasesField value={aliases} onChange={setAliases} />
+ {aliasesOpen ? <ExerciseAliasesField value={aliases} onChange={setAliases} autoFocus />
+ : <div><ExerciseAliasesLink names={normalizeAliases(aliases)} onOpen={() => setAliasesOpen(true)} /></div>}
<div className="chips" style={{ margin: '12px 0' }}>
{BODYPARTS.map(b => <button key={b} className={'chip' + (bp === b ? ' on' : '')} onClick={() => setBp(b)}>{t(b)}</button>)}
</div>
diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.js
index 258cd9284..4780126f9 100644
--- a/frontend/src/store/useStore.js
+++ b/frontend/src/store/useStore.js
@@ -1,4 +1,3 @@
-import { registerExerciseAliases } from '../lib/exercise-aliases.js'
import { create } from 'zustand'
import { api, setRemoteAuth } from '../lib/api.js'
import { localTZ } from '../lib/format.js'
@@ -30,6 +29,7 @@ import { DEFAULT_TEMPLATE_ID } from '../lib/structuralBalanceTemplates.js'
import { WC_DEFAULT } from '../lib/workout-controls.js'
import { sanitizeAccent } from '../lib/accent.js'
+import { registerExerciseAliases } from '../lib/exercise-aliases.js'
const KEY = 'gym_state_v1'
// Where the saved copy stands with the server: the revision it descends from, and its own `_ts`