feat: Add language separator and list English twice (#2739)

This commit is contained in:
Lipis 2021-01-07 21:39:57 +02:00 committed by GitHub
parent eb71e571e0
commit bafbe9bbc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -22,6 +22,10 @@ export const LanguageList = ({
value={currentLangCode} value={currentLangCode}
aria-label={i18n.t("buttons.selectLanguage")} aria-label={i18n.t("buttons.selectLanguage")}
> >
<option key={i18n.defaultLang.code} value={i18n.defaultLang.code}>
{i18n.defaultLang.label}
</option>
<option disabled>{"──────────"}</option>
{languages.map((lang) => ( {languages.map((lang) => (
<option key={lang.code} value={lang.code}> <option key={lang.code} value={lang.code}>
{lang.label} {lang.label}

View File

@ -9,6 +9,8 @@ export interface Language {
rtl?: boolean; rtl?: boolean;
} }
export const defaultLang = { code: "en", label: "English" };
const allLanguages: Language[] = [ const allLanguages: Language[] = [
{ code: "ar-SA", label: "العربية", rtl: true }, { code: "ar-SA", label: "العربية", rtl: true },
{ code: "bg-BG", label: "Български" }, { code: "bg-BG", label: "Български" },
@ -42,14 +44,10 @@ const allLanguages: Language[] = [
{ code: "uk-UA", label: "Українська" }, { code: "uk-UA", label: "Українська" },
{ code: "zh-CN", label: "简体中文" }, { code: "zh-CN", label: "简体中文" },
{ code: "zh-TW", label: "繁體中文" }, { code: "zh-TW", label: "繁體中文" },
]; ].concat([defaultLang]);
export const defaultLang = { code: "en", label: "English" }; export const languages: Language[] = allLanguages
.sort((left, right) => (left.label > right.label ? 1 : -1))
export const languages: Language[] = [defaultLang]
.concat(
allLanguages.sort((left, right) => (left.label > right.label ? 1 : -1)),
)
.filter( .filter(
(lang) => (lang) =>
(percentages as Record<string, number>)[lang.code] >= (percentages as Record<string, number>)[lang.code] >=