mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-16 18:36:24 +02:00
Fix locale routing (#247)
This commit is contained in:
parent
870a4bb13d
commit
0f35bd0518
5 changed files with 16 additions and 4 deletions
|
@ -152,6 +152,7 @@ const Page: NextPage<CreatePollPageProps> = ({
|
|||
<StandardLayout>
|
||||
<Head>
|
||||
<title>{formData?.eventDetails?.title ?? t("newPoll")}</title>
|
||||
<meta name="robots" content="noindex,nofollow" />
|
||||
</Head>
|
||||
<div className="max-w-full py-4 md:px-3 lg:px-6">
|
||||
<div className="mx-auto w-fit max-w-full lg:mx-0">
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { useTranslation } from "next-i18next";
|
||||
import * as React from "react";
|
||||
|
||||
import ChevronLeft from "../../icons/chevron-left.svg";
|
||||
|
@ -13,6 +14,7 @@ export interface DateNavigationToolbarProps {
|
|||
|
||||
const DateNavigationToolbar: React.VoidFunctionComponent<DateNavigationToolbarProps> =
|
||||
({ year, label, onPrevious, onToday, onNext }) => {
|
||||
const { t } = useTranslation("app");
|
||||
return (
|
||||
<div className="flex h-14 w-full shrink-0 items-center border-b px-4">
|
||||
<div className="grow">
|
||||
|
@ -25,7 +27,7 @@ const DateNavigationToolbar: React.VoidFunctionComponent<DateNavigationToolbarPr
|
|||
<ChevronLeft className="h-5" />
|
||||
</button>
|
||||
<button type="button" onClick={onToday}>
|
||||
Today
|
||||
{t("today")}
|
||||
</button>
|
||||
<button type="button" onClick={onNext}>
|
||||
<ChevronRight className="h-5" />
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import Link from "next/link";
|
||||
import { useRouter } from "next/router";
|
||||
import { Trans, useTranslation } from "next-i18next";
|
||||
import * as React from "react";
|
||||
|
||||
|
@ -15,6 +16,7 @@ import { LanguageSelect } from "../poll/language-selector";
|
|||
|
||||
const Footer: React.VoidFunctionComponent = () => {
|
||||
const { t } = useTranslation("common");
|
||||
const router = useRouter();
|
||||
return (
|
||||
<div className="mt-16 bg-slate-50/70">
|
||||
<div className="mx-auto max-w-7xl space-y-8 p-8 lg:flex lg:space-x-16 lg:space-y-0">
|
||||
|
@ -132,7 +134,12 @@ const Footer: React.VoidFunctionComponent = () => {
|
|||
</div>
|
||||
<div className="lg:w-2/6">
|
||||
<div className="mb-4 font-medium">{t("language")}</div>
|
||||
<LanguageSelect className="mb-4 w-full" />
|
||||
<LanguageSelect
|
||||
className="mb-4 w-full"
|
||||
onChange={(locale) => {
|
||||
router.push(router.asPath, router.asPath, { locale });
|
||||
}}
|
||||
/>
|
||||
<a
|
||||
href="https://github.com/lukevella/rallly/wiki/Guide-for-translators"
|
||||
className="inline-flex items-center rounded-md border px-3 py-2 text-xs text-slate-500"
|
||||
|
|
|
@ -17,7 +17,6 @@ export const LanguageSelect: React.VoidFunctionComponent<{
|
|||
Cookies.set("NEXT_LOCALE", e.target.value, {
|
||||
expires: 365,
|
||||
});
|
||||
router.push(router.asPath, router.asPath, { locale: e.target.value });
|
||||
onChange?.(e.target.value);
|
||||
}}
|
||||
>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import clsx from "clsx";
|
||||
import { useRouter } from "next/router";
|
||||
import { useTranslation } from "next-i18next";
|
||||
import { usePlausible } from "next-plausible";
|
||||
import React from "react";
|
||||
|
@ -12,6 +13,8 @@ const Preferences: React.VoidFunctionComponent = () => {
|
|||
const { weekStartsOn, setWeekStartsOn, timeFormat, setTimeFormat } =
|
||||
usePreferences();
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const plausible = usePlausible();
|
||||
return (
|
||||
<div>
|
||||
|
@ -19,7 +22,7 @@ const Preferences: React.VoidFunctionComponent = () => {
|
|||
<div className="grow text-sm text-slate-500">
|
||||
{t("common:language")}
|
||||
</div>
|
||||
<LanguageSelect className="w-full" />
|
||||
<LanguageSelect className="w-full" onChange={() => router.reload()} />
|
||||
</div>
|
||||
<div className="grow space-y-2">
|
||||
<div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue