/** * Fetch all the translations and update them. */ function run() { $handle = new MessageHandle($this->title); $translations = ApiQueryMessageTranslations::getTranslations($handle); foreach ($translations as $page => $data) { $tTitle = Title::makeTitle($this->title->getNamespace(), $page); $tHandle = new MessageHandle($tTitle); TTMServer::onChange($tHandle, $data[0], $tHandle->isFuzzy()); } return true; }
/** * Runs message checks, adds tp:transver tags and updates statistics. * Hook: PageContentSaveComplete */ public static function onSave(WikiPage $wikiPage, $user, $content, $summary, $minor, $_, $_, $flags, $revision) { if ($content instanceof TextContent) { $text = $content->getNativeData(); } else { // Screw it, not interested return true; } $title = $wikiPage->getTitle(); $handle = new MessageHandle($title); if (!$handle->isValid()) { return true; } // Update it. if ($revision === null) { $rev = $wikiPage->getTitle()->getLatestRevId(); } else { $rev = $revision->getID(); } $fuzzy = self::checkNeedsFuzzy($handle, $text); $fuzzyOp = self::updateFuzzyTag($title, $rev, $fuzzy); // Skip the hook if no change in status or content if ($revision || $fuzzyOp) { Hooks::run('TranslateEventTranslationEdit', array($handle)); } if ($fuzzy === false) { Hooks::run('Translate:newTranslation', array($handle, $rev, $text, $user)); } TTMServer::onChange($handle, $text, $fuzzy); return true; }