xref: /PHP-7.0/ext/intl/doc/msgfmt_api.php (revision 02e4d7a2)
1<?php
2
3/**
4 * Message formatter class.
5 *
6 * Message Format provides for runtime formatting of messages in a manner
7 * somewhat similar to sprintf. The pattern string has its component parts
8 * replaced in a locale-sensitive manner using items in the arguments array.
9 *
10 * @see http://www.icu-project.org/apiref/icu4c/umsg_8h.html
11 *
12 */
13class MessageFormatter {
14
15	/**
16	 * Constructs a new Message Formatter
17	 *
18	 * @param  string   $locale  the locale to use when formatting arguments
19	 * @param  string   $pattern the pattern string to stick arguments into
20	 */
21	public function __construct($locale, $pattern) {}
22
23	/**
24	 * Constructs a new Message Formatter
25	 *
26	 * @param  string   $locale  the locale to use when formatting arguments
27	 * @param  string   $pattern the pattern string to stick arguments into
28	 */
29	public static function create($locale, $pattern) {}
30
31	/**
32	 * Format the message
33	 * @param   array   $args   arguments to insert into the pattern string
34	 * @return  string  the formatted string, or false if an error occurred
35	 */
36	public function format($args) {}
37
38	/**
39	 * Parse input string and returns any extracted items as an array
40	 *
41	 * $error will contain any error code. If an error occurs, $parse_pos contains
42	 * the position of the error.
43	 *
44	 * @param  string  $value      string to parse for items
45	 * @return array               array containing items extracted
46	 *
47	 */
48	public function parse($value) {}
49
50	/**
51	 * Inserts the items in $args into $pattern, formatting them
52	 * according to $locale. This is the static implementation.
53	 *
54	 * @param string    $locale   the locale to use when formatting numbers and dates and suchlike
55	 * @param string    $pattern  the pattern string to insert things into
56	 * @param array     $args     the array of values to insert into $pattern
57	 * @return string             the formatted pattern string or false if an error occurred
58	 */
59	public static function formatMessage($locale, $pattern, $args) {}
60
61	/**
62	 * parses input string and returns any extracted items as an array
63	 *
64	 * $error will contain any error code. If an error occurs, $parse_pos contains
65	 * the position of the error.
66	 *
67	 * @param  string  $locale     the locale to use when formatting numbers and dates and suchlike
68	 * @param  string  $value      string to parse for items
69	 * @return array               array containing items extracted
70	 *
71	 */
72	public static function parseMessage($locale, $value) {}
73
74	/**
75	 * Get the pattern used by the formatter
76	 *
77	 * @return  string  the pattern string for this message formatter
78	 */
79	public function getPattern() {}
80
81	/**
82	 * Set the pattern used by the formatter
83	 *
84	 * @param  string  $pattern  the pattern string to use in this message formatter
85	 * @return boolean 'true' if successful, 'false' if an error
86	 */
87	public function setPattern($pattern) {}
88
89	/**
90	 * Get the error code from last operation
91	 *
92	 * Returns error code from the last number formatting operation.
93	 *
94	 * @return integer the error code, one of UErrorCode values. Initial value is U_ZERO_ERROR.
95	 */
96	public function getErrorCode() {}
97	/**
98	 * Get the error text from the last operation.
99	 *
100	 * @return string Description of the last error.
101	 */
102	public function getErrorMessage() {}
103	/**
104	 * Get the locale for which the formatter was created.
105	 *
106	 * @return string locale name
107	 */
108	public function getLocale() {}
109}
110
111	/** Now the same as procedural API */
112
113
114	/**
115	 * Constructs a new Message Formatter
116	 *
117	 * @param  string   $locale  the locale to use when formatting arguments
118	 * @param  string   $pattern the pattern string to stick arguments into
119	 * @return MessageFormatter formatter object
120	 */
121	function msgfmt_create($locale, $pattern) {}
122
123	/**
124	 * Format the message
125	 * @param MessageFormatter $fmt The message formatter
126	 * @param   array   $args   arguments to insert into the pattern string
127	 * @return  string  the formatted string, or false if an error occurred
128	 */
129	function msgfmt_format($fmt, $args) {}
130
131	/**
132	 * parses input string and returns any extracted items as an array
133	 *
134	 * $error will contain any error code. If an error occurs, $parse_pos contains
135	 * the position of the error.
136	 *
137	 * @param MessageFormatter $fmt The message formatter
138	 * @param  string  $value      string to parse for items
139	 * @return array               array containing items extracted
140	 *
141	 */
142	function msgfmt_parse($fmt, $value) {}
143
144	/**
145	 * Inserts the items in $args into $pattern, formatting them
146	 * according to $locale. This is the static implementation.
147	 *
148	 * @param string    $locale   the locale to use when formatting numbers and dates and suchlike
149	 * @param string    $pattern  the pattern string to insert things into
150	 * @param array     $args     the array of values to insert into $pattern
151	 * @return string             the formatted pattern string or false if an error occurred
152	 */
153	function msgfmt_format_message($locale, $pattern, $args) {}
154
155	/**
156	 * parses input string and returns any extracted items as an array
157	 *
158	 * $error will contain any error code. If an error occurs, $parse_pos contains
159	 * the position of the error.
160	 *
161	 * @param  string  $locale     the locale to use when formatting numbers and dates and suchlike
162	 * @param  string  $value      string to parse for items
163	 * @return array               array containing items extracted
164	 *
165	 */
166	function msgfmt_parse_message($locale, $value) {}
167
168	/**
169	 * Get the pattern used by the formatter
170	 *
171	 * @param MessageFormatter $fmt The message formatter
172	 * @return  string  the pattern string for this message formatter
173	 */
174	function msgfmt_get_pattern($fmt) {}
175
176	/**
177	 * Set the pattern used by the formatter
178	 *
179	 * @param MessageFormatter $fmt The message formatter
180	 * @param  string  $pattern  the pattern string to use in this message formatter
181	 * @return boolean 'true' if successful, 'false' if an error
182	 */
183	function msgfmt_set_pattern($fmt, $pattern) {}
184
185	/**
186	 * Get the error code from last operation
187	 *
188	 * Returns error code from the last number formatting operation.
189	 *
190	 * @param MessageFormatter $fmt The message formatter
191	 * @return integer the error code, one of UErrorCode values. Initial value is U_ZERO_ERROR.
192	 */
193	function msgfmt_get_error_code($fmt) {}
194	/**
195	 * Get the error text from the last operation.
196	 *
197	 * @param MessageFormatter $fmt The message formatter
198	 * @return string Description of the last error.
199	 */
200	function msgfmt_get_error_message($fmt) {}
201
202	/**
203	 * Get the locale for which the formatter was created.
204	 *
205	 * @param NumberFormatter $formatter The formatter resource
206	 * @return string locale name
207	 */
208	function msgfmt_get_locale($formatter) {}
209?>
210