mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-27 13:17:51 +02:00
Add locale support (#228)
This commit is contained in:
parent
800af20132
commit
416a17c5b7
47 changed files with 967 additions and 467 deletions
27
src/components/poll/language-selector.tsx
Normal file
27
src/components/poll/language-selector.tsx
Normal file
|
@ -0,0 +1,27 @@
|
|||
import clsx from "clsx";
|
||||
import Cookies from "js-cookie";
|
||||
import { useRouter } from "next/router";
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
export const LanguageSelect: React.VoidFunctionComponent<{
|
||||
className?: string;
|
||||
onChange?: (language: string) => void;
|
||||
}> = ({ className, onChange }) => {
|
||||
const { t } = useTranslation("common");
|
||||
const router = useRouter();
|
||||
return (
|
||||
<select
|
||||
className={clsx("input", className)}
|
||||
defaultValue={router.locale}
|
||||
onChange={(e) => {
|
||||
Cookies.set("NEXT_LOCALE", e.target.value, {
|
||||
expires: 365,
|
||||
});
|
||||
onChange?.(e.target.value);
|
||||
}}
|
||||
>
|
||||
<option value="en">{t("english")}</option>
|
||||
<option value="de">{t("german")}</option>
|
||||
</select>
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue