Remove languages less than 70% completed, merge language lists (#78)

This commit is contained in:
Nutomic 2022-02-18 19:32:23 +00:00 committed by GitHub
parent b58dfee675
commit c42835e080
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 84 deletions

@ -1 +1 @@
Subproject commit ebe80fa15d9f7d17979c317291834ab4021cb8eb
Subproject commit ef6a2d42a0c03e6e66f1670d828b738a72cb3880

View file

@ -2,7 +2,7 @@ import { Component, ChangeEvent, linkEvent } from "inferno";
import { Link } from "inferno-router";
import { LinkLine } from "./link-line";
import { Icon } from "./icon";
import { getLanguageName, i18n } from "../i18next";
import { i18n, languages } from "../i18next";
export class Navbar extends Component<any, any> {
constructor(props: any, context: any) {
@ -43,7 +43,7 @@ export class Navbar extends Component<any, any> {
value={language}
selected={i18n.language.startsWith(language)}
>
{getLanguageName(language)}
{languages.find(l => l.code.startsWith(language)).name}
</option>
))}
</select>

View file

@ -1,94 +1,54 @@
import i18next, { i18nTyped } from "i18next";
import i18next, { i18nTyped, Resource } from "i18next";
// Languages
import { bg } from "./translations/bg";
import { de } from "./translations/de";
import { el } from "./translations/el";
import { en } from "./translations/en";
import { ru } from "./translations/ru";
import { zh } from "./translations/zh";
import { es } from "./translations/es";
import { eu } from "./translations/eu";
import { bg } from "./translations/bg";
import { nl } from "./translations/nl";
import { fa } from "./translations/fa";
import { fi } from "./translations/fi";
import { fr } from "./translations/fr";
import { el } from "./translations/el";
import { ko } from "./translations/ko";
import { pl } from "./translations/pl";
import { ar } from "./translations/ar";
import { eo } from "./translations/eo";
import { de } from "./translations/de";
import { gl } from "./translations/gl";
import { id } from "./translations/id";
import { it } from "./translations/it";
import { ja } from "./translations/ja";
import { km } from "./translations/km";
import { ko } from "./translations/ko";
import { nb_NO } from "./translations/nb_NO";
import { zh_Hant } from "./translations/zh_Hant";
import { fa } from "./translations/fa";
import { id } from "./translations/id";
import { mnc } from "./translations/mnc";
import { sv } from "./translations/sv";
import { vi } from "./translations/vi";
import { nl } from "./translations/nl";
import { pl } from "./translations/pl";
import { pt } from "./translations/pt";
import { pt_BR } from "./translations/pt_BR";
import { ru } from "./translations/ru";
import { zh } from "./translations/zh";
// https://github.com/nimbusec-oss/inferno-i18next/blob/master/tests/T.test.js#L66
const resources = {
en,
ru,
zh,
es,
eu,
bg,
nl,
fi,
fr,
el,
ko,
pl,
ar,
eo,
de,
gl,
it,
ja,
km,
nb_NO,
zh_Hant,
fa,
id,
mnc,
sv,
vi,
pt,
};
export const languages = [
{ resource: bg, code: "bg", name: "Български" },
{ resource: de, code: "de", name: "Deutsch" },
{ resource: el, code: "el", name: "Ελληνικά" },
{ resource: en, code: "en", name: "English" },
{ resource: es, code: "es", name: "Español" },
{ resource: eu, code: "eu", name: "Euskara" },
{ resource: fa, code: "fa", name: "فارسی" },
{ resource: fi, code: "fi", name: "Suomi" },
{ resource: fr, code: "fr", name: "Français" },
{ resource: gl, code: "gl", name: "Galego" },
{ resource: id, code: "id", name: "Bahasa Indonesia" },
{ resource: it, code: "it", name: "Italiano" },
{ resource: ja, code: "ja", name: "日本語" },
{ resource: ko, code: "ko", name: "한국어" },
{ resource: nb_NO, code: "nb_NO", name: "Norsk (bokmål)" },
{ resource: nl, code: "nl", name: "Nederlands" },
{ resource: pl, code: "pl", name: "Polski" },
{ resource: pt, code: "pt", name: "Português" },
{ resource: pt_BR, code: "pt_BR", name: "Português (Brasil)" },
{ resource: ru, code: "ru", name: "Русский" },
{ resource: zh, code: "zh", name: "中文" },
];
const languageNames = {
en: "English",
ru: "Русский",
zh: "中文",
es: "Español",
eu: "Euskara",
bg: "Български",
nl: "Nederlands",
fi: "Suomi",
fr: "Français",
el: "Ελληνικά",
ko: "한국어",
pl: "Polski",
ar: "العربية",
eo: "Esperanto",
de: "Deutsch",
gl: "Galego",
it: "Italiano",
ja: "日本語",
km: "ភាសាខ្មែរ",
nb_NO: "Norsk (Bokmål)",
zh_Hant: "文言",
fa: "فارسی",
id: "Bahasa Indonesia",
mnc: "ᠮᠠᠨᠵᡠ ᡤᡳᠰᡠᠨ",
sv: "Svenska",
vi: "Tiếng Việt",
pt: "Português",
};
const resources: Resource = {};
languages.forEach(l => (resources[l.code] = l.resource));
function format(value: any, format: any): any {
return format === "uppercase" ? value.toUpperCase() : value;
@ -107,10 +67,6 @@ export const i18n = i18next as i18nTyped;
export { resources };
export function getLanguageName(key: string): string {
return languageNames[key];
}
// https://gist.github.com/hunan-rostomyan/28e8702c1cecff41f7fe64345b76f2ca
export function getLanguageFromCookie(cookies?: string): string | null {
if (cookies == null) {