From 30aaedb0a831110fb9775033196b08ffc7c8be4f Mon Sep 17 00:00:00 2001 From: f0x52 Date: Wed, 12 Oct 2022 19:18:41 +0200 Subject: [PATCH] [frontend] use ISO639 library for language selection (#909) --- web/source/package.json | 1 + web/source/settings/components/languages.jsx | 87 +++----------------- web/source/yarn.lock | 5 ++ 3 files changed, 18 insertions(+), 75 deletions(-) diff --git a/web/source/package.json b/web/source/package.json index 3f8bd5a9d..64ba01de9 100644 --- a/web/source/package.json +++ b/web/source/package.json @@ -26,6 +26,7 @@ "is-plain-object": "^5.0.0", "is-valid-domain": "^0.1.6", "js-file-download": "^0.4.12", + "langs": "^2.0.0", "livereload-js": "^3.4.1", "modern-normalize": "^1.1.0", "photoswipe": "^5.3.0", diff --git a/web/source/settings/components/languages.jsx b/web/source/settings/components/languages.jsx index 1522495da..177947d8a 100644 --- a/web/source/settings/components/languages.jsx +++ b/web/source/settings/components/languages.jsx @@ -19,80 +19,17 @@ "use strict"; const React = require("react"); +const langs = require("langs"); + +const asElements = langs.all().map((l) => { + let code = l["1"].toUpperCase(); + let name = l.name; + if (l.name != l.local) { + name = `${name} - ${l.local}`; + } + return ; +}); module.exports = function Languages() { - return - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; -}; + return asElements; +}; \ No newline at end of file diff --git a/web/source/yarn.lock b/web/source/yarn.lock index d88af5d57..31fff3c0d 100644 --- a/web/source/yarn.lock +++ b/web/source/yarn.lock @@ -3719,6 +3719,11 @@ labeled-stream-splicer@^2.0.0: inherits "^2.0.1" stream-splicer "^2.0.0" +langs@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/langs/-/langs-2.0.0.tgz#00c32ce48152a49a614450b9ba2632ab58a0a364" + integrity sha512-v4pxOBEQVN1WBTfB1crhTtxzNLZU9HPWgadlwzWKISJtt6Ku/CnpBrwVy+jFv8StjxsPfwPFzO0CMwdZLJ0/BA== + levn@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade"