Fix formatter enum translation (#2642)

* email template formatter consider enum translation

* htmlizer default value for enum translation & rename variable

---------

Co-authored-by: Eymen Elkum <eymen@eblasoft.com.tr>
This commit is contained in:
Eymen Elkum
2023-03-07 10:58:36 +03:00
committed by GitHub
parent 9c44f79b4d
commit 36c6883743
2 changed files with 14 additions and 4 deletions

View File

@@ -413,12 +413,12 @@ class Htmlizer
);
if ($this->metadata) {
$translation = $this->metadata->get(
$translationPath = $this->metadata->get(
['entityDefs', $entity->getEntityType(), 'fields', $attribute, 'translation']
);
if ($translation) {
$data[$attribute] = $this->language->get($translation . '.' . $data[$attribute]);
if ($translationPath) {
$data[$attribute] = $this->language->get($translationPath . '.' . $attribute, $data[$attribute]);
}
}
}

View File

@@ -73,7 +73,17 @@ class Formatter
return '';
}
return (string) $this->language->translateOption($value, $attribute, $entity->getEntityType());
$label = $this->language->translateOption($value, $attribute, $entity->getEntityType());
$translationPath = $this->metadata->get(
['entityDefs', $entity->getEntityType(), 'fields', $attribute, 'translation']
);
if ($translationPath) {
$label = $this->language->get($translationPath . '.' . $value, $label);
}
return $label;
}
if ($fieldType === 'array' || $fieldType === 'multiEnum' || $fieldType === 'checklist') {