You are here

public static function LingotekConfigChunk::saveSegmentTranslations in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.4 lib/Drupal/lingotek/LingotekConfigChunk.php \LingotekConfigChunk::saveSegmentTranslations()
  2. 7.5 lib/Drupal/lingotek/LingotekConfigChunk.php \LingotekConfigChunk::saveSegmentTranslations()

Save segment target translations for the given language

Parameters

obj: the SimpleXMLElement object containing the translations to be saved

string: the language code under which to save the translations

1 call to LingotekConfigChunk::saveSegmentTranslations()
LingotekConfigChunk::updateLocalContentByTarget in lib/Drupal/lingotek/LingotekConfigChunk.php
Updates the local content of $target_code with data from a Lingotek Document

File

lib/Drupal/lingotek/LingotekConfigChunk.php, line 789
Defines LingotekConfigChunk.

Class

LingotekConfigChunk
A class wrapper for Lingotek-specific behavior on ConfigChunks.

Code

public static function saveSegmentTranslations($document_xml, $target_language) {
  $rows = array();
  $sql = 'INSERT INTO {locales_target} (lid, translation, language) VALUES ';
  $subsql = '';
  $icount = 0;
  foreach ($document_xml as $drupal_field_name => $xml_obj) {
    $content = (string) $xml_obj->element;
    $content = self::unfilterPlaceholders(decode_entities($content));
    $lid = self::getLidFromTag($drupal_field_name);
    $rows += array(
      ":l_{$icount}" => $lid,
      ":c_{$icount}" => $content,
      ":lang_{$icount}" => $target_language,
    );
    $subsql .= "( :l_{$icount}, :c_{$icount}, :lang_{$icount}),";
    $icount++;
  }
  $subsql = rtrim($subsql, ',');
  db_query($sql . $subsql, $rows);
}