Matmarex has uploaded a new change for review.
https://gerrit.wikimedia.org/r/62442
Change subject: Kill the MediaWiki_I18N class
......................................................................
Kill the MediaWiki_I18N class
Per the doc comment, it was a "wrapper object for MediaWiki's
localization functions, to be passed to the template engine".
What it actually did was to call wfMessage( ... )->text() and then,
thanks to a regular expression blunder and instance state never being
set by anything, remove all dollar signs in the output. (No,
seriously, try it.)
Removed usages within QuickTemplate (it wasn't used anywhere else),
inlined wfMessage() calls.
Change-Id: I42b13beea0531e36b7eb47fd07514dd3cab95afd
---
M includes/SkinTemplate.php
1 file changed, 7 insertions(+), 51 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/42/62442/1
diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php
index e53d424..1ec4d5e 100644
--- a/includes/SkinTemplate.php
+++ b/includes/SkinTemplate.php
@@ -21,41 +21,6 @@
*/
/**
- * Wrapper object for MediaWiki's localization functions,
- * to be passed to the template engine.
- *
- * @private
- * @ingroup Skins
- */
-class MediaWiki_I18N {
- var $_context = array();
-
- function set( $varName, $value ) {
- $this->_context[$varName] = $value;
- }
-
- function translate( $value ) {
- wfProfileIn( __METHOD__ );
-
- // Hack for i18n:attributes in PHPTAL 1.0.0 dev version as of
2004-10-23
- $value = preg_replace( '/^string:/', '', $value );
-
- $value = wfMessage( $value )->text();
- // interpolate variables
- $m = array();
- while ( preg_match( '/\$([0-9]*?)/sm', $value, $m ) ) {
- list( $src, $var ) = $m;
- wfSuppressWarnings();
- $varValue = $this->_context[$var];
- wfRestoreWarnings();
- $value = str_replace( $src, $varValue, $value );
- }
- wfProfileOut( __METHOD__ );
- return $value;
- }
-}
-
-/**
* Template-filler skin base class
* Formerly generic PHPTal (http://phptal.sourceforge.net/) skin
* Based on Brion's smarty skin
@@ -1289,7 +1254,6 @@
*/
function __construct() {
$this->data = array();
- $this->translator = new MediaWiki_I18N();
}
/**
@@ -1307,13 +1271,6 @@
*/
public function setRef( $name, &$value ) {
$this->data[$name] =& $value;
- }
-
- /**
- * @param $t
- */
- public function setTranslator( &$t ) {
- $this->translator = &$t;
}
/**
@@ -1349,14 +1306,14 @@
* @private
*/
function msg( $str ) {
- echo htmlspecialchars( $this->translator->translate( $str ) );
+ echo htmlspecialchars( wfMessage( $str )->text() );
}
/**
* @private
*/
function msgHtml( $str ) {
- echo $this->translator->translate( $str );
+ echo wfMessage( $str )->text();
}
/**
@@ -1366,7 +1323,7 @@
function msgWiki( $str ) {
global $wgOut;
- $text = $this->translator->translate( $str );
+ $text = wfMessage( $str )->text();
echo $wgOut->parse( $text );
}
@@ -1384,7 +1341,7 @@
* @return bool
*/
function haveMsg( $str ) {
- $msg = $this->translator->translate( $str );
+ $msg = wfMessage( $str )->text();
return ( $msg != '-' ) && ( $msg != '' ); # ????
}
@@ -1697,7 +1654,7 @@
if ( isset( $item['text'] ) ) {
$text = $item['text'];
} else {
- $text = $this->translator->translate( isset(
$item['msg'] ) ? $item['msg'] : $key );
+ $text = wfMessage( isset( $item['msg'] ) ? $item['msg']
: $key )->text();
}
$html = htmlspecialchars( $text );
@@ -1833,8 +1790,7 @@
$realAttrs = array(
'type' => 'submit',
'name' => $mode,
- 'value' => $this->translator->translate(
- $mode == 'go' ? 'searcharticle'
: 'searchbutton' ),
+ 'value' => wfMessage( $mode == 'go' ?
'searcharticle' : 'searchbutton' )->text(),
);
$realAttrs = array_merge(
$realAttrs,
@@ -1860,7 +1816,7 @@
'src' => $attrs['src'],
'alt' => isset( $attrs['alt'] )
? $attrs['alt']
- : $this->translator->translate(
'searchbutton' ),
+ : wfMessage( 'searchbutton'
)->text(),
'width' => isset( $attrs['width'] ) ?
$attrs['width'] : null,
'height' => isset( $attrs['height'] ) ?
$attrs['height'] : null,
);
--
To view, visit https://gerrit.wikimedia.org/r/62442
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I42b13beea0531e36b7eb47fd07514dd3cab95afd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Matmarex <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits