fix: improve language docs + string parsing
This commit is contained in:
parent
86775ea95b
commit
e184341625
6 changed files with 255 additions and 92 deletions
16
testfiles/dict/gen_lang_names.js
Normal file
16
testfiles/dict/gen_lang_names.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
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));
|
||||
Reference in a new issue