support multi languages

This commit is contained in:
dong.nguyen committed 2026-10-14 11:15:48 +07:00
1 parent ca8ff2f983
commit 72a832c781
24 files changed
+995 -175

No files matched your search

+16 -15
View File
@@ -1,31 +1,32 @@
import { Link } from 'react-router'
import { profile } from '@/data/profile'
const footerLinks = [
{ label: 'Home', path: '/' },
{ label: 'About', path: '/about' },
{ label: 'Projects', path: '/projects' },
{ label: 'Contact', path: '/contact' },
]
import { useLanguage } from '@/hooks/useLanguage'
import { strings } from '@/i18n/strings'
const footerPaths = ['/', '/about', '/projects', '/contact'] as const
export function Footer() {
const year = new Date().getFullYear()
const { lang } = useLanguage()
return (
<footer className="footer" role="contentinfo">
<div className="footer-container">
<p className="footer-text">
&copy; {year} {profile.name}. All rights reserved.
&copy; {year} {profile.name}. {strings.footer.copyright[lang]}
</p>
<ul className="footer-links">
{footerLinks.map((link) => (
<li key={link.path}>
<Link to={link.path} className="footer-link">
{link.label}
</Link>
</li>
))}
{footerPaths.map((path) => {
const key = path === '/' ? 'home' : path.replace('/', '') as keyof typeof strings.footer.links
const label = strings.footer.links[key][lang]
return (
<li key={path}>
<Link to={path} className="footer-link">
{label}
</Link>
</li>
)
})}
</ul>
<div className="social-links">
+4 -1
View File
@@ -1,3 +1,5 @@
import { useLanguage } from '@/hooks/useLanguage'
import { strings } from '@/i18n/strings'
import { Navigation } from './Navigation'
import { BackToTop } from '@/components/ui/BackToTop'
import { Footer } from './Footer'
@@ -7,10 +9,11 @@ interface LayoutProps {
}
export function Layout({ children }: LayoutProps) {
const { lang } = useLanguage()
return (
<>
<a href="#main-content" className="skip-link">
Skip to content
{strings.common.skipLink[lang]}
</a>
<Navigation />
<main id="main-content" style={{ flex: 1 }}>
+41 -31
View File
@@ -1,19 +1,13 @@
import { useState, useEffect } from 'react'
import { Link, useLocation } from 'react-router'
import { useTheme } from '@/hooks/useTheme'
import { useLanguage } from '@/hooks/useLanguage'
import { strings } from '@/i18n/strings'
import { RollingTextLink } from '@/components/ui/RollingTextLink'
const navItems = [
{ label: 'Home', path: '/' },
{ label: 'About', path: '/about' },
{ label: 'Experience', path: '/experience' },
{ label: 'Projects', path: '/projects' },
{ label: 'Engineering', path: '/engineering' },
{ label: 'Contact', path: '/contact' },
]
const navPaths = ['/', '/about', '/experience', '/projects', '/engineering', '/contact'] as const
export function Navigation() {
const { cycleTheme, resolvedTheme } = useTheme()
const { lang, toggleLang } = useLanguage()
const [mobileOpen, setMobileOpen] = useState(false)
const location = useLocation()
@@ -43,16 +37,20 @@ export function Navigation() {
</Link>
<ul className="nav-menu">
{navItems.map((item) => (
<li key={item.path}>
<RollingTextLink
to={item.path}
className={item.path === location.pathname ? 'nav-link active' : 'nav-link'}
>
{item.label}
</RollingTextLink>
</li>
))}
{navPaths.map((path) => {
const navKey = path === '/' ? 'home' : path.replace('/', '') as keyof typeof strings.nav
const label = strings.nav[navKey][lang]
return (
<li key={path}>
<RollingTextLink
to={path}
className={path === location.pathname ? 'nav-link active' : 'nav-link'}
>
{label}
</RollingTextLink>
</li>
)
})}
</ul>
<div className="nav-actions">
@@ -74,6 +72,14 @@ export function Navigation() {
)}
</button>
<button
className="lang-toggle"
onClick={toggleLang}
aria-label="Switch language"
title={`Switch to ${lang === 'en' ? 'Tiếng Việt' : 'English'}`}
>
{lang === 'en' ? 'VI' : 'EN'}
</button>
<button
className="mobile-menu-btn"
onClick={() => setMobileOpen(!mobileOpen)}
@@ -96,17 +102,21 @@ export function Navigation() {
<div className={`mobile-menu ${mobileOpen ? 'open' : ''}`} role="dialog" aria-label="Mobile navigation">
<ul className="mobile-menu-list">
{navItems.map((item) => (
<li key={item.path}>
<RollingTextLink
to={item.path}
className={item.path === location.pathname ? 'mobile-menu-link active' : 'mobile-menu-link'}
onClick={() => setMobileOpen(false)}
>
{item.label}
</RollingTextLink>
</li>
))}
{navPaths.map((path) => {
const navKey = path === '/' ? 'home' : path.replace('/', '') as keyof typeof strings.nav
const label = strings.nav[navKey][lang]
return (
<li key={path}>
<RollingTextLink
to={path}
className={path === location.pathname ? 'mobile-menu-link active' : 'mobile-menu-link'}
onClick={() => setMobileOpen(false)}
>
{label}
</RollingTextLink>
</li>
)
})}
</ul>
</div>
</>
+8 -6
View File
@@ -2,21 +2,23 @@ import { SectionHeading } from '@/components/ui/SectionHeading'
import { InView } from '@/components/ui/InView'
import { Tag } from '@/components/ui/Tag'
import { profile } from '@/data/profile'
import { useLanguage } from '@/hooks/useLanguage'
import { strings } from '@/i18n/strings'
import { useField } from '@/i18n/useField'
export function About() {
const { lang } = useLanguage()
return (
<InView>
<section className="section container-wide" aria-labelledby="about-heading">
<SectionHeading title="About Me" tag="01 - About" />
<SectionHeading title={strings.about.heading[lang]} tag="01 - About" />
<div style={{ maxWidth: '700px' }}>
<p style={{ fontSize: '18px', marginBottom: '32px' }}>
{profile.bio}
{useField(profile.bio, profile.bioEn)}
</p>
<h3 style={{ fontSize: '20px', marginBottom: '16px', color: 'var(--text-primary)' }}>
How I Think About Engineering
{strings.about.engineeringTitle[lang]}
</h3>
<div className="philosophy-grid">
{profile.philosophy.map((point) => (
<div key={point.title} className="philosophy-card">
@@ -32,7 +34,7 @@ export function About() {
</div>
<h3 style={{ fontSize: '20px', marginTop: '32px', marginBottom: '12px', color: 'var(--text-primary)' }}>
What I'm Exploring
{strings.about.exploringTitle[lang]}
</h3>
<div className="interests-list">
{profile.currentInterests.map((interest) => (
+7 -5
View File
@@ -3,8 +3,10 @@ import { DownloadResume } from "@/components/sections/DownloadResume"
import { SectionHeading } from "@/components/ui/SectionHeading"
import { profile } from "@/data/profile"
import { InView } from "@/components/ui/InView"
import { useLanguage } from '@/hooks/useLanguage'
import { strings } from '@/i18n/strings'
export function Contact() {
const { lang } = useLanguage()
return (
<InView>
<motion.section
@@ -18,7 +20,7 @@ export function Contact() {
visible: { opacity: 1, transition: { duration: 0.5 } },
}}
>
<SectionHeading title="Contact" tag="06 - Contact" />
<SectionHeading title={strings.contact.heading[lang]} tag={`06 - ${strings.common.contactTag[lang]}`} />
<div style={{ maxWidth: '700px' }}>
<div className="contact-links">
<motion.a
@@ -40,7 +42,7 @@ export function Contact() {
</svg>
<div>
<div style={{ fontWeight: 500, color: "var(--text-primary)" }}>
Email
{strings.contact.email[lang]}
</div>
<div style={{ fontSize: "14px", color: "var(--text-muted)" }}>
{profile.email}
@@ -65,7 +67,7 @@ export function Contact() {
</svg>
<div>
<div style={{ fontWeight: 500, color: "var(--text-primary)" }}>
GitHub
{strings.contact.github[lang]}
</div>
<div style={{ fontSize: "14px", color: "var(--text-muted)" }}>
@yourusername
@@ -90,7 +92,7 @@ export function Contact() {
</svg>
<div>
<div style={{ fontWeight: 500, color: "var(--text-primary)" }}>
LinkedIn
{strings.contact.linkedin[lang]}
</div>
<div style={{ fontSize: "14px", color: "var(--text-muted)" }}>
Your Name
+10 -13
View File
@@ -1,6 +1,8 @@
import { resumeAvailable, resumeUrlFor, resumeLanguages } from '@/data/resume'
import type { Language } from '@/types'
import { useState, useRef, useEffect } from 'react'
import { useLanguage } from '@/hooks/useLanguage'
import { strings } from '@/i18n/strings'
const langLabels: Record<Language, string> = {
en: 'English',
@@ -8,6 +10,7 @@ const langLabels: Record<Language, string> = {
}
function DownloadButton({ lang }: { lang: Language }) {
const { lang: currentLang } = useLanguage()
return (
<a
href={resumeUrlFor(lang)}
@@ -28,7 +31,7 @@ function DownloadButton({ lang }: { lang: Language }) {
<path d="M12 2a1 1 0 0 1 1 1v9.586l2.707-2.707a1 1 0 1 1 1.414 1.414l-4.5 4.5a1 1 0 0 1-1.414 0l-4.5-4.5a1 1 0 1 1 1.414-1.414L11 12.586V3a1 1 0 0 1 1-1zm-7 16a1 1 0 1 1 0 2h14a1 1 0 1 1 0-2H5z" />
</svg>
<div>
<div style={{ fontWeight: 500, color: 'var(--text-primary)' }}>Download Resume</div>
<div style={{ fontWeight: 500, color: 'var(--text-primary)' }}>{strings.common.resumeDownload[currentLang]}</div>
<div style={{ fontSize: '14px', color: 'var(--text-muted)' }}>{langLabels[lang]}</div>
</div>
</a>
@@ -36,6 +39,7 @@ function DownloadButton({ lang }: { lang: Language }) {
}
function DownloadDropdown() {
const { lang } = useLanguage()
const [open, setOpen] = useState(false)
const ref = useRef<HTMLDivElement>(null)
@@ -70,7 +74,7 @@ function DownloadDropdown() {
<path d="M12 3v10m0 0l-3-3m3 3l3-3" />
<path d="M3 17h18" />
</svg>
<span>Download Resume</span>
<span>{strings.common.resumeDownload[lang]}</span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" width="16" height="16" className="chevron">
<polyline points="6 9 12 15 18 9" />
</svg>
@@ -99,18 +103,11 @@ export function DownloadResume() {
return (
<div style={{ marginTop: '32px' }}>
{/* Desktop: dropdown */}
<div className="download-resume-desktop">
{resumeLanguages.length > 1 ? (
<DownloadDropdown />
</div>
{/* Mobile: 2 buttons */}
<div className="download-resume-mobile">
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
{resumeLanguages.map(lang => (
<DownloadButton key={lang} lang={lang} />
))}
</div>
</div>
) : (
<DownloadButton lang={resumeLanguages[0]} />
)}
</div>
)
}
+8 -5
View File
@@ -2,8 +2,11 @@ import { SectionHeading } from '@/components/ui/SectionHeading'
import { motion } from "motion/react"
import { experiences } from "@/data/experience"
import { InView } from "@/components/ui/InView"
import { useLanguage } from '@/hooks/useLanguage'
import { strings } from '@/i18n/strings'
export function Experience() {
const { lang } = useLanguage()
return (
<InView>
<motion.section
@@ -20,7 +23,7 @@ export function Experience() {
},
}}
>
<SectionHeading title="Experience" tag="03 - Experience" />
<SectionHeading title={strings.experience.heading[lang]} tag="03 - Experience" />
<div style={{ maxWidth: '700px' }}>
<div className="timeline">
{experiences.map((exp, i) => (
@@ -40,7 +43,7 @@ export function Experience() {
>
<div className="timeline-marker" />
<div className="timeline-header">
<div className="timeline-title">{exp.title}</div>
<div className="timeline-title">{lang === 'vi' ? exp.title : exp.titleEn}</div>
<div className="timeline-company">{exp.company}</div>
<div className="timeline-duration">{exp.duration}</div>
{exp.location && (
@@ -48,7 +51,7 @@ export function Experience() {
)}
</div>
<ul className="timeline-responsibilities">
{exp.responsibilities.map((r) => (
{(lang === 'vi' ? exp.responsibilities : exp.responsibilitiesEn ?? []).map((r) => (
<li key={r}>{r}</li>
))}
</ul>
@@ -58,7 +61,7 @@ export function Experience() {
{achievement.title}
</div>
<div className="achievement-context">
{achievement.context}
{lang === 'vi' ? achievement.context : achievement.contextEn}
</div>
<div
style={{
@@ -67,7 +70,7 @@ export function Experience() {
marginBottom: "8px",
}}
>
{achievement.impact}
{lang === 'vi' ? achievement.impact : achievement.impactEn}
</div>
{achievement.metrics &&
achievement.metrics.length > 0 && (
+5 -2
View File
@@ -2,8 +2,11 @@ import { motion } from "motion/react"
import { SectionHeading } from "@/components/ui/SectionHeading"
import { skillGroups } from "@/data/skills"
import { InView } from "@/components/ui/InView"
import { useLanguage } from '@/hooks/useLanguage'
import { strings } from '@/i18n/strings'
export function Expertise() {
const { lang } = useLanguage()
return (
<InView>
<motion.section
@@ -20,7 +23,7 @@ export function Expertise() {
},
}}
>
<SectionHeading title="Core Expertise" tag="02 - Expertise" />
<SectionHeading title={strings.expertise.heading[lang]} tag="02 - Expertise" />
<div className="expertise-grid">
{skillGroups.map((group, i) => (
<motion.div
@@ -37,7 +40,7 @@ export function Expertise() {
whileHover={{ scale: 1.05, y: -2 }}
whileTap={{ scale: 0.98 }}
>
<h3>{group.title}</h3>
<h3>{lang === 'vi' ? group.title : group.titleEn}</h3>
<ul className="expertise-skills">
{group.skills.map((skill) => (
<li key={skill} className="expertise-skill">
+11 -7
View File
@@ -3,12 +3,15 @@ import { motion, useScroll, useTransform } from "motion/react"
import { InView } from "@/components/ui/InView"
import { resumeAvailable, resumeLanguages, resumeUrlFor } from "@/data/resume"
import type { Language } from '@/types'
import { useLanguage } from '@/hooks/useLanguage'
import { strings } from '@/i18n/strings'
import { useField } from '@/i18n/useField'
const langLabels: Record<Language, string> = {
en: 'English',
vi: 'Tiếng Việt',
}
function HeroDownloadDropdown() {
const { lang } = useLanguage()
const [open, setOpen] = useState(false)
const ref = useRef<HTMLDivElement>(null)
@@ -43,7 +46,7 @@ function HeroDownloadDropdown() {
<path d="M12 3v10m0 0l-3-3m3 3l3-3" />
<path d="M3 17h18" />
</svg>
<span>Download Resume</span>
<span>{strings.common.resumeDownload[lang]}</span>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" width="14" height="14" className="chevron">
<polyline points="6 9 12 15 18 9" />
</svg>
@@ -122,6 +125,7 @@ const socialLinks = [
export function Hero() {
const { scrollY } = useScroll()
const { lang } = useLanguage()
const y = useTransform(scrollY, [0, 300], [0, -80])
return (
<InView>
@@ -147,7 +151,7 @@ export function Hero() {
>
<span className="hero-greeting">
<span className="greeting-dot" />
Hi, I'm
{strings.hero.greeting[lang]}
</span>
</motion.div>
<motion.h1
@@ -173,7 +177,7 @@ export function Hero() {
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.5, delay: 0.5 }}
>
{profile.tagline}
{useField(profile.tagline, profile.taglineEn)}
</motion.p>
<motion.div
className="hero-cta"
@@ -182,10 +186,10 @@ export function Hero() {
transition={{ duration: 0.5, delay: 0.6 }}
>
<Button href="/projects" variant="primary">
View Projects
{strings.hero.ctaProjects[lang]}
</Button>
<Button href="/contact" variant="primary">
Contact Me
{strings.hero.ctaContact[lang]}
</Button>
{resumeAvailable && (
<>
@@ -206,7 +210,7 @@ export function Hero() {
<div className="scroll-mouse">
<div className="scroll-wheel" />
</div>
<span>Scroll</span>
<span>{strings.hero.scroll[lang]}</span>
</div>
<motion.div
className="hero-visual"
+9 -14
View File
@@ -4,18 +4,13 @@ import { motion } from "motion/react"
import { Badge } from "@/components/ui/Badge"
import { projects } from "@/data/projects"
import { InView } from "@/components/ui/InView"
import { useLanguage } from '@/hooks/useLanguage'
import { strings } from '@/i18n/strings'
const MotionLink = motion.create(Link)
const categoryLabels: Record<string, string> = {
"software-engineering": "Software Engineering",
logistics: "Logistics",
"ai-ml": "AI / ML",
"computer-vision": "Computer Vision",
architecture: "Architecture",
experiment: "Experiment",
}
export function Projects() {
const { lang } = useLanguage()
const featured = projects.filter((p) => p.featured).slice(0, 4)
return (
@@ -34,12 +29,12 @@ export function Projects() {
},
}}
>
<SectionHeading title="Featured Projects" tag="04 - Projects" />
<SectionHeading title={strings.projects.featured[lang]} tag="04 - Projects" />
<Link
to="/projects"
style={{ fontSize: "14px", fontWeight: 500, color: "var(--accent)", display: "block", marginBottom: "24px" }}
>
View All →
{strings.projects.viewAll[lang]} →
</Link>
<div className="projects-grid">
{featured.map((project, i) => (
@@ -62,10 +57,10 @@ export function Projects() {
<div className="project-card-header">
<h3>{project.title}</h3>
<Badge variant="outline">
{categoryLabels[project.category] || project.category}
{strings.projects.categories[project.category][lang]}
</Badge>
</div>
<p className="project-card-summary">{project.summary}</p>
<p className="project-card-summary">{lang === 'vi' ? project.summary : project.summaryEn}</p>
<div className="project-card-techs">
{project.technologies.slice(0, 4).map((tech) => (
<span key={tech} className="tag">
@@ -82,7 +77,7 @@ export function Projects() {
))}
</div>
)}
<span className="project-card-cta">View Details →</span>
<span className="project-card-cta">{strings.projects.viewDetails[lang]} →</span>
</div>
</MotionLink>
))}