ResolveLocale = function (isAvailableLocale, requestedLocales, options, relevantExtensionKeys) {
        const matcher = options.lookupMatcher;
        let r;
        if (matcher === "lookup") {
            r = LookupMatcher(isAvailableLocale, requestedLocales);
        } else {
            r = BestFitMatcher(isAvailableLocale, requestedLocales);
        }

        let foundLocale = r.locale;
        const result = bare({ dataLocale: foundLocale });
        let supportedExtension = "-u";
        _.forEach(relevantExtensionKeys, function (key) {
            const keyLocaleData = platform.getLocaleData(platform.LocaleDataKind[key], foundLocale);
            let value = keyLocaleData[0];
            let supportedExtensionAddition = "";
            if (r.extension) {
                const requestedValue = UnicodeExtensionValue(r.extension, key);
                if (requestedValue !== undefined) {
                    if (requestedValue !== "") {
                        if (_.arrayIndexOf(keyLocaleData, requestedValue) !== -1) {
                            value = requestedValue;
                            supportedExtensionAddition = `-${key}-${value}`;
                        }
                    } else if (_.arrayIndexOf(keyLocaleData, "true") !== -1) {
                        value = "true";
                    }
                }
            }

            if (_.hasOwnProperty(options, key)) {
                const optionsValue = options[key];
                if (_.arrayIndexOf(keyLocaleData, optionsValue) !== -1) {
                    if (optionsValue !== value) {
                        value = optionsValue;
                        supportedExtensionAddition = "";
                    }
                }
            }

            result[key] = value;
            supportedExtension += supportedExtensionAddition;
        });

        if (supportedExtension.length > 2) {
            const privateIndex = _.stringIndexOf(foundLocale, "-x-");
            if (privateIndex === -1) {
                foundLocale += supportedExtension;
            } else {
                const preExtension = _.substring(foundLocale, 0, privateIndex);
                const postExtension = _.substring(foundLocale, privateIndex);
                foundLocale = preExtension + supportedExtension + postExtension;
            }

            foundLocale = platform.normalizeLanguageTag(foundLocale);
        }

        result.locale = foundLocale;
        return result;
    }
Resolves a locale by finding which base locale or fallback is available on the system,
then determines which provided unicode options are available for that locale.

ECMA-402: #sec-resolvelocale

@param {Function} isAvailableLocale A function that takes a locale and returns if the locale is supported
@param {String[]} requestedLocales The result of calling CanonicalizeLocaleList on the user-requested locale array
@param {Object} options An object containing a lookupMatcher value and any value given by the user's option object,
mapped to the correct unicode extension key
@param {String[]} relevantExtensionKeys An array of unicode extension keys that we care about for the current lookup