r6588 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r6587‎ | r6588 | r6589 >
Date:03:00, 9 December 2004
Author:zhengzhu
Status:old
Tags:
Comment:
Added optional setting to allow UI messages act as content.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/maintenance/InitialiseMessages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/InitialiseMessages.inc
@@ -10,12 +10,14 @@
1111 * @subpackage Maintenance
1212 */
1313
 14+require_once('languages/Names.php');
1415
15 -
1616 function initialiseMessages( $overwrite = false, $messageArray = false ) {
1717 global $wgContLang, $wgContLanguageCode;
1818 global $wgContLangClass, $wgAllMessagesEn;
1919 global $wgDisableLangConversion;
 20+ global $wgForceUIMsgAsContentMsg;
 21+ global $wgLanguageNames;
2022 global $IP;
2123
2224 # overwrite language conversion option so that all variants
@@ -51,6 +53,22 @@
5254 }
5355 }
5456
 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+
5573 initialiseMessagesReal( $overwrite, $messages );
5674 }
5775
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -342,9 +342,14 @@
343343 * Get a message from anywhere, for the content
344344 */
345345 function wfMsgForContent( $key ) {
 346+ global $wgForceUIMsgAsContentMsg;
346347 $args = func_get_args();
347348 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 );
349354 }
350355
351356 /**
@@ -360,9 +365,14 @@
361366 * Get a message from the language file, for the content
362367 */
363368 function wfMsgNoDBForContent( $key ) {
 369+ global $wgForceUIMsgAsContentMsg;
364370 $args = func_get_args();
365371 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 );
367377 }
368378
369379
Index: trunk/phase3/includes/DefaultSettings.php
@@ -865,6 +865,24 @@
866866
867867 $wgWhitelistRead = array ( ':Accueil', ':Main_Page');
868868
 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+
869887 /**
870888 * Authentication plugin.
871889 */

Status & tagging log