Make WordPress Core


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

Sync pomo library with the current GlotPress version

File:
1 edited

Legend:

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

    r13830 r18528  
    33 * Class for a set of entries for translation and their associated headers
    44 *
    5  * @version $Id: translations.php 406 2010-02-07 11:10:24Z nbachiyski $
     5 * @version $Id: translations.php 590 2010-12-20 19:58:37Z nbachiyski $
    66 * @package pomo
    77 * @subpackage translations
    … …  
    2828                if (false === $key) return false;
    2929                $this->entries[$key] = &$entry;
     30                return true;
     31        }
     32       
     33        function add_entry_or_merge($entry) {
     34                if (is_array($entry)) {
     35                        $entry = new Translation_Entry($entry);
     36                }
     37                $key = $entry->key();
     38                if (false === $key) return false;
     39                if (isset($this->entries[$key]))
     40                        $this->entries[$key]->merge_with($entry);
     41                else
     42                        $this->entries[$key] = &$entry;
    3043                return true;
    3144        }
    … …  
    109122                }
    110123        }
     124       
     125        function merge_originals_with(&$other) {
     126                foreach( $other->entries as $entry ) {
     127                        if ( !isset( $this->entries[$entry->key()] ) )
     128                                $this->entries[$entry->key()] = $entry;
     129                        else
     130                                $this->entries[$entry->key()]->merge_with($entry);
     131                }
     132        }
    111133}
    112134
    … …  
    127149                return call_user_func($this->_gettext_select_plural_form, $count);
    128150        }
    129 
     151       
    130152        function nplurals_and_expression_from_header($header) {
    131153                if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches)) {
    … …  
    153175         * Adds parantheses to the inner parts of ternary operators in
    154176         * plural expressions, because PHP evaluates ternary oerators from left to right
    155          *
     177         * 
    156178         * @param string $expression the expression without parentheses
    157179         * @return string the expression with parentheses added
    … …  
    181203                return rtrim($res, ';');
    182204        }
    183 
     205       
    184206        function make_headers($translation) {
    185207                $headers = array();
    … …  
    194216                return $headers;
    195217        }
    196 
     218       
    197219        function set_header($header, $value) {
    198220                parent::set_header($header, $value);
    … …  
    213235        var $entries = array();
    214236        var $headers = array();
    215 
     237       
    216238        function add_entry($entry) {
    217239                return true;
Note: See TracChangeset for help on using the changeset viewer.