Commit 7f1f7594 by Carsten Brandt

small doc adjustments

parent 4d6d9525
...@@ -54,13 +54,15 @@ class Formatter extends Component ...@@ -54,13 +54,15 @@ class Formatter extends Component
{ {
/** /**
* @var string the text to be displayed when formatting a `null` value. * @var string the text to be displayed when formatting a `null` value.
* Defaults to `'<span class="not-set">(not set)</span>'`. * Defaults to `'<span class="not-set">(not set)</span>'`, where `(not set)`
* will be translated according to [[locale]].
*/ */
public $nullDisplay; public $nullDisplay;
/** /**
* @var array the text to be displayed when formatting a boolean value. The first element corresponds * @var array the text to be displayed when formatting a boolean value. The first element corresponds
* to the text displayed for `false`, the second element for `true`. * to the text displayed for `false`, the second element for `true`.
* Defaults to `['No', 'Yes']`. * Defaults to `['No', 'Yes']`, where `Yes` and `No`
* will be translated according to [[locale]]..
*/ */
public $booleanFormat; public $booleanFormat;
/** /**
...@@ -175,14 +177,12 @@ class Formatter extends Component ...@@ -175,14 +177,12 @@ class Formatter extends Component
'decimalSeparator' => null, 'decimalSeparator' => null,
]; ];
/** /**
* @var boolean whether the php `intl` extension is loaded. * @var boolean whether the php `intl` extension is loaded.
*/ */
private $_intlLoaded = false; private $_intlLoaded = false;
/** /**
* @inheritdoc * @inheritdoc
*/ */
...@@ -191,19 +191,15 @@ class Formatter extends Component ...@@ -191,19 +191,15 @@ class Formatter extends Component
if ($this->timeZone === null) { if ($this->timeZone === null) {
$this->timeZone = Yii::$app->timeZone; $this->timeZone = Yii::$app->timeZone;
} }
if ($this->locale === null) { if ($this->locale === null) {
$this->locale = Yii::$app->language; $this->locale = Yii::$app->language;
} }
if ($this->booleanFormat === null) { if ($this->booleanFormat === null) {
$this->booleanFormat = [Yii::t('yii', 'No'), Yii::t('yii', 'Yes')]; $this->booleanFormat = [Yii::t('yii', 'No'), Yii::t('yii', 'Yes')];
} }
if ($this->nullDisplay === null) { if ($this->nullDisplay === null) {
$this->nullDisplay = '<span class="not-set">' . Yii::t('yii', '(not set)') . '</span>'; $this->nullDisplay = '<span class="not-set">' . Yii::t('yii', '(not set)') . '</span>';
} }
$this->_intlLoaded = extension_loaded('intl'); $this->_intlLoaded = extension_loaded('intl');
// TODO refactor number formatters // TODO refactor number formatters
......
...@@ -76,16 +76,6 @@ class FormatterTest extends TestCase ...@@ -76,16 +76,6 @@ class FormatterTest extends TestCase
$this->assertSame(date('Y-m-d', $value), $this->formatter->format($value, 'data')); $this->assertSame(date('Y-m-d', $value), $this->formatter->format($value, 'data'));
} }
// public function testSetLocale(){
// $value = '12300';
// $this->formatter->setLocale('de-DE');
// $this->assertSame('12.300,00', $this->formatter->asDouble($value, 2));
// $value = time();
// $this->assertSame(date('d.m.Y', $value), $this->formatter->asDate($value));
// $this->formatter->setLocale('en-US');
//
// }
public function testAsRaw() public function testAsRaw()
{ {
...@@ -201,6 +191,18 @@ class FormatterTest extends TestCase ...@@ -201,6 +191,18 @@ class FormatterTest extends TestCase
} }
// public function testSetLocale(){
// $value = '12300';
// $this->formatter->setLocale('de-DE');
// $this->assertSame('12.300,00', $this->formatter->asDouble($value, 2));
// $value = time();
// $this->assertSame(date('d.m.Y', $value), $this->formatter->asDate($value));
// $this->formatter->setLocale('en-US');
//
// }
// date format // date format
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment