mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: update locale checks
This commit is contained in:
@ -24,19 +24,24 @@ const LocaleSelect: FC<Props> = (props: Props) => {
|
||||
onChange={(_, value) => handleSelectChange(value as Locale)}
|
||||
>
|
||||
{availableLocales.map((locale) => {
|
||||
try {
|
||||
const languageName = new Intl.DisplayNames([locale], { type: "language" }).of(locale);
|
||||
if (languageName === undefined) {
|
||||
return (
|
||||
<Option key={locale} value={locale}>
|
||||
{locale}
|
||||
</Option>
|
||||
);
|
||||
}
|
||||
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}>
|
||||
{locale}
|
||||
</Option>
|
||||
);
|
||||
})}
|
||||
</Select>
|
||||
);
|
||||
|
Reference in New Issue
Block a user