protected function formatTranslation(StashedTranslation $translation) { $title = $translation->getTitle(); $handle = new MessageHandle($title); // Prepare for the worst $definition = ''; $comparison = ''; if ($handle->isValid()) { $groupId = MessageIndex::getPrimaryGroupId($handle); $group = MessageGroups::getGroup($groupId); $key = $handle->getKey(); $definition = $group->getMessage($key, $group->getSourceLanguage()); $comparison = $group->getMessage($key, $handle->getCode()); } return array('title' => $title->getPrefixedText(), 'definition' => $definition, 'translation' => $translation->getValue(), 'comparison' => $comparison, 'metadata' => $translation->getMetadata()); }
/** * Adds a new translation to the stash. If the same key already exists, the * previous translation and metadata will be replaced with the new one. */ public function addTranslation(StashedTranslation $item) { $row = array('ts_user' => $item->getUser()->getId(), 'ts_title' => $item->getTitle()->getDBKey(), 'ts_namespace' => $item->getTitle()->getNamespace(), 'ts_value' => $item->getValue(), 'ts_metadata' => serialize($item->getMetadata())); $indexes = array(array('ts_user', 'ts_namespace', 'ts_title')); $this->db->replace($this->dbTable, $indexes, $row, __METHOD__); }