You are here

public function LingotekConfigChunk::documentLingotekXML in Lingotek Translation 7.5

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

Gets the contents of this item formatted as XML to be sent to Lingotek.

Return value

string The XML document representing the entity's translatable content.

Overrides LingotekTranslatableEntity::documentLingotekXML

File

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

Class

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

Code

public function documentLingotekXML() {
  $translatable = array();

  // for now, assume all strings in locales_source table for the given chunk are translatable
  if (TRUE) {
    $translatable = array_keys($this->source_data);
  }
  $content = '';
  foreach ($translatable as $field) {
    $text = lingotek_filter_placeholders($this->source_data[$field], TRUE);
    if ($text) {
      $current_field = '<' . self::TAG_PREFIX . $field . '>';
      $current_field .= '<element><![CDATA[' . $text . ']]></element>' . "\n";
      $current_field .= '</' . self::TAG_PREFIX . $field . '>';
      $content .= $current_field . "\n";
    }
  }
  return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><contents>{$content}</contents>";
}