You are here

function l10n_client_save_string in Localization client 6

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

Menu callback. Saves a string translation coming as POST data.

1 string reference to 'l10n_client_save_string'
l10n_client_menu in ./l10n_client.module
Implementation of hook_menu().

File

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

Code

function l10n_client_save_string() {
  global $user, $language;
  if (l10n_client_access()) {
    if (isset($_POST['source']) && isset($_POST['target']) && isset($_POST['textgroup']) && !empty($_POST['form_token']) && drupal_valid_token($_POST['form_token'], 'l10n_client_form')) {
      include_once 'includes/locale.inc';
      $report = array(
        'skips' => 0,
        'additions' => 0,
        'updates' => 0,
        'deletes' => 0,
      );
      _locale_import_one_string_db($report, $language->language, $_POST['source'], $_POST['target'], $_POST['textgroup'], NULL, LOCALE_IMPORT_OVERWRITE);
      cache_clear_all('locale:', 'cache', TRUE);
      _locale_invalidate_js($language->language);

      // Submit to remote server if enabled.
      if (variable_get('l10n_client_use_server', FALSE) && user_access('submit translations to localization server') && !empty($user->l10n_client_key)) {
        l10n_client_submit_translation($language->language, $_POST['source'], $_POST['target'], $user->l10n_client_key, l10n_client_user_token($user));
      }
    }
  }
}