Changes from branches/2.8/wp-includes/pomo/translations.php at r11627 to trunk/wp-includes/pomo/translations.php at r10810
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/pomo/translations.php
r11627 r10810 3 3 * Class for a set of entries for translation and their associated headers 4 4 * 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 $ 6 6 * @package pomo 7 7 * @subpackage translations … … 20 20 * @return bool true on success, false if the entry doesn't have a key 21 21 */ 22 function add_entry($entry) { 23 if (is_array($entry)) { 24 $entry = new Translation_Entry($entry); 25 } 22 function add_entry(&$entry) { 26 23 $key = $entry->key(); 27 24 if (false === $key) return false; 28 $this->entries[$key] = $entry;25 $this->entries[$key] = &$entry; 29 26 return true; 30 27 } … … 91 88 if ($translated && 0 <= $index && $index < $total_plural_forms && 92 89 is_array($translated->translations) && 93 isset($translated->translations[$index]))90 count($translated->translations) == $total_plural_forms) 94 91 return $translated->translations[$index]; 95 92 else … … 97 94 } 98 95 99 /**100 * Merge $other in the current object.101 *102 * @param Object &$other Another Translation object, whose translations will be merged in this one103 * @return void104 **/105 function merge_with(&$other) {106 $this->entries = array_merge($this->entries, $other->entries);107 }108 }109 110 class Gettext_Translations extends Translations {111 96 /** 112 97 * The gettext implmentation of select_plural_form. … … 146 131 * Adds parantheses to the inner parts of ternary operators in 147 132 * plural expressions, because PHP evaluates ternary oerators from left to right 148 * 133 * 149 134 * @param string $expression the expression without parentheses 150 135 * @return string the expression with parentheses added … … 174 159 return rtrim($res, ';'); 175 160 } 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); 188 170 } 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 197 171 } 198 172
Note: See TracChangeset
for help on using the changeset viewer.