Merge "Setup: Move MWDebug logic to MWDebug.php"
[lhc/web/wiklou.git] / includes / libs / Message / ITextFormatter.php
1 <?php
2
3 namespace Wikimedia\Message;
4
5 /**
6 * ITextFormatter is a simplified interface to the Message class. It converts
7 * MessageValue message specifiers to localized text in a certain language.
8 *
9 * MessageValue supports message keys, and parameters with a wide variety of
10 * types. It does not expose any details of how messages are retrieved from
11 * storage or what format they are stored in.
12 *
13 * Thus, TextFormatter supports single message keys, but not the concept of
14 * presence or absence of a key from storage. So it does not support
15 * fallback sequences of multiple keys.
16 *
17 * The caller cannot modify the details of message translation, such as which
18 * of multiple sources the message is taken from. Any such flags may be injected
19 * into the factory constructor.
20 *
21 * Implementations of TextFormatter are not required to perfectly format
22 * any message in any language. Implementations should make a best effort to
23 * produce human-readable text.
24 *
25 * @package MediaWiki\MessageFormatter
26 */
27 interface ITextFormatter {
28 /**
29 * Get the internal language code in which format() is
30 * @return string
31 */
32 function getLangCode();
33
34 /**
35 * Convert a MessageValue to text.
36 *
37 * The result is not safe for use as raw HTML.
38 *
39 * @param MessageValue $message
40 * @return string
41 */
42 function format( MessageValue $message );
43 }