Roo-Code/webview-ui/src/components/settings/LanguageSettings.tsx
Chris Estreich a414c7d028
Wrangle our settings-related types and add support for settings import / export (#1997)
* Strongly type our settings use composition where possible

* Update src/core/contextProxy.ts

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Update src/core/contextProxy.ts

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Add comment, tweak function name

* Add changeset

* Clean up toolGroup types

* Comments tweak

* Remove unused type

* More type safety

* Improve import / export, add translations

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-03-26 16:29:01 -07:00

49 lines
1.6 KiB
TypeScript

import { HTMLAttributes } from "react"
import { useAppTranslation } from "@/i18n/TranslationContext"
import { Globe } from "lucide-react"
import { cn } from "@/lib/utils"
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from "@/components/ui"
import { Language, LANGUAGES } from "../../../../src/shared/language"
import { SetCachedStateField } from "./types"
import { SectionHeader } from "./SectionHeader"
import { Section } from "./Section"
type LanguageSettingsProps = HTMLAttributes<HTMLDivElement> & {
language: string
setCachedStateField: SetCachedStateField<"language">
}
export const LanguageSettings = ({ language, setCachedStateField, className, ...props }: LanguageSettingsProps) => {
const { t } = useAppTranslation()
return (
<div className={cn("flex flex-col gap-2", className)} {...props}>
<SectionHeader>
<div className="flex items-center gap-2">
<Globe className="w-4" />
<div>{t("settings:sections.language")}</div>
</div>
</SectionHeader>
<Section>
<Select value={language} onValueChange={(value) => setCachedStateField("language", value as Language)}>
<SelectTrigger className="w-full">
<SelectValue placeholder={t("settings:common.select")} />
</SelectTrigger>
<SelectContent>
<SelectGroup>
{Object.entries(LANGUAGES).map(([code, name]) => (
<SelectItem key={code} value={code}>
{name}
<span className="text-muted-foreground">({code})</span>
</SelectItem>
))}
</SelectGroup>
</SelectContent>
</Select>
</Section>
</div>
)
}