From 2a5db3e7ab0a601245cac66f0f7be9226e6da8bf Mon Sep 17 00:00:00 2001 From: Nikhil Tanwar <2002nikhiltanwar@gmail.com> Date: Mon, 10 Jan 2022 23:28:07 +0530 Subject: [PATCH 1/2] Use iso6391to3.js for language tag value Improves upon the previous method of truncating language to first 2 values which was showing wrong values --- static/skin/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/static/skin/index.js b/static/skin/index.js index eb1388997..b6504dd18 100644 --- a/static/skin/index.js +++ b/static/skin/index.js @@ -114,12 +114,18 @@ ${downloadLink ? `
Download ${humanFriendlyZimSize ? ` - ${humanFriendlyZimSize}
`: ''}` : ''}
${description}
-
${language.substr(0, 2).toUpperCase()}
+
${getLanguageCodeToDisplay(language)}
${tagHtml}
`; return divTag; } + function getLanguageCodeToDisplay(langCode3Letter) { + const langCode2Letter = (Object.keys(iso6391To3).find(key => iso6391To3[key] === langCode3Letter)); + const res = (langCode2Letter != undefined) ? langCode2Letter : langCode3Letter; + return res.toUpperCase(); + } + function toggleFooter(show=false) { if (show) { footer.style.display = 'block'; From 0633f68f801e45c59190b80cbd99411656594476 Mon Sep 17 00:00:00 2001 From: Nikhil Tanwar <2002nikhiltanwar@gmail.com> Date: Tue, 11 Jan 2022 00:35:04 +0530 Subject: [PATCH 2/2] Add new values from wikipedia Added new values. This now covers all iso 639-1 codes from https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes --- static/skin/iso6391To3.js | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/static/skin/iso6391To3.js b/static/skin/iso6391To3.js index 540f3eb8d..f1e3b7594 100644 --- a/static/skin/iso6391To3.js +++ b/static/skin/iso6391To3.js @@ -1,15 +1,22 @@ +// Source: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes // eslint-disable-next-line no-unused-vars const iso6391To3 = { "aa": "aar", + "ab": "abk", + "ae": "ave", "af": "afr", "ak": "aka", "am": "amh", + "an": "arg", "ar": "ara", "as": "asm", + "av": "ava", + "ay": "aym", "az": "aze", "ba": "bak", "be": "bel", "bg": "bul", + "bi": "bis", "bm": "bam", "bn": "ben", "bo": "bod", @@ -17,24 +24,33 @@ const iso6391To3 = { "bs": "bos", "ca": "cat", "ce": "che", + "ch": "cha", "co": "cos", + "cr": "cre", "cs": "ces", + "cu": "chu", "cv": "chv", "cy": "cym", "da": "dan", "de": "deu", + "dv": "div", "dz": "dzo", + "el": "ell", "ee": "ewe", "en": "eng", + "eo": "epo", "es": "spa", "et": "est", "eu": "eus", "fa": "fas", "ff": "ful", "fi": "fin", + "fj": "fij", "fo": "fao", "fr": "fra", + "fy": "fry", "ga": "gle", + "gd": "gla", "gl": "glg", "gn": "grn", "gu": "guj", @@ -42,44 +58,78 @@ const iso6391To3 = { "ha": "hau", "he": "heb", "hi": "hin", + "ho": "hmo", "hr": "hrv", + "ht": "hat", "hu": "hun", "hy": "hye", + "hz": "her", + "ia": "ina", "id": "ind", + "ie": "ile", "ig": "ibo", + "ii": "iii", + "ik": "ipk", + "io": "ido", "is": "isl", "it": "ita", "iu": "iku", "ja": "jpn", "jv": "jav", "ka": "kat", + "kg": "kon", "ki": "kik", + "kj": "kua", + "kl": "kal", "kk": "kaz", "km": "khm", "kn": "kan", "ko": "kor", + "kr": "kau", "ks": "kas", "ku": "kur", + "kv": "kom", "kw": "cor", "ky": "kir", + "la": "lat", "lb": "ltz", "lg": "lug", + "li": "lim", "ln": "lin", "lo": "lao", "lt": "lit", + "lu": "lub", "lv": "lav", "mg": "mlg", + "mh": "mah", "mi": "mri", "mk": "mkd", "ml": "mal", "mn": "mon", "mr": "mar", + "ms": "msa", "mt": "mlt", "my": "mya", + "na": "nau", + "nb": "nob", + "nd": "nde", + "ne": "nep", + "ng": "ndo", "nl": "nld", + "nn": "nno", + "no": "nor", + "nr": "nbl", + "nv": "nav", "ny": "nya", + "oc": "oci", + "oj": "oji", "om": "orm", + "or": "ori", + "os": "oss", + "pa": "pan", + "pi": "pli", "pl": "pol", + "ps": "pus", "pt": "por", "qu": "que", "rm": "roh", @@ -88,7 +138,10 @@ const iso6391To3 = { "ru": "rus", "rw": "kin", "sa": "san", + "sc": "srd", "sd": "snd", + "se": "sme", + "sm": "smo", "sg": "sag", "si": "sin", "sk": "slk", @@ -98,27 +151,37 @@ const iso6391To3 = { "sq": "sqi", "sr": "srp", "ss": "ssw", + "st": "sot", + "su": "sun", "sv": "swe", + "sw": "swa", "ta": "tam", "te": "tel", "tg": "tgk", "th": "tha", "ti": "tir", "tk": "tuk", + "tl": "tgl", "tn": "tsn", + "to": "ton", "tr": "tur", "ts": "tso", "tt": "tat", + "tw": "twi", + "ty": "tah", "ug": "uig", "uk": "ukr", "ur": "urd", "uz": "uzb", "ve": "ven", "vi": "vie", + "vo": "vol", "wa": "wln", "wo": "wol", "xh": "xho", + "yi": "yid", "yo": "yor", + "za": "zha", "zh": "zho", "zu": "zul" } \ No newline at end of file