mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-08 01:14:34 +02:00
Started to make changed fields names in element edited log entry extra data translatable
This commit is contained in:
parent
1faeddccb2
commit
6b06ce9ac3
3 changed files with 478 additions and 51 deletions
|
@ -154,7 +154,7 @@ class LogEntryExtraFormatter
|
|||
}
|
||||
|
||||
if ($context instanceof ElementEditedLogEntry && $context->hasChangedFieldsInfo()) {
|
||||
$array['log.element_edited.changed_fields'] = htmlspecialchars(implode(', ', $context->getChangedFields()));
|
||||
$array['log.element_edited.changed_fields'] = $this->getChangedFieldsTranslated($context);
|
||||
}
|
||||
|
||||
if ($context instanceof LegacyInstockChangedLogEntry) {
|
||||
|
@ -200,4 +200,21 @@ class LogEntryExtraFormatter
|
|||
|
||||
return $array;
|
||||
}
|
||||
|
||||
private function getChangedFieldsTranslated(ElementEditedLogEntry $entry): string
|
||||
{
|
||||
$output = [];
|
||||
|
||||
foreach($entry->getChangedFields() as $field) {
|
||||
$key = 'log.element_edited.changed_fields.'.$field;
|
||||
//If the key is not found, use the field name as a fallback
|
||||
$tmp = $this->translator->trans($key);
|
||||
if ($key === $tmp) {
|
||||
$tmp = $field;
|
||||
}
|
||||
$output[] = htmlspecialchars($tmp);
|
||||
}
|
||||
|
||||
return implode(', ', $output);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue