Skip to content

Commit

Permalink
Special needs for dictionaries - two language codes
Browse files Browse the repository at this point in the history
  • Loading branch information
snomos committed Sep 25, 2023
1 parent 7b7eb0f commit 39325df
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
40 changes: 40 additions & 0 deletions assets/js/langtable.js
Original file line number Diff line number Diff line change
Expand Up @@ -8178,3 +8178,43 @@ function doesTopicsHaveSomeFilter(topics, filters) {
})
})
}

// Dictionary page:

function addNegUnorderedDictList(repos, mainFilter, filters) {
ul = document.createElement('ul')
for (const repo of repos) {
if (repo.name.startsWith(mainFilter)) {
if (!doesTopicsHaveSomeFilter(repo.topics, filters)) {
ul.appendChild(addDictLi(repo))
}
}
}
// If no repos found, inform the user:
if (!ul.firstChild) {
const p = document.createElement('p')
p.appendChild(document.createTextNode('No repos found.'))
return p
} else {
return ul
}
}

function addDictLi(repo) {
const li = document.createElement('li')
li.appendChild(addr(reponame2dictname(repo.name), repo.name + '/'))
li.appendChild(document.createTextNode(' '))
li.appendChild(addr('(source)', repo.html_url))

return li
}

function reponame2dictname(reponame) {
parts = reponame.split('-');

if (parts.length === 3) {
return code2langname[parts[1]] + ' - ' + code2langname[parts[2]]
}

return code2langname[parts[1]] + ' (' + parts.slice(3).join('-') + ')'
}
10 changes: 5 additions & 5 deletions dicts/DictionarySources.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ domExperLangs.appendChild(addRepoTable({{lang_repos}}, 'dict-', ['maturity-exper

<script>
const domUndefLangs = document.querySelector('#undef_languges');
domUndefLangs.appendChild(addNegUnorderedList({{lang_repos}}, 'dict-', ['maturity-exper', 'maturity-beta', 'maturity-alpha', 'maturity-prod']))
domUndefLangs.appendChild(addNegUnorderedDictList({{lang_repos}}, 'dict-', ['maturity-exper', 'maturity-beta', 'maturity-alpha', 'maturity-prod']))
</script>

<!-- Scripts for Geographic areas: -->
Expand Down Expand Up @@ -158,12 +158,12 @@ domAfricaLangs.appendChild(addUnorderedList({{lang_repos}}, 'dict-', ['geo-afric

<script>
const domOthrLangs = document.querySelector('#geo_other');
domOthrLangs.appendChild(addNegUnorderedList({{lang_repos}}, 'dict-', ['geo-nordic', 'geo-europe', 'geo-russia', 'geo-northamerica', 'geo-africa']))
domOthrLangs.appendChild(addNegUnorderedDictList({{lang_repos}}, 'dict-', ['geo-nordic', 'geo-europe', 'geo-russia', 'geo-northamerica', 'geo-africa']))
</script>

<script>
const domUndefLangs = document.querySelector('#geo_undef');
domUndefLangs.appendChild(addNegUnorderedList({{lang_repos}}, 'dict-', ['geo-]))
domUndefLangs.appendChild(addNegUnorderedDictList({{lang_repos}}, 'dict-', ['geo-]))
</script>
<!-- Scripts for language families: -->
Expand Down Expand Up @@ -199,10 +199,10 @@ domNigerCongoLangs.appendChild(addUnorderedList({{lang_repos}}, 'dict-', ['langf
<script>
const domOthrFamLangs = document.querySelector('#fam_other');
domOthrFamLangs.appendChild(addNegUnorderedList({{lang_repos}}, 'dict-', ['langfam-uralic', 'langfam-indoeuropean', 'langfam-algic', 'langfam-eskimo-aleut', 'langfam-turkic', 'langfam-niger-congo']))
domOthrFamLangs.appendChild(addNegUnorderedDictList({{lang_repos}}, 'dict-', ['langfam-uralic', 'langfam-indoeuropean', 'langfam-algic', 'langfam-eskimo-aleut', 'langfam-turkic', 'langfam-niger-congo']))
</script>
<script>
const domUndefFamLangs = document.querySelector('#fam_undef');
domUndefFamLangs.appendChild(addNegUnorderedList({{lang_repos}}, 'dict-', ['langfam-']))
domUndefFamLangs.appendChild(addNegUnorderedDictList({{lang_repos}}, 'dict-', ['langfam-']))
</script>

0 comments on commit 39325df

Please sign in to comment.