Lookup the plural function given a locale

@param {String} locale
@param {String} format
@return {Function}
176751
function lookup(locale, format, obj) {
  if (!locale) throw new Error('missing required "locale" parameter');
  locale = locale.toLowerCase().replace('-', '_');
  format = format || 'cardinal';
  var p = obj[format];
  if (!p) throw new Error('unsupported format "' + format + '"');
  var fn = p[locale] || p[locale.split('_')[0]];
  if (fn) return fn;

  throw new Error('unsupported locale "' + locale + '"');
}
513353
function getCurrencySymbol(code, format, locale) {
    if (locale === void 0) { locale = 'en'; }
    var currency = getLocaleCurrencies(locale)[code] || CURRENCIES_EN[code] || [];
    var symbolNarrow = currency[1 /* SymbolNarrow */];
    if (format === 'narrow' && typeof symbolNarrow === 'string') {
        return symbolNarrow;
    }
    return currency[0 /* Symbol */] || code;
}
499482
function parseGettext(locale, data, options = {}) {
  const out = {
    charset: 'utf-8',
    headers: {
      'project-id-version': options.project || 'i18next-conv',
      'mime-version': '1.0',
      'content-type': 'text/plain; charset=utf-8',
      'content-transfer-encoding': '8bit',
    },
    translations: {},
  };

  const ext = plurals.getRule(locale);
  const trans = {};

  out.headers['plural-forms'] = `nplurals=${ext.nplurals}; plural=${ext.plurals}`;

  if (!options.noDate) {
    out.headers['pot-creation-date'] = new Date().toISOString();
    out.headers['po-revision-date'] = new Date().toISOString();
    if (options.potCreationDate && typeof options.potCreationDate.toISOString === 'function') out.headers['pot-creation-date'] = options.potCreationDate.toISOString();
    if (options.poRevisionDate && typeof options.poRevisionDate.toISOString === 'function') out.headers['po-revision-date'] = options.poRevisionDate.toISOString();
  }
  if (options.language) {
    out.headers.language = options.language;
  }
  const delkeys = [];

  Object.keys(data).forEach((m) => {
    const kv = data[m];

    if (kv.plurals) {
      const pArray = [];

      for (let i = 0, len = kv.plurals.length; i < len; i += 1) {
        const plural = kv.plurals[i];
        pArray.splice(getGettextPluralPosition(ext, plural.pluralNumber - 1), 0, plural.value);
      }
      pArray.splice(getGettextPluralPosition(ext, kv.pluralNumber - 1), 0, kv.value);

      if (typeof trans[kv.context] !== 'object') trans[kv.context] = {};
      if (options.keyasareference) {
        if (typeof trans[kv.context][kv.value] === 'object') {
          // same context and msgid. this could theorically be merged.
          trans[kv.context][kv.value].comments.reference.push(kv.key);
        } else {
          trans[kv.context][kv.value] = {
            msgctxt: kv.context,
            msgid: pArray[0],
            msgid_plural: pArray.slice(1, pArray.length),
            msgstr: kv.translated_value,
            comments: { reference: [kv.key] },
          };
        }
        if (kv.key !== kv.value) {
          delkeys.push([kv.context, kv.key]);
        }
      } else {
        trans[kv.context][kv.key] = {
          msgctxt: kv.context,
          msgid: kv.key,
          msgid_plural: kv.key,
          msgstr: pArray,
        };
      }
    } else {
      if (typeof trans[kv.context] !== 'object') trans[kv.context] = {};

      if (options.keyasareference) {
        if (typeof trans[kv.context][kv.value] === 'object') {
          // same context and msgid. this could theorically be merged.
          trans[kv.context][kv.value].comments.reference.push(kv.key);
        } else {
          trans[kv.context][kv.value] = {
            msgctxt: kv.context,
            msgid: kv.value,
            msgstr: kv.translated_value,
            comments: {
              reference: [kv.key],
            },
          };
        }
        if (kv.key !== kv.value) {
          delkeys.push([kv.context, kv.key]);
        }
      } else {
        trans[kv.context][kv.key] = { msgctxt: kv.context, msgid: kv.key, msgstr: kv.value };
      }
    }
  });

  delkeys.forEach((a) => {
    const c = a[0];
    const k = a[1];
    delete trans[c][k];
  });

  // re-format reference comments to be able to compile with gettext-parser...
  Object.keys(trans).forEach((ctxt) => {
    Object.keys(trans[ctxt]).forEach((id) => {
      if (trans[ctxt][id].comments && trans[ctxt][id].comments.reference) {
        trans[ctxt][id].comments.reference = trans[ctxt][id].comments.reference.join('\n');
      }
    });
  });

  out.translations = trans;
  return Promise.resolve(out);
}
135049
function Compiler(locales, formats, pluralFn) {
  this.locales = locales;
  this.formats = formats;
  this.pluralFn = pluralFn;
}
1352198
function(_string, _locale) {
            var rules = loadRulesFor(_locale);
            return rules ? applyRules(_string, rules.plural, rules.uncountable) : _string;
          }
