protected function parseResponse(TranslationQueryResponse $reply) { $body = $reply->getBody(); $response = FormatJson::decode($body); if (!is_object($response)) { throw new TranslationWebServiceException('Invalid json: ' . serialize($body)); } $text = preg_replace('~^<div>(.*)</div>$~', '\\1', $response->contents); $text = $this->unwrapUntranslatable($text); return trim($text); }
protected function parseResponse(TranslationQueryResponse $reply) { $body = $reply->getBody(); $parsed = FormatJson::decode($body, true); if (!is_array($parsed)) { throw new TranslationWebServiceException('Invalid json: ' . serialize($body)); } if (!isset($parsed['ttmserver'])) { throw new TranslationWebServiceException('Unexpected reply from remote server'); } return $parsed['ttmserver']; }
protected function parseResponse(TranslationQueryResponse $reply) { $body = $reply->getBody(); $response = FormatJson::decode($body); if (!is_object($response)) { throw new TranslationWebServiceException('Invalid json: ' . serialize($body)); } elseif ($response->code !== 200) { throw new TranslationWebServiceException($response->message); } $text = Sanitizer::decodeCharReferences($response->text[0]); $text = $this->unwrapUntranslatable($text); return trim($text); }
protected function parseResponse(TranslationQueryResponse $reply) { $body = $reply->getBody(); $text = preg_replace('~<string.*>(.*)</string>~', '\\1', $body); $text = Sanitizer::decodeCharReferences($text); $text = $this->unwrapUntranslatable($text); return $text; }
protected function parseResponse(TranslationQueryResponse $reply) { $xml = simplexml_load_string($reply->getBody()); $text = Sanitizer::decodeCharReferences($xml->translation->paragraph); $text = $this->unwrapUntranslatable($text); return $text; }