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.

catalogue: name import script, 4834 is a dumbbell exercise

Duarte Santos617a90e09916
diff --git a/catalogue/exercises/4834.json b/catalogue/exercises/4834.json
index de6a71bab..584d744df 100644
--- a/catalogue/exercises/4834.json
+++ b/catalogue/exercises/4834.json
@@ -2,7 +2,7 @@
"id": "4834",
"name": "dumbbell alternate chest press on stability ball",
"bodyPart": "chest",
- "equipment": "stability ball",
+ "equipment": "dumbbell",
"target": "pectorals",
"secondaryMuscles": [
"triceps",
diff --git a/scripts/catalogue/import-names.mjs b/scripts/catalogue/import-names.mjs
new file mode 100644
index 000000000..9fccc9f99
--- /dev/null
+++ b/scripts/catalogue/import-names.mjs
@@ -0,0 +1,33 @@
+#!/usr/bin/env node
+// Folds the v1.4.0 name translations (<archive>/work/names/out/<lang>-NN.json) into
+// catalogue/i18n/<lang>.json. Only fills names that are missing; a name someone already wrote is
+// never replaced. One-off, kept for the record.
+//
+// node scripts/catalogue/import-names.mjs /path/to/opengym-media
+import fs from 'node:fs'
+import path from 'node:path'
+import { fileURLToPath } from 'node:url'
+
+const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..')
+const dir = path.join(path.resolve(process.argv[2] || '/mnt/backup-hdd/opengym-media'), 'work/names/out')
+const byLang = {}
+for (const f of fs.readdirSync(dir).filter(f => f.endsWith('.json')).sort()) {
+ const lang = f.replace(/-\d+\.json$/, '')
+ Object.assign(byLang[lang] ||= {}, JSON.parse(fs.readFileSync(path.join(dir, f), 'utf8')))
+}
+for (const [lang, names] of Object.entries(byLang)) {
+ const p = path.join(ROOT, 'catalogue/i18n', lang + '.json')
+ const cur = fs.existsSync(p) ? JSON.parse(fs.readFileSync(p, 'utf8')) : {}
+ let added = 0
+ for (const [id, name] of Object.entries(names)) {
+ const row = cur[id] ||= {}
+ if (!row.name) { row.name = name; added++ }
+ }
+ // Rows in id order, and inside a row name, description, instructions: the order a translator reads.
+ const sorted = Object.fromEntries(Object.keys(cur).sort().map(id => {
+ const r = cur[id]
+ return [id, Object.fromEntries(['name', 'description', 'instructions'].filter(k => r[k] != null).map(k => [k, r[k]]))]
+ }))
+ fs.writeFileSync(p, JSON.stringify(sorted, null, 2) + '\n')
+ console.log(`${lang}: +${added} names`)
+}