feat(i18n): complete Brazilian Portuguese instructions
This commit is contained in:
1 parent
cf7b3496a5
commit
3d3e44c973
11 files changed
+9110
-45
No files matched your search
@@ -10,9 +10,9 @@ The translations are produced from the English instructions in
|
||||
`frontend/src/lib/exercises-data.js` with language-model assistance from OpenAI
|
||||
Codex and, for larger structured batches, Anthropic Claude Code. They are
|
||||
original translations, not copied from another Portuguese exercise dataset.
|
||||
Each batch is checked against the English source and reviewed for Brazilian
|
||||
terminology, but it must not be described as native-speaker reviewed until a
|
||||
named human reviewer has actually completed that review.
|
||||
Each batch is structurally checked against the English source and audited for
|
||||
Brazilian terminology. It must not be described as native-speaker reviewed
|
||||
until a named human reviewer has actually completed that review.
|
||||
|
||||
The translation policy is meaning-faithful rather than word-for-word: preserve
|
||||
the number and order of steps, retain the intended movement and safety cues,
|
||||
@@ -32,12 +32,18 @@ steps left unchanged in English. The frontend test also verifies that the
|
||||
generated `frontend/src/instr/pt-BR.js` exactly matches this source.
|
||||
|
||||
Do not add `pt-BR` to `INSTR_LANGS` until all 1,324 exercise IDs are translated
|
||||
and reviewed. Until then, the released app must continue to show the honest
|
||||
English-instructions notice instead of silently mixing Portuguese and English.
|
||||
and the full automated corpus gates pass. Until then, the released app must
|
||||
continue to show the honest English-instructions notice instead of silently
|
||||
mixing Portuguese and English.
|
||||
|
||||
Use the terminology in `GLOSSARY.md` for every batch.
|
||||
|
||||
For a structured batch, use `scripts/translate-pt-br-stage.mjs` with a dataset
|
||||
body part and limit. It calls Claude in read-only structured-output mode and
|
||||
writes only after every returned ID and step count validates. The normal pack
|
||||
builder and frontend tests remain mandatory after generation.
|
||||
checkpoints only after every returned ID and step count in that batch validates,
|
||||
so a long stage can resume safely. The normal pack builder and frontend tests
|
||||
remain mandatory after generation.
|
||||
|
||||
Use `--provider=codex` to run the same schema-constrained workflow through an
|
||||
authenticated Codex CLI when Claude is unavailable. Both providers run without
|
||||
write tools; only this validator updates the curated JSON after a valid batch.
|
||||
@@ -1,23 +1,23 @@
|
||||
# Brazilian Portuguese instruction translation plan
|
||||
|
||||
Translate in batches of 10 exercises. Every batch must regenerate the runtime
|
||||
pack, pass the full frontend suite and receive a language/content review before
|
||||
the next batch. Progress is measured from `pt-BR.json`, not from generated
|
||||
files.
|
||||
Translate in schema-validated, checkpointed batches. After a stage, regenerate
|
||||
the runtime pack and run the frontend suite; after the complete corpus, perform
|
||||
the independent language/content review. Progress is measured from
|
||||
`pt-BR.json`, not from generated files.
|
||||
|
||||
| Stage | Dataset body part | Total exercises | Order |
|
||||
|---:|---|---:|---|
|
||||
| 0 | Foundation sample across categories | 20 translated | Complete |
|
||||
| 1 | Waist / abs / core | 169 | Complete |
|
||||
| 2 | Chest / pectorals | 163 | Pending |
|
||||
| 3 | Back / lats / upper back | 203 | Pending |
|
||||
| 4 | Shoulders / delts | 143 | Pending |
|
||||
| 5 | Upper arms / biceps / triceps | 292 | Pending |
|
||||
| 6 | Lower arms / forearms | 37 | Pending |
|
||||
| 7 | Upper legs / glutes / quads / hamstrings | 227 | Pending |
|
||||
| 8 | Lower legs / calves | 59 | Pending |
|
||||
| 9 | Cardio and neck | 31 | Pending |
|
||||
| 10 | Full-corpus terminology and native-speaker QA | 1,324 | Pending |
|
||||
| 2 | Chest / pectorals | 163 | Complete |
|
||||
| 3 | Back / lats / upper back | 203 | Complete |
|
||||
| 4 | Shoulders / delts | 143 | Complete |
|
||||
| 5 | Upper arms / biceps / triceps | 292 | Complete |
|
||||
| 6 | Lower arms / forearms | 37 | Complete |
|
||||
| 7 | Upper legs / glutes / quads / hamstrings | 227 | Complete |
|
||||
| 8 | Lower legs / calves | 59 | Complete |
|
||||
| 9 | Cardio and neck | 31 | Complete |
|
||||
| 10 | Full-corpus terminology and independent QA | 1,324 | Ready for review |
|
||||
|
||||
The body-part stages cover all 1,324 dataset IDs exactly once. The foundation
|
||||
sample already contributes to several stages, so stage progress must exclude
|
||||
@@ -29,3 +29,9 @@ until Stage 10 confirms 1,324/1,324 coverage.
|
||||
- Stage 1 completed in 2026-08-19: 169/169 waist IDs. Combined corpus progress
|
||||
is 179/1,324 exercises and 996 instruction steps because the foundation
|
||||
sample also contains 10 exercises from later stages.
|
||||
- Stages 2–9 completed in 2026-08-19: source coverage reached 1,324/1,324.
|
||||
Automated Stage 10 gates passed for 7,710/7,710 steps: exact ID and step
|
||||
coverage, non-empty content, curated-source parity, glossary/English/PT-PT
|
||||
leakage checks, complete frontend tests and production build. The independent
|
||||
full-corpus review prompt is prepared separately for Claude Code; do not claim
|
||||
native-speaker review unless a named human actually performs one.
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawnSync } from 'node:child_process'
|
||||
import { readFileSync, writeFileSync } from 'node:fs'
|
||||
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url'
|
||||
|
||||
@@ -10,14 +11,18 @@ const sourcePath = join(root, 'scripts', 'instruction-sources', 'pt-BR.json')
|
||||
const glossaryPath = join(root, 'scripts', 'instruction-sources', 'GLOSSARY.md')
|
||||
const exercisesPath = join(root, 'frontend', 'src', 'lib', 'exercises-data.js')
|
||||
const claude = process.env.CLAUDE_BIN || 'claude'
|
||||
const codex = process.env.CODEX_BIN || 'codex'
|
||||
const stageOrder = ['chest', 'back', 'shoulders', 'upper arms', 'lower arms', 'upper legs', 'lower legs', 'cardio', 'neck']
|
||||
|
||||
const option = name => process.argv.find(arg => arg.startsWith(`--${name}=`))?.split('=').slice(1).join('=')
|
||||
const bodyPart = option('body-part')
|
||||
const provider = option('provider') || 'claude'
|
||||
const limit = Number(option('limit') || 10)
|
||||
const batchSize = Number(option('batch-size') || 10)
|
||||
const apply = process.argv.includes('--apply')
|
||||
|
||||
if (!bodyPart) throw new Error('Usage: translate-pt-br-stage.mjs --body-part=waist [--limit=10] [--batch-size=10] [--apply]')
|
||||
if (!bodyPart) throw new Error('Usage: translate-pt-br-stage.mjs --body-part=waist|all [--limit=10] [--batch-size=10] [--apply]')
|
||||
if (!['claude', 'codex'].includes(provider)) throw new Error('provider must be claude or codex')
|
||||
if (!Number.isInteger(limit) || limit < 1 || !Number.isInteger(batchSize) || batchSize < 1) {
|
||||
throw new Error('limit and batch-size must be positive integers')
|
||||
}
|
||||
@@ -25,7 +30,10 @@ if (!Number.isInteger(limit) || limit < 1 || !Number.isInteger(batchSize) || bat
|
||||
const translations = JSON.parse(readFileSync(sourcePath, 'utf8'))
|
||||
const glossary = readFileSync(glossaryPath, 'utf8')
|
||||
const { EXDB } = await import(pathToFileURL(exercisesPath))
|
||||
const pending = EXDB.filter(exercise => exercise.bp === bodyPart && !translations[exercise.id]).slice(0, limit)
|
||||
const requestedParts = bodyPart === 'all' ? stageOrder : [bodyPart]
|
||||
const pending = requestedParts
|
||||
.flatMap(part => EXDB.filter(exercise => exercise.bp === part && !translations[exercise.id]))
|
||||
.slice(0, limit)
|
||||
|
||||
if (!pending.length) {
|
||||
console.log(`No untranslated ${bodyPart} exercises remain.`)
|
||||
@@ -71,25 +79,65 @@ ${glossary}
|
||||
INPUT:
|
||||
${JSON.stringify(input)}`
|
||||
|
||||
console.log(`Translating ${start + 1}-${start + batch.length} of ${pending.length} (${batch[0].id}…${batch.at(-1).id})`)
|
||||
const result = spawnSync(claude, [
|
||||
'-p', '--model', 'sonnet', '--effort', 'high', '--no-session-persistence',
|
||||
'--permission-mode', 'dontAsk', '--disallowedTools', 'Bash', 'Edit', 'Write', 'Read',
|
||||
'--output-format', 'json', '--max-budget-usd', '2', '--json-schema', JSON.stringify(schema)
|
||||
], { input: prompt, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 })
|
||||
console.log(`Translating ${start + 1}-${start + batch.length} of ${pending.length} with ${provider} (${batch[0].id}…${batch.at(-1).id})`)
|
||||
let structured
|
||||
if (provider === 'claude') {
|
||||
const result = spawnSync(claude, [
|
||||
'-p', '--model', 'sonnet', '--effort', 'high', '--no-session-persistence',
|
||||
'--permission-mode', 'dontAsk', '--disallowedTools', 'Bash', 'Edit', 'Write', 'Read',
|
||||
'--output-format', 'json', '--max-budget-usd', '2', '--json-schema', JSON.stringify(schema)
|
||||
], { input: prompt, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 })
|
||||
if (result.status !== 0) throw new Error(result.stderr || result.stdout || `Claude exited ${result.status}`)
|
||||
const envelope = JSON.parse(result.stdout)
|
||||
if (envelope.is_error || !envelope.structured_output) throw new Error(envelope.result || 'Claude returned no structured output')
|
||||
structured = envelope.structured_output
|
||||
} else {
|
||||
const temp = mkdtempSync(join(tmpdir(), 'opengym-pt-br-'))
|
||||
const schemaPath = join(temp, 'schema.json')
|
||||
const outputPath = join(temp, 'output.json')
|
||||
const codexSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
translations: {
|
||||
type: 'array', minItems: batch.length, maxItems: batch.length,
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'string' },
|
||||
steps: { type: 'array', items: { type: 'string' } }
|
||||
},
|
||||
required: ['id', 'steps'], additionalProperties: false
|
||||
}
|
||||
}
|
||||
},
|
||||
required: ['translations'], additionalProperties: false
|
||||
}
|
||||
try {
|
||||
writeFileSync(schemaPath, JSON.stringify(codexSchema))
|
||||
const result = spawnSync(codex, [
|
||||
'exec', '--skip-git-repo-check', '--ephemeral', '--ignore-user-config',
|
||||
'--sandbox', 'read-only', '--output-schema', schemaPath,
|
||||
'--output-last-message', outputPath, '-'
|
||||
], { input: prompt, encoding: 'utf8', cwd: temp, maxBuffer: 16 * 1024 * 1024 })
|
||||
if (result.status !== 0) throw new Error(result.stderr || result.stdout || `Codex exited ${result.status}`)
|
||||
structured = JSON.parse(readFileSync(outputPath, 'utf8'))
|
||||
} finally {
|
||||
rmSync(temp, { recursive: true, force: true })
|
||||
}
|
||||
}
|
||||
|
||||
if (result.status !== 0) throw new Error(result.stderr || `Claude exited ${result.status}`)
|
||||
const envelope = JSON.parse(result.stdout)
|
||||
if (envelope.is_error || !envelope.structured_output) throw new Error(envelope.result || 'Claude returned no structured output')
|
||||
|
||||
const rows = envelope.structured_output.translations
|
||||
const rows = structured.translations
|
||||
const received = new Map(rows.map(row => [row.id, row.steps]))
|
||||
if (received.size !== batch.length) throw new Error('Claude returned duplicate or missing IDs')
|
||||
if (received.size !== batch.length) throw new Error(`${provider} returned duplicate or missing IDs`)
|
||||
for (const exercise of batch) {
|
||||
const steps = received.get(exercise.id)
|
||||
if (!steps || steps.length !== exercise.st.length) throw new Error(`${exercise.id}: invalid step count`)
|
||||
next[exercise.id] = steps
|
||||
}
|
||||
if (apply) {
|
||||
writeFileSync(sourcePath, JSON.stringify(next, null, 2) + '\n')
|
||||
console.log(`Checkpoint: ${Object.keys(next).length}/${EXDB.length} exercises`)
|
||||
}
|
||||
}
|
||||
|
||||
if (!apply) {
|
||||
@@ -97,5 +145,4 @@ if (!apply) {
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
writeFileSync(sourcePath, JSON.stringify(next, null, 2) + '\n')
|
||||
console.log(`Updated ${sourcePath}: ${Object.keys(next).length}/${EXDB.length} exercises`)
|
||||
Reference in new issue
Block a user