From 45b2583efde192224d0b559a6afa8c8b82634ae7 Mon Sep 17 00:00:00 2001 From: Andreas Date: Thu, 5 Aug 2021 04:09:57 +0200 Subject: [PATCH] Fix pt-br returning () (#716) * Fix pt-br returning () * Replace ISO-639-1 with Intl.DisplayNames --- package-lock.json | 25 ++++++------------------- package.json | 1 - src/.vuepress/scripts/languages.js | 15 +++++++++++---- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5743c1cc..20761f40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,6 @@ "axios": "^0.21.1", "core-js": "2.6.4", "element-ui": "^2.15.3", - "iso-639-1": "^2.1.9", "lodash.groupby": "^4.6.0", "lodash.sortby": "^4.7.0", "marked": "^2.1.3", @@ -2137,6 +2136,8 @@ "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.16.0.tgz", "integrity": "sha512-5+5VxRFmSf97nM8Jr2wzOwLqRo6zphH2aX+7KsAUONObyzakDNq2G/bgbhinxB4PoV9L3aXQYhiDKyIKWd2c8g==", "hasInstallScript": true, + "optional": true, + "peer": true, "funding": { "type": "opencollective", "url": "https://opencollective.com/core-js" @@ -9692,14 +9693,6 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, - "node_modules/iso-639-1": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/iso-639-1/-/iso-639-1-2.1.9.tgz", - "integrity": "sha512-owRu9up+Cpx/hwSzm83j6G8PtC7U99UCtPVItsafefNfEgMl+pi8KBwhXwJkJfp6IouyYWFxj8n24SvCWpKZEQ==", - "engines": { - "node": ">=6.0" - } - }, "node_modules/isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", @@ -18883,7 +18876,6 @@ "resolved": "https://registry.npmjs.org/@vue/babel-preset-app/-/babel-preset-app-4.5.13.tgz", "integrity": "sha512-pM7CR3yXB6L8Gfn6EmX7FLNE3+V/15I3o33GkSNsWvgsMp6HVGXKkXgojrcfUUauyL1LZOdvTmu4enU2RePGHw==", "requires": { - "@babel/core": "^7.11.0", "@babel/helper-compilation-targets": "^7.9.6", "@babel/helper-module-imports": "^7.8.3", "@babel/plugin-proposal-class-properties": "^7.8.3", @@ -18896,15 +18888,15 @@ "@vue/babel-plugin-jsx": "^1.0.3", "@vue/babel-preset-jsx": "^1.2.4", "babel-plugin-dynamic-import-node": "^2.3.3", - "core-js": "^3.6.5", "core-js-compat": "^3.6.5", "semver": "^6.1.0" }, "dependencies": { "core-js": { - "version": "3.16.0", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.16.0.tgz", - "integrity": "sha512-5+5VxRFmSf97nM8Jr2wzOwLqRo6zphH2aX+7KsAUONObyzakDNq2G/bgbhinxB4PoV9L3aXQYhiDKyIKWd2c8g==" + "version": "https://registry.npmjs.org/core-js/-/core-js-3.16.0.tgz", + "integrity": "sha512-5+5VxRFmSf97nM8Jr2wzOwLqRo6zphH2aX+7KsAUONObyzakDNq2G/bgbhinxB4PoV9L3aXQYhiDKyIKWd2c8g==", + "optional": true, + "peer": true } } }, @@ -24821,11 +24813,6 @@ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, - "iso-639-1": { - "version": "2.1.9", - "resolved": "https://registry.npmjs.org/iso-639-1/-/iso-639-1-2.1.9.tgz", - "integrity": "sha512-owRu9up+Cpx/hwSzm83j6G8PtC7U99UCtPVItsafefNfEgMl+pi8KBwhXwJkJfp6IouyYWFxj8n24SvCWpKZEQ==" - }, "isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", diff --git a/package.json b/package.json index a04cd4a3..981c0743 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,6 @@ "axios": "^0.21.1", "core-js": "2.6.4", "element-ui": "^2.15.3", - "iso-639-1": "^2.1.9", "lodash.groupby": "^4.6.0", "lodash.sortby": "^4.7.0", "marked": "^2.1.3", diff --git a/src/.vuepress/scripts/languages.js b/src/.vuepress/scripts/languages.js index 9baf8739..dd3fdc6f 100644 --- a/src/.vuepress/scripts/languages.js +++ b/src/.vuepress/scripts/languages.js @@ -1,9 +1,16 @@ -import ISO6391 from "iso-639-1"; - export function simpleLangName(code) { - return code === "all" ? "All" : ISO6391.getName(code); + if (code === "all") { + return "All"; + } + const namesInEnglish = new Intl.DisplayNames(["en"], { type: "language" }); + return namesInEnglish.of(code); } export function langName(code) { - return code === "all" ? "All" : `${ISO6391.getName(code)} (${ISO6391.getNativeName(code)})`; + if (code === "all") { + return "All"; + } + const namesInEnglish = new Intl.DisplayNames(["en"], { type: "language" }); + const namesInNative = new Intl.DisplayNames([code], { type: "language" }); + return `${namesInEnglish.of(code)} - ${namesInNative.of(code)}`; }