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