Index: trunk/extensions/Translate/FFS.php |
— | — | @@ -1086,13 +1086,21 @@ |
1087 | 1087 | } |
1088 | 1088 | if( !$ok ) return; |
1089 | 1089 | |
| 1090 | + $authors = $this->doAuthors($collection); |
| 1091 | + if( $authors != '' ) fwrite( $this->fw, "\t$authors" ); |
1090 | 1092 | fwrite( $this->fw, "\t'{$collection->code}': {\n" ); |
1091 | 1093 | fwrite( $this->fw, $this->writeBlock( $collection ) ); |
1092 | 1094 | fwrite( $this->fw, "\t},\n" ); |
1093 | 1095 | } |
1094 | 1096 | |
1095 | 1097 | public function writeIntoVariable( MessageCollection $collection ) { |
1096 | | - return "# -*- coding: utf-8 -*-\nmsg = {\n" . $this->writeBlock( $collection ) . '}'; |
| 1098 | + return <<<PHP |
| 1099 | +# -*- coding: utf-8 -*- |
| 1100 | +{$this->doAuthors($collection)}msg = { |
| 1101 | +\t'{$collection->code}': { |
| 1102 | +{$this->writeBlock( $collection )}\t} |
| 1103 | +} |
| 1104 | +PHP; |
1097 | 1105 | } |
1098 | 1106 | |
1099 | 1107 | protected function writeBlock( MessageCollection $collection ) { |
— | — | @@ -1100,11 +1108,24 @@ |
1101 | 1109 | $block = ''; |
1102 | 1110 | foreach( $collection as $message ) { |
1103 | 1111 | if( $message->translation() == '' ) continue; |
1104 | | - $block .= "\t\t'{$message->key()}': u'{$message->translation()}',\n"; |
| 1112 | + $translation = str_replace( '\'', '\\\'', $message->translation() ); |
| 1113 | + $block .= "\t\t'{$message->key()}': u'{$translation}',\n"; |
1105 | 1114 | } |
1106 | 1115 | return $block; |
1107 | 1116 | } |
1108 | 1117 | |
| 1118 | + protected function doAuthors( MessageCollection $collection ) { |
| 1119 | + $output = ''; |
| 1120 | + $authors = $collection->getAuthors(); |
| 1121 | + $authors = $this->filterAuthors( $authors, $collection->code ); |
| 1122 | + |
| 1123 | + foreach ( $authors as $author ) { |
| 1124 | + $output .= "# Author: $author\n"; |
| 1125 | + } |
| 1126 | + |
| 1127 | + return $output; |
| 1128 | + } |
| 1129 | + |
1109 | 1130 | public function __destruct() { |
1110 | 1131 | if( $this->fw !== null ) { |
1111 | 1132 | fwrite( $this->fw, "}" ); |