/** * Display the translated string. */ protected function renderBody() { $app = $this->Application->getGlobalization(); //get the text from either Property Text or the body $text = $this->getText(); if (strlen($text) == 0) { $text = parent::renderBody(); } //trim it if ($this->doTrim()) { $text = trim($text); } //no translation handler provided if (empty($app->Translation)) { return strtr($text, $this->getParameters()); } Translation::init(); $catalogue = $this->getCatalogue(); if (empty($catalogue) && isset($app->Translation['catalogue'])) { $catalogue = $app->Translation['catalogue']; } $key = $this->getKey(); if (!empty($key)) { $text = $key; } //translate it return Translation::formatter()->format($text, $this->getParameters(), $catalogue, $this->charset()); }
/** * Renders the localized number, be it currency or decimal, or percentage. * If the culture is not specified, the default application * culture will be used. * This method overrides parent's implementation. */ protected function renderBody() { $app = $this->Application->getGlobalization(); //initialized the default class wide formatter if (is_null(self::$formatter)) { self::$formatter = new NumberFormat($app->Culture); } $culture = $this->getCulture(); $pattern = $this->getPattern(); $type = $this->getType(); if (empty($pattern)) { $pattern = $type; } $value = $this->getValue(); if (strlen($value) == 0) { $value = parent::renderBody(); } //return the specific cultural formatted number if (!empty($culture) && $app->Culture != $culture) { $formatter = new NumberFormat($culture); return $formatter->format($value, $pattern, $this->getCurrency(), $this->charset()); } //return the application wide culture formatted number. return self::$formatter->format($value, $pattern, $this->getCurrency(), $this->charset()); }
/** * Get the date-time value for this control. * @return string date time value. */ function getValue() { $value = $this->getViewState('Value', ''); if (empty($value)) { $text = parent::renderBody(); if (empty($text)) { return time(); } else { return $text; } } return $value; }