r112005 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112004‎ | r112005 | r112006 >
Date:11:38, 21 February 2012
Author:nikerabbit
Status:ok
Tags:i18nreview 
Comment:
Don't override certain headers unconditionally - let them be customised by a hook
Reduce the number of headers added by default
Modified paths:
  • /trunk/extensions/Translate/ffs/Gettext.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/ffs/Gettext.php
@@ -352,7 +352,7 @@
353353 }
354354
355355 protected function doGettextHeader( MessageCollection $collection, $template, &$pluralCount ) {
356 - global $wgSitename, $wgServer, $wgCanonicalServer;
 356+ global $wgSitename;
357357
358358 $code = $collection->code;
359359 $name = TranslateUtils::getLanguageName( $code );
@@ -374,33 +374,25 @@
375375 // Make sure there is no empty line before msgid
376376 $output = trim( $output ) . "\n";
377377
378 - // @todo portal is twn specific
379 - $portal = Title::makeTitle( NS_PORTAL, $code )->getCanonicalUrl();
380 - $server = $wgCanonicalServer;
381 -
382378 $specs = isset( $template['HEADERS'] ) ? $template['HEADERS'] : array();
383379
384380 $timestamp = wfTimestampNow();
385 - $specs['Project-Id-Version'] = $this->group->getLabel();
386 - $specs['Report-Msgid-Bugs-To'] = $wgSitename;
387381 $specs['PO-Revision-Date'] = self::formatTime( $timestamp );
388382 if ( $this->offlineMode ) {
389383 $specs['POT-Creation-Date'] = self::formatTime( $timestamp );
390384 } elseif ( $this->group instanceof MessageGroupBase ) {
391385 $specs['X-POT-Import-Date'] = self::formatTime( wfTimestamp( TS_MW, $this->getPotTime() ) );
392386 }
393 - $specs['Language-Team'] = "$name <$portal>";
394387 $specs['Content-Type'] = 'text/plain; charset=UTF-8';
395388 $specs['Content-Transfer-Encoding'] = '8bit';
 389+ wfRunHooks( 'Translate:GettextFFS:headerFields', array( &$specs, $this->group, $code ) );
396390 $specs['X-Generator'] = $this->getGenerator();
397 - $specs['X-Translation-Project'] = "$wgSitename at $server";
398 - $specs['X-Language-Code'] = $code;
 391+
399392 if ( $this->offlineMode ) {
 393+ $specs['X-Language-Code'] = $code;
400394 $specs['X-Message-Group'] = $this->group->getId();
401 - } else {
402 - // Prepend # so that message import does not think this is a file it can import
403 - $specs['X-Message-Group'] = '#' . $this->group->getId();
404395 }
 396+
405397 $plural = self::getPluralRule( $code );
406398 if ( $plural ) {
407399 $specs['Plural-Forms'] = $plural;

Status & tagging log