Added fallback for invalid locale (#3962)

This commit is contained in:
Erik Jan de Wit 2022-12-08 06:25:27 -05:00 committed by GitHub
parent b0ce0bb181
commit 3d031c79e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -68,8 +68,13 @@ export type BundleForm = {
messageBundle: KeyValueType; messageBundle: KeyValueType;
}; };
const localeToDisplayName = (locale: string) => const localeToDisplayName = (locale: string) => {
new Intl.DisplayNames([locale], { type: "language" }).of(locale); try {
return new Intl.DisplayNames([locale], { type: "language" }).of(locale);
} catch (error) {
return locale;
}
};
export const LocalizationTab = ({ save, realm }: LocalizationTabProps) => { export const LocalizationTab = ({ save, realm }: LocalizationTabProps) => {
const { t } = useTranslation("realm-settings"); const { t } = useTranslation("realm-settings");