r75333 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75332‎ | r75333 | r75334 >
Date:19:10, 24 October 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Turns out we actually need special handling for line breaks
Modified paths:
  • /trunk/extensions/Translate/utils/TranslationHelpers.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/utils/TranslationHelpers.php
@@ -424,6 +424,7 @@
425425
426426 $code = $this->targetLanguage;
427427 $definition = trim( strval( $this->getDefinition() ) );
 428+ $definition = str_replace( "\n", "<newline/>", $definition );
428429
429430 $memckey = wfMemckey( 'translate-tmsug-badcodes-' . $serviceName );
430431 $unsupported = $wgMemc->get( $memckey );
@@ -471,6 +472,7 @@
472473 $ret = $req->getContent();
473474 $text = preg_replace( '~<string.*>(.*)</string>~', '\\1', $ret );
474475 $text = Sanitizer::decodeCharReferences( $text );
 476+ $text = trim( preg_replace( "~\s*<newline></newline>\s*~", "\n", $text ) );
475477 $text = $this->suggestionField( $text );
476478 return Html::rawElement( 'div', null, self::legend( $serviceName ) . $text . self::clear() );
477479 }

Status & tagging log