/** * Merge the extracted comments of two translations. * * @param Translation $from * @param Translation $to * @param int $options */ public static function mergeExtractedComments(Translation $from, Translation $to, $options = self::DEFAULTS) { if ($options & self::EXTRACTED_COMMENTS_THEIRS) { $to->deleteExtractedComments(); } if (!($options & self::EXTRACTED_COMMENTS_OURS)) { foreach ($from->getExtractedComments() as $comment) { $to->addExtractedComment($comment); } } }
public static function getByRow($row) { $result = null; if ($row && $row['mtID']) { $result = new Translation($row['context'], $row['msgid'], $row['msgidPlural']); $result->mtID = $row['mtID']; $result->mtSectionID = $row['mtSectionID']; $result->setTranslation($row['msgstr']); if (isset($row['comments'])) { foreach (explode("\n", $row['comments']) as $comment) { $result->addExtractedComment($comment); } } if ($result->hasPlural() && isset($row['msgstrPlurals'])) { foreach (explode("", $row['msgstrPlurals']) as $pluralIndex => $plural) { $result->setPluralTranslation($plural, $pluralIndex); } } if (isset($row['reference'])) { foreach (explode("\n", $row['reference']) as $reference) { if ($reference !== '') { $line = null; $p = strrpos($reference, ':'); if ($p) { $s = substr($reference, $p + 1); if (preg_match('/^\\d+$/', $s)) { $line = (int) $s; $reference = substr($reference, 0, $p); } } $result->addReference($reference, $line); } } } if (isset($row['flags'])) { foreach (explode("\n", $row['flags']) as $flag) { if ($flag !== '') { $result->addFlag($flag); } } } } return $result; }