1361427
function translate(singular, plural) {
    if (!locales[currentLocale]) {
        read(currentLocale);
    }

    if (plural) {
        if (!locales[currentLocale][singular]) {
            locales[currentLocale][singular] = {
                'one': singular,
                'other': plural
            };
            write(currentLocale);
        }
    }

    if (!locales[currentLocale][singular]) {
        locales[currentLocale][singular] = singular;
        write(currentLocale);
    }
    return locales[currentLocale][singular];
}
54356
public PluralRules forLocale(ULocale locale, PluralRules.PluralType type) {
        String rulesId = getRulesIdForLocale(locale, type);
        if (rulesId == null || rulesId.trim().length() == 0) {
            return PluralRules.DEFAULT;
        }
        PluralRules rules = getRulesForRulesId(rulesId);
        if (rules == null) {
            rules = PluralRules.DEFAULT;
        }
        return rules;
    }
1263488
private Map<String, String> getLocaleIdToRulesIdMap(PluralType type) {
        checkBuildRulesIdMaps();
        return (type == PluralType.CARDINAL) ? localeIdToCardinalRulesId : localeIdToOrdinalRulesId;
    }
1200557
function normalizeFormat(format) {
  const clone = Object.assign({}, format);
  clone.prefix = normalizePrefixSuffix(format.prefix);
  clone.suffix = normalizePrefixSuffix(format.suffix);
  return clone;
}
836962
def get(number, locale):
        
        if locale == 'pt_BR':
            # temporary set a locale for brazilian
            locale = 'xbr'

        if len(locale) > 3:
            locale = locale.split("_")[0]

        rule = PluralizationRules._rules.get(locale, lambda _: 0)
        _return = rule(number)
        if not isinstance(_return, int) or _return < 0:
            return 0
        return _return
545651
public static String pluralize(final Locale locale, final Number number, final PluralizeParams params)
    {
        return withinLocale(new Callable<String>()
        {
            @Override
            public String call() throws Exception
            {
                return pluralize(number, params);
            }
        }, locale);
    }
384531
function (f) {
			var fmt = f || this.format
			, sepchar = getSeparator(fmt)
			, local = this;

			return _.map((fmt || 'yyyy mm dd').split(sepchar), function(part) {
				return local.template()[part];
			});
		}
1058526
def pluralize(locale, entry, count)
      return entry unless entry.is_a?(Hash) and count
      key = :zero if count == 0 && entry.has_key?(:zero)
      key ||= count <= 1 ? :one : :other
      raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key)
      entry[key]
    end
866663
@Deprecated
  public String format(Locale locale, Duration duration, DurationFormat format) {
    return format(duration);
  }
1083002
def get_plural_tag_index(number, locale):
    
    locale = Locale.parse(locale)
    plural_rule = locale.plural_form
    used_tags = plural_rule.tags | set([_fallback_tag])
    tag, index = plural_rule(number), 0
    for _tag in _plural_tags:
        if _tag == tag:
            return index
        if _tag in used_tags:
            index += 1
1346017
function addTextLocale(locale, body, options = {}) {
  const gt = new Gettext();
  const domain = 'messages';
  const {
    filter,
    gettextDefaultCharset = 'UTF-8',
  } = options;

  if (body.length > 0) {
    gt.addTranslations(locale, domain, po.parse(body, gettextDefaultCharset));
  }

  if (filter) {
    const filterAsync = Promise.promisify(filter);
    return filterAsync(gt, locale);
  }

  return Promise.resolve(gt.catalogs[locale] && gt.catalogs[locale][domain].translations);
}
80635
public synchronized Pluralizer find(Locale l) {
        while (l != null) {
            List<Locale> candidates = control
                                    .getCandidateLocales(PLURALIZER_CLASS, l);
            for (Locale c: candidates) {
                Pluralizer p = pluralizers.get(c);
                if (p != null) return p;
            }
            l = control.getFallbackLocale(PLURALIZER_CLASS, l);
        }
        return null;
    }