Nikerabbit has uploaded a new change for review.
https://gerrit.wikimedia.org/r/60661
Change subject: Replace method which already exists as strtr
......................................................................
Replace method which already exists as strtr
Change-Id: I1a1c5c5c3e72916413191c13c19f0328569444d0
---
M tag/TPParse.php
1 file changed, 1 insertion(+), 18 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate
refs/changes/61/60661/1
diff --git a/tag/TPParse.php b/tag/TPParse.php
index 84a298d..ec70c35 100644
--- a/tag/TPParse.php
+++ b/tag/TPParse.php
@@ -156,7 +156,6 @@
public function getSourcePageText() {
$text = $this->template;
- /// @todo Use str_replace outside of the loop.
foreach ( $this->sections as $ph => $s ) {
$text = str_replace( $ph, $s->getMarkedText(), $text );
}
@@ -198,7 +197,7 @@
}
// Substitute variables into section text and
substitute text into document
- $sectiontext = self::replaceVariables(
$s->getVariables(), $sectiontext );
+ $sectiontext = strtr( $sectiontext, $s->getVariables()
);
$text = str_replace( $ph, $sectiontext, $text );
}
@@ -209,22 +208,6 @@
$cb = array( __CLASS__, 'replaceTagCb' );
$text = preg_replace_callback(
'~(<translate>)(.*)(</translate>)~sU', $cb, $text );
$text = TranslatablePage::unArmourNowiki( $nph, $text );
-
- return $text;
- }
-
- /**
- * Replaces variables from given text.
- * @todo Is plain str_replace not enough (even the loop is not needed)?
- *
- * @param array $variables
- * @param string $text
- * @return string
- */
- protected static function replaceVariables( $variables, $text ) {
- foreach ( $variables as $key => $value ) {
- $text = str_replace( $key, $value, $text );
- }
return $text;
}
--
To view, visit https://gerrit.wikimedia.org/r/60661
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a1c5c5c3e72916413191c13c19f0328569444d0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits