Index: trunk/phase3/maintenance/InitialiseMessages.inc |
— | — | @@ -10,12 +10,14 @@ |
11 | 11 | * @subpackage Maintenance |
12 | 12 | */ |
13 | 13 | |
| 14 | +require_once('languages/Names.php'); |
14 | 15 | |
15 | | - |
16 | 16 | function initialiseMessages( $overwrite = false, $messageArray = false ) { |
17 | 17 | global $wgContLang, $wgContLanguageCode; |
18 | 18 | global $wgContLangClass, $wgAllMessagesEn; |
19 | 19 | global $wgDisableLangConversion; |
| 20 | + global $wgForceUIMsgAsContentMsg; |
| 21 | + global $wgLanguageNames; |
20 | 22 | global $IP; |
21 | 23 | |
22 | 24 | # overwrite language conversion option so that all variants |
— | — | @@ -51,6 +53,22 @@ |
52 | 54 | } |
53 | 55 | } |
54 | 56 | |
| 57 | + /* |
| 58 | + initialize all messages in $wgForceUIMsgAsContentMsg for all |
| 59 | + languages in Names.php |
| 60 | + */ |
| 61 | + if( is_array( $wgForceUIMsgAsContentMsg ) ) { |
| 62 | + foreach( $wgForceUIMsgAsContentMsg as $uikey ) { |
| 63 | + foreach( $wgLanguageNames as $code => $name) { |
| 64 | + if( $code == $wgContLanguageCode ) |
| 65 | + continue; |
| 66 | + $msg = $wgContLang->getMessage( $uikey ); |
| 67 | + if( $msg ) |
| 68 | + $messages[$uikey. '/' . $code] = $msg; |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | + |
55 | 73 | initialiseMessagesReal( $overwrite, $messages ); |
56 | 74 | } |
57 | 75 | |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -342,9 +342,14 @@ |
343 | 343 | * Get a message from anywhere, for the content |
344 | 344 | */ |
345 | 345 | function wfMsgForContent( $key ) { |
| 346 | + global $wgForceUIMsgAsContentMsg; |
346 | 347 | $args = func_get_args(); |
347 | 348 | array_shift( $args ); |
348 | | - return wfMsgReal( $key, $args, true, true ); |
| 349 | + $forcontent = true; |
| 350 | + if( is_array( $wgForceUIMsgAsContentMsg ) && |
| 351 | + in_array( $key, $wgForceUIMsgAsContentMsg ) ) |
| 352 | + $forcontent = false; |
| 353 | + return wfMsgReal( $key, $args, true, $forcontent ); |
349 | 354 | } |
350 | 355 | |
351 | 356 | /** |
— | — | @@ -360,9 +365,14 @@ |
361 | 366 | * Get a message from the language file, for the content |
362 | 367 | */ |
363 | 368 | function wfMsgNoDBForContent( $key ) { |
| 369 | + global $wgForceUIMsgAsContentMsg; |
364 | 370 | $args = func_get_args(); |
365 | 371 | array_shift( $args ); |
366 | | - return wfMsgReal( $key, $args, false, true ); |
| 372 | + $forcontent = true; |
| 373 | + if( is_array( $wgForceUIMsgAsContentMsg ) && |
| 374 | + in_array( $key, $wgForceUIMsgAsContentMsg ) ) |
| 375 | + $forcontent = false; |
| 376 | + return wfMsgReal( $key, $args, false, $forcontent ); |
367 | 377 | } |
368 | 378 | |
369 | 379 | |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -865,6 +865,24 @@ |
866 | 866 | |
867 | 867 | $wgWhitelistRead = array ( ':Accueil', ':Main_Page'); |
868 | 868 | |
| 869 | +/* |
| 870 | +When translating messages with wfMsg(), it is not always clear what should |
| 871 | +be considered UI messages and what shoud be content messages. |
| 872 | + |
| 873 | +For example, for regular wikipedia site like en, there should be only one |
| 874 | +'mainpage', therefore when getting the link of 'mainpage', we should |
| 875 | +treate it as content of the site and call wfMsgForContent(), while for |
| 876 | +rendering the text of the link, we call wfMsg(). The code in default |
| 877 | +behaves this way. However, sites like common do offer different versions |
| 878 | +of 'mainpage' and the like for different languages. This array provides a |
| 879 | +way to override the default behavior. For example, to allow language specific |
| 880 | +mainpage and community portal, set |
| 881 | + |
| 882 | +$wgForceUIMsgAsContentMsg = array( 'mainpage', 'portal-url' ); |
| 883 | + |
| 884 | +*/ |
| 885 | +$wgForceUIMsgAsContentMsg = array(); |
| 886 | + |
869 | 887 | /** |
870 | 888 | * Authentication plugin. |
871 | 889 | */ |