index.js
function translate(cldr, locale, opts) {
  if (typeof cldr === 'string') return augment(interpolate(cldr, opts));

  opts = opts || {};

  var pluralize = lookup(locale, cldr._format || opts.pluralFormat, plural);
  if (Array.isArray(cldr)) cldr = convertArray(cldr, pluralize, opts);

  validate(cldr, pluralize);

  var paramsObj = {};
  var cases = toFunctions(cldr, pluralize, opts, paramsObj);
  var paramsKeys = Object.keys(paramsObj);

  var key = cldr._plural_key ||
            opts.pluralKey ||
            discoverKey(paramsKeys,
                        opts.discoverableKeys || {'smart_count':1, 'count':1, 'length':1, 'items':1, 'total':1},
                        opts.defaultPluralKey || 'smart_count');

  var validatePluralKey = opts.validatePluralKey !== false;
  var silentValidation = !!opts.validatePluralSilent;
  var decimal = number.decimal[locale] || number.decimal.en;
  var toLocaleString = opts.toLocaleString !== false;

  return augment(function(params) {
    if (typeof params === 'number') params = convertSmartCount(params, key);

    var count = parseInt(params[key], 10);
    if (validatePluralKey && isNaN(count)) {
      if (silentValidation) return [];
      throw new Error('expected "' + key + '" to be a number. got "' + (typeof params[key]) + '".');
    }

    if (toLocaleString) params = formatNumbers(params, decimal);

    return (cases[count] || cases[pluralize(count || 0)])(params);
  }, paramsKeys);
}
function translate(cldr, locale, opts) {
  if (typeof cldr === 'string') return augment(interpolate(cldr, opts));

  opts = opts || {};

  var pluralize = lookup(locale, cldr._format || opts.pluralFormat, plural);
  if (Array.isArray(cldr)) cldr = convertArray(cldr, pluralize, opts);

  validate(cldr, pluralize);

  var paramsObj = {};
  var cases = toFunctions(cldr, pluralize, opts, paramsObj);
  var paramsKeys = Object.keys(paramsObj);

  var key = cldr._plural_key ||
            opts.pluralKey ||
            discoverKey(paramsKeys,
                        opts.discoverableKeys || {'smart_count':1, 'count':1, 'length':1, 'items':1, 'total':1},
                        opts.defaultPluralKey || 'smart_count');

  var validatePluralKey = opts.validatePluralKey !== false;
  var silentValidation = !!opts.validatePluralSilent;
  var decimal = number.decimal[locale] || number.decimal.en;
  var toLocaleString = opts.toLocaleString !== false;

  return augment(function(params) {
    if (typeof params === 'number') params = convertSmartCount(params, key);

    var count = parseInt(params[key], 10);
    if (validatePluralKey && isNaN(count)) {
      if (silentValidation) return [];
      throw new Error('expected "' + key + '" to be a number. got "' + (typeof params[key]) + '".');
    }

    if (toLocaleString) params = formatNumbers(params, decimal);

    return (cases[count] || cases[pluralize(count || 0)])(params);
  }, paramsKeys);
}
function translate ( cldr , locale , opts ) { if ( typeof cldr === 'string' ) return augment ( interpolate ( cldr , opts ) ) ; opts = opts || { } ; var pluralize = lookup ( locale , cldr . _format || opts . pluralFormat , plural ) ; if ( Array . isArray ( cldr ) ) cldr = convertArray ( cldr , pluralize , opts ) ; validate ( cldr , pluralize ) ; var paramsObj = { } ; var cases = toFunctions ( cldr , pluralize , opts , paramsObj ) ; var paramsKeys = Object . keys ( paramsObj ) ; var key = cldr . _plural_key || opts . pluralKey || discoverKey ( paramsKeys , opts . discoverableKeys || { 'smart_count' : 1 , 'count' : 1 , 'length' : 1 , 'items' : 1 , 'total' : 1 } , opts . defaultPluralKey || 'smart_count' ) ; var validatePluralKey = opts . validatePluralKey !== false ; var silentValidation = ! ! opts . validatePluralSilent ; var decimal = number . decimal [ locale ] || number . decimal . en ; var toLocaleString = opts . toLocaleString !== false ; return augment ( function ( params ) { if ( typeof params === 'number' ) params = convertSmartCount ( params , key ) ; var count = parseInt ( params [ key ] , 10 ) ; if ( validatePluralKey && isNaN ( count ) ) { if ( silentValidation ) return [ ] ; throw new Error ( 'expected "' + key + '" to be a number. got "' + ( typeof params [ key ] ) + '".' ) ; } if ( toLocaleString ) params = formatNumbers ( params , decimal ) ; return ( cases [ count ] || cases [ pluralize ( count || 0 ) ] ) ( params ) ; } , paramsKeys ) ; }
Compile a translation function

@param {String|Array|Object} cldr
@param {String} locale
@param {Object?} opts
@return {Function}
Compile a translation function