mirror of
https://github.com/usememos/memos.git
synced 2024-12-19 00:51:30 +03:00
chore: update locale checks
This commit is contained in:
parent
7ec5d07cb8
commit
ca336af4fa
@ -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>
|
||||
);
|
||||
})}
|
||||
|
Loading…
Reference in New Issue
Block a user