msgfmt_api.php 6.5 KB

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