Completed
Push — master ( f56d28...9862b6 )
by Aitor Riba
02:11
created
src/Translation.php 3 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 
36 36
         // Checking whether from_lang or to_lang are set as app_locale.
37 37
 
38
-        if ($this->from == 'app_locale') {$this->from = App::getLocale();}
38
+        if ($this->from == 'app_locale') {$this->from = App::getLocale(); }
39 39
 
40
-        if ($this->to == 'app_locale') {$this->to = App::getLocale();}
40
+        if ($this->to == 'app_locale') {$this->to = App::getLocale(); }
41 41
     }
42 42
 
43 43
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         }
116 116
 
117 117
 
118
-        $available_transoltors = ['apertium', 'mymemory'];
118
+        $available_transoltors = [ 'apertium', 'mymemory' ];
119 119
 
120 120
         // Checks available translators.
121 121
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
          // Check if it can be translated from online sources.
146 146
 
147 147
          $host = 'api.mymemory.translated.net';
148
-         if($socket =@ fsockopen($host, 80, $errno, $errstr, 30)) {
148
+         if ($socket = @ fsockopen($host, 80, $errno, $errstr, 30)) {
149 149
 
150 150
              // Host online
151 151
              $urlString = urlencode($this->string);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
                  if ($this->debug == true) {
160 160
                      $details = $data->responseDetails;
161 161
                      if ($data->responseStatus == 403) {
162
-                         $details =($data->responseDetails);
162
+                         $details = ($data->responseDetails);
163 163
                      }
164 164
                      $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.": ".$details."</font>";
165 165
                  }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                  $words = explode(' ', $transObtained);
180 180
                  foreach ($words as $word) {
181 181
                      if ($word != '') {
182
-                         if ($word[0] == '*') {
182
+                         if ($word[ 0 ] == '*') {
183 183
                              $errors = $errors.substr($word, 1).', ';
184 184
                          }
185 185
                      }
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         // Check if it can be translated from online sources.
216 216
 
217 217
         $host = 'api.apertium.org';
218
-        if($socket =@ fsockopen($host, 80, $errno, $errstr, 30)) {
218
+        if ($socket = @ fsockopen($host, 80, $errno, $errstr, 30)) {
219 219
 
220 220
             // Host online
221 221
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                 $words = explode(' ', $transObtained);
248 248
                 foreach ($words as $word) {
249 249
                     if ($word != '') {
250
-                        if ($word[0] == '*') {
250
+                        if ($word[ 0 ] == '*') {
251 251
                             $errors = $errors.substr($word, 1).', ';
252 252
                         }
253 253
                     }
Please login to merge, or discard this patch.
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -138,67 +138,67 @@
 block discarded – undo
138 138
     /**
139 139
      * Get translation from mymemory API.
140 140
      */
141
-     private function mymemoryTrans()
142
-     {
143
-         // Check if it can be translated from online sources.
144
-
145
-         $host = 'api.mymemory.translated.net';
146
-         if($socket =@ fsockopen($host, 80, $errno, $errstr, 30)) {
147
-
148
-             // Host online
149
-             $urlString = urlencode($this->string);
150
-             $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to";
151
-             $json = file_get_contents($url);
152
-             $data = json_decode($json);
153
-
154
-             // Checking response status
155
-
156
-             if ($data->responseStatus != 200) {
157
-                 if ($this->debug == true) {
158
-                     $details = $data->responseDetails;
159
-                     if ($data->responseStatus == 403) {
160
-                         $details =($data->responseDetails);
161
-                     }
162
-                     $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.": ".$details."</font>";
163
-                 }
164
-
165
-                 return;
166
-             }
167
-
168
-             $transObtained = $data->responseData->translatedText;
169
-
170
-             $this->translation = ucfirst(strtolower(trim($transObtained)));
171
-
172
-
173
-             // Checking debug setting to determinate how to output translation
174
-
175
-             if ($this->debug === true) {
176
-                 $errors = '';
177
-                 $words = explode(' ', $transObtained);
178
-                 foreach ($words as $word) {
179
-                     if ($word != '') {
180
-                         if ($word[0] == '*') {
181
-                             $errors = $errors.substr($word, 1).', ';
182
-                         }
183
-                     }
184
-                 }
185
-
186
-                 if ($errors == '') {
187
-                     $this->translation = "<font style='color:#00CC00;'>".$this->translation."</font>";
188
-                 } else {
189
-                     $this->translation = "<font style='color:orange;'>Unknoun words: ".substr($errors, 0, -2)."</font>";
190
-                 }
191
-             }
192
-
193
-             fclose($socket);
194
-             return;
195
-
196
-         } else {
197
-
198
-             //host offline
199
-             $this->hostDown();
200
-         }
201
-     }
141
+        private function mymemoryTrans()
142
+        {
143
+            // Check if it can be translated from online sources.
144
+
145
+            $host = 'api.mymemory.translated.net';
146
+            if($socket =@ fsockopen($host, 80, $errno, $errstr, 30)) {
147
+
148
+                // Host online
149
+                $urlString = urlencode($this->string);
150
+                $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to";
151
+                $json = file_get_contents($url);
152
+                $data = json_decode($json);
153
+
154
+                // Checking response status
155
+
156
+                if ($data->responseStatus != 200) {
157
+                    if ($this->debug == true) {
158
+                        $details = $data->responseDetails;
159
+                        if ($data->responseStatus == 403) {
160
+                            $details =($data->responseDetails);
161
+                        }
162
+                        $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.": ".$details."</font>";
163
+                    }
164
+
165
+                    return;
166
+                }
167
+
168
+                $transObtained = $data->responseData->translatedText;
169
+
170
+                $this->translation = ucfirst(strtolower(trim($transObtained)));
171
+
172
+
173
+                // Checking debug setting to determinate how to output translation
174
+
175
+                if ($this->debug === true) {
176
+                    $errors = '';
177
+                    $words = explode(' ', $transObtained);
178
+                    foreach ($words as $word) {
179
+                        if ($word != '') {
180
+                            if ($word[0] == '*') {
181
+                                $errors = $errors.substr($word, 1).', ';
182
+                            }
183
+                        }
184
+                    }
185
+
186
+                    if ($errors == '') {
187
+                        $this->translation = "<font style='color:#00CC00;'>".$this->translation."</font>";
188
+                    } else {
189
+                        $this->translation = "<font style='color:orange;'>Unknoun words: ".substr($errors, 0, -2)."</font>";
190
+                    }
191
+                }
192
+
193
+                fclose($socket);
194
+                return;
195
+
196
+            } else {
197
+
198
+                //host offline
199
+                $this->hostDown();
200
+            }
201
+        }
202 202
 
203 203
     /**
204 204
      * Get translation from apertium API.
Please login to merge, or discard this patch.
Braces   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -127,9 +127,7 @@
 block discarded – undo
127 127
 
128 128
         if ($this->translator == 'apertium') {
129 129
             return $this->apertiumTrans();
130
-        }
131
-
132
-        elseif ($this->translator == 'mymemory') {
130
+        } elseif ($this->translator == 'mymemory') {
133 131
             return $this->mymemoryTrans();
134 132
         }
135 133
 
Please login to merge, or discard this patch.