Use iso6391to3.js for language tag value

Improves upon the previous method of truncating language to first 2 values which was showing wrong values
This commit is contained in:
Nikhil Tanwar 2022-01-10 23:28:07 +05:30 committed by Emmanuel Engelhart
parent 468a080b09
commit 2a5db3e7ab
1 changed files with 7 additions and 1 deletions

View File

@ -114,12 +114,18 @@
${downloadLink ? `<div class="book__download"><span data-link="${downloadLink}">Download ${humanFriendlyZimSize ? ` - ${humanFriendlyZimSize}</span></div>`: ''}` : ''}
</div>
<div class="book__description" title="${description}">${description}</div>
<div class="book__languageTag" ${languageAttr}>${language.substr(0, 2).toUpperCase()}</div>
<div class="book__languageTag" ${languageAttr}>${getLanguageCodeToDisplay(language)}</div>
<div class="book__tags"><div class="book__tags--wrapper">${tagHtml}</div></div>
</div></div></a>`;
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';