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