]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/pomo/po.php
Wordpress 3.3-scripts
[autoinstalls/wordpress.git] / wp-includes / pomo / po.php
index 6c40c5a4eee44ea7e9c9324ee32a4a2ab79d6a20..8320bc1e1d9a90ef47157a7476c71cb760b2113f 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * Class for working with PO files
  *
- * @version $Id: po.php 123 2009-05-13 19:35:43Z nbachiyski $
+ * @version $Id: po.php 589 2010-12-18 01:40:57Z nbachiyski $
  * @package pomo
  * @subpackage po
  */
@@ -16,8 +16,10 @@ ini_set('auto_detect_line_endings', 1);
 /**
  * Routines for working with PO files
  */
+if ( !class_exists( 'PO' ) ):
 class PO extends Gettext_Translations {
        
+       var $comments_before_headers = '';
 
        /**
         * Exports headers to a PO entry
@@ -30,7 +32,11 @@ class PO extends Gettext_Translations {
                        $header_string.= "$header: $value\n";
                }
                $poified = PO::poify($header_string);
-               return rtrim("msgid \"\"\nmsgstr $poified");
+               if ($this->comments_before_headers)
+                       $before_headers = $this->prepend_each_line(rtrim($this->comments_before_headers)."\n", '# ');
+               else
+                       $before_headers = '';
+               return rtrim("{$before_headers}msgid \"\"\nmsgstr $poified");
        }
 
        /**
@@ -74,6 +80,15 @@ class PO extends Gettext_Translations {
                if (false === $res) return false;
                return fclose($fh);
        }
+       
+       /**
+        * Text to include as a comment before the start of the PO contents
+        * 
+        * Doesn't need to include # in the beginning of lines, these are added automatically
+        */
+       function set_comment_before_headers( $text ) {
+               $this->comments_before_headers = $text;
+       }
 
        /**
         * Formats a string in PO-style
@@ -316,7 +331,9 @@ class PO extends Gettext_Translations {
                                return false;
                        }
                }
-               if (array() == array_filter($entry->translations)) $entry->translations = array();
+               if (array() == array_filter($entry->translations, create_function('$t', 'return $t || "0" === $t;'))) {
+                       $entry->translations = array();
+               }
                return array('entry' => $entry, 'lineno' => $lineno);
        }
        
@@ -357,4 +374,4 @@ class PO extends Gettext_Translations {
                return $s;
        }
 }
-?>
+endif;
\ No newline at end of file