mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 13:02:24 +08:00
Addded pluralization and singularization exception for currency
This commit is contained in:
@ -51,6 +51,7 @@ class BaseInflector
|
|||||||
'/us$/i' => 'uses',
|
'/us$/i' => 'uses',
|
||||||
'/(alias)$/i' => '\1es',
|
'/(alias)$/i' => '\1es',
|
||||||
'/(ax|cris|test)is$/i' => '\1es',
|
'/(ax|cris|test)is$/i' => '\1es',
|
||||||
|
'/(currenc)y$/' => '\1ies',
|
||||||
'/s$/' => 's',
|
'/s$/' => 's',
|
||||||
'/^$/' => '',
|
'/^$/' => '',
|
||||||
'/$/' => 's',
|
'/$/' => 's',
|
||||||
@ -97,6 +98,7 @@ class BaseInflector
|
|||||||
'/(n)ews$/i' => '\1\2ews',
|
'/(n)ews$/i' => '\1\2ews',
|
||||||
'/(n)etherlands$/i' => '\1\2etherlands',
|
'/(n)etherlands$/i' => '\1\2etherlands',
|
||||||
'/eaus$/' => 'eau',
|
'/eaus$/' => 'eau',
|
||||||
|
'/(currenc)ies$/' => '\1y',
|
||||||
'/^(.*us)$/' => '\\1',
|
'/^(.*us)$/' => '\\1',
|
||||||
'/s$/i' => '',
|
'/s$/i' => '',
|
||||||
];
|
];
|
||||||
|
|||||||
@ -31,6 +31,7 @@ class InflectorTest extends TestCase
|
|||||||
'test' => 'tests',
|
'test' => 'tests',
|
||||||
'car' => 'cars',
|
'car' => 'cars',
|
||||||
'netherlands' => 'netherlands',
|
'netherlands' => 'netherlands',
|
||||||
|
'currency' => 'currencies',
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($testData as $testIn => $testOut) {
|
foreach ($testData as $testIn => $testOut) {
|
||||||
@ -59,6 +60,7 @@ class InflectorTest extends TestCase
|
|||||||
'tests' => 'test',
|
'tests' => 'test',
|
||||||
'cars' => 'car',
|
'cars' => 'car',
|
||||||
'Netherlands' => 'Netherlands',
|
'Netherlands' => 'Netherlands',
|
||||||
|
'currencies' => 'currency',
|
||||||
];
|
];
|
||||||
foreach ($testData as $testIn => $testOut) {
|
foreach ($testData as $testIn => $testOut) {
|
||||||
$this->assertEquals($testOut, Inflector::singularize($testIn));
|
$this->assertEquals($testOut, Inflector::singularize($testIn));
|
||||||
|
|||||||
Reference in New Issue
Block a user