r80379 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80378‎ | r80379 | r80380 >
Date:10:47, 15 January 2011
Author:roberthl
Status:deferred
Tags:
Comment:
Translate: Read authors from python message files.
Modified paths:
  • /trunk/extensions/Translate/FFS.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/FFS.php
@@ -1071,6 +1071,7 @@
10721072 if( !isset( $this->data[$code] ) ) $this->data[$code] = array();
10731073 return array( 'MESSAGES' => $this->data[$code] );
10741074 }
 1075+
10751076
10761077 public function write( MessageCollection $collection ) {
10771078 if( $this->fw === null ) {
@@ -1087,7 +1088,7 @@
10881089 if( !$ok ) return;
10891090
10901091 $authors = $this->doAuthors($collection);
1091 - if( $authors != '' ) fwrite( $this->fw, "\t$authors" );
 1092+ if( $authors != '' ) fwrite( $this->fw, "$authors" );
10921093 fwrite( $this->fw, "\t'{$collection->code}': {\n" );
10931094 fwrite( $this->fw, $this->writeBlock( $collection ) );
10941095 fwrite( $this->fw, "\t},\n" );
@@ -1096,8 +1097,8 @@
10971098 public function writeIntoVariable( MessageCollection $collection ) {
10981099 return <<<PHP
10991100 # -*- coding: utf-8 -*-
1100 -{$this->doAuthors($collection)}msg = {
1101 -\t'{$collection->code}': {
 1101+msg = {
 1102+{$this->doAuthors($collection)}\t'{$collection->code}': {
11021103 {$this->writeBlock( $collection )}\t}
11031104 }
11041105 PHP;
@@ -1116,11 +1117,26 @@
11171118
11181119 protected function doAuthors( MessageCollection $collection ) {
11191120 $output = '';
1120 - $authors = $collection->getAuthors();
1121 - $authors = $this->filterAuthors( $authors, $collection->code );
11221121
 1122+ // Read authors.
 1123+ $fr = fopen( $this->group->getSourceFilePath( $collection->code ), 'r' );
 1124+ $authors = array();
 1125+ while( !feof( $fr ) ) {
 1126+ $line = fgets( $fr );
 1127+ if( strpos( $line, "\t# Author:" ) === 0 ) {
 1128+ $authors[] = trim( substr( $line, strlen( "\t# Author: " ) ) );
 1129+ } elseif( $line === "\t'{$collection->code}': {\n" ) {
 1130+ break;
 1131+ } else {
 1132+ $authors = array();
 1133+ }
 1134+ }
 1135+ $authors2 = $collection->getAuthors();
 1136+ $authors2 = $this->filterAuthors( $authors2, $collection->code );
 1137+ $authors = array_unique( array_merge( $authors, $authors2 ) );
 1138+
11231139 foreach ( $authors as $author ) {
1124 - $output .= "# Author: $author\n";
 1140+ $output .= "\t# Author: $author\n";
11251141 }
11261142
11271143 return $output;

Status & tagging log