/** * 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; }
/** * Get the translations in all languages. Cached for performance. * Fuzzy translation are not included. * * @return array Language code => Translation */ public function getTranslations() { static $cache = array(); $key = $this->handle->getTitle()->getPrefixedText(); if (array_key_exists($key, $cache)) { return $cache[$key]; } $data = ApiQueryMessageTranslations::getTranslations($this->handle); $namespace = $this->handle->getTitle()->getNamespace(); $cache[$key] = array(); foreach ($data as $page => $info) { $tTitle = Title::makeTitle($namespace, $page); $tHandle = new MessageHandle($tTitle); $fuzzy = MessageHandle::hasFuzzyString($info[0]) || $tHandle->isFuzzy(); if ($fuzzy) { continue; } $code = $tHandle->getCode(); $cache[$key][$code] = $info[0]; } return $cache[$key]; }