trans = $translator; } public function getFunctions() { return array( ); } public function getFilters() { return [ new TwigFilter('lc_trad', [$this, 'lcTrad']) ]; } public function lcTrad($field, $entityName, $type="field") { $tradKey = $type.'.'.$entityName.'.'.$field; $tradDefaultKey = $type.'.default.'.$field; $trad = $this->trans->trans($tradKey, array(), 'lcshop'); if($trad == $tradKey){ $trad = $this->trans->trans($tradDefaultKey, array(), 'lcshop'); } return $trad; } }