Exemplo n.º 1
0
 /**
  * Parses percent number using proper format from CLDR.
  *
  * @param string $numberToParse Number to be parsed
  * @param \TYPO3\FLOW3\I18n\Locale $locale Locale to use
  * @param string $formatLength One of NumbersReader FORMAT_LENGTH constants
  * @param boolean $strictMode Work mode (strict when TRUE, lenient when FALSE)
  * @return mixed Parsed float number or FALSE on failure
  * @api
  */
 public function parsePercentNumber($numberToParse, \TYPO3\FLOW3\I18n\Locale $locale, $formatLength = \TYPO3\FLOW3\I18n\Cldr\Reader\NumbersReader::FORMAT_LENGTH_DEFAULT, $strictMode = TRUE)
 {
     \TYPO3\FLOW3\I18n\Cldr\Reader\NumbersReader::validateFormatLength($formatLength);
     return $this->doParsingWithParsedFormat($numberToParse, $this->numbersReader->parseFormatFromCldr($locale, \TYPO3\FLOW3\I18n\Cldr\Reader\NumbersReader::FORMAT_TYPE_PERCENT, $formatLength), $this->numbersReader->getLocalizedSymbolsForLocale($locale), $strictMode);
 }
Exemplo n.º 2
0
 /**
  * Formats number with format string for currency defined in CLDR for
  * particular locale.
  *
  * Currency symbol provided will be inserted into formatted number string.
  *
  * Note: currently length is not used in currencyFormats from CLDR.
  * But it's defined in the specification, so we support it here.
  *
  * @param mixed $number Float or int, can be negative, can be NaN or infinite
  * @param \TYPO3\FLOW3\I18n\Locale $locale
  * @param string $currency Currency symbol (or name)
  * @param string $formatLength One of NumbersReader FORMAT_LENGTH constants
  * @return string Formatted number. Will return string-casted version of $number if there is no pattern for given $locale / $formatLength
  * @api
  */
 public function formatCurrencyNumber($number, \TYPO3\FLOW3\I18n\Locale $locale, $currency, $formatLength = \TYPO3\FLOW3\I18n\Cldr\Reader\NumbersReader::FORMAT_LENGTH_DEFAULT)
 {
     \TYPO3\FLOW3\I18n\Cldr\Reader\NumbersReader::validateFormatLength($formatLength);
     return $this->doFormattingWithParsedFormat($number, $this->numbersReader->parseFormatFromCldr($locale, \TYPO3\FLOW3\I18n\Cldr\Reader\NumbersReader::FORMAT_TYPE_CURRENCY, $formatLength), $this->numbersReader->getLocalizedSymbolsForLocale($locale), $currency);
 }