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