Skip to content

Commit aa34e0c

Browse files
Merge pull request chriskacerguis#526 from softwarespot/master
Improvements with non-English developers in mind
2 parents 104b5c5 + ad26eee commit aa34e0c

24 files changed

+1868
-1796
lines changed

application/config/rest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,13 @@
477477
|
478478
*/
479479
$config['rest_ajax_only'] = FALSE;
480+
481+
/*
482+
|--------------------------------------------------------------------------
483+
| REST Language File
484+
|--------------------------------------------------------------------------
485+
|
486+
| Language file to load from the language directory
487+
|
488+
*/
489+
$config['rest_language'] = 'english';

application/controllers/Rest_server.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
defined('BASEPATH') OR exit('No direct script access allowed');
34

45
class Rest_server extends CI_Controller {

application/controllers/api/Example.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function users_get()
5656
// Set the response and exit
5757
$this->response([
5858
'status' => FALSE,
59-
'error' => 'No users were found'
59+
'message' => 'No users were found'
6060
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
6161
}
6262
}
@@ -96,7 +96,7 @@ public function users_get()
9696
{
9797
$this->set_response([
9898
'status' => FALSE,
99-
'error' => 'User could not be found'
99+
'message' => 'User could not be found'
100100
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
101101
}
102102
}

application/controllers/api/Key.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function index_put()
5252
{
5353
$this->response([
5454
'status' => FALSE,
55-
'error' => 'Could not save the key'
55+
'message' => 'Could not save the key'
5656
], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
5757
}
5858
}
@@ -73,7 +73,7 @@ public function index_delete()
7373
// It doesn't appear the key exists
7474
$this->response([
7575
'status' => FALSE,
76-
'error' => 'Invalid API key'
76+
'message' => 'Invalid API key'
7777
], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
7878
}
7979

@@ -83,7 +83,7 @@ public function index_delete()
8383
// Respond that the key was destroyed
8484
$this->response([
8585
'status' => TRUE,
86-
'success' => 'API key was deleted'
86+
'message' => 'API key was deleted'
8787
], REST_Controller::HTTP_NO_CONTENT); // NO_CONTENT (204) being the HTTP response code
8888
}
8989

@@ -104,7 +104,7 @@ public function level_post()
104104
// It doesn't appear the key exists
105105
$this->response([
106106
'status' => FALSE,
107-
'error' => 'Invalid API key'
107+
'message' => 'Invalid API key'
108108
], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
109109
}
110110

@@ -113,14 +113,14 @@ public function level_post()
113113
{
114114
$this->response([
115115
'status' => TRUE,
116-
'success' => 'API key was updated'
116+
'message' => 'API key was updated'
117117
], REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
118118
}
119119
else
120120
{
121121
$this->response([
122122
'status' => FALSE,
123-
'error' => 'Could not update the key level'
123+
'message' => 'Could not update the key level'
124124
], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
125125
}
126126
}
@@ -141,7 +141,7 @@ public function suspend_post()
141141
// It doesn't appear the key exists
142142
$this->response([
143143
'status' => FALSE,
144-
'error' => 'Invalid API key'
144+
'message' => 'Invalid API key'
145145
], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
146146
}
147147

@@ -150,14 +150,14 @@ public function suspend_post()
150150
{
151151
$this->response([
152152
'status' => TRUE,
153-
'success' => 'Key was suspended'
153+
'message' => 'Key was suspended'
154154
], REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
155155
}
156156
else
157157
{
158158
$this->response([
159159
'status' => FALSE,
160-
'error' => 'Could not suspend the user'
160+
'message' => 'Could not suspend the user'
161161
], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
162162
}
163163
}
@@ -179,7 +179,7 @@ public function regenerate_post()
179179
// It doesn't appear the key exists
180180
$this->response([
181181
'status' => FALSE,
182-
'error' => 'Invalid API key'
182+
'message' => 'Invalid API key'
183183
], REST_Controller::HTTP_BAD_REQUEST); // BAD_REQUEST (400) being the HTTP response code
184184
}
185185

@@ -201,7 +201,7 @@ public function regenerate_post()
201201
{
202202
$this->response([
203203
'status' => FALSE,
204-
'error' => 'Could not save the key'
204+
'message' => 'Could not save the key'
205205
], REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // INTERNAL_SERVER_ERROR (500) being the HTTP response code
206206
}
207207
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>403 Forbidden</title>
5+
</head>
6+
<body>
7+
8+
<p>Directory access is forbidden.</p>
9+
10+
</body>
11+
</html>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
/*
4+
* English language
5+
*/
6+
7+
$lang['text_rest_invalid_api_key'] = 'Invalid API key %s'; // %s is the REST API key
8+
$lang['text_rest_invalid_credentials'] = 'Invalid credentials';
9+
$lang['text_rest_ip_denied'] = 'IP denied';
10+
$lang['text_rest_ip_unauthorized'] = 'IP unauthorized';
11+
$lang['text_rest_unauthorized'] = 'Unauthorized';
12+
$lang['text_rest_ajax_only'] = 'Only Ajax requests are only allowed';
13+
$lang['text_rest_api_key_unauthorized'] = 'This API key does not have access to the requested controller';
14+
$lang['text_rest_api_key_permissions'] = 'This API key does not have enough permissions';
15+
$lang['text_rest_api_key_time_limit'] = 'This API key has reached the time limit for this method';
16+
$lang['text_rest_unknown_method'] = 'Unknown method';
17+
$lang['text_rest_unsupported'] = 'Unsupported protocol';

application/language/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>403 Forbidden</title>
5+
</head>
6+
<body>
7+
8+
<p>Directory access is forbidden.</p>
9+
10+
</body>
11+
</html>

0 commit comments

Comments
 (0)