Replace some occurrences of wfMsg* by alternatives. Undeprecated wfMsgReplaceArgs.
authorSiebrand Mazeland <s.mazeland@xs4all.nl>
Mon, 3 Sep 2012 08:03:42 +0000 (10:03 +0200)
committerSiebrand Mazeland <s.mazeland@xs4all.nl>
Mon, 3 Sep 2012 09:49:58 +0000 (11:49 +0200)
* wfMsgReplaceArgs isn't really i18n related. It just replaces text parts.
* Updated language.txt. Now refers to mediawiki.org.
* Removed deprecated Block::formatExpiry(). Merge Id7d057a4 first.
* Reformatted weirdly formatted array in ApiBase.php.
* Removed wfMsg() in RandomTest.php.

Change-Id: Ied5cfda8fa5d9283dfeebdcb0e1af8453d47e7a9

docs/language.txt
includes/Block.php
includes/EditPage.php
includes/GlobalFunctions.php
includes/OutputPage.php
includes/WikiPage.php
includes/api/ApiBase.php
includes/installer/WebInstaller.php
includes/normal/RandomTest.php

index 1df9881..42a6027 100644 (file)
@@ -1,21 +1,5 @@
 language.txt
 
-The Language object handles all readable text produced by the software. The most
-used function is getMessage(), usually called with the wrapper function wfMsg()
-which calls that method on the global language object. It just returns a piece
-of text given a text key. It is recommended that you use each key only
-once--bits of text in different contexts that happen to be identical in English
-may not be in other languages, so it's better to add new keys than to reuse them
-a lot. Likewise, if there is text that gets combined with things like names and
-titles, it is better to put markers like "$1" inside a piece of text and use
-str_replace() than to compose such messages in code, because their order may
-change in other languages too.
+The Language object handles all readable text produced by the software.
 
-While the system is running, there will be one global language object, which
-will be a subtype of Language. The methods in these objects will return the
-native text requested if available, otherwise they fall back to sending English
-text (which is why the LanguageEn object has no code at all--it just inherits
-the English defaults of the Language base class).
-
-The names of the namespaces are also contained in the language object, though
-the numbers are fixed.
+See http://www.mediawiki.org/wiki/Localisation#General_use_.28for_developers.29
index 6e8f9f3..732699d 100644 (file)
@@ -1002,41 +1002,6 @@ class Block {
                return wfGetDB( DB_SLAVE )->getInfinity();
        }
 
