Index: trunk/extensions/Translate/utils/TranslationHelpers.php |
— | — | @@ -225,7 +225,7 @@ |
226 | 226 | try { |
227 | 227 | return call_user_func_array( $cb, $params ); |
228 | 228 | } catch ( TranslationHelperExpection $e ) { |
229 | | - return"<!-- Box $type not available: {$e->getMessage()} -->"; |
| 229 | + return "<!-- Box $type not available: {$e->getMessage()} -->"; |
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
— | — | @@ -313,6 +313,13 @@ |
314 | 314 | public function getSuggestionBox( $async = false ) { |
315 | 315 | global $wgTranslateTranslationServices; |
316 | 316 | |
| 317 | + $handlers = array( |
| 318 | + 'ttmserver' => 'getTTMServerBox', |
| 319 | + 'microsoft' => 'getMicrosoftSuggestion', |
| 320 | + 'apertium' => 'getApertiumSuggestion', |
| 321 | + ); |
| 322 | + |
| 323 | + $errors = ''; |
317 | 324 | $boxes = array(); |
318 | 325 | foreach ( $wgTranslateTranslationServices as $name => $config ) { |
319 | 326 | if ( $async === 'async' ) { |
— | — | @@ -321,12 +328,13 @@ |
322 | 329 | $config['timeout'] = $config['timeout-sync']; |
323 | 330 | } |
324 | 331 | |
325 | | - if ( $config['type'] === 'ttmserver' ) { |
326 | | - $boxes[] = $this->getTTMServerBox( $name, $config ); |
327 | | - } elseif ( $config['type'] === 'microsoft' ) { |
328 | | - $boxes[] = $this->getMicrosoftSuggestion( $name, $config ); |
329 | | - } elseif ( $config['type'] === 'apertium' ) { |
330 | | - $boxes[] = $this->getApertiumSuggestion( $name, $config ); |
| 332 | + if ( isset( $handlers[$config['type']] ) ) { |
| 333 | + $method = $handlers[$config['type']]; |
| 334 | + try { |
| 335 | + $boxes[] = $this->$method( $name, $config ); |
| 336 | + } catch ( TranslationHelperExpection $e ) { |
| 337 | + $errors .= "<!-- Box $name not available: {$e->getMessage()} -->\n"; |
| 338 | + } |
331 | 339 | } else { |
332 | 340 | throw new MWException( __METHOD__ . ": Unsupported type {$config['type']}" ); |
333 | 341 | } |
— | — | @@ -338,10 +346,10 @@ |
339 | 347 | // Enclose if there is more than one box |
340 | 348 | if ( count( $boxes ) ) { |
341 | 349 | $sep = Html::element( 'hr', array( 'class' => 'mw-translate-sep' ) ); |
342 | | - return TranslateUtils::fieldset( wfMsgHtml( 'translate-edit-tmsugs' ), |
| 350 | + return $errors . TranslateUtils::fieldset( wfMsgHtml( 'translate-edit-tmsugs' ), |
343 | 351 | implode( "$sep\n", $boxes ), array( 'class' => 'mw-translate-edit-tmsugs' ) ); |
344 | 352 | } else { |
345 | | - return null; |
| 353 | + return $errors; |
346 | 354 | } |
347 | 355 | } |
348 | 356 | |