This repository has been archived on 2026-05-27. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
rustypipe/testfiles/dict/gen_lang_names.js
2023-05-11 17:18:58 +02:00

16 lines
446 B
JavaScript

const fs = require("fs");
const dict = JSON.parse(fs.readFileSync("dictionary.json"));
const intl = new Intl.DisplayNames(["en"], { type: "language" });
let langs = Object.keys(dict);
Object.values(dict).forEach(entry => {
if (entry.equivalent) {
langs.push(...entry.equivalent);
}
});
langs.sort();
const res = Object.fromEntries(langs.map((l) => [l, intl.of(l)]));
fs.writeFileSync("lang_names.json", JSON.stringify(res, null, 2));