diff --git a/website/src/.vitepress/config/scripts/languages.ts b/website/src/.vitepress/config/scripts/languages.ts index 01ed77cb..c2a0db44 100644 --- a/website/src/.vitepress/config/scripts/languages.ts +++ b/website/src/.vitepress/config/scripts/languages.ts @@ -3,14 +3,19 @@ export function simpleLangName(code: string) { return "All"; } const namesInEnglish = new Intl.DisplayNames(["en"], { type: "language" }); - return namesInEnglish.of(code)!; + return capitalize(namesInEnglish.of(code)!, "en"); } export function langName(code: string) { if (code === "all") { return "All"; } + const namesInEnglish = new Intl.DisplayNames(["en"], { type: "language" }); const namesInNative = new Intl.DisplayNames([code], { type: "language" }); - return `${namesInEnglish.of(code)} - ${namesInNative.of(code)}`; + return `${capitalize(namesInEnglish.of(code)!, "en")} - ${capitalize(namesInNative.of(code)!, code)}`; +} + +function capitalize(string: string, locale: string) { + return string.charAt(0).toLocaleUpperCase(locale) + string.substring(1); }