Index: trunk/extensions/Translate/FFS.php |
— | — | @@ -1078,7 +1078,6 @@ |
1079 | 1079 | return array( 'MESSAGES' => self::$data[$this->group->getId()][$code] ); |
1080 | 1080 | } |
1081 | 1081 | |
1082 | | - |
1083 | 1082 | public function write( MessageCollection $collection ) { |
1084 | 1083 | if ( $this->fw === null ) { |
1085 | 1084 | $sourceLanguage = $this->group->getSourceLanguage(); |
— | — | @@ -1098,7 +1097,10 @@ |
1099 | 1098 | if ( !$ok ) return; |
1100 | 1099 | |
1101 | 1100 | $authors = $this->doAuthors( $collection ); |
1102 | | - if ( $authors != '' ) fwrite( $this->fw, "$authors" ); |
| 1101 | + if ( $authors != '' ) { |
| 1102 | + fwrite( $this->fw, "$authors" ); |
| 1103 | + } |
| 1104 | + |
1103 | 1105 | fwrite( $this->fw, "\t'{$collection->code}': {\n" ); |
1104 | 1106 | fwrite( $this->fw, $this->writeBlock( $collection ) ); |
1105 | 1107 | fwrite( $this->fw, "\t},\n" ); |
— | — | @@ -1117,17 +1119,22 @@ |
1118 | 1120 | protected function writeBlock( MessageCollection $collection ) { |
1119 | 1121 | $block = ''; |
1120 | 1122 | $messages = array(); |
| 1123 | + |
1121 | 1124 | foreach ( $collection as $message ) { |
1122 | 1125 | if ( $message->translation() == '' ) continue; |
1123 | 1126 | $translation = str_replace( '\\', '\\\\', $message->translation() ); |
1124 | 1127 | $translation = str_replace( '\'', '\\\'', $translation ); |
1125 | 1128 | $translation = str_replace( "\n", '\n', $translation ); |
| 1129 | + $translation = str_replace( TRANSLATE_FUZZY, '', $translation ); |
1126 | 1130 | $messages[$message->key()] = $translation; |
1127 | 1131 | } |
| 1132 | + |
1128 | 1133 | ksort( $messages ); |
| 1134 | + |
1129 | 1135 | foreach ( $messages as $key => $translation ) { |
1130 | 1136 | $block .= "\t\t'{$key}': u'{$translation}',\n"; |
1131 | 1137 | } |
| 1138 | + |
1132 | 1139 | return $block; |
1133 | 1140 | } |
1134 | 1141 | |
— | — | @@ -1137,8 +1144,10 @@ |
1138 | 1145 | // Read authors. |
1139 | 1146 | $fr = fopen( $this->group->getSourceFilePath( $collection->code ), 'r' ); |
1140 | 1147 | $authors = array(); |
| 1148 | + |
1141 | 1149 | while ( !feof( $fr ) ) { |
1142 | 1150 | $line = fgets( $fr ); |
| 1151 | + |
1143 | 1152 | if ( strpos( $line, "\t# Author:" ) === 0 ) { |
1144 | 1153 | $authors[] = trim( substr( $line, strlen( "\t# Author: " ) ) ); |
1145 | 1154 | } elseif ( $line === "\t'{$collection->code}': {\n" ) { |
— | — | @@ -1147,6 +1156,7 @@ |
1148 | 1157 | $authors = array(); |
1149 | 1158 | } |
1150 | 1159 | } |
| 1160 | + |
1151 | 1161 | $authors2 = $collection->getAuthors(); |
1152 | 1162 | $authors2 = $this->filterAuthors( $authors2, $collection->code ); |
1153 | 1163 | $authors = array_unique( array_merge( $authors, $authors2 ) ); |
— | — | @@ -1161,7 +1171,7 @@ |
1162 | 1172 | public function __destruct() { |
1163 | 1173 | if ( $this->fw !== null ) { |
1164 | 1174 | fwrite( $this->fw, "}" ); |
1165 | | - fclose( $this->fw ); |
| 1175 | + fclose( $this->fw ); |
1166 | 1176 | } |
1167 | 1177 | } |
1168 | 1178 | } |