Skip to content

Commit

Permalink
update language chooser to be a select menu
Browse files Browse the repository at this point in the history
  • Loading branch information
astudentinearth committed Jan 17, 2025
1 parent b531764 commit 2492519
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
16 changes: 16 additions & 0 deletions packages/app-desktop/src/features/settings/language-select.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Select, SelectContent, SelectItem, SelectTrigger } from "@renderer/components/ui/select";
import { Language, LanguageNameMap } from "@renderer/types/lang";

export default function LanguageSelect({lang, onValueChange}: {lang: Language, onValueChange?: (val: Language)=>void}) {
return (
<Select value={lang} onValueChange={onValueChange}>
<SelectTrigger>
{LanguageNameMap[lang]}
</SelectTrigger>
<SelectContent>
<SelectItem value="tr">Türkçe</SelectItem>
<SelectItem value="en">English</SelectItem>
</SelectContent>
</Select>
)
}
17 changes: 3 additions & 14 deletions packages/app-desktop/src/features/settings/workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { useLocalStore } from "@renderer/context/local-state";
import { useBackup, useWorkspaceExport } from "@renderer/hooks/query";
import { Languages } from "lucide-react";
import { useTranslation } from "react-i18next";
import LanguageSelect from "./language-select";
import { Language } from "@renderer/types/lang";
//import { StartupBehvaiourSelect } from "./startup-behaviour-select";
// import { updateUserSettings, useSettingsStore } from "@renderer/context/settings-store";
// import { produce } from "immer";
Expand Down Expand Up @@ -55,20 +57,7 @@ export function WorkspaceSettings() {
<Languages size={18} className="inline" /> {t("languageText")}
</span>
<div className="flex gap-2 place-self-end">
<Button
onClick={() => i18n.changeLanguage("tr")}
variant={i18n.resolvedLanguage == "tr" ? "default" : "secondary"}
className="flex-shrink-0 w-fit"
>
Türkçe
</Button>
<Button
onClick={() => i18n.changeLanguage("en")}
variant={i18n.resolvedLanguage == "en" ? "default" : "secondary"}
className="flex-shrink-0 w-fit"
>
English
</Button>
<LanguageSelect lang={i18n.resolvedLanguage as Language ?? "en"} onValueChange={(lang)=>i18n.changeLanguage(lang)}/>
</div>
{/* <span>{t("startupBehaviourText")}</span>
<StartupBehvaiourSelect value={startup} onValueCahnge={startupChange}/> */}
Expand Down
2 changes: 2 additions & 0 deletions packages/app-desktop/src/lib/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ export function hexToHslVariable(hexstr: string) {
const hsl = hex.hsl(sanitized);
return `${hsl[0]} ${hsl[1]}% ${hsl[2]}%`;
}


7 changes: 7 additions & 0 deletions packages/app-desktop/src/types/lang.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

export const LanguageNameMap = {
"tr": "Türkçe",
"en": "English"
};

export type Language = keyof typeof LanguageNameMap;

0 comments on commit 2492519

Please sign in to comment.