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
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.
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 ) {
/**
* Replace message parameter keys on the given formatted output.
*
- * @deprecated since 1.18
- *
* @param $message String
* @param $args Array
* @return string
*
* 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.
*
$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' );
}
}
$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 );
}
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 )
);
}
$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 ) );
}
$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" .
$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 );
}
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 ) );