Skip to content

Commit

Permalink
Fix third numeral form for 'год' in Russian
Browse files Browse the repository at this point in the history
  • Loading branch information
wapmorgan committed Jun 27, 2018
1 parent 3e95214 commit 3ac5a06
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/Russian/NounPluralization.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class NounPluralization extends \morphos\NounPluralization implements Cases
'блюдце' => 'блюдец',
'полотенце' => 'полотенец',
'гривна' => 'гривен',
'год' => 'лет',
];

protected static $immutableWords = [
Expand Down Expand Up @@ -87,6 +88,11 @@ public static function pluralize($word, $count = 2, $animateness = false)
case self::TWO_FOUR:
return NounDeclension::getCase($word, self::RODIT, $animateness);
case self::FIVE_OTHER:
// special case for YEAR >= 5
if ($word === 'год') {
return 'лет';
}

return NounPluralization::getCase($word, self::RODIT, $animateness);
}
}
Expand Down
5 changes: 0 additions & 5 deletions src/Russian/TimeSpeller.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ public static function spellUnit($count, $unit)
throw new InvalidArgumentException('Unknown time unit: '.$unit);
}

// special case for YEAR >= 5
if ($unit == self::YEAR && NounPluralization::getNumeralForm($count) == NounPluralization::FIVE_OTHER) {
return $count.' лет';
}

return pluralize($count, self::$units[$unit]);
}
}
1 change: 1 addition & 0 deletions src/Russian/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ function normalizeFullName($name)
* @param string $word Название предмета
* @param bool $animateness Признак одушевленности
* @return string Строка в формате "ЧИСЛО [СУЩ в правильной форме]"
* @throws \Exception
*/
function pluralize($count, $word, $animateness = false)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Russian/NounPluralizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function pluralWordsProvider()
['песец', true, ['песцы', 'песцов', 'песцам', 'песцов', 'песцами', 'песцах']],
['пятно', false, ['пятна', 'пятен', 'пятнам', 'пятна', 'пятнами', 'пятнах']],
['волчище', false, ['волчища', 'волчищ', 'волчищам', 'волчища', 'волчищами', 'волчищах']],
['год', false, ['года', 'годов', 'годам', 'года', 'годами', 'годах']],
['год', false, ['года', 'лет ', 'годам', 'года', 'годами', 'годах']],
['месяц', false, ['месяцы', 'месяцев', 'месяцам', 'месяцы', 'месяцами', 'месяцах']],
['новость', false, ['новости', 'новостей', 'новостям', 'новости', 'новостями', 'новостях']],
['тень', false, ['тени', 'теней', 'теням', 'тени', 'тенями', 'тенях']],
Expand Down

0 comments on commit 3ac5a06

Please sign in to comment.