Components
Language Toggle
A toggle group component for switching between available languages in your Electron application
Edit on GitHub
The LangToggle component provides a visual toggle group for switching between available languages in your Electron application. It integrates with react-i18next for internationalization and persists the selected language preference.
Features
- Visual language switcher: Displays available languages as a toggle group
- i18next integration: Seamlessly works with
react-i18nextfor translations - Persistent selection: Saves language preference through the IPC layer
- Dynamic language list: Automatically renders options from your configured languages
Usage
import LangToggle from "@/components/lang-toggle";
export default function Settings() {
return (
<div>
<h2>Language Settings</h2>
<LangToggle />
</div>
);
}How It Works
- The component retrieves the current language from
i18n.languageusing theuseTranslationhook - Available languages are loaded from the
@/localization/langsconfiguration file - When a user selects a language,
setAppLanguageis called to:- Update the i18next instance with the new language
- Persist the preference through the IPC layer
Examples
Basic Usage
import LangToggle from "@/components/lang-toggle";
export default function SettingsPage() {
return (
<div className="space-y-6">
<section>
<h3 className="text-lg font-medium mb-2">Language</h3>
<p className="text-sm text-muted-foreground mb-4">
Select your preferred language
</p>
<LangToggle />
</section>
</div>
);
}Configuring Languages
Go to Inernationalization to learn how to set up and configure available languages for your application.