]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Twitter-compatible API - running all strings through gettext() now
authorzach <zach@controlyourself.ca>
Tue, 19 Aug 2008 00:29:03 +0000 (20:29 -0400)
committerzach <zach@controlyourself.ca>
Tue, 19 Aug 2008 00:29:03 +0000 (20:29 -0400)
darcs-hash:20080819002903-462f3-94e62891db9b9de049a918034742e545f663e840.gz

actions/twitapiaccount.php
actions/twitapiblocks.php
actions/twitapidirect_messages.php
actions/twitapifavorites.php
actions/twitapifriendships.php
actions/twitapihelp.php
actions/twitapinotifications.php
actions/twitapistatuses.php
actions/twitapiusers.php
lib/twitterapi.php

index 0a57ad91c3c759ecb909174dee4f01082a7d5521..716ddd1543a3d3c22b7fbb8c3bc95131a68ef121 100644 (file)
@@ -46,7 +46,7 @@ class TwitapiaccountAction extends TwitterapiAction {
                        header('Content-Type: application/json; charset=utf-8');                
                        print '{"authorized":true}';
                } else {
-                       common_user_error("API method not found!", $code=404);
+                       common_user_error(_('API method not found!'), $code=404);
                }
                        
                exit();
@@ -54,7 +54,7 @@ class TwitapiaccountAction extends TwitterapiAction {
        
        function end_session($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }
        
@@ -65,9 +65,8 @@ class TwitapiaccountAction extends TwitterapiAction {
 
                if (!is_null($location) && strlen($location) > 255) {
                        
-                       // XXX: But Twitter just truncates and runs with it. -- Zach
-                       header('HTTP/1.1 406 Not Acceptable');                  
-                       print "That's too long. Max notice size is 255 chars.\n";
+                       // XXX: But Twitter just truncates and runs with it. -- Zach                    
+                       $this->client_error(_('That\'s too long. Max notice size is 255 chars.'), 406, $apidate['content-type']);
                        exit();
                }
                
@@ -106,13 +105,13 @@ class TwitapiaccountAction extends TwitterapiAction {
 
        function update_delivery_device($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }
        
        function rate_limit_status($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }
 }
\ No newline at end of file
index a498d2038d56889e1aaf2433bdf77ae96c8f4781..0fdbba199f1ad710782e39344c10d0021b38ebd8 100644 (file)
@@ -25,13 +25,13 @@ class TwitapiblocksAction extends TwitterapiAction {
 
        function create($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }
        
        function destroy($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }
        
index 9a84082e6d1293be39d9b628062b45402936ff55..aad055fbf26755169d3d7ab4fb23d643533f6f2f 100644 (file)
@@ -40,26 +40,26 @@ class Twitapidirect_messagesAction extends TwitterapiAction {
 
        function direct_messages($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }
        
        function sent($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }
        
        # had to change this from "new" to "create" to avoid PHP reserved word  
        function create($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }
                
        function destroy($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }
        
index 4de5676034764fde61fb7db195398030560e0b09..b5380bd948c5ecfa7ba8797e4f56fd452c57d101 100644 (file)
@@ -38,19 +38,19 @@ class TwitapifavoritesAction extends TwitterapiAction {
 
        function favorites($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }
 
        function create($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }
        
        function destroy($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }       
 
index 05c192ea6fc8bc46938c64d5a60b2dac2539a9bf..ae15d171e7c95e0233b2f26a0bc5484f477934b8 100644 (file)
@@ -52,7 +52,8 @@ class TwitapifriendshipsAction extends TwitterapiAction {
                $user = $apidata['user'];
                
                if ($user->isSubscribed($other)) {
-                       $this->client_error("Could not follow user: $other->nickname is already on your list.", 403, $apidata['content-type']);
+                       $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname);
+                       $this->client_error($errmsg, 403, $apidata['content-type']);
                        exit();
                }
                
@@ -67,7 +68,8 @@ class TwitapifriendshipsAction extends TwitterapiAction {
                $result = $sub->insert();
 
                if (!$result) {
-                       $this->client_error("Could not follow user: $other->nickname.", 400, $apidata['content-type']);                 
+                       $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname);
+                       $this->client_error($errmsg, 400, $apidata['content-type']);                    
                        exit();
                }
                
index 7695190fca1f6212bf9894b9e17510383bd6657c..2ac4178de8d8ae4a83b634032433acbf0e52fc8c 100644 (file)
@@ -42,14 +42,14 @@ class TwitapihelpAction extends TwitterapiAction {
                        print '"ok"';
                        $this->end_document('json');
                } else {
-                       common_user_error("API method not found!", $code=404);
+                       common_user_error(_('API method not found!'), $code=404);
                }
                exit();
        }
 
        function downtime_schedule($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }
        
index 95fe550b1266a55b86100a4ec6014cd42eb8e270..9e3cc15c424366bd05968c0065a0c0477523dd1f 100644 (file)
@@ -26,13 +26,13 @@ class TwitapinotificationsAction extends TwitterapiAction {
 
        function follow($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }
        
        function leave($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
                exit();
        }
        
index 92c6fbb634a41fe3f8dc8693bf1b697133ca2393..6a63dd03778e07da23fa36497d56509c033701d5 100644 (file)
@@ -82,12 +82,12 @@ class TwitapistatusesAction extends TwitterapiAction {
                                        $this->show_json_timeline($notice);
                                        break;
                                default:
-                                       common_user_error("API method not found!", $code = 404);
+                                       common_user_error(_('API method not found!'), $code = 404);
                                        break;
                        }
 
                } else {
-                       common_server_error('Couldn\'t find any statuses.', $code = 503);
+                       common_server_error(_('Couldn\'t find any statuses.'), $code = 503);
                }
 
                exit();
@@ -253,7 +253,7 @@ class TwitapistatusesAction extends TwitterapiAction {
                        $this->show_json_timeline($notice);
                        break;
                 default:
-                       common_user_error("API method not found!", $code = 404);
+                       common_user_error(_('API method not found!'), $code = 404);
                }
 
                exit();
@@ -364,7 +364,7 @@ class TwitapistatusesAction extends TwitterapiAction {
                        $this->show_json_timeline($notice);
                        break;
                 default:
-                       common_user_error("API method not found!", $code = 404);
+                       common_user_error(_('API method not found!'), $code = 404);
                }
 
                exit();
@@ -397,7 +397,7 @@ class TwitapistatusesAction extends TwitterapiAction {
                    // as "truncated."  Sending this error may screw up some clients
                    // that assume Twitter will truncate for them.  Should we just
                    // truncate too? -- Zach
-                       $this->client_error('That\'s too long. Max notice size is 140 chars.', $code = 406, $apidata['content-type']);
+                       $this->client_error(_('That\'s too long. Max notice size is 140 chars.'), $code = 406, $apidata['content-type']);
                        exit();
                }
 
@@ -411,7 +411,7 @@ class TwitapistatusesAction extends TwitterapiAction {
                        if ($reply) {
                                $reply_to = $in_reply_to_status_id;
                        } else {
-                               $this->client_error('Not found', $code = 404, $apidata['content-type']);
+                               $this->client_error(_('Not found'), $code = 404, $apidata['content-type']);
                                exit();
                        }
                }
@@ -521,7 +521,7 @@ class TwitapistatusesAction extends TwitterapiAction {
                        $this->show_json_timeline($notices);
                        break;
                 default:
-                       common_user_error("API method not found!", $code = 404);
+                       common_user_error(_('API method not found!'), $code = 404);
                }
 
 
@@ -548,6 +548,7 @@ class TwitapistatusesAction extends TwitterapiAction {
 
        */
        function destroy($args, $apidata) {
+       
                parent::handle($args);
                common_server_error("API method under construction.", $code=501);
        }
@@ -702,7 +703,7 @@ class TwitapistatusesAction extends TwitterapiAction {
        */
        function featured($args, $apidata) {
                parent::handle($args);
-               common_server_error("API method under construction.", $code=501);
+               common_server_error(_('API method under construction.'), $code=501);
        }
 
        function get_user($id, $apidata) {
@@ -716,4 +717,3 @@ class TwitapistatusesAction extends TwitterapiAction {
        }
 }
 
-
index d66dc8863280ddbc296ab3fbaaebbcd3910eafb3..233de3c217d790a7de1d350bc2d254e6e999f38d 100644 (file)
@@ -72,7 +72,7 @@ class TwitapiusersAction extends TwitterapiAction {
 
                if (!$user) {
                        // XXX: Twitter returns a random(?) user instead of throwing and err! -- Zach
-                       $this->client_error("User not found.", 404, $apidata['content-type']);
+                       $this->client_error(_('User not found.'), 404, $apidata['content-type']);
                        exit();
                }
                
@@ -119,7 +119,7 @@ class TwitapiusersAction extends TwitterapiAction {
                        $this->show_twitter_json_users($twitter_user);
                        $this->end_document('json');
                } else {
-                       common_user_error("API method not found!", $code = 404);
+                       common_user_error(_('API method not found!'), $code = 404);
                }
                        
                exit();
index 8b4c24cabc77f8152b2e75c3cacc0275c48e0c7d..f06c1d18868d2b065f7b00d012e9447ac652e6ec 100644 (file)
@@ -245,7 +245,7 @@ class TwitterapiAction extends Action {
                        $this->init_twitter_atom();
                        break;
                 default:
-                       $this->client_error(_('Unsupported type'));
+                       $this->client_error(_('Not a supported data format.'));
                        break;
                }
                
@@ -266,7 +266,7 @@ class TwitterapiAction extends Action {
                        $this->end_twitter_rss();
                        break;
                 default:
-                       $this->client_error(_('Unsupported type'));
+                       $this->client_error(_('Not a supported data format.'));
                        break;
                }
                return;
@@ -351,7 +351,7 @@ class TwitterapiAction extends Action {
                        $this->show_twitter_json_users($profile_array);
                        break;
                 default:
-                       $this->client_error(_('not a supported data format'));
+                       $this->client_error(_('Not a supported data format.'));
                        return;
                }
                return;