function normalizeLang(lang) {
    const langs = configs.langs.map(code => code.replace('pt-BR', 'pt'));

    if (lang.match(/^zh-(Hant|TW|HK|MO)/)) {
        lang = 'zh-Hant';
    } else if (lang.match(/^zh/)) {
        lang = 'zh-Hans';
    } else {
        lang = lang.substring(0, 2);
    }
    return includes(langs, lang) ? lang : undefined;
}
Normalize the given language code to one of the supported codes. The
returned value is ISO 639-1 code, but the exception is Chinese
(zh-Hans or zh-Hant). Returns undefined if not supported.
@param {string} lang - Language code
@returns {string} Normalized language code