You are here

public function i18n_translation_set::add_item in Internationalization 7

Add translation item

2 calls to i18n_translation_set::add_item()
i18n_path_translation_set::add_item in i18n_path/i18n_path.inc
Add translation item
i18n_translation_set::add_translations in i18n_translation/i18n_translation.inc
Add array of translation items
1 method overrides i18n_translation_set::add_item()
i18n_path_translation_set::add_item in i18n_path/i18n_path.inc
Add translation item

File

i18n_translation/i18n_translation.inc, line 393
Internationalization (i18n) module - Translation set

Class

i18n_translation_set
@file Internationalization (i18n) module - Translation set

Code

public function add_item($item, $langcode = NULL) {
  $object = i18n_object($this->type, $item);
  $langcode = $langcode ? $langcode : $object
    ->get_langcode();

  // Check whether this item belongs to another translation set
  $old_tsid = $object
    ->get_tsid();
  if ($old_tsid && $old_tsid != $this->tsid) {
    $this->related_translations[$old_tsid] = i18n_translation_set_load($old_tsid);
    $this->related_translations[$old_tsid]
      ->remove_object($object);
  }
  if ($langcode) {
    $this
      ->get_translations();
    $object
      ->set_tsid($this->tsid);
    $this->translations[$langcode] = $object;
    $this->object_languages[$object
      ->get_index()] = $langcode;
  }
  return $this;
}