Example #1
0
 public function render(\Erebot\IntlInterface $translator)
 {
     $locale = $translator->getLocale(\Erebot\IntlInterface::LC_NUMERIC);
     $formatter = new \NumberFormatter($locale, \NumberFormatter::IGNORE);
     $result = (string) $formatter->format($this->value, \NumberFormatter::TYPE_INT32);
     return $result;
 }
Example #2
0
 /**
  * \copydoc ::Erebot::Styling::VariableInterface::render()
  *
  * \note
  *      If no currency was passed to this class' constructor,
  *      the currency associated with the translator's locale
  *      is used.
  */
 public function render(\Erebot\IntlInterface $translator)
 {
     $locale = $translator->getLocale(\Erebot\IntlInterface::LC_MONETARY);
     $formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
     $currency = $this->currency !== null ? $this->currency : $formatter->getSymbol(\NumberFormatter::INTL_CURRENCY_SYMBOL);
     return (string) $formatter->formatCurrency($this->value, $currency);
 }
Example #3
0
 public function render(\Erebot\IntlInterface $translator)
 {
     $locale = $translator->getLocale(\Erebot\IntlInterface::LC_NUMERIC);
     $formatter = new \NumberFormatter($locale, \NumberFormatter::DECIMAL);
     $formatter->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, 0);
     $formatter->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, 100);
     $result = (string) $formatter->format($this->value);
     return $result;
 }
Example #4
0
 public function render(\Erebot\IntlInterface $translator)
 {
     $locale = $translator->getLocale(\Erebot\IntlInterface::LC_MESSAGES);
     $coreTranslator = new \Erebot\Intl('Erebot\\Styling');
     $coreTranslator->setLocale(\Erebot\IntlInterface::LC_MESSAGES, $locale);
     // DO NOT CHANGE THE CODE BELOW, ESPECIALLY COMMENTS & WHITESPACES.
     // It has all been carefully crafted to make both xgettext and
     // PHP_CodeSniffer happy! Also, it avoids relying on OS line endings
     // as it breaks xgettext on at least Windows platforms.
     $rule = $coreTranslator->_("%with-words:\n" . "    0: 0 seconds;\n" . "    1: 1 second;\n" . "    2: =#0= seconds;\n" . "    60/60: <%%min<;\n" . "    61/60: <%%min<, >%with-words>;\n" . "    3600/60: <%%hr<;\n" . "    3601/60: <%%hr<, >%with-words>;\n" . "    86400/86400: <%%day<;\n" . "    86401/86400: <%%day<, >%with-words>;\n" . "    604800/604800: <%%week<;\n" . "    604801/604800: <%%week<, >%with-words>;\n" . "%%min:\n" . "    1: 1 minute;\n" . "    2: =#0= minutes;\n" . "%%hr:\n" . "    1: 1 hour;\n" . "    2: =#0= hours;\n" . "%%day:\n" . "    1: 1 day;\n" . "    2: =#0= days;\n" . "%%week:\n" . "    1: 1 week;\n" . "    2: =#0= weeks;");
     $formatter = new \NumberFormatter($locale, \NumberFormatter::PATTERN_RULEBASED, $rule);
     return (string) $formatter->format($this->value);
 }
Example #5
0
 public function render(\Erebot\IntlInterface $translator)
 {
     $timezone = $this->timezone !== null ? $this->timezone : date_default_timezone_get();
     $formatter = new \IntlDateFormatter($translator->getLocale(\Erebot\IntlInterface::LC_TIME), $this->datetype, $this->timetype, $timezone);
     return (string) $formatter->format($this->value);
 }