Index: trunk/phase3/includes/Message.php |
— | — | @@ -4,53 +4,79 @@ |
5 | 5 | * processing them into variety of formats that are needed in MediaWiki. |
6 | 6 | * |
7 | 7 | * It is intented to replace the old wfMsg* functions that over time grew |
8 | | - * unusable. |
| 8 | + * unusable. \see https://www.mediawiki.org/wiki/New_messages_API for |
| 9 | + * equivalence between old and new functions. |
9 | 10 | * |
10 | | - * Examples: |
| 11 | + * Below, you will find several examples of wfMessage() usage. |
| 12 | + * |
| 13 | + * |
11 | 14 | * Fetching a message text for interface message |
| 15 | + * @code |
12 | 16 | * $button = Xml::button( wfMessage( 'submit' )->text() ); |
13 | | - * </pre> |
| 17 | + * @endcode |
| 18 | + * |
14 | 19 | * Messages can have parameters: |
| 20 | + * |
| 21 | + * @code |
15 | 22 | * wfMessage( 'welcome-to' )->params( $wgSitename )->text(); |
16 | | - * {{GRAMMAR}} and friends work correctly |
| 23 | + * @endcode |
| 24 | + * |
| 25 | + * {{GRAMMAR}} and friends work correctly |
| 26 | + * @code |
17 | 27 | * wfMessage( 'are-friends', $user, $friend ); |
18 | 28 | * wfMessage( 'bad-message' )->rawParams( '<script>...</script>' )->escaped(); |
19 | | - * </pre> |
| 29 | + * @endcode |
| 30 | + * |
20 | 31 | * Sometimes the message text ends up in the database, so content language is needed. |
| 32 | + * @code |
21 | 33 | * wfMessage( 'file-log', $user, $filename )->inContentLanguage()->text() |
22 | 34 | * </pre> |
23 | | - * Checking if message exists: |
| 35 | + * @endcode |
| 36 | + * |
| 37 | + * Checking whether a message exists: |
| 38 | + * @code |
24 | 39 | * wfMessage( 'mysterious-message' )->exists() |
25 | | - * </pre> |
| 40 | + * @endcode |
| 41 | + * |
26 | 42 | * If you want to use a different language: |
| 43 | + * @code |
27 | 44 | * wfMessage( 'email-header' )->inLanguage( $user->getOption( 'language' ) )->plain() |
28 | | - * Note that you cannot parse the text except in the content or interface |
29 | | - * languages |
30 | | - * </pre> |
| 45 | + * @endcode |
31 | 46 | * |
| 47 | + * \note You cannot parse the text except in the content or interface |
| 48 | + * \note languages |
32 | 49 | * |
33 | 50 | * Comparison with old wfMsg* functions: |
34 | 51 | * |
35 | 52 | * Use full parsing. |
| 53 | + * |
| 54 | + * @code |
36 | 55 | * wfMsgExt( 'key', array( 'parseinline' ), 'apple' ); |
37 | 56 | * === wfMessage( 'key', 'apple' )->parse(); |
38 | | - * </pre> |
| 57 | + * @endcode |
| 58 | + * |
39 | 59 | * Parseinline is used because it is more useful when pre-building html. |
40 | 60 | * In normal use it is better to use OutputPage::(add|wrap)WikiMsg. |
41 | 61 | * |
42 | 62 | * Places where html cannot be used. {{-transformation is done. |
| 63 | + * @code |
43 | 64 | * wfMsgExt( 'key', array( 'parsemag' ), 'apple', 'pear' ); |
44 | 65 | * === wfMessage( 'key', 'apple', 'pear' )->text(); |
45 | | - * </pre> |
| 66 | + * @endcode |
46 | 67 | * |
47 | 68 | * Shortcut for escaping the message too, similar to wfMsgHTML, but |
48 | 69 | * parameters are not replaced after escaping by default. |
| 70 | + * @code |
49 | 71 | * $escaped = wfMessage( 'key' )->rawParams( 'apple' )->escaped(); |
50 | | - * </pre> |
| 72 | + * @endcode |
51 | 73 | * |
52 | 74 | * @todo |
53 | 75 | * - test, can we have tests? |
54 | 76 | * |
| 77 | + * \see https://www.mediawiki.org/wiki/WfMessage() |
| 78 | + * \see https://www.mediawiki.org/wiki/New_messages_API |
| 79 | + * \see https://www.mediawiki.org/wiki/Localisation |
| 80 | + * |
55 | 81 | * @since 1.17 |
56 | 82 | * @author Niklas Laxström |
57 | 83 | */ |