Also replaces all placeholders with formatted versions of provided values. = Examples = Unregistered User translation of label with the id "user.unregistered" and a fallback to "Unregistered User" {f:translate(id: 'some.label.id', value: 'fallback result')} translation of label with the id "some.label.id" and a fallback to "fallback result" translation from custom source "SomeLabelsCatalog" for locale "de_DE" translation from custom source "LabelsCatalog" in "OtherPackage" translation of the label "Untranslated foo and 99.9" Untranslated label translation of the label "Untranslated label"
Inheritance: extends Neos\FluidAdaptor\Core\ViewHelper\AbstractViewHelper
 /**
  * @test
  * @dataProvider translationFallbackDataProvider
  * @param string $id
  * @param string $value
  * @param string $translatedId
  * @param string $translatedValue
  * @param string $expectedResult
  */
 public function translationFallbackTests($id, $value, $translatedId, $translatedValue, $expectedResult)
 {
     $this->mockTranslator->expects($this->any())->method('translateById', $id)->will($this->returnValue($translatedId));
     $this->mockTranslator->expects($this->any())->method('translateByOriginalLabel', $value)->will($this->returnValue($translatedValue));
     $actualResult = $this->translateViewHelper->render($id, $value);
     $this->assertSame($expectedResult, $actualResult);
 }
 /**
  * Renders the translated label.
  *
  * Replaces all placeholders with corresponding values if they exist in the
  * translated label.
  *
  * @param string $id Id to use for finding translation (trans-unit id in XLIFF)
  * @param string $value If $key is not specified or could not be resolved, this value is used. If this argument is not set, child nodes will be used to render the default
  * @param array $arguments Numerically indexed array of values to be inserted into placeholders
  * @param string $source Name of file with translations
  * @param string $package Target package key. If not set, the current package key will be used
  * @param mixed $quantity A number to find plural form for (float or int), NULL to not use plural forms
  * @param string $languageIdentifier An identifier of a language to use (NULL for using the default language)
  * @return string Translated label or source label / ID key
  * @throws ViewHelper\Exception
  */
 public function render($id = null, $value = null, array $arguments = array(), $source = 'Main', $package = null, $quantity = null, $languageIdentifier = null)
 {
     if (preg_match(TranslationHelper::I18N_LABEL_ID_PATTERN, $id) === 1) {
         // In the longer run, this "extended ID" format should directly be resolved in the localization service
         list($package, $source, $id) = explode(':', $id, 3);
         $source = str_replace('.', '/', $source);
     }
     if ($languageIdentifier === null) {
         $languageIdentifier = $this->userService->getInterfaceLanguage();
     }
     // Catch exception in case the translation file doesn't exist, should be fixed in Flow 3.1
     try {
         $translation = parent::render($id, $value, $arguments, $source, $package, $quantity, $languageIdentifier);
         // Fallback to english label if label was not available in specific language
         if ($translation === $id && $languageIdentifier !== 'en') {
             $translation = parent::render($id, $value, $arguments, $source, $package, $quantity, 'en');
         }
         return $translation;
     } catch (Exception $exception) {
         return $value ?: $id;
     }
 }