Make WordPress Core


Ignore:
Timestamp:
10/31/2012 10:13:51 PM (12 years ago)
Author:
nbachiyski
Message:

Sync POMO with GlotPress

See http://glotpress.trac.wordpress.org/browser/trunk/pomo/

File:
1 edited

Legend:

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

    r18528 r22349  
    33 * Class for working with PO files
    44 *
    5  * @version $Id: po.php 589 2010-12-18 01:40:57Z nbachiyski $
     5 * @version $Id: po.php 718 2012-10-31 00:32:02Z nbachiyski $
    66 * @package pomo
    77 * @subpackage po
     
    1919if ( !class_exists( 'PO' ) ):
    2020class PO extends Gettext_Translations {
    21    
     21
    2222    var $comments_before_headers = '';
    2323
     
    8181        return fclose($fh);
    8282    }
    83    
     83
    8484    /**
    8585     * Text to include as a comment before the start of the PO contents
    86      * 
     86     *
    8787     * Doesn't need to include # in the beginning of lines, these are added automatically
    8888     */
     
    121121        return $po;
    122122    }
    123    
     123
    124124    /**
    125125     * Gives back the original string from a PO-formatted string
    126      * 
     126     *
    127127     * @static
    128128     * @param string $string PO-formatted string
     
    154154
    155155    /**
    156      * 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
    157157     * returns the modified string
    158158     *
     
    230230        }
    231231        PO::read_line($f, 'clear');
    232         return $res !== false;
    233     }
    234    
     232        if ( false === $res ) {
     233            return false;
     234        }
     235        if ( ! $this->headers && ! $this->entries ) {
     236            return false;
     237        }
     238        return true;
     239    }
     240
    235241    function read_entry($f, $lineno = 0) {
    236242        $entry = new Translation_Entry();
     
    337343        return array('entry' => $entry, 'lineno' => $lineno);
    338344    }
    339    
     345
    340346    function read_line($f, $action = 'read') {
    341347        static $last_line = '';
     
    350356        }
    351357        $line = $use_last_line? $last_line : fgets($f);
     358        $line = gp_endswith( $line, "\r\n" )? rtrim( $line, "\r\n" ) . "\n" : $line;
    352359        $last_line = $line;
    353360        $use_last_line = false;
    354361        return $line;
    355362    }
    356    
     363
    357364    function add_comment_to_entry(&$entry, $po_comment_line) {
    358365        $first_two = substr($po_comment_line, 0, 2);
     
    368375        }
    369376    }
    370    
     377
    371378    function trim_quotes($s) {
    372379        if ( substr($s, 0, 1) == '"') $s = substr($s, 1);
Note: See TracChangeset for help on using the changeset viewer.