equal
deleted
inserted
replaced
19 * Routines for working with PO files |
19 * Routines for working with PO files |
20 */ |
20 */ |
21 if ( ! class_exists( 'PO', false ) ) : |
21 if ( ! class_exists( 'PO', false ) ) : |
22 class PO extends Gettext_Translations { |
22 class PO extends Gettext_Translations { |
23 |
23 |
24 var $comments_before_headers = ''; |
24 public $comments_before_headers = ''; |
25 |
25 |
26 /** |
26 /** |
27 * Exports headers to a PO entry |
27 * Exports headers to a PO entry |
28 * |
28 * |
29 * @return string msgid/msgstr PO entry for this PO file headers, doesn't contain newline at the end |
29 * @return string msgid/msgstr PO entry for this PO file headers, doesn't contain newline at the end |
210 } |
210 } |
211 |
211 |
212 /** |
212 /** |
213 * Builds a string from the entry for inclusion in PO file |
213 * Builds a string from the entry for inclusion in PO file |
214 * |
214 * |
215 * @param Translation_Entry $entry the entry to convert to po string (passed by reference). |
215 * @param Translation_Entry $entry the entry to convert to po string. |
216 * @return string|false PO-style formatted string for the entry or |
216 * @return string|false PO-style formatted string for the entry or |
217 * false if the entry is empty |
217 * false if the entry is empty |
218 */ |
218 */ |
219 public static function export_entry( &$entry ) { |
219 public static function export_entry( $entry ) { |
220 if ( null === $entry->singular || '' === $entry->singular ) { |
220 if ( null === $entry->singular || '' === $entry->singular ) { |
221 return false; |
221 return false; |
222 } |
222 } |
223 $po = array(); |
223 $po = array(); |
224 if ( ! empty( $entry->translator_comments ) ) { |
224 if ( ! empty( $entry->translator_comments ) ) { |
281 return $translation; |
281 return $translation; |
282 } |
282 } |
283 |
283 |
284 /** |
284 /** |
285 * @param string $filename |
285 * @param string $filename |
286 * @return boolean |
286 * @return bool |
287 */ |
287 */ |
288 function import_from_file( $filename ) { |
288 function import_from_file( $filename ) { |
289 $f = fopen( $filename, 'r' ); |
289 $f = fopen( $filename, 'r' ); |
290 if ( ! $f ) { |
290 if ( ! $f ) { |
291 return false; |
291 return false; |
452 } |
452 } |
453 |
453 |
454 /** |
454 /** |
455 * @param resource $f |
455 * @param resource $f |
456 * @param string $action |
456 * @param string $action |
457 * @return boolean |
457 * @return bool |
458 */ |
458 */ |
459 function read_line( $f, $action = 'read' ) { |
459 function read_line( $f, $action = 'read' ) { |
460 static $last_line = ''; |
460 static $last_line = ''; |
461 static $use_last_line = false; |
461 static $use_last_line = false; |
462 if ( 'clear' === $action ) { |
462 if ( 'clear' === $action ) { |