Files
riotpiao.com/lib/LanguageContext.tsx
Story Crater Bot b9ae470bc1 feat: portfolio redesign with i18n, RBC project showcase, CI/CD
- Add i18n support (EN/ZH) with language toggle
- Redesign header with education dropdown, contact copy buttons
- Add RBC project showcase with bullet points, skills highlighting
- Create terraform-drift placeholder page
- Add ProjectShowcase component with media toggle (image/video)
- Update experience timeline with action-driven descriptions
- Add Docker + Forgejo CI workflow for image builds
- Update K8s manifests for riotpiao.com ingress
- Add DESIGN.md documenting design system patterns
2026-08-31 13:59:46 -07:00

35 lines
868 B
TypeScript

'use client'
import { createContext, useContext, useState, ReactNode } from 'react'
import translations from './translations.json'
type Language = 'en' | 'zh'
interface LanguageContextType {
lang: Language
setLang: (lang: Language) => void
t: typeof translations.en
}
const LanguageContext = createContext<LanguageContextType | undefined>(undefined)
export function LanguageProvider({ children }: { children: ReactNode }) {
const [lang, setLang] = useState<Language>('en')
const t = lang === 'zh' ? translations.zh : translations.en
return (
<LanguageContext.Provider value={{ lang, setLang, t }}>
{children}
</LanguageContext.Provider>
)
}
export function useLanguage() {
const context = useContext(LanguageContext)
if (!context) {
throw new Error('useLanguage must be used within LanguageProvider')
}
return context
}