mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding asserts forgot in last commit.
Fixes #6115 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8044 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
19ec3765dd
commit
8f2efce9ee
2 changed files with 21 additions and 18 deletions
|
@ -213,31 +213,31 @@ class I18n extends Object {
|
|||
if (strpos($header, "plurals=3")) {
|
||||
if (strpos($header, "100!=11")) {
|
||||
if (strpos($header, "10<=4")) {
|
||||
return $n % 10 === 1 && $n % 100 !== 11 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
return $n % 10 == 1 && $n % 100 != 11 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
} elseif (strpos($header, "100<10")) {
|
||||
return $n % 10 === 1 && $n % 100 !== 11 ? 0 : ($n % 10 >= 2 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
return $n % 10 == 1 && $n % 100 != 11 ? 0 : ($n % 10 >= 2 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
}
|
||||
return $n % 10 == 1 && $n % 100 != 11 ? 0 : ($n != 0 ? 1 : 2);
|
||||
} elseif (strpos($header, "n==2")) {
|
||||
return $n === 1 ? 0 : ($n === 2 ? 1 : 2);
|
||||
return $n == 1 ? 0 : ($n == 2 ? 1 : 2);
|
||||
} elseif (strpos($header, "n==0")) {
|
||||
return $n === 1 ? 0 : ($n === 0 || ($n % 100 > 0 && $n % 100 < 20) ? 1 : 2);
|
||||
return $n == 1 ? 0 : ($n == 0 || ($n % 100 > 0 && $n % 100 < 20) ? 1 : 2);
|
||||
} elseif (strpos($header, "n>=2")) {
|
||||
return $n === 1 ? 0 : ($n >= 2 && $n <= 4 ? 1 : 2);
|
||||
return $n == 1 ? 0 : ($n >= 2 && $n <= 4 ? 1 : 2);
|
||||
} elseif (strpos($header, "10>=2")) {
|
||||
return $n === 1 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
return $n == 1 ? 0 : ($n % 10 >= 2 && $n % 10 <= 4 && ($n % 100 < 10 || $n % 100 >= 20) ? 1 : 2);
|
||||
}
|
||||
return $n % 10 === 1 ? 0 : ($n % 10 === 2 ? 1 : 2);
|
||||
return $n % 10 == 1 ? 0 : ($n % 10 == 2 ? 1 : 2);
|
||||
} elseif (strpos($header, "plurals=4")) {
|
||||
if (strpos($header, "100==2")) {
|
||||
return $n % 100 === 1 ? 0 : ($n % 100 === 2 ? 1 : ($n % 100 === 3 || $n % 100 === 4 ? 2 : 3));
|
||||
return $n % 100 == 1 ? 0 : ($n % 100 == 2 ? 1 : ($n % 100 == 3 || $n % 100 == 4 ? 2 : 3));
|
||||
} elseif (strpos($header, "n>=3")) {
|
||||
return $n === 1 ? 0 : ($n === 2 ? 1 : ($n == 0 || ($n >= 3 && $n <= 10) ? 2 : 3));
|
||||
return $n == 1 ? 0 : ($n == 2 ? 1 : ($n == 0 || ($n >= 3 && $n <= 10) ? 2 : 3));
|
||||
} elseif (strpos($header, "100>=1")) {
|
||||
return $n === 1 ? 0 : ($n == 0 || ($n % 100 >= 1 && $n % 100 <= 10) ? 1 : ($n % 100 >= 11 && $n % 100 <= 20 ? 2 : 3));
|
||||
return $n == 1 ? 0 : ($n == 0 || ($n % 100 >= 1 && $n % 100 <= 10) ? 1 : ($n % 100 >= 11 && $n % 100 <= 20 ? 2 : 3));
|
||||
}
|
||||
} elseif (strpos($header, "plurals=5")) {
|
||||
return $n === 1 ? 0 : ($n === 2 ? 1 : ($n >= 3 && $n <= 6 ? 2 : ($n >= 7 && $n <= 10 ? 3 : 4)));
|
||||
return $n == 1 ? 0 : ($n == 2 ? 1 : ($n >= 3 && $n <= 6 ? 2 : ($n >= 7 && $n <= 10 ? 3 : 4)));
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -2470,16 +2470,19 @@ class I18nTest extends CakeTestCase {
|
|||
$this->assertEqual(__('this is a "quoted string"', true), $expected);
|
||||
}
|
||||
function testFloatValue() {
|
||||
Configure::write('Config.language', 'rule_3_po');
|
||||
Configure::write('Config.language', 'rule_9_po');
|
||||
|
||||
$result = __n('%d = 1', '%d = 0 or > 1', (float)1, true);
|
||||
$expected = '%d is 1 (from core translated)';
|
||||
$expected = '%d is 1 (translated)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = __n('%d = 1', '%d = 0 or > 1', (float)2, true);
|
||||
$expected = "%d ends in 2-4, not 12-14 (from core translated)";
|
||||
$expected = "%d ends in 2-4, not 12-14 (translated)";
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = __n('%d = 1', '%d = 0 or > 1', (float)5, true);
|
||||
$expected = "%d everything else (from core translated)";
|
||||
$expected = "%d everything else (translated)";
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* Singular method
|
||||
|
@ -2500,7 +2503,7 @@ class I18nTest extends CakeTestCase {
|
|||
function __domainPlural($domain = 'test_plugin') {
|
||||
$plurals = array();
|
||||
for ($number = 0; $number <= 25; $number++) {
|
||||
$plurals[] = sprintf(__dn($domain, '%d = 1', '%d = 0 or > 1', $number, true), $number );
|
||||
$plurals[] = sprintf(__dn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, true), (float)$number );
|
||||
}
|
||||
return $plurals;
|
||||
}
|
||||
|
@ -2523,7 +2526,7 @@ class I18nTest extends CakeTestCase {
|
|||
function __plural() {
|
||||
$plurals = array();
|
||||
for ($number = 0; $number <= 25; $number++) {
|
||||
$plurals[] = sprintf(__n('%d = 1', '%d = 0 or > 1', $number, true), $number );
|
||||
$plurals[] = sprintf(__n('%d = 1', '%d = 0 or > 1', (float)$number, true), (float)$number );
|
||||
}
|
||||
return $plurals;
|
||||
}
|
||||
|
@ -2546,7 +2549,7 @@ class I18nTest extends CakeTestCase {
|
|||
function __pluralFromCore() {
|
||||
$plurals = array();
|
||||
for ($number = 0; $number <= 25; $number++) {
|
||||
$plurals[] = sprintf(__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', $number, true), $number );
|
||||
$plurals[] = sprintf(__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', (float)$number, true), (float)$number );
|
||||
}
|
||||
return $plurals;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue