mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Fix and test pluralisation usages
This commit is contained in:
parent
cfa6a36697
commit
e4c68bc2bf
@ -681,10 +681,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
public function i18n_pluralise($count)
|
public function i18n_pluralise($count)
|
||||||
{
|
{
|
||||||
$default = 'one ' . $this->i18n_singular_name() . '|{count} ' . $this->i18n_plural_name();
|
$default = 'one ' . $this->i18n_singular_name() . '|{count} ' . $this->i18n_plural_name();
|
||||||
return i18n::pluralise(
|
return i18n::_t(
|
||||||
static::class.'.PLURALS',
|
static::class.'.PLURALS',
|
||||||
$default,
|
$default,
|
||||||
$count
|
[ 'count' => $count ]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,16 +493,16 @@ class ChangeSet extends DataObject
|
|||||||
// Describe non-important items
|
// Describe non-important items
|
||||||
if ($countedOther) {
|
if ($countedOther) {
|
||||||
if ($counted) {
|
if ($counted) {
|
||||||
$parts[] = i18n::pluralise(
|
$parts[] = i18n::_t(
|
||||||
'ChangeSet.DESCRIPTION_OTHER_ITEM_PLURALS',
|
'ChangeSet.DESCRIPTION_OTHER_ITEM_PLURALS',
|
||||||
'one other item|{count} other items',
|
'one other item|{count} other items',
|
||||||
$countedOther
|
[ 'count' => $countedOther ]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$parts[] = i18n::pluralise(
|
$parts[] = i18n::_t(
|
||||||
'ChangeSet.DESCRIPTION_ITEM_PLURALS',
|
'ChangeSet.DESCRIPTION_ITEM_PLURALS',
|
||||||
'one item|{count} items',
|
'one item|{count} items',
|
||||||
$countedOther
|
[ 'count' => $countedOther ]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,6 +104,17 @@ class ChangeSetTest extends SapphireTest
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDescription()
|
||||||
|
{
|
||||||
|
$cs = new ChangeSet();
|
||||||
|
$cs->write();
|
||||||
|
$cs->addObject($this->objFromFixture(ChangeSetTest\EndObject::class, 'end1'));
|
||||||
|
$this->assertEquals('one item', $cs->getDescription());
|
||||||
|
|
||||||
|
$cs->addObject($this->objFromFixture(ChangeSetTest\EndObjectChild::class, 'endchild1'));
|
||||||
|
$this->assertEquals('2 items', $cs->getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
public function testRepeatedSyncIsNOP()
|
public function testRepeatedSyncIsNOP()
|
||||||
{
|
{
|
||||||
$this->publishAllFixtures();
|
$this->publishAllFixtures();
|
||||||
|
@ -4,6 +4,7 @@ namespace SilverStripe\ORM\Tests;
|
|||||||
|
|
||||||
use SilverStripe\Core\Config\Config;
|
use SilverStripe\Core\Config\Config;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\i18n\i18n;
|
||||||
use SilverStripe\ORM\DataObjectSchema;
|
use SilverStripe\ORM\DataObjectSchema;
|
||||||
use SilverStripe\ORM\FieldType\DBBoolean;
|
use SilverStripe\ORM\FieldType\DBBoolean;
|
||||||
use SilverStripe\ORM\FieldType\DBField;
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
@ -1645,13 +1646,18 @@ class DataObjectTest extends SapphireTest
|
|||||||
DataObjectTest\Bogey::class => 'Bogeys',
|
DataObjectTest\Bogey::class => 'Bogeys',
|
||||||
DataObjectTest\Ploy::class => 'Ploys',
|
DataObjectTest\Ploy::class => 'Ploys',
|
||||||
);
|
);
|
||||||
|
i18n::set_locale('en_NZ');
|
||||||
foreach ($assertions as $class => $expectedPluralName) {
|
foreach ($assertions as $class => $expectedPluralName) {
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expectedPluralName,
|
$expectedPluralName,
|
||||||
singleton($class)->plural_name(),
|
DataObject::singleton($class)->plural_name(),
|
||||||
"Assert that the plural_name for '$class' is correct."
|
"Assert that the plural_name for '$class' is correct."
|
||||||
);
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$expectedPluralName,
|
||||||
|
DataObject::singleton($class)->i18n_plural_name(),
|
||||||
|
"Assert that the i18n_plural_name for '$class' is correct."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user