country-coder
country-coder copied to clipboard
Add ISO639 official language codes
As discussed in https://github.com/rapideditor/country-coder/issues/131
Preview:
Code:
import fs from 'fs'
const borders = JSON.parse(fs.readFileSync('borders.json'))
const langs = JSON.parse(fs.readFileSync('langs.json'))
console.log(`{"type":"FeatureCollection","features":[`)
borders.features.forEach((f, o) => {
const l = langs[f.properties.iso1A2]
if (l) f.properties.iso639 = l
const comma = o < (borders.features.length-1)
console.log(JSON.stringify(f) + (comma ? ',' : ''))
})
process.stdout.write(`]}`)
I think these are technically named ISO 639-1 codes, let me know if you think I should rename the field.
Maybe I should also split the strings into an array 🤔
These are technically BCP 47 language tags, which include ISO 639-1 and -2 and -3 language codes combined with ISO 3166 country codes. It doesn’t seem to include any ISO 15924 script codes, which would be important for any Serbian- or Chinese-speaking region.