From ce386d57f8b072359f6ca8a267cf330a08bbd826 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 29 Mar 2021 13:12:35 -0400 Subject: [PATCH] Using countries library instead. --- package.json | 2 +- src/shared/components/support.tsx | 13 ++++++++++--- yarn.lock | 10 +++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index dfd88b0..abdcdcc 100644 --- a/package.json +++ b/package.json @@ -42,11 +42,11 @@ "babel-plugin-inferno": "^6", "clean-webpack-plugin": "^3.0.0", "copy-webpack-plugin": "^8.0.0", + "countries-list": "^2.6.1", "css-loader": "^5.1.3", "eslint": "^7.20.0", "eslint-plugin-prettier": "^3.3.1", "husky": "^5.2.0", - "iso-639-1": "^2.1.9", "lint-staged": "^10.5.4", "mini-css-extract-plugin": "^1.3.8", "node-sass": "^5.0.0", diff --git a/src/shared/components/support.tsx b/src/shared/components/support.tsx index 1ff4f98..148128a 100644 --- a/src/shared/components/support.tsx +++ b/src/shared/components/support.tsx @@ -4,7 +4,7 @@ import { DonateLines } from "./donate-lines"; import { i18n } from "../i18next"; import { T } from "inferno-i18next"; import { translators } from "../translations/translators"; -import ISO6391 from "iso-639-1"; +import { languagesAll, countries } from "countries-list"; const title = i18n.t("support_title"); @@ -52,6 +52,7 @@ let coders: Coder[] = [ export interface Translation { lang: string; + country?: string; translators: Translator[]; } @@ -147,7 +148,8 @@ export class Support extends Component { {i18n.t("thanks_translators")} {convertTranslators().map(t => ( - {ISO6391.getNativeName(t.lang) || t.lang} + {languagesAll[t.lang].native} + {t.country && {countries[t.country].native}} : {t.translators.map((translator, i) => ( @@ -195,8 +197,13 @@ export class Support extends Component { function convertTranslators(): Translation[] { let trans: Translation[] = []; for (const [key, value] of Object.entries(translators)) { + let split = key.split("_"); + let lang = split[0]; + let country = split[1] !== undefined ? split[1].toUpperCase() : undefined; + let t: Translation = { - lang: key, + lang, + country, translators: value, }; trans.push(t); diff --git a/yarn.lock b/yarn.lock index 8af2c1d..9c22c25 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2443,6 +2443,11 @@ cosmiconfig@^7.0.0: path-type "^4.0.0" yaml "^1.10.0" +countries-list@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/countries-list/-/countries-list-2.6.1.tgz#d479757ac873b1e596ccea0a925962d20396c0cb" + integrity sha512-jXM1Nv3U56dPQ1DsUSsEaGmLHburo4fnB7m+1yhWDUVvx5gXCd1ok/y3gXCjXzhqyawG+igcPYcAl4qjkvopaQ== + create-error-class@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/create-error-class/-/create-error-class-3.0.2.tgz#06be7abef947a3f14a30fd610671d401bca8b7b6" @@ -4588,11 +4593,6 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= -iso-639-1@^2.1.9: - version "2.1.9" - resolved "https://registry.yarnpkg.com/iso-639-1/-/iso-639-1-2.1.9.tgz#e41b11d4f1808e5316d0252c3fa16eeb9b37bb58" - integrity sha512-owRu9up+Cpx/hwSzm83j6G8PtC7U99UCtPVItsafefNfEgMl+pi8KBwhXwJkJfp6IouyYWFxj8n24SvCWpKZEQ== - isobject@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89"