feat(i18n): complete pt-BR core instructions
This commit is contained in:
1 parent
c667539f10
commit
ad69235f6e
8 files changed
+1377
-119
No files matched your search
@@ -20,6 +20,9 @@ Preferred terms keep the instruction pack consistent with Brazilian gym usage.
|
||||
| repetition / rep | repetição | repetiçãozinha |
|
||||
| bodyweight | peso corporal | peso do corpo, when used as a category |
|
||||
| starting position | posição inicial | posição de partida |
|
||||
| resistance band / band | faixa elástica | banda |
|
||||
| stability ball | bola de estabilidade | bola suíça |
|
||||
| floor / ground | chão | piso |
|
||||
|
||||
Write instructions using Brazilian `você` conventions and neutral imperative
|
||||
forms: `mantenha`, `contraia`, `eleve`, `retorne`. Avoid Portuguese (Portugal)
|
||||
|
||||
@@ -7,11 +7,12 @@ the upstream exercise dataset does not currently ship Portuguese instructions.
|
||||
## Provenance and review status
|
||||
|
||||
The translations are produced from the English instructions in
|
||||
`frontend/src/lib/exercises-data.js` with OpenAI Codex language-model
|
||||
assistance. 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.
|
||||
`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.
|
||||
|
||||
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,
|
||||
@@ -35,3 +36,8 @@ and reviewed. 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.
|
||||
@@ -8,7 +8,7 @@ files.
|
||||
| Stage | Dataset body part | Total exercises | Order |
|
||||
|---:|---|---:|---|
|
||||
| 0 | Foundation sample across categories | 20 translated | Complete |
|
||||
| 1 | Waist / abs / core | 169 | In progress |
|
||||
| 1 | Waist / abs / core | 169 | Complete |
|
||||
| 2 | Chest / pectorals | 163 | Pending |
|
||||
| 3 | Back / lats / upper back | 203 | Pending |
|
||||
| 4 | Shoulders / delts | 143 | Pending |
|
||||
@@ -23,3 +23,9 @@ 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
|
||||
IDs already present in the source file. Do not add `pt-BR` to `INSTR_LANGS`
|
||||
until Stage 10 confirms 1,324/1,324 coverage.
|
||||
|
||||
## Checkpoints
|
||||
|
||||
- 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.
|
||||
+1242
-107
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawnSync } from 'node:child_process'
|
||||
import { 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', '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 = '/Users/matheus/.local/bin/claude'
|
||||
|
||||
const option = name => process.argv.find(arg => arg.startsWith(`--${name}=`))?.split('=').slice(1).join('=')
|
||||
const bodyPart = option('body-part')
|
||||
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 (!Number.isInteger(limit) || limit < 1 || !Number.isInteger(batchSize) || batchSize < 1) {
|
||||
throw new Error('limit and batch-size must be positive integers')
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
if (!pending.length) {
|
||||
console.log(`No untranslated ${bodyPart} exercises remain.`)
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
const next = { ...translations }
|
||||
for (let start = 0; start < pending.length; start += batchSize) {
|
||||
const batch = pending.slice(start, start + batchSize)
|
||||
const schema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
translations: {
|
||||
type: 'array', minItems: batch.length, maxItems: batch.length,
|
||||
items: {
|
||||
oneOf: batch.map(exercise => ({
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { const: exercise.id },
|
||||
steps: { type: 'array', minItems: exercise.st.length, maxItems: exercise.st.length, items: { type: 'string', minLength: 1 } }
|
||||
},
|
||||
required: ['id', 'steps'], additionalProperties: false
|
||||
}))
|
||||
}
|
||||
}
|
||||
},
|
||||
required: ['translations'], additionalProperties: false
|
||||
}
|
||||
const input = batch.map(({ id, n, st }) => ({ id, name: n, steps: st }))
|
||||
const prompt = `Translate every instruction step below from English into natural Brazilian Portuguese for a fitness app.
|
||||
|
||||
Rules:
|
||||
- Return only the structured JSON required by the schema, with every ID exactly once and in input order.
|
||||
- Preserve the exact number, order, movement meaning and safety cues of the English steps.
|
||||
- Use Brazilian você conventions and neutral imperatives: mantenha, contraia, eleve, retorne.
|
||||
- Follow the glossary. In particular, translate "engage your core/abs" as "contraia o abdômen", never "ative o core".
|
||||
- Do not use Portuguese (Portugal) wording. Do not add explanations or repair source mechanics.
|
||||
- Translate only instruction steps; IDs remain unchanged.
|
||||
|
||||
GLOSSARY:
|
||||
${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 })
|
||||
|
||||
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 received = new Map(rows.map(row => [row.id, row.steps]))
|
||||
if (received.size !== batch.length) throw new Error('Claude 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) {
|
||||
console.log(`Validated ${pending.length} translations. Re-run with --apply to update ${sourcePath}.`)
|
||||
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