mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10:40 +07:00
support multi languages
This commit is contained in:
1 parent
ca8ff2f983
commit
72a832c781
24 files changed
+995
-175
No files matched your search
@@ -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">
|
||||
© {year} {profile.name}. All rights reserved.
|
||||
© {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">
|
||||
|
||||
@@ -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 }}>
|
||||
|
||||
@@ -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>
|
||||
</>
|
||||
|
||||
Reference in new issue
Block a user