r70994 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70993‎ | r70994 | r70995 >
Date:21:19, 12 August 2010
Author:roberthl
Status:deferred
Tags:
Comment:
Translate:
- Fix JavaScript message export.
Modified paths:
  • /trunk/extensions/Translate/FFS.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/FFS.php
@@ -447,38 +447,44 @@
448448 );
449449 }
450450
451 - public function writeIntoVariable( MessageCollection $collection ) {
452 - $r = $this->header( $collection->code, $collection->getAuthors() );
 451+ public function writeReal( MessageCollection $collection ) {
 452+ $header = $this->header( $collection->code, $collection->getAuthors() );
453453
454454 $mangler = $this->group->getMangler();
455455
456456 // Get and write messages.
 457+ $body = '';
457458 foreach ( $collection as $message ) {
 459+ if( strlen( $message->translation() ) === 0 ) continue;
 460+
458461 $key = $mangler->unmangle( $message->key() );
459462 $key = $this->transformKey( Xml::escapeJsString( $key ) );
460463
461464 $translation = Xml::escapeJsString( $message->translation() );
462465
463 - $r .= " {$key}: \"{$translation}\",\n\n";
 466+ $body .= " {$key}: \"{$translation}\",\n\n";
464467 }
465468
 469+ if( strlen( $body ) === 0 ) return false;
 470+
466471 // Strip last comma, re-add trailing newlines.
467 - $r = substr( $r, 0, - 3 );
468 - $r .= "\n\n";
 472+ $body = substr( $body, 0, - 3 );
 473+ $body .= "\n\n";
469474
470 - return $r . $this->footer();
 475+ return $header . $body . $this->footer();
471476 }
472477
473478 protected function authorsList( $authors ) {
474479 if( count( $authors ) === 0 ) return '';
475480
 481+ $authorsList = '';
476482 foreach ( $authors as $author ) {
477483 $authorsList .= " * - $author\n";
478484 }
479485 return "/* Translators:\n$authorsList */\n\n";
480486 }
481487
482 - private static function unescapeJsString( $string ) {
 488+ protected static function unescapeJsString( $string ) {
483489 // See ECMA 262 section 7.8.4 for string literal format
484490 $pairs = array(
485491 "\\" => "\\\\",

Status & tagging log