WordPress.org

GlotPress

Ticket #173: gp.173.diff

File gp.173.diff, 2.1 KB (added by nacin, 2 years ago)
  • scripts/import-originals.php

     
    2222                        $this->error( __("Couldn't load translations from file!") ); 
    2323                } 
    2424 
    25                 list( $originals_added, $originals_existing ) = GP::$original->import_for_project( $project, $translations ); 
    26                 echo sprintf( __("%s new strings were added, %s existing were updated."), $originals_added, $originals_existing )."\n"; 
     25                list( $originals_added, $originals_existing, $originals_obsoleted ) = GP::$original->import_for_project( $project, $translations ); 
     26                echo sprintf( __("%s new strings were added, %s existing were updated, %s were removed."), $originals_added, $originals_existing, $originals_obsoleted )."\n"; 
    2727        } 
    2828} 
    2929 
  • gp-includes/things/original.php

     
    5656        function import_for_project( $project, $translations ) { 
    5757                global $gpdb; 
    5858                wp_cache_delete( $project->id, self::$count_cache_group ); 
    59                 $originals_added = $originals_existing = 0; 
     59                $originals_added = $originals_existing = $originals_obsoleted = 0; 
    6060                $all_originals_for_project = $this->many_no_map( "SELECT * FROM $this->table WHERE project_id= %d", $project->id ); 
    6161                $originals_by_key = array(); 
    6262                foreach( $all_originals_for_project as $original ) { 
     
    8484                // Mark previously active, but now removed strings as obsolete 
    8585                foreach ( $originals_by_key as $key => $value) { 
    8686                        if ( !key_exists($key, $translations->entries ) ) { 
    87                                 $this->update( array('status' => '-obsolete'), array( 'id' => $original->id ) ); 
     87                                $this->update( array('status' => '-obsolete'), array( 'id' => $value->id ) ); 
     88                                $originals_obsoleted++; 
    8889                        } 
    8990                } 
    90                 return array( $originals_added, $originals_existing ); 
     91                return array( $originals_added, $originals_existing, $originals_obsoleted ); 
    9192        } 
    9293 
    9394        function should_be_updated_with( $data, $original = null ) {