// EN / 日本語 language switch and the one-time Japanese suggestion card (shared by /en/ and /ja/). // On /en/ and /ja/ the URL decides the language: the switch is plain links. Only the root router // (index.html) picks a language, using the choice remembered here first and the browser language second. // The choice is stored in localStorage and in an `nh_lang` cookie the router and the quote app can read. const LANG_PAGES = { en: '/en/', ja: '/ja/' }; const LANG_KEY = 'nh-lang'; const LANG_SUGGEST_KEY = 'nh-lang-suggest'; function rememberLang(lang) { try { localStorage.setItem(LANG_KEY, lang); } catch (e) { /* storage blocked */ } document.cookie = `nh_lang=${lang}; path=/; max-age=31536000; SameSite=Lax`; } function storedLang() { try { const v = localStorage.getItem(LANG_KEY); if (v) return v; } catch (e) { /* storage blocked */ } const m = document.cookie.match(/(?:^|; )nh_lang=([^;]+)/); return m ? m[1] : null; } // variant: 'pill' (header and menu) or 'footer' (text links on the dark footer). // Each label is written in its own language, never "Japanese" / "英語". function LangSwitch({ current, variant = 'pill', className = '' }) { const items = variant === 'footer' ? [['en', 'English'], ['ja', '日本語']] : [['en', 'EN'], ['ja', '日本語']]; return (