mirror of
https://github.com/tachiyomiorg/website.git
synced 2024-10-31 23:15:05 +01:00
Capitalize the language name in some cases (#14)
This commit is contained in:
parent
87679463a4
commit
489801174e
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user