- Spotify: drop album line, normalize ";" separators to ",", add open-in-Spotify link and live progress bar - Games: resolve missing artwork via public Discord RPC app icons with placeholder fallback; add in-site game profile modal (IGDB + Steam + ITAD: artwork, details, reviews, prices) - Proxy game data through same-origin /api/game and /api/discord-app routes, CORS-locked to https://fristy.net - Lanyard: SSR REST first paint, then live WebSocket with heartbeat, reconnect backoff and polling fallback - Localize presence UI (tr/en/de): elapsed times, dates, numbers, currency, review labels, game descriptions - Sort projects by last update, descending - Slim dark scrollbars, compact Spotify progress bar
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { LOCALES, LOCALE_LABELS, LOCALE_COOKIE, isLocale, type Locale } from "@/lib/i18n/locales";
|
|
|
|
function writeLocaleCookie(locale: Locale): void {
|
|
document.cookie = `${LOCALE_COOKIE}=${locale}; path=/; max-age=31536000; SameSite=Lax`;
|
|
}
|
|
|
|
export function LanguageSwitcher({ current }: { current: Locale }) {
|
|
function switchTo(locale: Locale) {
|
|
if (locale === current || !isLocale(locale)) {
|
|
return;
|
|
}
|
|
writeLocaleCookie(locale);
|
|
window.location.reload();
|
|
}
|
|
|
|
return (
|
|
<div
|
|
role="group"
|
|
aria-label="language"
|
|
className="flex items-center gap-1 rounded-full border border-white/10 bg-white/5 p-1"
|
|
>
|
|
{LOCALES.map((locale) => (
|
|
<button
|
|
key={locale}
|
|
type="button"
|
|
onClick={() => switchTo(locale)}
|
|
aria-pressed={locale === current}
|
|
className={`cursor-pointer rounded-full px-2.5 py-1 font-mono text-xs transition-colors ${
|
|
locale === current
|
|
? "bg-blurple text-white"
|
|
: "text-zinc-400 hover:text-white"
|
|
}`}
|
|
>
|
|
{LOCALE_LABELS[locale]}
|
|
</button>
|
|
))}
|
|
</div>
|
|
);
|
|
}
|