You are here

protected function i18n_string_textgroup_default::save_string in Internationalization 7

Save / update string object

There seems to be a race condition sometimes so skip errors, #277711

Parameters

$string: Full string object to be saved

$source: Source string object

2 calls to i18n_string_textgroup_default::save_string()
i18n_string_textgroup_default::string_add in i18n_string/i18n_string.inc
Add source string to the locale tables for translation.
i18n_string_textgroup_default::update_check in i18n_string/i18n_string.inc
Recheck strings after update

File

i18n_string/i18n_string.inc, line 701
API for internationalization strings

Class

i18n_string_textgroup_default
Textgroup handler for i18n_string API

Code

protected function save_string($string, $update = FALSE) {
  if (!$string
    ->get_source()) {

    // Create source string so we get an lid
    $this
      ->save_source($string);
  }

  // Convert objectid to objectkey if it's numeric.
  if (!isset($string->objectkey)) {
    if (is_numeric($string->objectid)) {
      $string->objectkey = (int) $string->objectid;
    }
  }

  // Make sure objectkey is numeric.
  if (!is_numeric($string->objectkey)) {
    $string->objectkey = 0;
  }
  if (!isset($string->format)) {
    $string->format = '';
  }
  $status = db_merge('i18n_string')
    ->key(array(
    'lid' => $string->lid,
  ))
    ->fields(array(
    'textgroup' => $string->textgroup,
    'context' => $string->context,
    'objectid' => $string->objectid,
    'type' => $string->type,
    'property' => $string->property,
    'objectindex' => $string->objectkey,
    'format' => $string->format,
  ))
    ->execute();
  return $status;
}