i18n: Add Hungarian (hu) — UI, exercise instructions, and exercise names
Rebased onto the Brazilian-Portuguese localization that landed while this was
in progress — that MR introduced EXERCISE_NAME_LANGS/exerciseNameFor()/
exerciseNameSearchText() in lib/i18n-core.js and a generated-pack convention
(scripts/exercise-name-sources/<lang>.json → scripts/build-<lang>-exercise-
names.mjs → frontend/src/exercise-names/<lang>.js), which is exactly the
mechanism this MR originally invented independently as NAME_LANGS/nameFor().
Dropped that duplicate plumbing entirely and reused theirs instead:
- frontend/src/locales/hu.js — full UI translation, 740/740 keys (654 from
the original translation pass, 86 more added to cover the drop-set/rest-
pause, equipment-profile, server-pairing and session-note strings that
landed in the same window).
- frontend/src/instr/hu.js — unchanged mechanism, all 1,324 exercises' step-
by-step instructions. The upstream exercise dataset (hasaneyldrm/exercises-
dataset) still has no hu field, so this stays hand-maintained here.
- scripts/exercise-name-sources/hu.json + scripts/build-hu-exercise-
names.mjs (mirrors the pt-BR ones) → frontend/src/exercise-names/hu.js —
all 1,324 exercise names, added to EXERCISE_NAME_LANGS. Exercise names
now render the same bilingual way pt-BR's do: the translated name alone
when it's the same loanword as English (e.g. "burpee"), otherwise
"translated (english)".
- One small generalization to exerciseNameFor(): its loanword-casing
comparison was hardcoded to `.toLocaleLowerCase('pt-BR')`. Changed to the
active language instead, so it is correct for hu (and any language after
it) rather than only for pt-BR. No behavior change for pt-BR itself.
- Workout.remove.test.jsx's locale-coverage test hardcoded an expected pack
count; already fixed once for the 12th language, re-applied here since hu
is now the 14th — derives the count from LANGS so this stops recurring.
Translated in bulk with AI assistance and validated programmatically (id
coverage against the 1,324-exercise catalogue, key-set parity across all 13
locales via check-locales.mjs, duplicate/collision and encoding checks) —
not yet proofread line-by-line by a fluent human reviewer, same disclosure
standard scripts/exercise-name-sources/README.md and instruction-sources/
README.md already hold the pt-BR translations to.
node frontend/scripts/check-locales.mjs: 13 locales, 740 keys each, in sync.
Full frontend test suite: 39 files / 533 tests passing.
This commit is contained in:
8 files changed
+2063
-10
No files matched your search
@@ -6,6 +6,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import Workout, { removeActiveExercise } from './Workout.jsx'
|
||||
import { DEF, useStore } from '../store/useStore.js'
|
||||
import { useUI } from '../store/useUI.js'
|
||||
import { LANGS } from '../lib/i18n-core.js'
|
||||
|
||||
vi.mock('../lib/sound.js', () => ({ beep: vi.fn(), vibrate: vi.fn() }))
|
||||
vi.mock('../lib/api.js', () => ({ api: vi.fn(() => Promise.resolve({})) }))
|
||||
@@ -109,9 +110,13 @@ describe('remove-exercise locale coverage', () => {
|
||||
'Which exercise in this superset do you want to remove?'
|
||||
]
|
||||
const packs = import.meta.glob('../locales/*.js', { eager: true, import: 'default' })
|
||||
// Every non-English language has its own pack (English is the source, so it has none) —
|
||||
// derived from LANGS rather than hardcoded so adding a language doesn't silently
|
||||
// understate this test's own coverage.
|
||||
const nonEnglishLangCount = Object.keys(LANGS).length - 1
|
||||
|
||||
it('defines every new prompt in all twelve locale packs', () => {
|
||||
expect(Object.keys(packs)).toHaveLength(12)
|
||||
it('defines every new prompt in every non-English locale pack', () => {
|
||||
expect(Object.keys(packs)).toHaveLength(nonEnglishLangCount)
|
||||
Object.entries(packs).forEach(([path, pack]) => {
|
||||
required.forEach(key => expect(pack, `${path} is missing ${key}`).toHaveProperty(key))
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user