Localization: 12 UI languages + exercise instructions in 10 (#7)
Adds a Language setting (Settings → Appearance) that translates the whole app: a tiny dependency-free i18n layer (English source strings as keys, per-language dictionaries in frontend/src/locales/) plus per-language exercise-instruction packs generated from the upstream dataset (frontend/src/instr/, via scripts/build-instructions.mjs). UI: en, de, es, fr, it, pt, pl, tr, ru, zh, ko, hi. Instructions: all of those except de/pt (not in the upstream dataset — fall back to English). Body-part/equipment/muscle labels and date formats are localized too; exercise names stay English (upstream limitation). Everything is lazy-loaded per language (Vite code-splitting), so the initial bundle is unchanged; the choice syncs with the profile like the theme. Closes #7.
This commit is contained in:
1 parent
b9f8d18bbd
commit
c05b0756ec
44 files changed
+3891
-274
No files matched your search
@@ -2,6 +2,7 @@ import { useEffect } from 'react'
|
||||
import { HashRouter, Routes, Route, Navigate, useNavigate, useLocation } from 'react-router-dom'
|
||||
import { useStore } from './store/useStore.js'
|
||||
import { ACCENTS } from './lib/format.js'
|
||||
import { setLang, useLang } from './lib/i18n.js'
|
||||
import { setNav } from './lib/nav.js'
|
||||
import { startFlow } from './sheets.jsx'
|
||||
import TabBar from './components/TabBar.jsx'
|
||||
@@ -31,8 +32,11 @@ function Shell() {
|
||||
const loc = useLocation()
|
||||
const { S, user, ready } = useStore()
|
||||
const isGuest = useStore(s => s.isGuest())
|
||||
const langV = useLang() // re-renders the whole shell when the language (pack) changes
|
||||
useEffect(() => { setNav(navigate) }, [navigate])
|
||||
useEffect(() => { applyPrefs(S.theme, S.accent) }, [S.theme, S.accent])
|
||||
useEffect(() => { setLang(S.lang || 'en') }, [S.lang])
|
||||
useEffect(() => { document.documentElement.lang = S.lang || 'en' }, [langV, S.lang])
|
||||
// every tab/route change starts at the top of the page
|
||||
useEffect(() => { window.scrollTo(0, 0) }, [loc.pathname])
|
||||
|
||||
|
||||
Reference in new issue
Block a user