WordPress.org

Make WordPress Core

Ticket #3997: xmlrpc-i18n.diff

File xmlrpc-i18n.diff, 15.0 KB (added by nbachiyski, 11 years ago)

XML-RPC i18n fixes

  • xmlrpc.php

     
    140140
    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                }
    146146                return true;
     
    241241                }
    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        }
    247247
     
    302302                // to add new pages.
    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
    308308                // Mark this as content for a page.
     
    335335                        !$actual_page
    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
    341341                // Set the user context and make sure they can delete pages.
    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
    347347                // Attempt to delete the page.
    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
    353353                return(true);
     
    376376                        !$actual_page
    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
    382382                // Set the user context and make sure they are allowed to edit pages.
    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
    388388                // Mark this as content for a page.
     
    481481                // allowed to add a category.
    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
    487487                // We need this to make use of the wp_insert_category()
     
    513513
    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
    519519                return($cat_id);
     
    666666                $posts_list = wp_get_recent_posts($num_posts);
    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                }
    672672
     
    713713
    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
    719719          /* warning: here we make the assumption that the weblog's URL is on the same server */
     
    748748
    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
    754754          /* warning: here we make the assumption that the weblog's URL is on the same server */
     
    759759            fwrite($f, $content);
    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
    765765          return true;
     
    786786          $cap = ($publish) ? 'publish_posts' : 'edit_posts';
    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';
    792792
     
    804804          $post_ID = wp_insert_post($post_data);
    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 );
    810810
     
    834834          $actual_post = wp_get_single_post($post_ID,ARRAY_A);
    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
    840840                $this->escape($actual_post);
    841841
    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);
    852852          $post_category = xmlrpc_getpostcategory($content);
     
    857857          $result = wp_update_post($postdata);
    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 );
    863863
     
    884884          $actual_post = wp_get_single_post($post_ID,ARRAY_A);
    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
    900900          return true;
     
    925925
    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.
    931931                $post_type = "post";
     
    976976                                        }
    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                        }
    982982                        $post_author = $content_struct["wp_author_id"];
     
    10321032          $post_ID = wp_insert_post($postdata);
    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
    10381038          $this->attach_uploads( $post_ID, $post_content );
     
    10861086
    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);
    10921092
     
    10941094                // now and return an error.  Other wise a new post will be
    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
    11001100          extract($postdata);
     
    11371137                                        }
    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                        }
    11431143                        $post_author = $content_struct["wp_author_id"];
     
    11731173
    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
    11811181          if ($post_more) {
     
    12061206
    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 );
    12121212
     
    12751275
    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        }
    12811281
     
    12971297                $posts_list = wp_get_recent_posts($num_posts);
    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                }
    13031303
     
    14281428                set_current_user(0, $user_login);
    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                }
    14341434
     
    14821482                $posts_list = wp_get_recent_posts($num_posts);
    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                }
    14881488
     
    15851585
    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) {
    15911591                        $catids[] = $cat['categoryId'];
     
    16261626                $actual_post = wp_get_single_post($post_ID, ARRAY_A);
    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
    16321632                $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID");
     
    16671667
    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);
    16731673
     
    17081708                // Check if the page linked to is in our site
    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
    17141714                // FIXME: does url_to_postid() cover all these cases already?
     
    17611761                        return new IXR_Error(33, 'The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.');
    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
    17671767                if ( 'closed' == $post->ping_status )
     
    17711771                $result = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post_ID' AND comment_author_url = '$pagelinkedfrom'");
    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 !
    17771777                sleep(1);
     
    17791779                // Let's check the remote site
    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():
    17851785                $linea = str_replace('<!DOC', '<DOC', $linea);
     
    17891789                preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle);
    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
    17951795
     
    18251825                }
    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);
    18311831
     
    18721872
    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
    18781878                $comments = $wpdb->get_results("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = $post_ID");