mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-12 21:29:33 +00:00
Revert "Füge Unterstützung für Datenquellen-Synonyme hinzu."
This commit is contained in:
parent
dc4461d0e9
commit
3d3d655b54
27 changed files with 37 additions and 277 deletions
|
|
@ -68,11 +68,9 @@ class TreeViewGenerator
|
|||
protected TranslatorInterface $translator,
|
||||
private readonly UrlGeneratorInterface $router,
|
||||
private readonly SidebarSettings $sidebarSettings,
|
||||
protected ?array $dataSourceSynonyms = [],
|
||||
) {
|
||||
$this->rootNodeEnabled = $this->sidebarSettings->rootNodeEnabled;
|
||||
$this->rootNodeExpandedByDefault = $this->sidebarSettings->rootNodeExpanded;
|
||||
$this->dataSourceSynonyms = $dataSourceSynonyms ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -228,16 +226,14 @@ class TreeViewGenerator
|
|||
|
||||
protected function entityClassToRootNodeString(string $class): string
|
||||
{
|
||||
$locale = $this->translator->getLocale();
|
||||
|
||||
return match ($class) {
|
||||
Category::class => $this->getTranslatedOrSynonym('category', $locale),
|
||||
StorageLocation::class => $this->getTranslatedOrSynonym('storelocation', $locale),
|
||||
Footprint::class => $this->getTranslatedOrSynonym('footprint', $locale),
|
||||
Manufacturer::class => $this->getTranslatedOrSynonym('manufacturer', $locale),
|
||||
Supplier::class => $this->getTranslatedOrSynonym('supplier', $locale),
|
||||
Project::class => $this->getTranslatedOrSynonym('project', $locale),
|
||||
Assembly::class => $this->getTranslatedOrSynonym('assembly', $locale),
|
||||
Category::class => $this->translator->trans('category.labelp'),
|
||||
StorageLocation::class => $this->translator->trans('storelocation.labelp'),
|
||||
Footprint::class => $this->translator->trans('footprint.labelp'),
|
||||
Manufacturer::class => $this->translator->trans('manufacturer.labelp'),
|
||||
Supplier::class => $this->translator->trans('supplier.labelp'),
|
||||
Project::class => $this->translator->trans('project.labelp'),
|
||||
Assembly::class => $this->translator->trans('assembly.labelp'),
|
||||
default => $this->translator->trans('tree.root_node.text'),
|
||||
};
|
||||
}
|
||||
|
|
@ -294,22 +290,4 @@ class TreeViewGenerator
|
|||
return $repo->getGenericNodeTree($parent); //@phpstan-ignore-line
|
||||
});
|
||||
}
|
||||
|
||||
protected function getTranslatedOrSynonym(string $key, string $locale): string
|
||||
{
|
||||
$currentTranslation = $this->translator->trans($key . '.labelp');
|
||||
|
||||
// Call alternatives from DataSourcesynonyms (if available)
|
||||
if (!empty($this->dataSourceSynonyms[$key][$locale])) {
|
||||
$alternativeTranslation = $this->dataSourceSynonyms[$key][$locale];
|
||||
|
||||
// Use alternative translation when it deviates from the standard translation
|
||||
if ($alternativeTranslation !== $currentTranslation) {
|
||||
return $alternativeTranslation;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise return the standard translation
|
||||
return $currentTranslation;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue