/** * Loads translations keys for each property of the entity of the controller with labels * * domain: project (if not specified) * key: * entities.<entityName>.<propertyName> * * for example: * entities.news-entry.published * entities.news-entry.teaser * * if property is i18n property the i18n will be stripped */ protected function initPropertyTranslations($domain = NULL) { $entityMeta = $this->getEntityMeta(); $translator = $this->translationContainer->getTranslator(); $this->on('init.labeler', function ($labeler) use($domain, $entityMeta, $translator) { foreach ($entityMeta->getSetMeta()->getKeys() as $propertyName) { $property = $entityMeta->getPropertyMeta($propertyName); $labeler->label($property->getName(), $translator->trans(sprintf('entities.%s.%s', $entityMeta->getEntityName(), $property->getCanonicalName()), array(), $domain ?: 'project')); } }); }
public function initControlsFor(ContentStream $cs, TranslationContainer $translationContainer) { $translator = $translationContainer->getTranslator(); $trans = function ($key) use($translator) { return $translator->trans($key, array(), 'cms'); }; if ($cs->getType() === 'page-content') { foreach ($this->headlines as $level) { $this->addNewControl('Headline', (object) array('level' => $level), sprintf('%s (H%d)', $level === 1 ? $trans('sce.widget.headline') . ' ' : $trans('sce.widget.headline'), $level), 'text'); } $this->addNewControl('Paragraph', NULL, $trans('sce.widget.paragraph'), 'text'); $this->addNewControl('Li', NULL, $trans('sce.widget.li'), 'text'); $this->addNewControl('Image', NULL, $trans('sce.widget.image'), 'images'); $this->addNewControl('DownloadsList', (object) array('headline' => '', 'downloads' => array()), $trans('sce.widget.downloadsList'), 'text'); $this->addNewControl('WebsiteWidget', (object) array('label' => $trans('sce.widget.calendar'), 'name' => 'calendar'), $trans('sce.widget.calendar'), 'misc'); } }