fix: language list containing duplicate en lang (#6583)

This commit is contained in:
David Luzar 2023-05-13 22:50:14 +02:00 committed by GitHub
parent 306e133651
commit 5bf27a463c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 58 deletions

View File

@ -538,6 +538,10 @@
height: 3px;
}
select::-webkit-scrollbar {
width: 10px;
}
::-webkit-scrollbar-thumb {
background: var(--scrollbar-thumb);
border-radius: 10px;

View File

@ -1,7 +1,7 @@
import { useSetAtom } from "jotai";
import React from "react";
import { appLangCodeAtom } from "..";
import { defaultLang, useI18n } from "../../i18n";
import { useI18n } from "../../i18n";
import { languages } from "../../i18n";
export const LanguageList = ({ style }: { style?: React.CSSProperties }) => {
@ -16,9 +16,6 @@ export const LanguageList = ({ style }: { style?: React.CSSProperties }) => {
aria-label={t("buttons.selectLanguage")}
style={style}
>
<option key={defaultLang.code} value={defaultLang.code}>
{defaultLang.label}
</option>
{languages.map((lang) => (
<option key={lang.code} value={lang.code}>
{lang.label}

View File

@ -14,7 +14,9 @@ export interface Language {
export const defaultLang = { code: "en", label: "English" };
const allLanguages: Language[] = [
export const languages: Language[] = [
defaultLang,
...[
{ code: "ar-SA", label: "العربية", rtl: true },
{ code: "bg-BG", label: "Български" },
{ code: "ca-ES", label: "Català" },
@ -59,15 +61,14 @@ const allLanguages: Language[] = [
{ code: "zh-TW", label: "繁體中文" },
{ code: "vi-VN", label: "Tiếng Việt" },
{ code: "mr-IN", label: "मराठी" },
].concat([defaultLang]);
export const languages: Language[] = allLanguages
.sort((left, right) => (left.label > right.label ? 1 : -1))
]
.filter(
(lang) =>
(percentages as Record<string, number>)[lang.code] >=
COMPLETION_THRESHOLD,
);
)
.sort((left, right) => (left.label > right.label ? 1 : -1)),
];
const TEST_LANG_CODE = "__test__";
if (process.env.NODE_ENV === ENV.DEVELOPMENT) {