Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
A Spanish profile now reads the catalogue in Spanish. Only pt-BR and hu had a
name pack, so every other language — Spanish included, which is this fork's
default — showed 1,324 English titles.
The pack is generated the way the pt-BR and hu ones were, with two differences
that matter to a self-hosted instance:
- `scripts/translate-es-exercise-names.mjs` talks to an OpenAI-compatible
endpoint instead of the `claude` CLI, because that is what the instance
already has: the same router the Coach runs on. Point it at one with
COACH_BASE_URL / COACH_MODEL / COACH_API_KEY.
- It is resumable. Ids already in the source file are skipped, so a run that
stops half way continues where it left off and a review only re-translates
what it deletes. With 1,324 rows, a pass that had to start over would never be
repeated.
Three rounds of review went into the file, each one caught by reading the output
rather than by the script succeeding:
1. "chin-up" and "pull-up" came back as English loanwords — the terms the
catalogue itself uses — so the core vocabulary is now pinned in the prompt and
asserted by the test (dominada, sentadilla, peso muerto, zancada, plancha…).
2. 142 rows led with the equipment ("Banda sentadilla", "Mancuerna press"), which
is the English word order. Spanish names the movement first: "Sentadilla con
banda". Those rows were re-translated, and the test now refuses a title that
starts with a piece of equipment — "Peso muerto" is why "Peso" is not on that
list.
3. Four rows dropped their (male) qualifier and four named variations kept an
English head noun ("Hack squat con barra"); both were fixed, the first by hand
since the review is allowed to edit the source.
The pack is honest about its provenance, like the pt-BR one: model-produced,
not reviewed by a native speaker, and the README says so.
36 lines
1.9 KiB
JavaScript
36 lines
1.9 KiB
JavaScript
#!/usr/bin/env node
|
|
/*
|
|
* Turn scripts/exercise-name-sources/es.json into the runtime pack the app loads.
|
|
*
|
|
* The source is the editable artefact (a review edits Spanish there); this file exists so the
|
|
* app ships a pack that is checked against the catalogue rather than whatever a script happened
|
|
* to write. Same shape as build-pt-br-exercise-names.mjs, and it fails loudly on a missing or
|
|
* empty entry: a half-translated pack would show some exercises in English with no clue why.
|
|
*/
|
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
import { dirname, join } from 'node:path'
|
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
|
|
const root = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
const sourcePath = join(root, 'scripts', 'exercise-name-sources', 'es.json')
|
|
const outputPath = join(root, 'frontend', 'src', 'exercise-names', 'es.js')
|
|
const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')
|
|
|
|
const source = JSON.parse(readFileSync(sourcePath, 'utf8'))
|
|
const { EXDB } = await import(pathToFileURL(exercisesPath).href)
|
|
const known = new Set(EXDB.map(exercise => exercise.id))
|
|
|
|
for (const id of Object.keys(source)) {
|
|
if (!known.has(id)) throw new Error(`Unknown exercise ID: ${id}`)
|
|
if (typeof source[id] !== 'string' || !source[id].trim()) throw new Error(`${id}: name must be a non-empty string`)
|
|
}
|
|
if (Object.keys(source).length !== EXDB.length) {
|
|
throw new Error(`Incomplete es exercise names: ${Object.keys(source).length}/${EXDB.length}`)
|
|
}
|
|
|
|
const ordered = {}
|
|
for (const exercise of EXDB) ordered[exercise.id] = source[exercise.id].trim()
|
|
mkdirSync(dirname(outputPath), { recursive: true })
|
|
writeFileSync(outputPath, '// generated by scripts/build-es-exercise-names.mjs — edit scripts/exercise-name-sources/es.json\nexport default ' + JSON.stringify(ordered) + '\n')
|
|
console.log(`Generated ${EXDB.length}/${EXDB.length} es exercise names.`)
|