Make WordPress Core

Changeset 5166 for trunk/xmlrpc.php


Ignore:
Timestamp:
04/01/2007 03:59:50 PM (18 years ago)
Author:
ryan
Message:

Translate APP and XMLRPC errors. Props nbachiyski. fixes #3997

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xmlrpc.php

    r5115 r5166  
    141141    function login_pass_ok($user_login, $user_pass) {
    142142        if (!user_pass_ok($user_login, $user_pass)) {
    143             $this->error = new IXR_Error(403, 'Bad login/pass combination.');
     143            $this->error = new IXR_Error(403, __('Bad login/pass combination.'));
    144144            return false;
    145145        }
     
    242242        // If the page doesn't exist indicate that.
    243243        else {
    244             return(new IXR_Error(404, "Sorry, no such page."));
     244            return(new IXR_Error(404, __("Sorry, no such page.")));
    245245        }
    246246    }
     
    303303        $user = set_current_user(0, $username);
    304304        if(!current_user_can("publish_pages")) {
    305             return(new IXR_Error(401, "Sorry, you can not add new pages."));
     305            return(new IXR_Error(401, __("Sorry, you can not add new pages.")));
    306306        }
    307307
     
    336336            || ($actual_page["post_type"] != "page")
    337337        ) {
    338             return(new IXR_Error(404, "Sorry, no such page."));
     338            return(new IXR_Error(404, __("Sorry, no such page.")));
    339339        }
    340340
     
    342342        set_current_user(0, $username);
    343343        if(!current_user_can("delete_page", $page_id)) {
    344             return(new IXR_Error(401, "Sorry, you do not have the right to delete this page."));
     344            return(new IXR_Error(401, __("Sorry, you do not have the right to delete this page.")));
    345345        }
    346346
     
    348348        $result = wp_delete_post($page_id);
    349349        if(!$result) {
    350             return(new IXR_Error(500, "Failed to delete the page."));
     350            return(new IXR_Error(500, __("Failed to delete the page.")));
    351351        }
    352352
     
    377377            || ($actual_page["post_type"] != "page")
    378378        ) {
    379             return(new IXR_Error(404, "Sorry, no such page."));
     379            return(new IXR_Error(404, __("Sorry, no such page.")));
    380380        }
    381381
     
    383383        set_current_user(0, $username);
    384384        if(!current_user_can("edit_page", $page_id)) {
    385             return(new IXR_Error(401, "Sorry, you do not have the right to edit this page."));
     385            return(new IXR_Error(401, __("Sorry, you do not have the right to edit this page.")));
    386386        }
    387387
     
    482482        set_current_user(0, $username);
    483483        if(!current_user_can("manage_categories", $page_id)) {
    484             return(new IXR_Error(401, "Sorry, you do not have the right to add a category."));
     484            return(new IXR_Error(401, __("Sorry, you do not have the right to add a category.")));
    485485        }
    486486
     
    514514        $cat_id = wp_insert_category($new_category);
    515515        if(!$cat_id) {
    516             return(new IXR_Error(500, "Sorry, the new category failed."));
     516            return(new IXR_Error(500, __("Sorry, the new category failed.")));
    517517        }
    518518
     
    667667
    668668        if (!$posts_list) {
    669             $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
     669            $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.'));
    670670            return $this->error;
    671671        }
     
    714714      set_current_user(0, $user_login);
    715715      if ( !current_user_can('edit_themes') ) {
    716         return new IXR_Error(401, 'Sorry, this user can not edit the template.');
     716        return new IXR_Error(401, __('Sorry, this user can not edit the template.'));
    717717      }
    718718
     
    749749      set_current_user(0, $user_login);
    750750      if ( !current_user_can('edit_themes') ) {
    751         return new IXR_Error(401, 'Sorry, this user can not edit the template.');
     751        return new IXR_Error(401, __('Sorry, this user can not edit the template.'));
    752752      }
    753753
     
    760760        fclose($f);
    761761      } else {
    762         return new IXR_Error(500, 'Either the file is not writable, or something wrong happened. The file has not been updated.');
     762        return new IXR_Error(500, __('Either the file is not writable, or something wrong happened. The file has not been updated.'));
    763763      }
    764764
     
    787787      $user = set_current_user(0, $user_login);
    788788      if ( !current_user_can($cap) )
    789         return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
     789        return new IXR_Error(401, __('Sorry, you can not post on this weblog or category.'));
    790790
    791791      $post_status = ($publish) ? 'publish' : 'draft';
     
    805805
    806806      if (!$post_ID) {
    807         return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.');
     807        return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));
    808808      }
    809809      $this->attach_uploads( $post_ID, $post_content );
     
    835835
    836836      if (!$actual_post) {
    837         return new IXR_Error(404, 'Sorry, no such post.');
     837        return new IXR_Error(404, __('Sorry, no such post.'));
    838838      }
    839839
     
    842842      set_current_user(0, $user_login);
    843843      if ( !current_user_can('edit_post', $post_ID) )
    844         return new IXR_Error(401, 'Sorry, you do not have the right to edit this post.');
     844        return new IXR_Error(401, __('Sorry, you do not have the right to edit this post.'));
    845845
    846846      extract($actual_post);
    847847
    848848      if ( ('publish' == $post_status) && !current_user_can('publish_posts') )
    849         return new IXR_Error(401, 'Sorry, you do not have the right to publish this post.');
     849        return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.'));
    850850
    851851      $post_title = xmlrpc_getposttitle($content);
     
    858858
    859859      if (!$result) {
    860         return new IXR_Error(500, 'For some strange yet very annoying reason, this post could not be edited.');
     860        return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be edited.'));
    861861      }
    862862      $this->attach_uploads( $ID, $post_content );
     
    885885
    886886      if (!$actual_post) {
    887         return new IXR_Error(404, 'Sorry, no such post.');
     887        return new IXR_Error(404, __('Sorry, no such post.'));
    888888      }
    889889
    890890      set_current_user(0, $user_login);
    891891      if ( !current_user_can('edit_post', $post_ID) )
    892         return new IXR_Error(401, 'Sorry, you do not have the right to delete this post.');
     892        return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.'));
    893893
    894894      $result = wp_delete_post($post_ID);
    895895
    896896      if (!$result) {
    897         return new IXR_Error(500, 'For some strange yet very annoying reason, this post could not be deleted.');
     897        return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be deleted.'));
    898898      }
    899899
     
    926926      $user = set_current_user(0, $user_login);
    927927      if ( !current_user_can('publish_posts') )
    928         return new IXR_Error(401, 'Sorry, you can not post on this weblog or category.');
     928        return new IXR_Error(401, __('Sorry, you can not post on this weblog or category.'));
    929929
    930930        // The post_type defaults to post, but could also be page.
     
    977977                    break;
    978978                default:
    979                     return(new IXR_Error(401, "Invalid post type."));
     979                    return(new IXR_Error(401, __("Invalid post type.")));
    980980                    break;
    981981            }
     
    10331033
    10341034      if (!$post_ID) {
    1035         return new IXR_Error(500, 'Sorry, your entry could not be posted. Something wrong happened.');
     1035        return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.'));
    10361036      }
    10371037
     
    10871087      // Edit page caps are checked in editPage.  Just check post here.
    10881088      if ( ( 'post' == $post_type ) && !current_user_can('edit_post', $post_ID) )
    1089         return new IXR_Error(401, 'Sorry, you can not edit this post.');
     1089        return new IXR_Error(401, __('Sorry, you can not edit this post.'));
    10901090
    10911091      $postdata = wp_get_single_post($post_ID, ARRAY_A);
     
    10951095        // created (which was the old behavior).
    10961096        if(empty($postdata["ID"])) {
    1097             return(new IXR_Error(404, "Invalid post id."));
     1097            return(new IXR_Error(404, __("Invalid post id.")));
    10981098        }
    10991099
     
    11381138                    break;
    11391139                default:
    1140                     return(new IXR_Error(401, "Invalid post type."));
     1140                    return(new IXR_Error(401, __("Invalid post type.")));
    11411141                    break;
    11421142            }
     
    11741174      if ( ('publish' == $post_status) ) {
    11751175        if ( ( 'page' == $post_type ) && !current_user_can('publish_pages') )
    1176             return new IXR_Error(401, 'Sorry, you do not have the right to publish this page.');
     1176            return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.'));
    11771177        else if ( !current_user_can('publish_posts') )
    1178             return new IXR_Error(401, 'Sorry, you do not have the right to publish this post.');
     1178            return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.'));
    11791179      }
    11801180
     
    12071207      $result = wp_update_post($newpost);
    12081208      if (!$result) {
    1209         return new IXR_Error(500, 'Sorry, your entry could not be edited. Something wrong happened.');
     1209        return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.'));
    12101210      }
    12111211      $this->attach_uploads( $ID, $post_content );
     
    12761276        return $resp;
    12771277      } else {
    1278         return new IXR_Error(404, 'Sorry, no such post.');
     1278        return new IXR_Error(404, __('Sorry, no such post.'));
    12791279      }
    12801280    }
     
    12981298
    12991299        if (!$posts_list) {
    1300             $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
     1300            $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.'));
    13011301            return $this->error;
    13021302        }
     
    14291429        if ( !current_user_can('upload_files') ) {
    14301430            logIO('O', '(MW) User does not have upload_files capability');
    1431             $this->error = new IXR_Error(401, 'You are not allowed to upload files to this site.');
     1431            $this->error = new IXR_Error(401, __('You are not allowed to upload files to this site.'));
    14321432            return $this->error;
    14331433        }
     
    14831483
    14841484        if (!$posts_list) {
    1485             $this->error = new IXR_Error(500, 'Either there are no posts, or something went wrong.');
     1485            $this->error = new IXR_Error(500, __('Either there are no posts, or something went wrong.'));
    14861486            return $this->error;
    14871487        }
     
    15861586        set_current_user(0, $user_login);
    15871587        if ( !current_user_can('edit_post', $post_ID) )
    1588             return new IXR_Error(401, 'Sorry, you can not edit this post.');
     1588            return new IXR_Error(401, __('Sorry, you can not edit this post.'));
    15891589
    15901590        foreach($categories as $cat) {
     
    16271627
    16281628        if (!$actual_post) {
    1629             return new IXR_Error(404, 'Sorry, no such post.');
     1629            return new IXR_Error(404, __('Sorry, no such post.'));
    16301630        }
    16311631
     
    16681668        set_current_user(0, $user_login);
    16691669        if ( !current_user_can('edit_post', $post_ID) )
    1670             return new IXR_Error(401, 'Sorry, you can not edit this post.');
     1670            return new IXR_Error(401, __('Sorry, you can not edit this post.'));
    16711671
    16721672        $postdata = wp_get_single_post($post_ID,ARRAY_A);
     
    17091709        $pos1 = strpos($pagelinkedto, str_replace(array('http://www.','http://','https://www.','https://'), '', get_option('home')));
    17101710        if( !$pos1 )
    1711                 return new IXR_Error(0, 'Is there no link to us?');
     1711                return new IXR_Error(0, __('Is there no link to us?'));
    17121712
    17131713        // let's find which post is linked to
     
    17621762
    17631763        if ( $post_ID == url_to_postid($pagelinkedfrom) )
    1764             return new IXR_Error(0, 'The source URL and the target URL cannot both point to the same resource.');
     1764            return new IXR_Error(0, __('The source URL and the target URL cannot both point to the same resource.'));
    17651765
    17661766        // Check if pings are on
     
    17721772
    17731773        if ( $wpdb->num_rows ) // We already have a Pingback from this URL
    1774             return new IXR_Error(48, 'The pingback has already been registered.');
     1774            return new IXR_Error(48, __('The pingback has already been registered.'));
    17751775
    17761776        // very stupid, but gives time to the 'from' server to publish !
     
    17801780        $linea = wp_remote_fopen( $pagelinkedfrom );
    17811781        if ( !$linea )
    1782             return new IXR_Error(16, 'The source URL does not exist.');
     1782            return new IXR_Error(16, __('The source URL does not exist.'));
    17831783
    17841784        // Work around bug in strip_tags():
     
    17901790        $title = $matchtitle[1];
    17911791        if ( empty( $title ) )
    1792             return new IXR_Error(32, 'We cannot find a title on that page.');
     1792            return new IXR_Error(32, __('We cannot find a title on that page.'));
    17931793
    17941794        $linea = strip_tags( $linea, '<a>' ); // just keep the tag we need
     
    18261826
    18271827        if ( empty($context) ) // Link to target not found
    1828             return new IXR_Error(17, 'The source URL does not contain a link to the target URL, and so cannot be used as a source.');
     1828            return new IXR_Error(17, __('The source URL does not contain a link to the target URL, and so cannot be used as a source.'));
    18291829
    18301830        $pagelinkedfrom = preg_replace('#&([^amp\;])#is', '&amp;$1', $pagelinkedfrom);
     
    18731873        if (!$actual_post) {
    18741874            // No such post = resource not found
    1875             return new IXR_Error(32, 'The specified target URL does not exist.');
     1875            return new IXR_Error(32, __('The specified target URL does not exist.'));
    18761876        }
    18771877
Note: See TracChangeset for help on using the changeset viewer.