Selects the standard plural form for the number/formatter/rules.
327209
public static StandardPlural selectPlural(
            Number number, NumberFormat fmt, PluralRules rules,
            StringBuffer formattedNumber, FieldPosition pos) {
        UFieldPosition fpos = new UFieldPosition(pos.getFieldAttribute(), pos.getField());
        fmt.format(number, formattedNumber, fpos);
        // TODO: Long, BigDecimal & BigInteger may not fit into doubleValue().
        FixedDecimal fd = new FixedDecimal(
                number.doubleValue(),
                fpos.getCountVisibleFractionDigits(), fpos.getFractionDigits());
        String pluralKeyword = rules.select(fd);
        pos.setBeginIndex(fpos.getBeginIndex());
        pos.setEndIndex(fpos.getEndIndex());
        return StandardPlural.orOtherFromString(pluralKeyword);
    }
626346
public function ngettext($single, $plural, $number, &$num) {
        if ($this->short_circuit) {
            if ($number != 1)
                return $plural;
            else
                return $single;
        }

        // find out the appropriate form
        $select = $this->select_string($number);

        // this should contains all strings separated by NULLs
        $key = $single . chr(0) . $plural;


        if ($this->enable_cache) {
            if (!array_key_exists($key, $this->cache_translations)) {
                return ($number != 1) ? $plural : $single;
            }
            else {
                $result = $this->cache_translations[$key];
                $list = explode(chr(0), $result);
                return $list[$select];
            }
        }
        else {
            $num = $this->find_string($key);
            if ($num == -1) {
                return ($number != 1) ? $plural : $single;
            }
            else {
                $result = $this->get_translation_string($num);
                $list = explode(chr(0), $result);
                return $list[$select];
            }
        }
    }
1090531
def plural(self):
		'''  '''

		element = self._first('NN')
		if element:
			element = element.split('\r\n')[0]
			if ' | ' in element:
				# This means there is a plural
				singular, plural = element.split(' | ')
				return [plural.split(' ')[1]]
			else:
				# This means there is no plural
				return ['']
		return [None]
202070
def Plural(format_str):
  
  if format_str.startswith('plural?'):
    i = len('plural?')

    try:
      splitchar = format_str[i]  # Usually a space, but could be something else
      _, plural_val, singular_val = format_str.split(splitchar)
    except IndexError:
      raise Error('plural? must have exactly 2 arguments')

    def Formatter(value):
      plural = False
      if isinstance(value, int) and value > 1:
        plural = True
      if isinstance(value, list) and len(value) > 1:
        plural = True

      if plural:
        return plural_val
      else:
        return singular_val

    return Formatter

  else:
    return None
1042256
def format_number(num, singular = nil, plural = nil)
      bold_num = ::Cinch::Formatting.format(:bold, num.to_s)
      (bold_num + ' ' + (num == 1 ? singular : plural).to_s).strip
    end
504854
public static function plural(array $endings, int $number): string
    {
        $numberForOperations = abs($number);
        $cases = [2, 0, 1, 1, 1, 2];

        $isTwo = ($numberForOperations % 100 > 4 && $numberForOperations % 100 < 20);
        $endNum = $isTwo ? 2 : $cases[min($numberForOperations % 10, 5)];
        $string = $endings[$endNum];

        return sprintf($string, $number);
    }
531525
function createRules() {
  var rules = {};
  sets.forEach(function (set$$1) {
    set$$1.lngs.forEach(function (l) {
      rules[l] = {
        numbers: set$$1.nr,
        plurals: _rulesPluralsTypes[set$$1.fc]
      };
    });
  });
  return rules;
}
1203445
public static function irregular($singular, $plural, $locale = 'default')
    {
        $rules = !is_array($singular) ? [$singular => $plural] : $singular;

        $len = min(strlen($singular), strlen($plural));

        $prefix = '';
        $index = 0;
        while ($index < $len && ($singular[$index] === $plural[$index])) {
            $prefix .= $singular[$index];
            $index++;
        }
        if (!$sSuffix = substr($singular, $index)) {
            $sSuffix = '';
        }
        if (!$pSuffix = substr($plural, $index)) {
            $pSuffix = '';
        }

        static::singular("/({$singular})$/i", "\\1", $locale);
        static::singular("/({$prefix}){$pSuffix}$/i", "\\1{$sSuffix}", $locale);
        static::plural("/({$plural})$/i", "\\1", $locale);
        static::plural("/({$prefix}){$sSuffix}$/i", "\\1{$pSuffix}", $locale);
    }
