/** * @param string $subject * @param string $grid * @param Trans $trans * * @return Label */ private function getLabel($subject, $grid, Trans $trans) { if ($trans->isEnabled()) { $label = $trans->resolvePattern(array('{grid}' => $grid, '{extension}' => ActionsExtension::NAME, '{subject}' => $subject)); return new Label($label, true, $trans->getDomain()); } $formatter = new LabelFormatter(); return new Label($formatter->format($subject)); }
public function testWhenISetupTranslationIGetTranslatedLabels() { $collection = new Collection(ArrayDataProvider::getBeatlesData()); $schema = ArrayDataProvider::getBeatlesSchema(); $grid = $this->getFactory()->createGrid($collection, array('schema' => $schema, 'name' => 'beatles', 'label_trans' => Trans::enable())); $html = $this->getTwig('trans.html.twig', array(new TranslationExtension($this->getTranslator(__DIR__))))->render('{{ datagrid(grid) }}', array('grid' => $grid)); $this->assertFixtureEquals(__DIR__ . '/beatles.html', $html); }
public function testWhenISetupTranslationIGetTranslatedActionLabels() { $collection = new Collection(ArrayDataProvider::getBeatlesData()); $schema = ArrayDataProvider::getBeatlesSchema(); $actions = Actions::enable()->addGlobalUrl('create', '/beatles/create')->addEntityUrl('read', '/beatles/read/{slug}')->addEntityUrl('update', '/beatles/update/{slug}')->addEntityUrl('delete', '/beatles/delete/{slug}'); $grid = $this->getFactory()->createGrid($collection, array('schema' => $schema, 'actions' => $actions, 'name' => 'beatles', 'actions_trans' => Trans::enable())); $html = $this->getTwig('trans.html.twig', array(new TranslationExtension($this->getTranslator(__DIR__))))->render('{{ datagrid(grid) }}', array('grid' => $grid)); $this->assertFixtureEquals(__DIR__ . '/beatles.html', $html); }