https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113019
Revision: 113019
Author: nikerabbit
Date: 2012-03-05 11:53:33 +0000 (Mon, 05 Mar 2012)
Log Message:
-----------
Exception in one tm/mt module should not prevent other services from running
Modified Paths:
--------------
trunk/extensions/Translate/utils/TranslationHelpers.php
Modified: trunk/extensions/Translate/utils/TranslationHelpers.php
===================================================================
--- trunk/extensions/Translate/utils/TranslationHelpers.php 2012-03-05
11:53:21 UTC (rev 113018)
+++ trunk/extensions/Translate/utils/TranslationHelpers.php 2012-03-05
11:53:33 UTC (rev 113019)
@@ -225,7 +225,7 @@
try {
return call_user_func_array( $cb, $params );
} catch ( TranslationHelperExpection $e ) {
- return"<!-- Box $type not available: {$e->getMessage()}
-->";
+ return "<!-- Box $type not available:
{$e->getMessage()} -->";
}
}
@@ -313,6 +313,13 @@
public function getSuggestionBox( $async = false ) {
global $wgTranslateTranslationServices;
+ $handlers = array(
+ 'ttmserver' => 'getTTMServerBox',
+ 'microsoft' => 'getMicrosoftSuggestion',
+ 'apertium' => 'getApertiumSuggestion',
+ );
+
+ $errors = '';
$boxes = array();
foreach ( $wgTranslateTranslationServices as $name => $config )
{
if ( $async === 'async' ) {
@@ -321,12 +328,13 @@
$config['timeout'] = $config['timeout-sync'];
}
- if ( $config['type'] === 'ttmserver' ) {
- $boxes[] = $this->getTTMServerBox( $name,
$config );
- } elseif ( $config['type'] === 'microsoft' ) {
- $boxes[] = $this->getMicrosoftSuggestion(
$name, $config );
- } elseif ( $config['type'] === 'apertium' ) {
- $boxes[] = $this->getApertiumSuggestion( $name,
$config );
+ if ( isset( $handlers[$config['type']] ) ) {
+ $method = $handlers[$config['type']];
+ try {
+ $boxes[] = $this->$method( $name,
$config );
+ } catch ( TranslationHelperExpection $e ) {
+ $errors .= "<!-- Box $name not
available: {$e->getMessage()} -->\n";
+ }
} else {
throw new MWException( __METHOD__ . ":
Unsupported type {$config['type']}" );
}
@@ -338,10 +346,10 @@
// Enclose if there is more than one box
if ( count( $boxes ) ) {
$sep = Html::element( 'hr', array( 'class' =>
'mw-translate-sep' ) );
- return TranslateUtils::fieldset( wfMsgHtml(
'translate-edit-tmsugs' ),
+ return $errors . TranslateUtils::fieldset( wfMsgHtml(
'translate-edit-tmsugs' ),
implode( "$sep\n", $boxes ), array( 'class' =>
'mw-translate-edit-tmsugs' ) );
} else {
- return null;
+ return $errors;
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs