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.

i18n(de): make the correction loop converge

Mirko Köster6c65810d6182
diff --git a/scripts/de-name-rules.mjs b/scripts/de-name-rules.mjs
index 3853bd871..7f1097739 100644
--- a/scripts/de-name-rules.mjs
+++ b/scripts/de-name-rules.mjs
@@ -84,6 +84,40 @@ const LOANWORDS = new Set([
'ergometer', 'hack', 'hammer', 'kettlebell', 'kettlebells', 'pilates', 'plank', 'planks',
'romanian', 'scott', 'sit-up', 'sit-ups', 'skierg', 'smith', 'sprint', 'sprints', 'step',
'stepper', 'sumo', 'trap', 'yoga', 'v', 't', 'x', 'z', 'l', 'band', 'bands',
+ // Hyphenated as one token by `words`, so listing the parts is not enough — 'step' and 'v' are
+ // both above and neither matched "step-up" or "v-up". German gyms say these exactly as Sit-up
+ // is said, which is why that one was already here.
+ 'step-up', 'step-ups', 'v-up', 'v-ups',
+ // Plain German nouns that happen to be spelled the same in English, so the inverted check reads
+ // a correct German name as a leak. "Arm" is the one that stalled a batch: the model wrote
+ // "gebeugter Arm" and was told three times to write the German word, which it already had.
+ // Only the singulars — German pluralises these differently (Arme, Hände), so an English plural
+ // in a German name really is a leak.
+ 'arm', 'ball', 'hand', 'finger', 'rotation', 'position',
+ // Eponyms. A surname is the same word in every language, so flagging one is always a false
+ // positive — there is no "German word instead" for the model to write.
+ 'arnold', 'bradford', 'cossack', 'cuban', 'frankenstein', 'hyght', 'jefferson', 'jm',
+ 'london', 'otis', 'pallof', 'pendlay', 'rocky', 'russian', 'svend', 'tate', 'thibaudeau',
+ 'turkish', 'zercher', 'zottman',
+ // Anglicisms German gyms use untranslated. Deliberately short: Kniebeuge, Drücken, Rudern and
+ // Heben stay enforced, so this concedes the names that have no German form in use, not the
+ // ones a translation exists for.
+ 'twist', 'twists', 'twisting', 'twisted', 'pullover', 'split', 'drag', 'goblet', 'thruster',
+ 'kickback', 'kickbacks', 'skull', 'crusher', 'skullcrusher', 'good', 'morning',
+ // Attachment names, said as-is on a German gym floor. 'ez-bar' is deliberately absent: the
+ // equipment rule requires SZ-Stange for that machine, and the two would contradict each other.
+ 't-bar', 'v-bar', 'landmine',
+ // Found by surveying the titles still untranslated rather than by stalling on each in turn:
+ // Kettlebell Swing, Ball Slam, Donkey Wadenheben, Sissy Squat and the POV camera-angle entries
+ // all keep the English word on a German gym floor. Translatable neighbours are deliberately
+ // absent — shrug, swing's cousin jump, throw and catch all have German forms the model produces.
+ 'pov', 'slam', 'swing', 'donkey', 'sissy',
+ // Anatomical terms German takes from Latin unchanged, which is what stalled the pronation
+ // batch: "Pronation" IS the German word, so no correction the model can make will satisfy a
+ // rule that calls it English. The colloquial English forms stay flagged — 'glutes' and 'abs'
+ // are not here, because Gesäß and Bauch exist and PREFERRED_TERMS asks for them.
+ 'pronation', 'supination', 'hyperextension', 'flexor', 'adductor', 'deltoid',
+ 'pectoralis', 'gluteus', 'piriformis', 'rectus', 'femoris', 'tibialis', 'posterior', 'major',
// German gyms say Battle Ropes, not Kampfseile; the rope rule accepts either word for that
// reason. Everything else on this list is a term with no German equivalent in use.
'battle', 'battling', 'rope', 'ropes',
diff --git a/scripts/exercise-name-sources/README.md b/scripts/exercise-name-sources/README.md
index e1380000a..fe6b2d404 100644
--- a/scripts/exercise-name-sources/README.md
+++ b/scripts/exercise-name-sources/README.md
@@ -50,9 +50,14 @@ to write:
```sh
node scripts/translate-de-exercise-names.mjs --equipment='trap bar'
-node scripts/translate-de-exercise-names.mjs --equipment=dumbbell --apply
+node scripts/translate-de-exercise-names.mjs --equipment=dumbbell --limit=999 --apply
```
+`--limit` caps how many names one invocation translates and defaults to 40, so a run
+without it stops early and still exits successfully — pass a limit at least as large as
+the family you are translating. Names already in `de.json` are skipped, so re-running
+after an interrupt costs nothing.
+
Equipment and identity-changing qualifiers (assisted, weighted, one-arm,
seated, incline …) are checked against `scripts/de-name-rules.mjs` while the
batch is still in hand: a violation goes back to the model as a correction
diff --git a/scripts/translate-de-exercise-names.mjs b/scripts/translate-de-exercise-names.mjs
index 6dbd1a0cf..68d3f9cdb 100644
--- a/scripts/translate-de-exercise-names.mjs
+++ b/scripts/translate-de-exercise-names.mjs
@@ -125,6 +125,7 @@ Rules:
- Return only the structured JSON required by the schema, with every ID exactly once and in input order.
- Return only the German title in "name". Do not append, repeat or bracket the English title — the app shows it itself.
- A title is a noun phrase, not a sentence: no final full stop, and German noun capitalisation ("Bankdrücken mit Langhantel", "Rudern am Kabelzug").
+- Capitalise the first word whatever it is. A leading adjective is capitalised here even though German would lowercase it mid-sentence: "Abwechselnder Latzug am Kabelzug", "Assistierter Klimmzug an der Hebelmaschine".
- Preserve exercise identity: equipment, stance, grip, direction, side, assisted/weighted status and version qualifiers all distinguish one catalogue entry from another.
- Prefer established German gym terminology (Bankdrücken, Kniebeuge, Kreuzheben, Rudern, Latzug, Klimmzug, Liegestütz, Ausfallschritt, Wadenheben, Beinpresse, Fliegende, Nackendrücken).
- Use standard German ß (Gesäß, Fuß), not the Swiss ss — the app derives the Swiss spelling from this pack.
@@ -145,10 +146,16 @@ ${JSON.stringify(input)}`
// on while it still has the batch in hand. A batch that cannot be fixed is never written.
let prompt = basePrompt
let accepted
+ // A name that has passed the rules once is kept, and the model is never asked for it again.
+ // Without this the loop oscillates: told only about what is broken *now*, the model rewrites
+ // the batch from scratch and silently reverts the corrections it made on the previous attempt,
+ // so a batch can fail after three attempts having had every name clean at some point in them.
+ const pinned = new Map()
for (let attempt = 0; ; attempt++) {
const structured = await requestStructured(prompt, batch)
const received = new Map(structured.translations.map(row => [row.id, row.name.trim()]))
if (received.size !== batch.length) throw new Error(`${provider} returned duplicate or missing IDs`)
+ for (const [id, name] of pinned) received.set(id, name)
const problems = []
for (const exercise of batch) {
@@ -156,6 +163,7 @@ ${JSON.stringify(input)}`
if (!name) throw new Error(`${exercise.id}: missing translated name`)
const broken = checkName(exercise, name)
if (broken.length) problems.push({ id: exercise.id, name, broken })
+ else pinned.set(exercise.id, name)
}
if (!problems.length) {
@@ -172,8 +180,12 @@ ${JSON.stringify(input)}`
// Only the broken names are quoted back. Re-sending the whole batch as "wrong" invites the
// model to rewrite names that were already fine, which loses good work and breaks other rules.
+ // The settled names are still listed, because a model that is not shown them invents new ones
+ // for those IDs — harmless now that they are pinned, but it spends the batch's attention on
+ // work that will be discarded instead of on the names that are actually still wrong.
+ const settled = [...pinned].map(([id, name]) => `- ${id}: ${JSON.stringify(name)}`).join('\n')
prompt = `${basePrompt}
-
+${settled ? `\nThese names are already accepted. Return them back exactly as they are:\n${settled}\n` : ''}
Your previous answer broke these rules. Return the FULL JSON for every ID again, changing only the names listed here:
${problems.map(p => `- ${p.id} was: ${JSON.stringify(p.name)}\n${p.broken.map(v => ` ${v.fix}`).join('\n')}`).join('\n')}`
}