Index: trunk/tools/ToolserverI18N/public_html/demo/demo8.php |
— | — | @@ -8,28 +8,31 @@ |
9 | 9 | $I18N = new TsIntuition( 'general' /* name of textdomain here */ ); |
10 | 10 | |
11 | 11 | // 2) Register some interesting messages |
12 | | -$I18N->setMsg( 'apple-stats', 'Apple status: $1 {{PLURAL:$1|apple|apples}} in the basket.' ); |
| 12 | +$I18N->setMsgs( array( |
| 13 | + 'welcomeback' => 'Welcome back, $1! Would you like some $2?', |
| 14 | + 'basket' => 'The basket contains $1 {{PLURAL:$1|apple|apples}}.', |
| 15 | +) ); |
13 | 16 | |
14 | | -// 2) Use MessagesFunctions |
| 17 | +// 2) Use rendering and formatting |
15 | 18 | |
16 | 19 | // - Raw echo |
17 | 20 | echo $I18N->msg( 'apple-stats' ); |
18 | 21 | |
19 | 22 | echo '<br />'; |
20 | 23 | |
21 | | -// - Pass variables, setting $1 to '1' |
22 | | -echo '<br />' . $I18N->msg( 'apple-stats', array( 'variables' => array( '1' ) ) ); |
| 24 | +// - Pass variables |
| 25 | +echo '<br />' . $I18N->msg( 'welcomeback', array( 'variables' => array( 'John', 'coffee' ) ) ); |
23 | 26 | |
24 | | -// - Pass variables, setting $1 to '7' |
25 | | -echo '<br />' . $I18N->msg( 'apple-stats', array( 'variables' => array( '7' ) ) ); |
| 27 | +// - Pass variables |
| 28 | +echo '<br />' . $I18N->msg( 'welcomeback', array( 'variables' => array( 'George', 'tea' ) ) ); |
26 | 29 | |
27 | 30 | echo '<br />'; |
28 | 31 | |
29 | 32 | // - Trigger parser magic, setting $1 to '1' |
30 | | -echo '<br />' . $I18N->msg( 'apple-stats', array( 'variables' => array( '1' ), 'parsemag' => true ) ); |
| 33 | +echo '<br />' . $I18N->msg( 'basket', array( 'variables' => array( '1' ), 'parsemag' => true ) ); |
31 | 34 | |
32 | 35 | // - Trigger parser magic, setting $1 to '7' |
33 | | -echo '<br />' . $I18N->msg( 'apple-stats', array( 'variables' => array( '7' ), 'parsemag' => true ) ); |
| 36 | +echo '<br />' . $I18N->msg( 'basket', array( 'variables' => array( '7' ), 'parsemag' => true ) ); |
34 | 37 | |
35 | 38 | |
36 | 39 | |
Index: trunk/tools/ToolserverI18N/public_html/demo/demoBase.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | 'demo5' => 'Dashboard backlink and footer line', |
15 | 15 | 'demo6' => 'Utility examples', |
16 | 16 | 'demo7' => 'Language names', |
17 | | - 'demo8' => 'Plural examples', |
| 17 | + 'demo8' => 'Rendering examples', |
18 | 18 | ); |
19 | 19 | |
20 | 20 | $thisFile = basename( $_SERVER['SCRIPT_NAME'], '.php' ); |