1373939
private function select_string($n) {
        $string = $this->get_plural_forms();
        $string = str_replace('nplurals', "\$total", $string);
        $string = str_replace("n", $n, $string);
        $string = str_replace('plural', "\$plural", $string);

        $total = 0;
        $plural = 0;

        eval("$string");
        if ($plural >= $total) $plural = $total - 1;
        return $plural;
    }
715953
function createRules() {
  const rules = {};
  sets.forEach((set) => {
    set.lngs.forEach((l) => {
      rules[l] = {
        numbers: set.nr,
        plurals: _rulesPluralsTypes[set.fc]
      };
    });
  });
  return rules;
}
237525
def get_plural_name(cls):
        
        if not hasattr(cls.Meta, 'plural_name'):
            setattr(
                cls.Meta,
                'plural_name',
                inflection.pluralize(cls.get_name())
            )
        return cls.Meta.plural_name
919507
private function getPluralForms()
    {
        // lets assume message number 0 is header
        // this is true, right?

        // cache header field for plural forms
        if (is_null($this->pluralequation)) {
            if (isset($this->cache_translations[''])) {
                $header = $this->cache_translations[''];
            } else {
                $header = '';
            }
            $expr = $this->extractPluralsForms($header);
            $this->pluralequation = $this->sanitizePluralExpression($expr);
            $this->pluralcount = $this->extractPluralCount($expr);
        }

        return $this->pluralequation;
    }
3805
def _attempt_to_choose_formatting_pattern(self):
        """"""
        # We start to attempt to format only when at least MIN_LEADING_DIGITS_LENGTH digits of national
        # number (excluding national prefix) have been entered.
        if len(self._national_number) >= _MIN_LEADING_DIGITS_LENGTH:
            self._get_available_formats(self._national_number)
            # See if the accrued digits can be formatted properly already.
            formatted_number = self._attempt_to_format_accrued_digits()
            if len(formatted_number) > 0:
                return formatted_number
            if self._maybe_create_new_template():
                return self._input_accrued_national_number()
            else:
                return self._accrued_input
        else:
            return self._append_national_number(self._national_number)
1116454
def _choice_format(self, occur):
        """""" 
        middle = "%s" if self.rng_children() else "<empty/>%s"
        fmt = self.start_tag() + middle + self.end_tag()
        if self.occur != 2:
            return "<optional>" + fmt + "</optional>"
        else:
            return fmt
183364
public static function pluralize($input) {
		if (self::$pluralizer === null) {
			self::$pluralizer = new StandardEnglishSingularizer();
		}

		return self::$pluralizer->getPluralForm($input);
	}
271284
public PluralRules load(
        Locale locale,
        NumberType numType
    ) {

        Map<String, PluralRules> map;
        PluralRules stdRules;

        switch (numType) {
            case CARDINALS:
                map = CARDINAL_MAP;
                stdRules = STD_CARDINALS;
                break;
            case ORDINALS:
                map = ORDINAL_MAP;
                stdRules = STD_ORDINALS;
                break;
            default:
                throw new UnsupportedOperationException(numType.name());
        }

        PluralRules rules = null;
        String region = FormatUtils.getRegion(locale);

        if (!region.isEmpty()) {
            StringBuilder kb = new StringBuilder();
            kb.append(locale.getLanguage());
            kb.append('_');
            kb.append(region);
            rules = map.get(kb.toString());
        }

        if (rules == null) {
            rules = map.get(locale.getLanguage());
        }

        if (rules == null) {
            return stdRules;
        }

        return rules;

    }
1347886
function _formatCountable(number, singularStr, pluralStr) {
        return StringUtils.format(number > 1 ? pluralStr : singularStr, number);
    }