IsStructurallyValidLanguageTag = function (locale) {
        const parsed = parseLangtag(locale);
        if (parsed === null) {
            return false;
        }

        // check duplicate variants
        if (parsed.variants) {
            const variants = _.split(parsed.variants, "-");
            const uniqueVariants = _.unique(variants);

            if (variants.length !== uniqueVariants.length) {
                return false;
            }
        }

        if (parsed.extensions) {
            const extensionParts = _.split(parsed.extensions, "-");
            const singletons = _.map(_.filter(extensionParts, (element) => element.length === 1), (element) => _.toLowerCase(element));
            const uniqueSingletons = _.unique(singletons);

            return singletons.length === uniqueSingletons.length;
        }

        return true;
    }
Returns true if locale can be generated by RFC5646 section 2.1 and does not contain
duplicate variant or singleton subtags.

Note that ICU does not implement this correctly for our usage because it is
extremely permissive about what it will allow -- completely invalid language tags can
pass through a round of uloc_forLanguageTag/uloc_toLanguageTag or uloc_canonicalize
even if they are completely bogus.

ECMA402: #sec-isstructurallyvalidlanguagetag

@param {String} locale The locale to check
@returns {Boolean}