summaryrefslogtreecommitdiff
path: root/ext/intl/tests/msgfmt_bug70484.phpt
blob: f317be30dbc8f25122b106784019604084b0262a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
--TEST--
Bug #70484 selectordinal doesn't work with named parameters
--SKIPIF--
<?php
if (!extension_loaded('intl'))
	die('skip intl extension not enabled');
--FILE--
<?php

$locale = array("de", "fr", "en", "ru",);

$data = array(42, 42.42, 2147483643, 2147483643.12345, 5);

foreach ($locale as $lc) {
	echo "$lc string key\n";
	$m = new MessageFormatter($lc, "{n, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}");
	foreach ($data as $i) {
		var_dump($m->format(array("n" => $i)));
		if ($m->getErrorCode()) {
			echo "$lc $i ", $m->getErrorMessage();
		}
	}
	echo "\n";

	echo "$lc numeric key\n";
	$m = new MessageFormatter($lc, "{0, selectordinal, =5 {five} zero {#-zero} one {#-one} two {#-two} few {#-few} many {#-many} other {#-other}}");
	foreach ($data as $i) {
		var_dump($m->format(array($i)));
		if ($m->getErrorCode()) {
			echo "$lc $i ", $m->getErrorMessage();
		}
	}
	echo "\n";
}

?>
--EXPECTF--
de string key
string(8) "42-other"
string(11) "42,42-other"
string(19) "2.147.483.643-other"
string(23) "2.147.483.643,123-other"
string(4) "five"

de numeric key
string(8) "42-other"
string(11) "42,42-other"
string(19) "2.147.483.643-other"
string(23) "2.147.483.643,123-other"
string(4) "five"

fr string key
string(8) "42-other"
string(11) "42,42-other"
string(%d) "2%s147%s483%s643-other"
string(%d) "2%s147%s483%s643,123-other"
string(4) "five"

fr numeric key
string(8) "42-other"
string(11) "42,42-other"
string(%d) "2%s147%s483%s643-other"
string(%d) "2%s147%s483%s643,123-other"
string(4) "five"

en string key
string(6) "42-two"
string(11) "42.42-other"
string(17) "2,147,483,643-few"
string(23) "2,147,483,643.123-other"
string(4) "five"

en numeric key
string(6) "42-two"
string(11) "42.42-other"
string(17) "2,147,483,643-few"
string(23) "2,147,483,643.123-other"
string(4) "five"

ru string key
string(8) "42-other"
string(11) "42,42-other"
string(22) "2 147 483 643-other"
string(26) "2 147 483 643,123-other"
string(4) "five"

ru numeric key
string(8) "42-other"
string(11) "42,42-other"
string(22) "2 147 483 643-other"
string(26) "2 147 483 643,123-other"
string(4) "five"