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