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

This commit is contained in:
Kacper
2024-08-30 21:37:10 +05:30
committed by GitHub
parent d19e3e53f0
commit 821843bc6c
2 changed files with 6 additions and 2 deletions
@@ -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: {
+4
View File
@@ -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];