TYPO3 CMS  TYPO3_6-2
TranslateLabelSelectViewHelper.php
Go to the documentation of this file.
1 <?php
3 
29 
36  public function initializeArguments() {
37  parent::initializeArguments();
38  $this->registerArgument('optionLabelPrefix', 'string', 'Prefix for locallang lookup');
39  }
40 
49  protected function getOptions() {
50  $options = parent::getOptions();
51  foreach ($options as $value => $label) {
52  $options[$value] = $this->translateLabel($label);
53  }
54  return $options;
55  }
56 
63  protected function translateLabel($label) {
64  if ($label === '') {
65  return '';
66  }
67  $labelKey = $this->hasArgument('optionLabelPrefix') ? $this->arguments['optionLabelPrefix'] . $label : $label;
68  $translatedLabel = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($labelKey, $this->controllerContext->getRequest()->getControllerExtensionName());
69  return $translatedLabel ?: $label;
70  }
71 
72 }
registerArgument($name, $type, $description, $required=FALSE, $defaultValue=NULL)
static translate($key, $extensionName, $arguments=NULL)