diff -r 2f6f6f7551ca -r 32102edaa81b web/wp-includes/pomo/translations.php --- a/web/wp-includes/pomo/translations.php Thu Sep 16 15:45:36 2010 +0000 +++ b/web/wp-includes/pomo/translations.php Mon Nov 19 18:26:13 2012 +0100 @@ -2,7 +2,7 @@ /** * Class for a set of entries for translation and their associated headers * - * @version $Id: translations.php 291 2009-10-21 05:46:08Z nbachiyski $ + * @version $Id: translations.php 590 2010-12-20 19:58:37Z nbachiyski $ * @package pomo * @subpackage translations */ @@ -29,6 +29,19 @@ $this->entries[$key] = &$entry; return true; } + + function add_entry_or_merge($entry) { + if (is_array($entry)) { + $entry = new Translation_Entry($entry); + } + $key = $entry->key(); + if (false === $key) return false; + if (isset($this->entries[$key])) + $this->entries[$key]->merge_with($entry); + else + $this->entries[$key] = &$entry; + return true; + } /** * Sets $header PO header to $value @@ -68,7 +81,7 @@ /** * Given the number of items, returns the 0-based index of the plural form to use * - * Here, in the base Translations class, the commong logic for English is implmented: + * Here, in the base Translations class, the common logic for English is implemented: * 0 if there is one element, 1 otherwise * * This function should be overrided by the sub-classes. For example MO/PO can derive the logic @@ -104,7 +117,18 @@ * @return void **/ function merge_with(&$other) { - $this->entries = array_merge($this->entries, $other->entries); + foreach( $other->entries as $entry ) { + $this->entries[$entry->key()] = $entry; + } + } + + function merge_originals_with(&$other) { + foreach( $other->entries as $entry ) { + if ( !isset( $this->entries[$entry->key()] ) ) + $this->entries[$entry->key()] = $entry; + else + $this->entries[$entry->key()]->merge_with($entry); + } } }