Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r11627 r10810  
    33 * Class for a set of entries for translation and their associated headers
    44 *
    5  * @version $Id: translations.php 114 2009-05-11 17:30:38Z nbachiyski $
     5 * @version $Id: translations.php 35 2009-02-16 12:54:57Z nbachiyski $
    66 * @package pomo
    77 * @subpackage translations
     
    2020     * @return bool true on success, false if the entry doesn't have a key
    2121     */
    22     function add_entry($entry) {
    23         if (is_array($entry)) {
    24             $entry = new Translation_Entry($entry);
    25         }
     22    function add_entry(&$entry) {
    2623        $key = $entry->key();
    2724        if (false === $key) return false;
    28         $this->entries[$key] = $entry;
     25        $this->entries[$key] = &$entry;
    2926        return true;
    3027    }
     
    9188        if ($translated && 0 <= $index && $index < $total_plural_forms &&
    9289                is_array($translated->translations) &&
    93                 isset($translated->translations[$index]))
     90                count($translated->translations) == $total_plural_forms)
    9491            return $translated->translations[$index];
    9592        else
     
    9794    }
    9895
    99     /**
    100      * Merge $other in the current object.
    101      *
    102      * @param Object &$other Another Translation object, whose translations will be merged in this one
    103      * @return void
    104      **/
    105     function merge_with(&$other) {
    106         $this->entries = array_merge($this->entries, $other->entries);
    107     }
    108 }
    109 
    110 class Gettext_Translations extends Translations {
    11196    /**
    11297     * The gettext implmentation of select_plural_form.
     
    146131     * Adds parantheses to the inner parts of ternary operators in
    147132     * plural expressions, because PHP evaluates ternary oerators from left to right
    148      * 
     133     *
    149134     * @param string $expression the expression without parentheses
    150135     * @return string the expression with parentheses added
     
    174159        return rtrim($res, ';');
    175160    }
    176    
    177     function make_headers($translation) {
    178         $headers = array();
    179         // sometimes \ns are used instead of real new lines
    180         $translation = str_replace('\n', "\n", $translation);
    181         $lines = explode("\n", $translation);
    182         foreach($lines as $line) {
    183             $parts = explode(':', $line, 2);
    184             if (!isset($parts[1])) continue;
    185             $headers[trim($parts[0])] = trim($parts[1]);
    186         }
    187         return $headers;
     161
     162    /**
     163     * Merge $other in the current object.
     164     *
     165     * @param Object &$other Another Translation object, whose translations will be merged in this one
     166     * @return void
     167     **/
     168    function merge_with(&$other) {
     169        $this->entries = array_merge($this->entries, $other->entries);
    188170    }
    189 
    190     function set_header($header, $value) {
    191         parent::set_header($header, $value);
    192         if ('Plural-Forms' == $header)
    193             $this->_gettext_select_plural_form = $this->_make_gettext_select_plural_form($value);
    194     }
    195 
    196    
    197171}
    198172
Note: See TracChangeset for help on using the changeset viewer.