|
| 1 | +--TEST-- |
| 2 | +Bug #70484 selectordinal doesn't work with named parameters |
| 3 | +--SKIPIF-- |
| 4 | +<?php |
| 5 | +if (!extension_loaded('intl')) |
| 6 | + die('skip intl extension not enabled'); |
| 7 | +if (version_compare(INTL_ICU_VERSION, '5.0') < 0) |
| 8 | + die('skip for ICU 5.0+'); |
| 9 | +--FILE-- |
| 10 | +<?php |
| 11 | + |
| 12 | +$locale = array("de", "fr", "en", "ru",); |
| 13 | + |
| 14 | +$data = array(42, 42.42, 2147483643, 2147483643.12345, 5); |
| 15 | + |
| 16 | +foreach ($locale as $lc) { |
| 17 | + echo "$lc string key\n"; |
| 18 | + $m = new MessageFormatter($lc, "{n, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}"); |
| 19 | + foreach ($data as $i) { |
| 20 | + var_dump($m->format(array("n" => $i))); |
| 21 | + if ($m->getErrorCode()) { |
| 22 | + echo "$lc $i ", $m->getErrorMessage(); |
| 23 | + } |
| 24 | + } |
| 25 | + echo "\n"; |
| 26 | + |
| 27 | + echo "$lc numeric key\n"; |
| 28 | + $m = new MessageFormatter($lc, "{0, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}"); |
| 29 | + foreach ($data as $i) { |
| 30 | + var_dump($m->format(array($i))); |
| 31 | + if ($m->getErrorCode()) { |
| 32 | + echo "$lc $i ", $m->getErrorMessage(); |
| 33 | + } |
| 34 | + } |
| 35 | + echo "\n"; |
| 36 | +} |
| 37 | + |
| 38 | +?> |
| 39 | +==DONE== |
| 40 | +--EXPECT-- |
| 41 | +de string key |
| 42 | +string(8) "42-other" |
| 43 | +string(11) "42,42-other" |
| 44 | +string(19) "2.147.483.643-other" |
| 45 | +string(23) "2.147.483.643,123-other" |
| 46 | +string(4) "five" |
| 47 | + |
| 48 | +de numeric key |
| 49 | +string(8) "42-other" |
| 50 | +string(11) "42,42-other" |
| 51 | +string(19) "2.147.483.643-other" |
| 52 | +string(23) "2.147.483.643,123-other" |
| 53 | +string(4) "five" |
| 54 | + |
| 55 | +fr string key |
| 56 | +string(8) "42-other" |
| 57 | +string(11) "42,42-other" |
| 58 | +string(22) "2 147 483 643-other" |
| 59 | +string(26) "2 147 483 643,123-other" |
| 60 | +string(4) "five" |
| 61 | + |
| 62 | +fr numeric key |
| 63 | +string(8) "42-other" |
| 64 | +string(11) "42,42-other" |
| 65 | +string(22) "2 147 483 643-other" |
| 66 | +string(26) "2 147 483 643,123-other" |
| 67 | +string(4) "five" |
| 68 | + |
| 69 | +en string key |
| 70 | +string(6) "42-two" |
| 71 | +string(11) "42.42-other" |
| 72 | +string(17) "2,147,483,643-few" |
| 73 | +string(23) "2,147,483,643.123-other" |
| 74 | +string(4) "five" |
| 75 | + |
| 76 | +en numeric key |
| 77 | +string(6) "42-two" |
| 78 | +string(11) "42.42-other" |
| 79 | +string(17) "2,147,483,643-few" |
| 80 | +string(23) "2,147,483,643.123-other" |
| 81 | +string(4) "five" |
| 82 | + |
| 83 | +ru string key |
| 84 | +string(8) "42-other" |
| 85 | +string(11) "42,42-other" |
| 86 | +string(22) "2 147 483 643-other" |
| 87 | +string(26) "2 147 483 643,123-other" |
| 88 | +string(4) "five" |
| 89 | + |
| 90 | +ru numeric key |
| 91 | +string(8) "42-other" |
| 92 | +string(11) "42,42-other" |
| 93 | +string(22) "2 147 483 643-other" |
| 94 | +string(26) "2 147 483 643,123-other" |
| 95 | +string(4) "five" |
| 96 | + |
| 97 | +==DONE== |
0 commit comments