Make WordPress Core


Ignore:
Timestamp:
08/11/2011 04:29:35 AM (14 years ago)
Author:
nbachiyski
Message:

Sync pomo library with the current GlotPress version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/pomo/po.php

    r13830 r18528  
    33 * Class for working with PO files
    44 *
    5  * @version $Id: po.php 406 2010-02-07 11:10:24Z nbachiyski $
     5 * @version $Id: po.php 589 2010-12-18 01:40:57Z nbachiyski $
    66 * @package pomo
    77 * @subpackage po
     
    1919if ( !class_exists( 'PO' ) ):
    2020class PO extends Gettext_Translations {
    21 
     21   
     22    var $comments_before_headers = '';
    2223
    2324    /**
     
    3233        }
    3334        $poified = PO::poify($header_string);
    34         return rtrim("msgid \"\"\nmsgstr $poified");
     35        if ($this->comments_before_headers)
     36            $before_headers = $this->prepend_each_line(rtrim($this->comments_before_headers)."\n", '# ');
     37        else
     38            $before_headers = '';
     39        return rtrim("{$before_headers}msgid \"\"\nmsgstr $poified");
    3540    }
    3641
     
    7681        return fclose($fh);
    7782    }
     83   
     84    /**
     85     * Text to include as a comment before the start of the PO contents
     86     *
     87     * Doesn't need to include # in the beginning of lines, these are added automatically
     88     */
     89    function set_comment_before_headers( $text ) {
     90        $this->comments_before_headers = $text;
     91    }
    7892
    7993    /**
     
    107121        return $po;
    108122    }
    109 
     123   
    110124    /**
    111125     * Gives back the original string from a PO-formatted string
    112      *
     126     * 
    113127     * @static
    114128     * @param string $string PO-formatted string
     
    140154
    141155    /**
    142      * Inserts $with in the beginning of every new line of $string and
     156     * Inserts $with in the beginning of every new line of $string and 
    143157     * returns the modified string
    144158     *
     
    218232        return $res !== false;
    219233    }
    220 
     234   
    221235    function read_entry($f, $lineno = 0) {
    222236        $entry = new Translation_Entry();
     
    255269                }
    256270                // add comment
    257                 $this->add_comment_to_entry($entry, $line);
     271                $this->add_comment_to_entry($entry, $line);;
    258272            } elseif (preg_match('/^msgctxt\s+(".*")/', $line, $m)) {
    259273                if ($is_final($context)) {
     
    323337        return array('entry' => $entry, 'lineno' => $lineno);
    324338    }
    325 
     339   
    326340    function read_line($f, $action = 'read') {
    327341        static $last_line = '';
     
    340354        return $line;
    341355    }
    342 
     356   
    343357    function add_comment_to_entry(&$entry, $po_comment_line) {
    344358        $first_two = substr($po_comment_line, 0, 2);
     
    354368        }
    355369    }
    356 
     370   
    357371    function trim_quotes($s) {
    358372        if ( substr($s, 0, 1) == '"') $s = substr($s, 1);
Note: See TracChangeset for help on using the changeset viewer.