msgfmt_bug70484.phpt 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. --TEST--
  2. Bug #70484 selectordinal doesn't work with named parameters
  3. --EXTENSIONS--
  4. intl
  5. --FILE--
  6. <?php
  7. $locale = array("de", "fr", "en", "ru",);
  8. $data = array(42, 42.42, 2147483643, 2147483643.12345, 5);
  9. foreach ($locale as $lc) {
  10. echo "$lc string key\n";
  11. $m = new MessageFormatter($lc, "{n, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}");
  12. foreach ($data as $i) {
  13. var_dump($m->format(array("n" => $i)));
  14. if ($m->getErrorCode()) {
  15. echo "$lc $i ", $m->getErrorMessage();
  16. }
  17. }
  18. echo "\n";
  19. echo "$lc numeric key\n";
  20. $m = new MessageFormatter($lc, "{0, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}");
  21. foreach ($data as $i) {
  22. var_dump($m->format(array($i)));
  23. if ($m->getErrorCode()) {
  24. echo "$lc $i ", $m->getErrorMessage();
  25. }
  26. }
  27. echo "\n";
  28. }
  29. ?>
  30. --EXPECTF--
  31. de string key
  32. string(8) "42-other"
  33. string(11) "42,42-other"
  34. string(19) "2.147.483.643-other"
  35. string(23) "2.147.483.643,123-other"
  36. string(4) "five"
  37. de numeric key
  38. string(8) "42-other"
  39. string(11) "42,42-other"
  40. string(19) "2.147.483.643-other"
  41. string(23) "2.147.483.643,123-other"
  42. string(4) "five"
  43. fr string key
  44. string(8) "42-other"
  45. string(11) "42,42-other"
  46. string(%d) "2%s147%s483%s643-other"
  47. string(%d) "2%s147%s483%s643,123-other"
  48. string(4) "five"
  49. fr numeric key
  50. string(8) "42-other"
  51. string(11) "42,42-other"
  52. string(%d) "2%s147%s483%s643-other"
  53. string(%d) "2%s147%s483%s643,123-other"
  54. string(4) "five"
  55. en string key
  56. string(6) "42-two"
  57. string(11) "42.42-other"
  58. string(17) "2,147,483,643-few"
  59. string(23) "2,147,483,643.123-other"
  60. string(4) "five"
  61. en numeric key
  62. string(6) "42-two"
  63. string(11) "42.42-other"
  64. string(17) "2,147,483,643-few"
  65. string(23) "2,147,483,643.123-other"
  66. string(4) "five"
  67. ru string key
  68. string(8) "42-other"
  69. string(11) "42,42-other"
  70. string(22) "2 147 483 643-other"
  71. string(26) "2 147 483 643,123-other"
  72. string(4) "five"
  73. ru numeric key
  74. string(8) "42-other"
  75. string(11) "42,42-other"
  76. string(22) "2 147 483 643-other"
  77. string(26) "2 147 483 643,123-other"
  78. string(4) "five"