You are here

function l10n_client_submit_translation in Localization client 6

Same name and namespace in other branches
  1. 6.2 l10n_client.module \l10n_client_submit_translation()
  2. 7 l10n_client.module \l10n_client_submit_translation()

Submit translation to the server.

1 call to l10n_client_submit_translation()
l10n_client_save_string in ./l10n_client.module
Menu callback. Saves a string translation coming as POST data.

File

./l10n_client.module, line 636
Localization client. Provides on-page translation editing.

Code

function l10n_client_submit_translation($langcode, $source, $translation, $user_key, $user_token) {
  $server_uid = current(split(':', $user_key));
  $signature = md5($user_key . $langcode . $source . $translation . $user_token);
  $response = xmlrpc(variable_get('l10n_client_server', '') . '/xmlrpc.php', 'l10n.submit.translation', $langcode, $source, $translation, (int) $server_uid, $user_token, $signature);
  if (!empty($response) && isset($response['status'])) {
    if ($response['status']) {
      watchdog('l10n_client', 'Translation sent and accepted by remote server.');
    }
    else {
      watchdog('l10n_client', 'Translation rejected by remote server. Reason: %reason', array(
        '%reason' => $response['reason'],
      ), WATCHDOG_WARNING);
    }
    return $response['status'];
  }
  else {
    watchdog('l10n_client', 'The connection with the remote server failed with the following error: %error_code: %error_message.', array(
      '%error_code' => xmlrpc_errno(),
      '%error_message' => xmlrpc_error_msg(),
    ), WATCHDOG_ERROR);
    return FALSE;
  }
}