Skip to content

Scheduling infrastructure for absolutely everyone.

Fallback to next app default language (en) when user didn't specify locale. (#16425)

Kacper821843bc6c14
diff --git a/packages/features/ee/users/components/UserForm.tsx b/packages/features/ee/users/components/UserForm.tsx
index c88b481301e..25fe21e338f 100644
--- a/packages/features/ee/users/components/UserForm.tsx
+++ b/packages/features/ee/users/components/UserForm.tsx
@@ -4,7 +4,7 @@ import { Controller, useForm } from "react-hook-form";
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
import { useLocale } from "@calcom/lib/hooks/useLocale";
-import { localeOptions } from "@calcom/lib/i18n";
+import { defaultLocaleOption, localeOptions } from "@calcom/lib/i18n";
import { nameOfDay } from "@calcom/lib/weekday";
import {
Avatar,
@@ -76,7 +76,7 @@ export const UserForm = ({
{ value: "GOOGLE", label: "GOOGLE" },
{ value: "SAML", label: "SAML" },
];
- const defaultLocale = defaultValues?.locale || localeOptions[0].value;
+ const defaultLocale = defaultValues?.locale || defaultLocaleOption.value;
const form = useForm<FormValues>({
defaultValues: {
diff --git a/packages/lib/i18n.ts b/packages/lib/i18n.ts
index ed2a33d07fa..5de87507b00 100644
--- a/packages/lib/i18n.ts
+++ b/packages/lib/i18n.ts
@@ -8,3 +8,7 @@ export const localeOptions = locales.map((locale) => ({
value: locale,
label: new Intl.DisplayNames(locale, { type: "language" }).of(locale) || "",
}));
+
+export const defaultLocaleOption = localeOptions.find(
+ (locale) => locale.value === i18n.defaultLocale
+) as (typeof localeOptions)[number];