Compares a BCP 47 language priority list requestedLocales against the locales
in availableLocales and determines the best available language to meet the
request. Two algorithms are available to match the locales: the Lookup
algorithm described in RFC 4647 section 3.4, and an implementation dependent
best-fit algorithm. Independent of the locale matching algorithm, options
specified through Unicode locale extension sequences are negotiated
separately, taking the caller's relevant extension keys and locale data as
well as client-provided options into consideration. Returns an object with
a locale property whose value is the language tag of the selected locale,
and properties for each key in relevantExtensionKeys providing the selected
value for that key.
function resolveLocale(service, requestedLocales, options) {
  requestedLocales = initializeLocaleList(requestedLocales);

  var getOption = getGetOption(options, service);
  var matcher = getOption('localeMatcher', 'string',
                          ['lookup', 'best fit'], 'best fit');
  var resolved;
  if (matcher === 'lookup') {
    resolved = lookupMatcher(service, requestedLocales);
  } else {
    resolved = bestFitMatcher(service, requestedLocales);
  }

  return resolved;
}