WordPress.org

GlotPress

Changeset 375


Ignore:
Timestamp:
01/02/10 22:36:48 (4 years ago)
Author:
nbachiyski
Message:

array_merge() was breaking numeric strings, since it re-indexes the entries array. Don't use it anymore and just loop for the merge.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/pomo/translations.php

    r291 r375  
    105105     **/ 
    106106    function merge_with(&$other) { 
    107         $this->entries = array_merge($this->entries, $other->entries); 
     107        foreach( $other->entries as &$entry ) { 
     108            $this->entries[$entry->key()] = $entry; 
     109        } 
    108110    } 
    109111} 
  • trunk/t/test_translations.php

    r164 r375  
    6262        $this->assertEquals('dyadoy', $domain->translate_plural('dyado', 'dyados', -18881)); 
    6363    } 
     64     
     65    function test_digit_and_merge() { 
     66        $entry_digit_1 = new Translation_Entry(array('singular' => 1, 'translations' => array('1'))); 
     67        $entry_digit_2 = new Translation_Entry(array('singular' => 2, 'translations' => array('2'))); 
     68        $domain = new Translations(); 
     69        $domain->add_entry($entry_digit_1); 
     70        $domain->add_entry($entry_digit_2); 
     71        $dummy_translation = new Translations; 
     72        $this->assertEquals( '1', $domain->translate( '1' ) ); 
     73        $domain->merge_with( $dummy_translation ); 
     74        $this->assertEquals( '1', $domain->translate( '1' ) ); 
     75    } 
    6476    
    6577} 
Note: See TracChangeset for help on using the changeset viewer.