chore: update locale checks

This commit is contained in:
Steven 2023-09-10 10:53:37 +08:00
parent 7ec5d07cb8
commit ca336af4fa

View File

@ -24,17 +24,22 @@ const LocaleSelect: FC<Props> = (props: Props) => {
onChange={(_, value) => handleSelectChange(value as Locale)}
>
{availableLocales.map((locale) => {
const languageName = new Intl.DisplayNames([locale], { type: "language" }).of(locale);
if (languageName === undefined) {
return (
<Option key={locale} value={locale}>
{locale}
</Option>
);
try {
const languageName = new Intl.DisplayNames([locale], { type: "language" }).of(locale);
if (languageName) {
return (
<Option key={locale} value={locale}>
{languageName.charAt(0).toUpperCase() + languageName.slice(1)}
</Option>
);
}
} catch (error) {
// do nth
}
return (
<Option key={locale} value={locale}>
{languageName.charAt(0).toUpperCase() + languageName.slice(1)}
{locale}
</Option>
);
})}