-       /**
-        * Convert a DB-encoded expiry into a real string that humans can read.
-        *
-        * @param $encoded_expiry String: Database encoded expiry time
-        * @return Html-escaped String
-        * @deprecated since 1.18; use $wgLang->formatExpiry() instead
-        */
-       public static function formatExpiry( $encoded_expiry ) {
-               wfDeprecated( __METHOD__, '1.18' );
-
-               global $wgContLang;
-               static $msg = null;
-
-               if ( is_null( $msg ) ) {
-                       $msg = array();
-                       $keys = array( 'infiniteblock', 'expiringblock' );
-
-                       foreach ( $keys as $key ) {
-                               $msg[$key] = wfMessage( $key )->escaped();
-                       }
-               }
-
-               $expiry = $wgContLang->formatExpiry( $encoded_expiry, TS_MW );
-               if ( $expiry == wfGetDB( DB_SLAVE )->getInfinity() ) {
-                       $expirystr = $msg['infiniteblock'];
-               } else {
-                       global $wgLang;
-                       $expiredatestr = htmlspecialchars( $wgLang->date( $expiry, true ) );
-                       $expiretimestr = htmlspecialchars( $wgLang->time( $expiry, true ) );
-                       $expirystr = wfMsgReplaceArgs( $msg['expiringblock'], array( $expiredatestr, $expiretimestr ) );
-               }
-
-               return $expirystr;
-       }
-
        /**
         * Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute
         * ("24 May 2034"), into an absolute timestamp we can put into the database.
index f9bba19..48beb9a 100644 (file)
@@ -2459,7 +2459,7 @@ HTML
                wfRunHooks( 'EditPageCopyrightWarning', array( $title, &$copywarnMsg ) );
 
                return "<div id=\"editpage-copywarn\">\n" .
-                       call_user_func_array( "wfMsgNoTrans", $copywarnMsg ) . "\n</div>";
+                       call_user_func_array( 'wfMessage', $copywarnMsg )->plain() . "\n</div>";
        }
 
        protected function showStandardInputs( &$tabindex = 2 ) {
index 0a60518..2241545 100644 (file)
@@ -1539,8 +1539,6 @@ function wfMsgGetKey( $key, $useDB = true, $langCode = false, $transform = true
 /**
  * Replace message parameter keys on the given formatted output.
  *
- * @deprecated since 1.18
- *
  * @param $message String
  * @param $args Array
  * @return string
index bc9eaa9..9e39d47 100644 (file)
@@ -3548,7 +3548,7 @@ $templates
         *
         * Is equivalent to:
         *
-        *    $wgOut->addWikiText( "<div class='error'>\n" . wfMsgNoTrans( 'some-error' ) . "\n</div>" );
+        *    $wgOut->addWikiText( "<div class='error'>\n" . wfMessage( 'some-error' )->plain() . "\n</div>" );
         *
         * The newline after opening div is needed in some wikitext. See bug 19226.
         *
index 1021767..74772f2 100644 (file)
@@ -2406,9 +2406,9 @@ class WikiPage extends Page implements IDBAccessObject {
                $target = Revision::newFromId( $s->rev_id );
                if ( empty( $summary ) ) {
                        if ( $from == '' ) { // no public user name
-                               $summary = wfMessage( 'revertpage-nouser' )->inContentLanguage()->text();
+                               $summary = wfMessage( 'revertpage-nouser' );
                        } else {
-                               $summary = wfMessage( 'revertpage' )->inContentLanguage()->text();
+                               $summary = wfMessage( 'revertpage' );
                        }
                }
 
@@ -2418,7 +2418,11 @@ class WikiPage extends Page implements IDBAccessObject {
                        $wgContLang->timeanddate( wfTimestamp( TS_MW, $s->rev_timestamp ) ),
                        $current->getId(), $wgContLang->timeanddate( $current->getTimestamp() )
                );
-               $summary = wfMsgReplaceArgs( $summary, $args );
+               if( $summary instanceof Message ) {
+                       $summary = $summary->params( $args )->inContentLanguage()->text();
+               } else {
+                       $summary = wfMsgReplaceArgs( $summary, $args );
+               }
 
                # Truncate for whole multibyte characters.
                $summary = $wgContLang->truncate( $summary, 255 );
index 1e62766..875a381 100644 (file)
@@ -1401,10 +1401,9 @@ abstract class ApiBase extends ContextSource {
                }
 
                if ( isset( self::$messageMap[$key] ) ) {
-                       return array( 'code' =>
-                       wfMsgReplaceArgs( self::$messageMap[$key]['code'], $error ),
-                               'info' =>
-                               wfMsgReplaceArgs( self::$messageMap[$key]['info'], $error )
+                       return array(
+                               'code' => wfMsgReplaceArgs( self::$messageMap[$key]['code'], $error ),
+                               'info' => wfMsgReplaceArgs( self::$messageMap[$key]['info'], $error )
                        );
                }
 
index 0d5ea57..2f46ff0 100644 (file)
@@ -376,7 +376,7 @@ class WebInstaller extends Installer {
                $args = func_get_args();
                array_shift( $args );
                $args = array_map( 'htmlspecialchars', $args );
-               $msg = wfMsgReal( $msg, $args, false, false, false );
+               $msg = wfMessage( $msg, $args )->useDatabase( false )->plain();
                $this->output->addHTML( $this->getErrorBox( $msg ) );
        }
 
@@ -655,7 +655,7 @@ class WebInstaller extends Installer {
                $args = func_get_args();
                array_shift( $args );
                $args = array_map( 'htmlspecialchars', $args );
-               $text = wfMsgReal( $msg, $args, false, false, false );
+               $text = wfMessage( $msg, $args )->useDatabase( false )->plain();
                $html = $this->parse( $text, true );
 
                return "<div class=\"mw-help-field-container\">\n" .
@@ -685,7 +685,7 @@ class WebInstaller extends Installer {
                $args = func_get_args();
                array_shift( $args );
                $html = '<div class="config-message">' .
-                       $this->parse( wfMsgReal( $msg, $args, false, false, false ) ) .
+               $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) .
                        "</div>\n";
                $this->output->addHTML( $html );
        }
index d96cb09..23471e9 100644 (file)
@@ -57,10 +57,6 @@ function donorm( $str ) {
        return rtrim( utf8_normalize( $str . "\x01", UtfNormal::UNORM_NFC ), "\x01" );
 }
 
-function wfMsg($x) {
-       return $x;
-}
-
 function showDiffs( $a, $b ) {
        $ota = explode( "\n", str_replace( "\r\n", "\n", $a ) );
        $nta = explode( "\n", str_replace( "\r\n", "\n", $b ) );