mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10: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
@@ -1,25 +1,26 @@
|
||||
import { Link } from 'react-router'
|
||||
import { profile } from '@/data/profile'
|
||||
import { useLanguage } from '@/hooks/useLanguage'
|
||||
import { strings } from '@/i18n/strings'
|
||||
import { useI18n } from '@/i18n/provider'
|
||||
import { footerPaths } from '@/data/navigation'
|
||||
import { SocialLinks } from '@/components/ui/SocialLinks'
|
||||
|
||||
export function Footer() {
|
||||
const year = new Date().getFullYear()
|
||||
const { lang } = useLanguage()
|
||||
const { ui: s, content: c } = useI18n()
|
||||
|
||||
// The display name is localized (D6): the English footer now names "Dong
|
||||
// Nguyen" instead of carrying the Vietnamese name in both languages.
|
||||
return (
|
||||
<footer className="footer" role="contentinfo">
|
||||
<div className="footer-container">
|
||||
<p className="footer-text">
|
||||
© {year} {profile.name}. {strings.footer.copyright[lang]}
|
||||
© {year} {c.profile.name}. {s.footer.copyright}
|
||||
</p>
|
||||
|
||||
<ul className="footer-links">
|
||||
{footerPaths.map((path) => {
|
||||
const key = path === '/' ? 'home' : path.replace('/', '') as keyof typeof strings.footer.links
|
||||
const label = strings.footer.links[key][lang]
|
||||
const key = path === '/' ? 'home' : path.replace('/', '') as keyof typeof s.footer.links
|
||||
const label = s.footer.links[key]
|
||||
|
||||
return (
|
||||
<li key={path}>
|
||||
<Link to={path} className="footer-link">
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Link, useLocation } from 'react-router'
|
||||
import { AnimatePresence, motion } from 'motion/react'
|
||||
import { useTheme } from '@/hooks/useTheme'
|
||||
import { useLanguage } from '@/hooks/useLanguage'
|
||||
import { strings } from '@/i18n/strings'
|
||||
import { useI18n } from '@/i18n/provider'
|
||||
import { navPaths } from '@/data/navigation'
|
||||
import { RollingTextLink } from '@/components/ui/RollingTextLink'
|
||||
import { ThemePaletteMenu } from '@/components/layout/ThemePaletteMenu'
|
||||
@@ -15,8 +15,9 @@ import { ResumeNavButton } from '@/components/layout/ResumeNavButton'
|
||||
export function Navigation() {
|
||||
const { cycleTheme, resolvedTheme } = useTheme()
|
||||
const { lang, toggleLang } = useLanguage()
|
||||
const { ui: s } = useI18n()
|
||||
const targetLang = lang === 'en' ? 'vi' : 'en'
|
||||
const targetLabel = targetLang === 'en' ? strings.nav.langEn[lang] : strings.nav.langVi[lang]
|
||||
const targetLabel = targetLang === 'en' ? s.nav.langEn : s.nav.langVi
|
||||
const [mobileOpen, setMobileOpen] = useState(false)
|
||||
const location = useLocation()
|
||||
const triggerRef = useRef<HTMLButtonElement>(null)
|
||||
@@ -59,7 +60,7 @@ export function Navigation() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<nav className="nav" role="navigation" aria-label={strings.nav.mainNav[lang]}>
|
||||
<nav className="nav" role="navigation" aria-label={s.nav.mainNav}>
|
||||
<div className="nav-container">
|
||||
<div className="nav-brand">
|
||||
{/* Trigger first, brand next: the hamburger is the sheet's own control and sits at
|
||||
@@ -69,7 +70,7 @@ export function Navigation() {
|
||||
ref={triggerRef}
|
||||
className="mobile-menu-btn"
|
||||
onClick={() => setMobileOpen((prev) => !prev)}
|
||||
aria-label={mobileOpen ? strings.nav.closeMenu[lang] : strings.nav.openMenu[lang]}
|
||||
aria-label={mobileOpen ? s.nav.closeMenu : s.nav.openMenu}
|
||||
aria-expanded={mobileOpen}
|
||||
aria-controls="mobile-menu"
|
||||
>
|
||||
@@ -103,7 +104,7 @@ export function Navigation() {
|
||||
<Link to="/"> target the {CV} wordmark always had. The accessible name is the
|
||||
translated Home label; the icon itself is decorative. The current-page marker stays
|
||||
on the nav link and the sheet's Home row. */}
|
||||
<Link to="/" className="nav-logo" aria-label={strings.nav.home[lang]}>
|
||||
<Link to="/" className="nav-logo" aria-label={s.nav.home}>
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
||||
<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
|
||||
<polyline points="9 22 9 12 15 12 15 22" />
|
||||
@@ -116,8 +117,8 @@ export function Navigation() {
|
||||
|
||||
<ul className="nav-menu">
|
||||
{navPaths.map((path) => {
|
||||
const navKey = path === '/' ? 'home' : path.replace('/', '') as keyof typeof strings.nav
|
||||
const label = strings.nav[navKey][lang]
|
||||
const navKey = path === '/' ? 'home' : path.replace('/', '') as keyof typeof s.nav
|
||||
const label = s.nav[navKey]
|
||||
return (
|
||||
<li key={path}>
|
||||
<RollingTextLink
|
||||
@@ -139,8 +140,8 @@ export function Navigation() {
|
||||
<button
|
||||
className="nav-control lang-toggle"
|
||||
onClick={toggleLang}
|
||||
aria-label={strings.nav.langSwitch[lang]}
|
||||
title={`${strings.nav.switchTo[lang]} ${targetLabel}`}
|
||||
aria-label={s.nav.langSwitch}
|
||||
title={`${s.nav.switchTo} ${targetLabel}`}
|
||||
>
|
||||
<LanguageIcon lang={targetLang} />
|
||||
</button>
|
||||
@@ -148,8 +149,8 @@ export function Navigation() {
|
||||
<button
|
||||
className="nav-control theme-toggle"
|
||||
onClick={cycleTheme}
|
||||
aria-label={`${strings.nav.themeSwitch[lang]} (${resolvedTheme === 'dark' ? strings.nav.themeDark[lang] : strings.nav.themeLight[lang]})`}
|
||||
title={`${strings.nav.themeMode[lang]}: ${resolvedTheme === 'dark' ? strings.nav.themeDark[lang] : strings.nav.themeLight[lang]}`}
|
||||
aria-label={`${s.nav.themeSwitch} (${resolvedTheme === 'dark' ? s.nav.themeDark : s.nav.themeLight})`}
|
||||
title={`${s.nav.themeMode}: ${resolvedTheme === 'dark' ? s.nav.themeDark : s.nav.themeLight}`}
|
||||
>
|
||||
{resolvedTheme === 'dark' ? <SunIcon /> : <MoonIcon />}
|
||||
</button>
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { resumeAvailable } from '@/data/resume'
|
||||
import { useLanguage } from '@/hooks/useLanguage'
|
||||
import { useI18n } from '@/i18n/provider'
|
||||
import { useResumeDialog } from '@/hooks/useResumeDialog'
|
||||
import { ResumeDialog } from '@/components/ui/ResumeDialog'
|
||||
import { ResumeIcon } from '@/components/ui/icons'
|
||||
import { strings } from '@/i18n/strings'
|
||||
|
||||
/**
|
||||
* Bar entry for the resume: an icon-only `.nav-control` in the brand group, right after the home
|
||||
@@ -11,7 +10,7 @@ import { strings } from '@/i18n/strings'
|
||||
* accessible name is the translated action in `aria-label`, the hint is the `title`.
|
||||
*/
|
||||
export function ResumeNavButton() {
|
||||
const { lang } = useLanguage()
|
||||
const { ui: s } = useI18n()
|
||||
const { open, openDialog, close, containerRef, triggerRef, panelRef } = useResumeDialog()
|
||||
|
||||
if (!resumeAvailable) return null
|
||||
@@ -24,8 +23,8 @@ export function ResumeNavButton() {
|
||||
aria-haspopup="dialog"
|
||||
aria-expanded={open}
|
||||
aria-controls="resume-modal-nav"
|
||||
aria-label={strings.nav.resume[lang]}
|
||||
title={strings.common.resumeModalHint[lang]}
|
||||
aria-label={s.nav.resume}
|
||||
title={s.common.resumeModalHint}
|
||||
onClick={openDialog}
|
||||
>
|
||||
<ResumeIcon size={24} />
|
||||
|
||||
@@ -4,11 +4,12 @@ import { useTheme } from '@/hooks/useTheme'
|
||||
import { useLanguage } from '@/hooks/useLanguage'
|
||||
import { useClickOutside } from '@/hooks/useClickOutside'
|
||||
import { paletteIds, paletteMeta } from '@/data/palettes'
|
||||
import { strings } from '@/i18n/strings'
|
||||
import { useI18n } from '@/i18n/provider'
|
||||
|
||||
export function ThemePaletteMenu() {
|
||||
const { palette, setPalette } = useTheme()
|
||||
const { lang } = useLanguage()
|
||||
const { ui: s } = useI18n()
|
||||
const [open, setOpen] = useState(false)
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
const triggerRef = useRef<HTMLButtonElement>(null)
|
||||
@@ -33,8 +34,8 @@ export function ThemePaletteMenu() {
|
||||
className={`nav-control nav-palette-trigger ${open ? 'open' : ''}`}
|
||||
aria-expanded={open}
|
||||
aria-controls="palette-menu"
|
||||
aria-label={`${strings.nav.palette[lang]}: ${paletteMeta[palette].label[lang]}`}
|
||||
title={strings.nav.paletteAria[lang]}
|
||||
aria-label={`${s.nav.palette}: ${paletteMeta[palette].label[lang]}`}
|
||||
title={s.nav.paletteAria}
|
||||
onClick={() => setOpen((prev) => !prev)}
|
||||
>
|
||||
{/* Rotation tracks the submenu: 90° while it is open, back to 0° on selection, Escape or
|
||||
|
||||
Reference in new issue
Block a user