コード例 #1
0
 /**
  * Translate a given key or use the tag body as default.
  *
  * @return string The translated key or tag body if key doesn't exist
  */
 public function render()
 {
     $value = parent::render();
     if (!isset($value)) {
         $value = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($this->arguments['key'], 'roq_newsevent', $this->arguments);
     }
     return $value;
 }
コード例 #2
0
 /**
  * @test
  */
 public function resultIsNotHtmlEscapedIfSoRequested()
 {
     $this->subject = GeneralUtility::makeInstance(TranslateViewHelperFixtureForTranslatedString::class);
     $this->injectDependenciesIntoViewHelper($this->subject);
     $this->assertEquals('<p>hello world</p>', $this->subject->render('foo', NULL, NULL, TRUE));
 }
コード例 #3
0
 /**
  * Renders the translation and encodes to json string.
  *
  * @param string $key Translation Key
  * @param string $id Translation Key compatible to TYPO3 Flow
  * @param string $default If the given locallang key could not be found, this value is used. If this argument is not set, child nodes will be used to render the default
  * @param bool $htmlEscape TRUE if the result should be htmlescaped. This won't have an effect for the default value
  * @param array $arguments Arguments to be replaced in the resulting string
  * @param string $extensionName UpperCamelCased extension key (for example BlogExample)
  * @return string The translated key or tag body if key doesn't exist
  */
 public function render($key = null, $id = null, $default = null, $htmlEscape = null, array $arguments = null, $extensionName = null)
 {
     $result = (string) parent::render($key, $id, $default, $htmlEscape, $arguments, $extensionName);
     return json_encode($result);
 }