"use client"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import { IconLanguage } from "@tabler/icons-react"; import { Label } from "@kandev/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@kandev/ui/select"; import { SettingsSection } from "@/components/settings/settings-section"; import { CardContent } from "@kandev/ui/card"; import { SettingsCard } from "@/components/settings/settings-card"; import { readBootPayload } from "@/src/boot-payload"; import { pseudoLocaleAvailable } from "@/lib/i18n/boot"; import { activateLocale, i18n, LOCALE_LABELS, normalizeLocale, selectableLocales, type SupportedLocale, } from "@/lib/i18n"; import { GENERAL_SETTINGS_TARGETS } from "@/lib/settings-discovery/catalog/preferences"; /** * Language switcher. Applies immediately (no deferred save) — `activateLocale` * re-renders the app and persists the choice to the `kandev_locale` cookie — so * this surface owns no unsaved state and does not register a save contributor. * The pseudo QA locale is hidden in production builds. */ export function LanguageSettings() { const { t } = useTranslation(); const [locale, setLocale] = useState(() => normalizeLocale(i18n.language)); // Not `import.meta.env.PROD`: the e2e harness serves a production bundle, so // that constant would hide the pseudo locale the QA specs rely on. const options = selectableLocales(!pseudoLocaleAvailable(readBootPayload())); const handleChange = async (value: string) => { const activated = await activateLocale(value); setLocale(activated); }; return ( } title={t("settings:language")} description={t("settings:chooseTheLanguageUsedAcrossThe")} > {/* Card only supplies vertical padding; the horizontal px-4 comes from CardContent, which every other settings card here goes through. */}

{t("settings:changesTheLanguageOfTheKandev")}

); }