src/third_party/v8-3.25/src/i18n.js
/**
 * Returns an intersection of locales and service supported locales.
 * Parameter locales is treated as a priority list.
 */
Returns an intersection of locales and service supported locales.
Parameter locales is treated as a priority list.
Returns an intersection of locales and service supported locales . Parameter locales is treated as a priority list .
function supportedLocalesOf(service, locales, options) {
  if (IS_NULL(service.match(GetServiceRE()))) {
    throw new $Error('Internal error, wrong service type: ' + service);
  }
  if (options === undefined) {
    options = {};
  } else {
    options = toObject(options);
  }
  var matcher = options.localeMatcher;
  if (matcher !== undefined) {
    matcher = $String(matcher);
    if (matcher !== 'lookup' && matcher !== 'best fit') {
      throw new $RangeError('Illegal value for localeMatcher:' + matcher);
    }
  } else {
    matcher = 'best fit';
  }
  var requestedLocales = initializeLocaleList(locales);
  if (AVAILABLE_LOCALES[service] === undefined) {
    AVAILABLE_LOCALES[service] = getAvailableLocalesOf(service);
  }
  if (matcher === 'best fit') {
    return initializeLocaleList(bestFitSupportedLocalesOf(
        requestedLocales, AVAILABLE_LOCALES[service]));
  }
  return initializeLocaleList(lookupSupportedLocalesOf(
      requestedLocales, AVAILABLE_LOCALES[service]));
}
function supportedLocalesOf ( service , locales , options ) { if ( IS_NULL ( service . match ( GetServiceRE ( ) ) ) ) { throw new $Error ( 'Internal error, wrong service type: ' + service ) ; } if ( options === undefined ) { options = { } ; } else { options = toObject ( options ) ; } var matcher = options . localeMatcher ; if ( matcher !== undefined ) { matcher = $String ( matcher ) ; if ( matcher !== 'lookup' && matcher !== 'best fit' ) { throw new $RangeError ( 'Illegal value for localeMatcher:' + matcher ) ; } } else { matcher = 'best fit' ; } var requestedLocales = initializeLocaleList ( locales ) ; if ( AVAILABLE_LOCALES [ service ] === undefined ) { AVAILABLE_LOCALES [ service ] = getAvailableLocalesOf ( service ) ; } if ( matcher === 'best fit' ) { return initializeLocaleList ( bestFitSupportedLocalesOf ( requestedLocales , AVAILABLE_LOCALES [ service ] ) ) ; } return initializeLocaleList ( lookupSupportedLocalesOf ( requestedLocales , AVAILABLE_LOCALES [ service ] ) ) ; }
Returns an intersection of locales and service supported locales.
Returns an intersection of locales and service supported locales .
// Provide defaults if matcher was not specified. // Cache these, they don't ever change per service. // Use either best fit or lookup algorithm to match locales.