- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/pomo/translations.php
r13830 r18827 3 3 * Class for a set of entries for translation and their associated headers 4 4 * 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 $ 6 6 * @package pomo 7 7 * @subpackage translations … … 30 30 return true; 31 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; 43 return true; 44 } 32 45 33 46 /** … … 69 82 * Given the number of items, returns the 0-based index of the plural form to use 70 83 * 71 * Here, in the base Translations class, the common g logic for English is implmented:84 * Here, in the base Translations class, the common logic for English is implemented: 72 85 * 0 if there is one element, 1 otherwise 73 86 * … … 109 122 } 110 123 } 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 } 111 133 } 112 134 … … 127 149 return call_user_func($this->_gettext_select_plural_form, $count); 128 150 } 129 151 130 152 function nplurals_and_expression_from_header($header) { 131 153 if (preg_match('/^\s*nplurals\s*=\s*(\d+)\s*;\s+plural\s*=\s*(.+)$/', $header, $matches)) { … … 153 175 * Adds parantheses to the inner parts of ternary operators in 154 176 * plural expressions, because PHP evaluates ternary oerators from left to right 155 * 177 * 156 178 * @param string $expression the expression without parentheses 157 179 * @return string the expression with parentheses added … … 181 203 return rtrim($res, ';'); 182 204 } 183 205 184 206 function make_headers($translation) { 185 207 $headers = array(); … … 194 216 return $headers; 195 217 } 196 218 197 219 function set_header($header, $value) { 198 220 parent::set_header($header, $value); … … 213 235 var $entries = array(); 214 236 var $headers = array(); 215 237 216 238 function add_entry($entry) { 217 239 return true;
Note: See TracChangeset
for help on using the changeset viewer.