curated2: !68 (Thai and Hungarian both land: 14 languages)
This commit is contained in:
commit
f0777e362a
8 files changed
+2063
-10
No files matched your search
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
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', 'hu.json')
|
||||
const outputPath = join(root, 'frontend', 'src', 'exercise-names', 'hu.js')
|
||||
const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')
|
||||
|
||||
const source = JSON.parse(readFileSync(sourcePath, 'utf8'))
|
||||
const { EXDB } = await import(pathToFileURL(exercisesPath))
|
||||
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 hu 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-hu-exercise-names.mjs — edit scripts/exercise-name-sources/hu.json\nexport default ' + JSON.stringify(ordered) + '\n')
|
||||
console.log(`Generated ${EXDB.length}/${EXDB.length} hu exercise names.`)
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user