public function getLogicalFieldTranslation($field, $withLocale = true)
{
$accessor = PropertyAccess::createPropertyAccessor();
$fieldValue = $accessor->getValue($this->translate(), $field);
if (!empty($fieldValue) && $fieldValue !== '-') {
if ($withLocale) {
return '[' . $this->getCurrentLocale() . ']' . $fieldValue;
} else {
return $fieldValue;
}
}
foreach ($this->translations as $translation) {
$fieldValue = $accessor->getValue($translation, $field);
if (!empty($fieldValue) && $fieldValue !== '-') {
if ($withLocale) {
return '[' . $translation->getLocale() . ']' . $fieldValue;
} else {
return $fieldValue;
}
}
}
return '';
}