import { STRINGS, type Strings } from '../i18n/strings' export type Locale = 'it' | 'en' /** * Site language, persisted in a cookie so SSR renders the right language on * the first request. `t(key)` reads the current locale's UI string. */ export function useLocale() { const locale = useCookie('lang', { default: () => 'it', sameSite: 'lax' }) function setLocale(value: Locale) { locale.value = value } function t(key: K): Strings[K] { return STRINGS[locale.value][key] } return { locale, setLocale, t } }