if (isset($_POST['save_setting']) && $_POST['save_setting'] != '') {
    $BaiduTransOptions['api_key'] = trim($_POST['api_key']);
    update_option('wp-autopost-baidu-trans-options', $BaiduTransOptions);
    $BaiduTransOptions = get_option('wp-autopost-baidu-trans-options');
}
?>
<div class="wrap">
  <div class="icon32" id="icon-wp-autopost"><br/></div>
  <h2><?php 
echo __('Baidu Translator Options', 'wp-autopost');
?>
</h2>

<?php 
if (isset($_POST['test_translate']) && $_POST['test_translate'] != '') {
    $response = autopostBaiduTranslator::translate($_POST['src_text'], $_POST['fromLanguage'], $_POST['toLanguage'], $BaiduTransOptions['api_key']);
    if (isset($response['err'])) {
        echo '<div class="error fade"><p><strong>' . __('API Key', 'wp-autopost') . ':</strong><code>' . $BaiduTransOptions['api_key'] . '</code></p><p>Error : ' . $response['err'] . '</p></div>';
    } else {
        echo '<div class="updated fade"><p><strong>' . __('API Key', 'wp-autopost') . ':</strong><code>' . $BaiduTransOptions['api_key'] . '</code></p><p>Result : ';
        foreach ($response['trans_result'] as $trans_result) {
            echo htmlspecialchars($trans_result) . '<br/>';
        }
        echo '</p></div>';
    }
    @ob_flush();
    flush();
}
?>