Adds a Russian version (data/resume.ru.json, default language) with an RU/EN switch stored under the key shared with the front page and the portfolio. The top bar becomes the site-wide one (brand, Resume, Portfolio, Gitea, Contact, language, theme) with a second row of anchors for this page's sections, and the fonts move to Unbounded and Onest so the three pages share one type system. Portfolio links now point at /portfolio/. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XtcZtnG4GQA1d6mW5PNrS9
21 lines
619 B
TypeScript
21 lines
619 B
TypeScript
'use client'
|
|
|
|
import { useEffect, useState } from 'react'
|
|
import type { Lang } from './i18n'
|
|
|
|
/** The current language (html[data-lang], set before the first paint); re-reads when the switch is used. */
|
|
export function useLang(): Lang {
|
|
const [lang, setLang] = useState<Lang>('ru')
|
|
useEffect(() => {
|
|
const read = () => {
|
|
const html = document.documentElement
|
|
const current: Lang = html.dataset.lang === 'en' ? 'en' : 'ru'
|
|
setLang(current)
|
|
}
|
|
read()
|
|
window.addEventListener('langchange', read)
|
|
return () => window.removeEventListener('langchange', read)
|
|
}, [])
|
|
return lang
|
|
}
|