From c6b17aa22b6ef6f1ae670a1aa50853e6da630ba6 Mon Sep 17 00:00:00 2001 From: Luke Vella Date: Mon, 23 Oct 2023 09:51:11 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20dayjs=20locale=20should=20?= =?UTF-8?q?default=20to=20router=20locale?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/src/utils/dayjs.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/web/src/utils/dayjs.tsx b/apps/web/src/utils/dayjs.tsx index dccf97039..faedba5df 100644 --- a/apps/web/src/utils/dayjs.tsx +++ b/apps/web/src/utils/dayjs.tsx @@ -11,6 +11,7 @@ import relativeTime from "dayjs/plugin/relativeTime"; import timezone from "dayjs/plugin/timezone"; import updateLocale from "dayjs/plugin/updateLocale"; import utc from "dayjs/plugin/utc"; +import { useRouter } from "next/router"; import * as React from "react"; import { useAsync } from "react-use"; @@ -188,7 +189,8 @@ export const DayjsProvider: React.FunctionComponent<{ }; }; }> = ({ config, children }) => { - const l = config?.locale ?? "en"; + const router = useRouter(); + const l = config?.locale ?? router.locale ?? "en"; const state = useAsync(async () => { return await dayjsLocales[l].import(); }, [l]); @@ -249,7 +251,6 @@ export const ConnectedDayjsProvider = ({ children, }: React.PropsWithChildren) => { const { preferences } = usePreferences(); - return (