fix(i18n): update consent banner on locale switch
Use next-intl translations instead of reading NEXT_LOCALE cookie once, so banner text updates immediately when switching languages. fix(activity-feed): make loading UI match dark theme Avoid the white loading card on hard reload by using the same dark styling as the normal feed. Co-authored-by: dennis <dennis@konkol.net>
This commit is contained in:
@@ -1,49 +1,28 @@
|
||||
"use client";
|
||||
|
||||
import React, { useMemo, useState } from "react";
|
||||
import React, { useState } from "react";
|
||||
import { useConsent, type ConsentState } from "./ConsentProvider";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
export default function ConsentBanner() {
|
||||
const { consent, setConsent } = useConsent();
|
||||
const [draft, setDraft] = useState<ConsentState>({ analytics: false, chat: false });
|
||||
const [minimized, setMinimized] = useState(false);
|
||||
|
||||
const locale = useMemo(() => {
|
||||
if (typeof document === "undefined") return "en";
|
||||
const match = document.cookie
|
||||
.split(";")
|
||||
.map((c) => c.trim())
|
||||
.find((c) => c.startsWith("NEXT_LOCALE="));
|
||||
if (!match) return "en";
|
||||
return decodeURIComponent(match.split("=").slice(1).join("=")) || "en";
|
||||
}, []);
|
||||
const t = useTranslations("consent");
|
||||
|
||||
const shouldShow = consent === null;
|
||||
if (!shouldShow) return null;
|
||||
|
||||
const s = locale === "de"
|
||||
? {
|
||||
title: "Datenschutz-Einstellungen",
|
||||
description:
|
||||
"Wir nutzen optionale Dienste (Analytics und Chat), um die Seite zu verbessern. Du kannst deine Auswahl jederzeit ändern.",
|
||||
essential: "Essentiell",
|
||||
analytics: "Analytics",
|
||||
chat: "Chatbot",
|
||||
acceptAll: "Alles akzeptieren",
|
||||
acceptSelected: "Auswahl akzeptieren",
|
||||
rejectAll: "Alles ablehnen",
|
||||
}
|
||||
: {
|
||||
title: "Privacy settings",
|
||||
description:
|
||||
"We use optional services (analytics and chat) to improve the site. You can change your choice anytime.",
|
||||
essential: "Essential",
|
||||
analytics: "Analytics",
|
||||
chat: "Chatbot",
|
||||
acceptAll: "Accept all",
|
||||
acceptSelected: "Accept selected",
|
||||
rejectAll: "Reject all",
|
||||
};
|
||||
const s = {
|
||||
title: t("title"),
|
||||
description: t("description"),
|
||||
essential: t("essential"),
|
||||
analytics: t("analytics"),
|
||||
chat: t("chat"),
|
||||
acceptAll: t("acceptAll"),
|
||||
acceptSelected: t("acceptSelected"),
|
||||
rejectAll: t("rejectAll"),
|
||||
};
|
||||
|
||||
if (minimized) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user