public function translateFields($fields)
{
if (is_array($fields)) {
foreach ($fields as &$field) {
$this->translateFields($field);
}
} elseif ($fields instanceof Field) {
foreach (['label', 'desc'] as $prop) {
$getter = 'get' . ucfirst($prop);
$setter = 'set' . ucfirst($prop);
if (is_callable([$fields, $getter]) && is_callable([$fields, $setter])) {
$value = $fields->{$getter}();
if (substr($value, 0, 2) == '[[' && substr($value, -2) == ']]') {
$fields->{$setter}($this->translator->t(substr($value, 2, -2)));
}
}
}
if (is_array($fields->getChildren())) {
$this->translateFields($fields->getChildren());
}
}
}