1--TEST--
2msgfmt_format() with subpatterns
3--SKIPIF--
4<?php
5if (!extension_loaded('intl'))
6	die('skip intl extension not enabled');
7if (version_compare(INTL_ICU_VERSION, '4.8') < 0)
8	die('skip for ICU 4.8+');
9--FILE--
10<?php
11
12/*
13 * Format a number using misc locales/patterns.
14 */
15
16
17function ut_main()
18{
19
20$pattern=<<<_MSG_
21{0, select,
22  female {{1, plural, offset:1
23      =0 {{2} does not give a party.}
24      =1 {{2} invites {3} to her party.}
25      =2 {{2} invites {3} and one other person to her party.}
26     other {{2} invites {3} as one of the # people invited to her party.}}}
27  male   {{1, plural, offset:1
28      =0 {{2} does not give a party.}
29      =1 {{2} invites {3} to his party.}
30      =2 {{2} invites {3} and one other person to his party.}
31     other {{2} invites {3} as one of the # other people invited to his party.}}}
32  other {{1, plural, offset:1
33      =0 {{2} does not give a party.}
34      =1 {{2} invites {3} to their party.}
35      =2 {{2} invites {3} and one other person to their party.}
36      other {{2} invites {3} as one of the # other people invited to their party.}}}}
37_MSG_;
38
39
40$args = array(
41      array('female', 0,  'Alice', 'Bob'),
42      array('male',   1,  'Alice', 'Bob'),
43      array('none',   2,  'Alice', 'Bob'),
44      array('female', 27, 'Alice', 'Bob'),
45);
46
47$str_res = '';
48
49        $fmt = ut_msgfmt_create( 'en_US', $pattern );
50		if(!$fmt) {
51			$str_res .= dump(intl_get_error_message())."\n";
52			return $str_res;
53		}
54        foreach ($args as $arg) {
55            $str_res .= dump( ut_msgfmt_format($fmt, $arg) ). "\n";
56            $str_res .= dump( ut_msgfmt_format_message('en_US', $pattern, $arg) ) . "\n";
57    }
58    return $str_res;
59}
60
61include_once( 'ut_common.inc' );
62
63// Run the test
64ut_run();
65
66?>
67--EXPECT--
68'Alice does not give a party.'
69'Alice does not give a party.'
70'Alice invites Bob to his party.'
71'Alice invites Bob to his party.'
72'Alice invites Bob and one other person to their party.'
73'Alice invites Bob and one other person to their party.'
74'Alice invites Bob as one of the 26 people invited to her party.'
75'Alice invites Bob as one of the 26 people invited to her party.'
76