public function LingotekConfigChunk::updateLocalContentByTarget in Lingotek Translation 7.3
Same name and namespace in other branches
- 7.4 lib/Drupal/lingotek/LingotekConfigChunk.php \LingotekConfigChunk::updateLocalContentByTarget()
Updates the local content of $target_code with data from a Lingotek Document
Parameters
string $lingotek_locale: The code for the language that needs to be updated.
Return value
bool TRUE if the content updates succeeded, FALSE otherwise.
Overrides LingotekTranslatableEntity::updateLocalContentByTarget
1 call to LingotekConfigChunk::updateLocalContentByTarget()
- LingotekConfigChunk::updateLocalContent in lib/
Drupal/ lingotek/ LingotekConfigChunk.php - Updates the local content with data from a Lingotek Document.
File
- lib/
Drupal/ lingotek/ LingotekConfigChunk.php, line 696 - Defines LingotekConfigChunk.
Class
- LingotekConfigChunk
- A class wrapper for Lingotek-specific behavior on ConfigChunks.
Code
public function updateLocalContentByTarget($lingotek_locale) {
$metadata = $this
->metadata();
$document_id = $metadata['document_id'];
if (empty($document_id)) {
LingotekLog::error('Unable to refresh local contents for config chunk @cid. Could not find Lingotek Document ID.', array(
'@cid' => $this->cid,
));
return FALSE;
}
$api = LingotekApi::instance();
$document_xml = $api
->downloadDocument($document_id, $lingotek_locale);
$target_language = Lingotek::convertLingotek2Drupal($lingotek_locale);
/* FAST VERSION (git history for slow version) */
// 1. save the dirty targets associated with given language
$dirty_lids = self::getDirtyLidsByChunkIdAndLanguage($this->cid, $target_language);
// 2. delete all segment targets associated with given language
self::deleteSegmentTranslationsByChunkIdAndLanguage($this->cid, $target_language);
// 3. insert all segments for the given language
self::saveSegmentTranslations($document_xml, $target_language);
// 4. return the dirty targets' statuses
self::restoreDirtyLids($dirty_lids);
/* END FAST */
// set chunk status to current
$this
->setChunkStatus(LingotekSync::STATUS_CURRENT);
$this
->setChunkTargetsStatus(LingotekSync::STATUS_CURRENT, $target_language);
return TRUE;
}