Skip to content

Commit

Permalink
impl #88
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmerz committed Aug 26, 2024
1 parent cb716ba commit c35738e
Show file tree
Hide file tree
Showing 2 changed files with 33,114 additions and 0 deletions.
50 changes: 50 additions & 0 deletions devops/create-lang-label-service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const fs = require('fs');
const path = require('path');
const URL = 'https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry';4
const FILE = path.join(__dirname, '..', 'services', 'init', 'fcrepo', 'service', 'lang-label-service.jsonld.json');

const IANALANG = 'https://www.iana.org/assignments/language-subtag-registry#';

const template = [
{
"@id": "",
"@context": {
"ucdlib": "http://digital.ucdavis.edu/schema#"
},
"@type": [
"ucdlib:LabelService",
"ucdlib:Service"
]
}
];

(async () => {
let resp = await fetch(URL);
let text = await resp.text();
text = text.replace(/\n\s\s/g, ' ') // cleanup breaks
let items = text.split('%%');

for( let item of items ) {
let lines = item.split('\n');
let obj = {};
for( let line of lines ) {
if( !line.trim() ) continue;
let [key, value] = line.split(':');
obj[key.trim()] = value.trim();
}

// currently only interested in languages
if( obj.Type !== 'language' ) continue;

template.push({
"@id": IANALANG+obj.Subtag,
"http://schema.org/name": obj.Description
});
}

fs.writeFileSync(
FILE,
JSON.stringify(template, null, 2)
);

})();
Loading

0 comments on commit c35738e

Please sign in to comment.