Make the first letter of the language selector upper case (#1214)

This commit is contained in:
GuilleHoardings
2023-02-06 11:25:11 +09:00
committed by GitHub
parent 852a2b73a9
commit 40b1b5a32e
2 changed files with 14 additions and 2 deletions
@@ -20,11 +20,15 @@ const LanguageSelector = () => {
}
}, [cookies, setCookie, router]);
const firstLetterUppercase = (str) => {
return str.charAt(0).toLocaleUpperCase() + str.slice(1);
};
// Memo the set of locales and their display names.
const localesAndNames = useMemo(() => {
return router.locales.map((locale) => ({
locale,
name: new Intl.DisplayNames([locale], { type: "language" }).of(locale),
name: firstLetterUppercase(new Intl.DisplayNames([locale], { type: "language" }).of(locale)),
}));
}, [router.locales]);