feat: Add language separator and list English twice (#2739)
This commit is contained in:
parent
eb71e571e0
commit
bafbe9bbc8
@ -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}
|
||||||
|
12
src/i18n.ts
12
src/i18n.ts
@ -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] >=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user