mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-23 00:20:40 +07:00
refactor(i18n): split content into structure JSON and per-language dictionaries
Phase 1 of spec-v4-live-edit: data/i18n foundation, no visible feature.
- src/data/{profile,skills,experience,projects}.json: language-neutral
structure documents with thin typed loaders; all prose moved to
src/i18n/locales/{vi,en}/content.json; chrome strings to ui.json
- src/i18n/: dict-types, cross-document validator (runs at module load and
via pnpm validate:content), loader joining structure+text once (UI/CONTENT),
I18nProvider/useI18n mounted in App under LanguageProvider
- all 22 consumers read joined records via useI18n(); field.ts and
strings.ts deleted; *En field pairs removed from the domain types
- hero tagline renders as plain-text segments (D9); philosophy quotes as
paragraph arrays; footer display name now localizes per language (D6)
- resume generator consumes UI/CONTENT; generated resume HTML verified
byte-identical (EN+VI) before/after the migration
- AGENTS.md and v3/v3-i18n + v4 specs updated; deploy.yml concurrency group
This commit is contained in:
1 parent
f5687cce1c
commit
e6b4d83084
50 files changed
+2215
-961
No files matched your search
@@ -5,7 +5,7 @@ import { navPaths } from '@/data/navigation'
|
||||
import { paletteIds, paletteMeta } from '@/data/palettes'
|
||||
import { useTheme } from '@/hooks/useTheme'
|
||||
import { useLanguage } from '@/hooks/useLanguage'
|
||||
import { strings } from '@/i18n/strings'
|
||||
import { useI18n } from '@/i18n/provider'
|
||||
import { RollingTextLink } from '@/components/ui/RollingTextLink'
|
||||
import { SocialLinks } from '@/components/ui/SocialLinks'
|
||||
import { LanguageIcon } from '@/components/ui/LanguageIcon'
|
||||
@@ -18,6 +18,7 @@ interface MobileMenuProps {
|
||||
|
||||
export function MobileMenu({ open, onClose }: MobileMenuProps) {
|
||||
const { lang, setLang } = useLanguage()
|
||||
const { ui: s } = useI18n()
|
||||
const { resolvedTheme, setTheme, palette, setPalette } = useTheme()
|
||||
const location = useLocation()
|
||||
const reduceMotion = useReducedMotion()
|
||||
@@ -33,7 +34,7 @@ export function MobileMenu({ open, onClose }: MobileMenuProps) {
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
tabIndex={-1}
|
||||
aria-label={strings.nav.menuAria[lang]}
|
||||
aria-label={s.nav.menuAria}
|
||||
initial={{ opacity: 0, y: -12 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
exit={{ opacity: 0, y: -12 }}
|
||||
@@ -41,11 +42,11 @@ export function MobileMenu({ open, onClose }: MobileMenuProps) {
|
||||
onAnimationComplete={() => sheetRef.current?.focus()}
|
||||
>
|
||||
<div className="mobile-menu-inner">
|
||||
<nav className="mobile-menu-group" aria-label={strings.nav.groupMenu[lang]}>
|
||||
<span className="mobile-menu-heading">{strings.nav.groupMenu[lang]}</span>
|
||||
<nav className="mobile-menu-group" aria-label={s.nav.groupMenu}>
|
||||
<span className="mobile-menu-heading">{s.nav.groupMenu}</span>
|
||||
<ul className="mobile-menu-list">
|
||||
{navPaths.map((path, index) => {
|
||||
const navKey = path === '/' ? 'home' : path.replace('/', '') as keyof typeof strings.nav
|
||||
const navKey = path === '/' ? 'home' : path.replace('/', '') as keyof typeof s.nav
|
||||
const active = path === location.pathname
|
||||
return (
|
||||
<motion.li
|
||||
@@ -60,7 +61,7 @@ export function MobileMenu({ open, onClose }: MobileMenuProps) {
|
||||
className={active ? 'mobile-menu-link active' : 'mobile-menu-link'}
|
||||
onClick={onClose}
|
||||
>
|
||||
{strings.nav[navKey][lang]}
|
||||
{s.nav[navKey]}
|
||||
</RollingTextLink>
|
||||
</motion.li>
|
||||
)
|
||||
@@ -69,11 +70,11 @@ export function MobileMenu({ open, onClose }: MobileMenuProps) {
|
||||
</nav>
|
||||
|
||||
<div className="mobile-menu-group">
|
||||
<span className="mobile-menu-heading">{strings.nav.groupAppearance[lang]}</span>
|
||||
<span className="mobile-menu-heading">{s.nav.groupAppearance}</span>
|
||||
|
||||
<div className="mobile-menu-segment">
|
||||
<span className="mobile-menu-segment-label">{strings.nav.langGroup[lang]}</span>
|
||||
<div className="mobile-menu-segment-options" role="group" aria-label={strings.nav.langGroup[lang]}>
|
||||
<span className="mobile-menu-segment-label">{s.nav.langGroup}</span>
|
||||
<div className="mobile-menu-segment-options" role="group" aria-label={s.nav.langGroup}>
|
||||
{/* Icons, not words — globe for English, red flag for Tiếng Việt — in the same
|
||||
44px icon-only shape as the Theme color row. An icon cannot say which language
|
||||
it is, so each option carries its own-language name in aria-label and title. */}
|
||||
@@ -81,8 +82,8 @@ export function MobileMenu({ open, onClose }: MobileMenuProps) {
|
||||
type="button"
|
||||
className={lang === 'en' ? 'mobile-menu-icon-option active' : 'mobile-menu-icon-option'}
|
||||
aria-pressed={lang === 'en'}
|
||||
aria-label={strings.nav.langEn[lang]}
|
||||
title={strings.nav.langEn[lang]}
|
||||
aria-label={s.nav.langEn}
|
||||
title={s.nav.langEn}
|
||||
onClick={() => setLang('en')}
|
||||
>
|
||||
<LanguageIcon lang="en" />
|
||||
@@ -91,8 +92,8 @@ export function MobileMenu({ open, onClose }: MobileMenuProps) {
|
||||
type="button"
|
||||
className={lang === 'vi' ? 'mobile-menu-icon-option active' : 'mobile-menu-icon-option'}
|
||||
aria-pressed={lang === 'vi'}
|
||||
aria-label={strings.nav.langVi[lang]}
|
||||
title={strings.nav.langVi[lang]}
|
||||
aria-label={s.nav.langVi}
|
||||
title={s.nav.langVi}
|
||||
onClick={() => setLang('vi')}
|
||||
>
|
||||
<LanguageIcon lang="vi" />
|
||||
@@ -101,8 +102,8 @@ export function MobileMenu({ open, onClose }: MobileMenuProps) {
|
||||
</div>
|
||||
|
||||
<div className="mobile-menu-segment">
|
||||
<span className="mobile-menu-segment-label">{strings.nav.themeGroup[lang]}</span>
|
||||
<div className="mobile-menu-segment-options" role="group" aria-label={strings.nav.themeGroup[lang]}>
|
||||
<span className="mobile-menu-segment-label">{s.nav.themeGroup}</span>
|
||||
<div className="mobile-menu-segment-options" role="group" aria-label={s.nav.themeGroup}>
|
||||
{/* Icons, not words — the bar's own line art: moon for dark, sun for light.
|
||||
An icon alone cannot name a mode, so each option carries the translated
|
||||
mode name in aria-label and title. */}
|
||||
@@ -110,8 +111,8 @@ export function MobileMenu({ open, onClose }: MobileMenuProps) {
|
||||
type="button"
|
||||
className={resolvedTheme === 'dark' ? 'mobile-menu-icon-option active' : 'mobile-menu-icon-option'}
|
||||
aria-pressed={resolvedTheme === 'dark'}
|
||||
aria-label={strings.nav.themeDark[lang]}
|
||||
title={strings.nav.themeDark[lang]}
|
||||
aria-label={s.nav.themeDark}
|
||||
title={s.nav.themeDark}
|
||||
onClick={() => setTheme('dark')}
|
||||
>
|
||||
<MoonIcon />
|
||||
@@ -120,8 +121,8 @@ export function MobileMenu({ open, onClose }: MobileMenuProps) {
|
||||
type="button"
|
||||
className={resolvedTheme === 'light' ? 'mobile-menu-icon-option active' : 'mobile-menu-icon-option'}
|
||||
aria-pressed={resolvedTheme === 'light'}
|
||||
aria-label={strings.nav.themeLight[lang]}
|
||||
title={strings.nav.themeLight[lang]}
|
||||
aria-label={s.nav.themeLight}
|
||||
title={s.nav.themeLight}
|
||||
onClick={() => setTheme('light')}
|
||||
>
|
||||
<SunIcon />
|
||||
@@ -130,8 +131,8 @@ export function MobileMenu({ open, onClose }: MobileMenuProps) {
|
||||
</div>
|
||||
|
||||
<div className="mobile-menu-segment">
|
||||
<span className="mobile-menu-segment-label">{strings.nav.palette[lang]}</span>
|
||||
<div className="mobile-menu-segment-options" role="group" aria-label={strings.nav.palette[lang]}>
|
||||
<span className="mobile-menu-segment-label">{s.nav.palette}</span>
|
||||
<div className="mobile-menu-segment-options" role="group" aria-label={s.nav.palette}>
|
||||
{paletteIds.map((id) => (
|
||||
<button
|
||||
key={id}
|
||||
@@ -150,7 +151,7 @@ export function MobileMenu({ open, onClose }: MobileMenuProps) {
|
||||
</div>
|
||||
|
||||
<div className="mobile-menu-group">
|
||||
<span className="mobile-menu-heading">{strings.social.heading[lang]}</span>
|
||||
<span className="mobile-menu-heading">{s.social.heading}</span>
|
||||
<SocialLinks />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user