Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dd6fd82

Browse files
committed
Fix #30215 handle plural for negative numbers
1 parent 71e1370 commit dd6fd82

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Symfony/Component/Translation/PluralizationRules.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ class PluralizationRules
2525
/**
2626
* Returns the plural position to use for the given locale and number.
2727
*
28-
* @param int $number The number
28+
* @param float $number The number
2929
* @param string $locale The locale
3030
*
3131
* @return int The plural position
3232
*/
3333
public static function get($number, $locale/*, bool $triggerDeprecation = true*/)
3434
{
35+
$number = abs($number);
36+
3537
if (3 > \func_num_args() || func_get_arg(2)) {
3638
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2.', __CLASS__), \E_USER_DEPRECATED);
3739
}

src/Symfony/Contracts/Translation/TranslatorTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ public function trans($id, array $parameters = [], $domain = null, $locale = nul
138138
*/
139139
private function getPluralizationRule(float $number, string $locale): int
140140
{
141+
$number = abs($number);
142+
141143
switch ('pt_BR' !== $locale && \strlen($locale) > 3 ? substr($locale, 0, strrpos($locale, '_')) : $locale) {
142144
case 'af':
143145
case 'bn':

0 commit comments

Comments
 (0)