diff --git a/scripts/utils.js b/scripts/utils.js index c0c86b3446..4d4e053f40 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -6,6 +6,7 @@ const urlParser = require('url') const escapeStringRegexp = require('escape-string-regexp') const markdownInclude = require('markdown-include') const iso6393 = require('iso-639-3') +const transliteration = require('transliteration') const regions = require('./regions') const categories = require('./categories') const intlDisplayNames = new Intl.DisplayNames(['en'], { @@ -15,6 +16,13 @@ const intlDisplayNames = new Intl.DisplayNames(['en'], { const utils = {} +utils.name2id = function (name) { + return transliteration + .transliterate(name) + .replace(/\+/gi, 'Plus') + .replace(/[^a-z\d]+/gi, '') +} + utils.code2flag = function (code) { code = code.toUpperCase() switch (code) {