Load locale ondemand + spanish locale (#249)

This commit is contained in:
Luke Vella 2022-07-28 10:39:58 +01:00 committed by GitHub
parent 0f35bd0518
commit c2aea134ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 700 additions and 455 deletions

View file

@ -1,18 +1,16 @@
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();
const { t, i18n } = useTranslation("common");
return (
<select
className={clsx("input", className)}
defaultValue={router.locale}
defaultValue={i18n.language}
onChange={(e) => {
Cookies.set("NEXT_LOCALE", e.target.value, {
expires: 365,
@ -21,6 +19,7 @@ export const LanguageSelect: React.VoidFunctionComponent<{
}}
>
<option value="en">{t("english")}</option>
<option value="es">{t("spanish")}</option>
<option value="fr">{t("french")}</option>
<option value="de">{t("german")}</option>
<option value="sv">{t("swedish")}</option>