Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🐛 Fix dayjs locale should default to router locale

Luke Vellac6b17aa22b6e
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 (
<DayjsProvider
config={{