/** * Render js translation * * @return string */ public function render() { $json = \Zend_Json::encode($this->dataProvider->getTranslateData()); $this->translateInline->processResponseBody($json, false); $script = '(function($) {$.mage.translate.add(' . $json . ')})(jQuery);'; return '<script type="text/javascript">//<![CDATA[' . "\n{$script}\n" . '//]]></script>'; }
/** * @magentoAdminConfigFixture dev/translate_inline/active_admin 1 * @covers \Magento\Framework\Translate\Inline::getAjaxUrl */ public function testAjaxUrl() { $body = '<html><body>some body</body></html>'; /** @var \Magento\Backend\Model\UrlInterface $url */ $url = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\UrlInterface'); $url->getUrl(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE . '/ajax/translate'); $this->_translateInline->processResponseBody($body, true); $this->assertContains($url->getUrl(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE . '/ajax/translate'), $body); }
/** * Render current layout * * @param ResponseInterface $response * @return $this */ protected function render(ResponseInterface $response) { $output = $this->layout->getOutput(); $this->translateInline->processResponseBody($output); $response->appendBody($output); return $this; }
/** * Render HTML based on requested layout handle name * * @param string $handle * @return string */ protected function _getHtmlByHandle($handle) { $layout = $this->layoutFactory->create(); $layout->getUpdate()->load([$handle]); $layout->generateXml(); $layout->generateElements(); $output = $layout->getOutput(); $this->_translateInline->processResponseBody($output); return $output; }
/** * Render HTML based on requested layout handle name * * @param string $handle * @return string */ protected function _getHtmlByHandle($handle) { $layout = $this->_view->getLayout(); $layout->getUpdate()->addPageHandles(array($handle)); $layout->getUpdate()->load(); $layout->generateXml(); $layout->generateElements(); $output = $layout->getOutput(); $this->_translateInline->processResponseBody($output); return $output; }
/** * Rendering layout * * @param string $output * @return $this */ public function renderLayout($output = '') { if ($this->_actionFlag->get('', 'no-renderLayout')) { return $this; } \Magento\Framework\Profiler::start('LAYOUT'); \Magento\Framework\Profiler::start('layout_render'); if ('' !== $output) { $this->getLayout()->addOutputElement($output); } $this->_eventManager->dispatch('controller_action_layout_render_before'); $this->_eventManager->dispatch('controller_action_layout_render_before_' . $this->_request->getFullActionName()); $output = $this->getLayout()->getOutput(); $this->_translateInline->processResponseBody($output); $this->_response->appendBody($output); \Magento\Framework\Profiler::stop('layout_render'); \Magento\Framework\Profiler::stop('LAYOUT'); return $this; }
/** * Encode the mixed $data into the JSON format. * * @param mixed $data * @return string */ public function encode($data) { $json = \Zend_Json::encode($data); $this->translateInline->processResponseBody($json, true); return $json; }
/** * Set body to response * * @param string $body * @return void */ protected function setBody($body) { $this->_translateInline->processResponseBody($body); $this->getResponse()->setBody($body); }
/** * {@inheritdoc} */ protected function render(ResponseInterface $response) { $this->translateInline->processResponseBody($this->json, true); $response->representJson($this->json); return $this; }
/** * Translate html content * * @param string $html * @return string */ protected function _translateHtml($html) { $this->_translateInline->processResponseBody($html); return $html; }
/** * Encode the mixed $data into the JSON format. * * @param mixed $data * @return string */ public function encode($data) { $this->translateInline->processResponseBody($data); return \Zend_Json::encode($data); }