Changeset 2832

Show
Ignore:
Timestamp:
07/23/08 02:12:23 (4 months ago)
Author:
fumiakiy
Message:

Translate via plugin instance. BugId:80762

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-41/plugins/WXRImporter/lib/WXRImporter/WXRHandler.pm

    r2731 r2832  
    3737    my $self = shift; 
    3838    my $data = shift; 
     39    my $plugin = MT->component('WXRImporter/WXRImporter.pl'); 
    3940 
    4041    my $name = $data->{LocalName}; 
     
    5657 
    5758    if ($self->{start}) { 
    58         die MT->translate("File is not in WXR format.") 
     59        die $plugin->translate("File is not in WXR format.") 
    5960            unless (('rss' eq $name) && ('2.0' eq $attrs->{'{}version'}->{Value})); ## FIXME: This is checking RSS2. 
    6061        $self->{start} = 0; 
     
    204205    my $self = shift; 
    205206    my $data = shift; 
     207    my $plugin = MT->component('WXRImporter/WXRImporter.pl'); 
    206208     
    207209    my $cb = $self->{callback}; 
     
    253255            $cat->author_id($self->{parent}->id); 
    254256        } 
    255         $cb->(MT->translate("Creating new category ('[_1]')...", $cat->label)); 
     257        $cb->($plugin->translate("Creating new category ('[_1]')...", $cat->label)); 
    256258        if ($cat->save) { 
    257             $cb->(MT->translate("ok") . "\n"); 
     259            $cb->($plugin->translate("ok") . "\n"); 
    258260        } else { 
    259             $cb->(MT->translate("failed") . "\n"); 
    260             return die MT->translate( 
     261            $cb->($plugin->translate("failed") . "\n"); 
     262            return die $plugin->translate( 
    261263                 "Saving category failed: [_1]", $cat->errstr); 
    262264        } 
     
    267269    my $self = shift; 
    268270    my $data = shift; 
     271    my $plugin = MT->component('WXRImporter/WXRImporter.pl'); 
    269272 
    270273    my $cb   = $self->{callback}; 
     
    290293        return if ( MT::Tag->load( { name => $name } ) ); 
    291294        $tag->name($name); 
    292         $cb->( MT->translate( "Creating new tag ('[_1]')...", $tag->name ) ); 
     295        $cb->( $plugin->translate( "Creating new tag ('[_1]')...", $tag->name ) ); 
    293296        if ( $tag->save ) { 
    294             $cb->( MT->translate("ok") . "\n" ); 
     297            $cb->( $plugin->translate("ok") . "\n" ); 
    295298        } 
    296299        else { 
    297             $cb->( MT->translate("failed") . "\n" ); 
    298             return die MT->translate( "Saving tag failed: [_1]", $tag->errstr ); 
     300            $cb->( $plugin->translate("failed") . "\n" ); 
     301            return die $plugin->translate( "Saving tag failed: [_1]", $tag->errstr ); 
    299302        } 
    300303    } 
     
    354357    my $self = shift; 
    355358    my ($hashes) = @_; 
     359    my $plugin = MT->component('WXRImporter/WXRImporter.pl'); 
    356360 
    357361    my $blog = $self->{blog}; 
     
    445449    )) 
    446450    { 
    447         $cb->(MT->translate("Duplicate asset ('[_1]') found.  Skipping.", $asset_values->{label})); 
     451        $cb->($plugin->translate("Duplicate asset ('[_1]') found.  Skipping.", $asset_values->{label})); 
    448452        $cb->("\n"); 
    449453        return 1; 
     
    466470        $asset->image_height($h); 
    467471    } 
    468     $cb->(MT->translate("Saving asset ('[_1]')...", $asset->label)); 
     472    $cb->($plugin->translate("Saving asset ('[_1]')...", $asset->label)); 
    469473    $asset->add_tags(@tags) if 0 < scalar(@tags); 
    470     $cb->(MT->translate(" and asset will be tagged ('[_1]')...", join(',', @tags))); 
     474    $cb->($plugin->translate(" and asset will be tagged ('[_1]')...", join(',', @tags))); 
    471475    if ($asset->save) { 
    472         $cb->(MT->translate("ok (ID [_1])", $asset->id) . "\n"); 
     476        $cb->($plugin->translate("ok (ID [_1])", $asset->id) . "\n"); 
    473477        if ( exists($self->{'wp_download'}) && $self->{'wp_download'} ) { 
    474478            _get_item_via_http($asset->id, $old_url); 
    475479        } 
    476480    } else { 
    477         $cb->(MT->translate("failed") . "\n"); 
    478         die MT->translate( 
     481        $cb->($plugin->translate("failed") . "\n"); 
     482        die $plugin->translate( 
    479483            "Saving entry failed: [_1]", $asset->errstr); 
    480484    } 
     
    484488    my $self = shift; 
    485489    my ($class_type, $hashes) = @_; 
     490    my $plugin = MT->component('WXRImporter/WXRImporter.pl'); 
    486491 
    487492    my $blog = $self->{blog}; 
     
    643648    )) 
    644649    { 
    645         $cb->(MT->translate("Duplicate entry ('[_1]') found.  Skipping.", $post->title)); 
     650        $cb->($plugin->translate("Duplicate entry ('[_1]') found.  Skipping.", $post->title)); 
    646651        $cb->("\n"); 
    647652        return 1; 
     
    655660    # Now save the entry/page. 
    656661    if ('entry' eq $class_type) { 
    657         $cb->(MT->translate("Saving entry ('[_1]')...", $post->title)); 
     662        $cb->($plugin->translate("Saving entry ('[_1]')...", $post->title)); 
    658663    } elsif ('page' eq $class_type) { 
    659         $cb->(MT->translate("Saving page ('[_1]')...", $post->title)); 
     664        $cb->($plugin->translate("Saving page ('[_1]')...", $post->title)); 
    660665    } 
    661666    if ($post->save) { 
    662         $cb->(MT->translate("ok (ID [_1])", $post->id) . "\n"); 
     667        $cb->($plugin->translate("ok (ID [_1])", $post->id) . "\n"); 
    663668    } else { 
    664         $cb->(MT->translate("failed") . "\n"); 
    665         die MT->translate( 
     669        $cb->($plugin->translate("failed") . "\n"); 
     670        die $plugin->translate( 
    666671            "Save failed: [_1]", $post->errstr); 
    667672    } 
     
    676681        $place->category_id($primary_cat_id); 
    677682        $place->save 
    678             or die MT->translate( 
     683            or die $plugin->translate( 
    679684                "Saving placement failed: [_1]", $place->errstr); 
    680685        delete $cat_ids{$primary_cat_id}; 
     
    688693        $place->category_id($cat_id); 
    689694        $place->save 
    690             or die MT->translate( 
     695            or die $plugin->translate( 
    691696                "Saving placement failed: [_1]", $place->errstr); 
    692697    } 
     
    695700    for my $comment (@{$feedbacks->{comments}}) { 
    696701        $comment->entry_id($post->id); 
    697         $cb->(MT->translate("Creating new comment (from '[_1]')...", $comment->author)); 
     702        $cb->($plugin->translate("Creating new comment (from '[_1]')...", $comment->author)); 
    698703        if ($comment->save) { 
    699             $cb->(MT->translate("ok (ID [_1])", $comment->id) . "\n"); 
     704            $cb->($plugin->translate("ok (ID [_1])", $comment->id) . "\n"); 
    700705        } else { 
    701             $cb->(MT->translate("failed") . "\n"); 
    702             die MT->translate( 
     706            $cb->($plugin->translate("failed") . "\n"); 
     707            die $plugin->translate( 
    703708                "Saving comment failed: [_1]", $comment->errstr); 
    704709        } 
     
    720725        $tb->save; 
    721726        unless ($tb) { 
    722             die MT->translate("Entry has no MT::Trackback object!"); 
     727            die $plugin->translate("Entry has no MT::Trackback object!"); 
    723728        } 
    724729        $post->trackback($tb); 
    725730        for my $ping (@{$feedbacks->{trackbacks}}) { 
    726731            $ping->tb_id($tb->id); 
    727             $cb->(MT->translate("Creating new ping ('[_1]')...", $ping->title)); 
     732            $cb->($plugin->translate("Creating new ping ('[_1]')...", $ping->title)); 
    728733            if ($ping->save) { 
    729                 $cb->(MT->translate("ok (ID [_1])", $ping->id) . "\n"); 
     734                $cb->($plugin->translate("ok (ID [_1])", $ping->id) . "\n"); 
    730735            } else { 
    731                 $cb->(MT->translate("failed") . "\n"); 
    732                 die MT->translate( 
     736                $cb->($plugin->translate("failed") . "\n"); 
     737                die $plugin->translate( 
    733738                    "Saving ping failed: [_1]", $ping->errstr); 
    734739            } 
     
    741746    my $self = shift; 
    742747    my ($cb, $value) = @_; 
     748    my $plugin = MT->component('WXRImporter/WXRImporter.pl'); 
    743749 
    744750    my $author = $self->{author}; 
     
    759765                $author->password('(none)'); 
    760766            } 
    761             $cb->(MT->translate("Creating new user ('[_1]')...", $value)); 
     767            $cb->($plugin->translate("Creating new user ('[_1]')...", $value)); 
    762768            if ($author->save) { 
    763                 $cb->(MT->translate("ok") . "\n"); 
     769                $cb->($plugin->translate("ok") . "\n"); 
    764770            } else { 
    765                 $cb->(MT->translate("failed") . "\n"); 
    766                 die MT->translate( 
     771                $cb->($plugin->translate("failed") . "\n"); 
     772                die $plugin->translate( 
    767773                    "Saving user failed: [_1]", $author->errstr); 
    768774            } 
    769             $cb->(MT->translate("Assigning permissions for new user...")); 
     775            $cb->($plugin->translate("Assigning permissions for new user...")); 
    770776            require MT::Role; 
    771777            require MT::Association; 
     
    774780                my $assoc; 
    775781                if ($assoc = MT::Association->link($author => $role => $self->{blog})) { 
    776                     $cb->(MT->translate("ok") . "\n"); 
     782                    $cb->($plugin->translate("ok") . "\n"); 
    777783                } else { 
    778                     $cb->(MT->translate("failed") . "\n"); 
    779                     die MT->translate( 
     784                    $cb->($plugin->translate("failed") . "\n"); 
     785                    die $plugin->translate( 
    780786                         "Saving permission failed: [_1]", $assoc->errstr); 
    781787                }