From 446f4a662ddbb9d05fbd47486e9eb71eea0251f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Tue, 11 Nov 2025 23:29:38 +0100 Subject: [PATCH] Reworked settings name and translation --- src/Services/ElementTypeNameGenerator.php | 4 +- src/Services/Trees/TreeViewGenerator.php | 2 - src/Settings/AppSettings.php | 6 ++ ...nonymsSettings.php => SynonymSettings.php} | 24 +++--- .../SystemSettings/SystemSettings.php | 3 +- templates/settings/settings.html.twig | 2 +- translations/messages.cs.xlf | 54 ------------- translations/messages.de.xlf | 54 ------------- translations/messages.en.xlf | 79 ++++++------------- 9 files changed, 46 insertions(+), 182 deletions(-) rename src/Settings/{SystemSettings/DataSourceSynonymsSettings.php => SynonymSettings.php} (79%) diff --git a/src/Services/ElementTypeNameGenerator.php b/src/Services/ElementTypeNameGenerator.php index ed546fb6..19bb19f5 100644 --- a/src/Services/ElementTypeNameGenerator.php +++ b/src/Services/ElementTypeNameGenerator.php @@ -34,7 +34,7 @@ use App\Entity\PriceInformations\Pricedetail; use App\Entity\ProjectSystem\Project; use App\Entity\ProjectSystem\ProjectBOMEntry; use App\Exceptions\EntityNotSupportedException; -use App\Settings\SystemSettings\DataSourceSynonymsSettings; +use App\Settings\SynonymSettings; use Symfony\Contracts\Translation\TranslatorInterface; /** @@ -46,7 +46,7 @@ final readonly class ElementTypeNameGenerator public function __construct( private TranslatorInterface $translator, private EntityURLGenerator $entityURLGenerator, - private DataSourceSynonymsSettings $synonymsSettings, + private SynonymSettings $synonymsSettings, ) { } diff --git a/src/Services/Trees/TreeViewGenerator.php b/src/Services/Trees/TreeViewGenerator.php index f1d37e6c..d55c87b7 100644 --- a/src/Services/Trees/TreeViewGenerator.php +++ b/src/Services/Trees/TreeViewGenerator.php @@ -38,7 +38,6 @@ use App\Services\Cache\ElementCacheTagGenerator; use App\Services\Cache\UserCacheKeyGenerator; use App\Services\ElementTypeNameGenerator; use App\Services\EntityURLGenerator; -use App\Services\Misc\DataSourceSynonymResolver; use App\Settings\BehaviorSettings\SidebarSettings; use Doctrine\ORM\EntityManagerInterface; use InvalidArgumentException; @@ -68,7 +67,6 @@ class TreeViewGenerator protected TranslatorInterface $translator, private readonly UrlGeneratorInterface $router, private readonly SidebarSettings $sidebarSettings, - protected readonly DataSourceSynonymResolver $synonymResolver, private readonly ElementTypeNameGenerator $elementTypeNameGenerator ) { $this->rootNodeEnabled = $this->sidebarSettings->rootNodeEnabled; diff --git a/src/Settings/AppSettings.php b/src/Settings/AppSettings.php index 42831d08..14d9395e 100644 --- a/src/Settings/AppSettings.php +++ b/src/Settings/AppSettings.php @@ -47,6 +47,12 @@ class AppSettings #[EmbeddedSettings()] public ?InfoProviderSettings $infoProviders = null; + #[EmbeddedSettings] + public ?SynonymSettings $synonyms = null; + #[EmbeddedSettings()] public ?MiscSettings $miscSettings = null; + + + } diff --git a/src/Settings/SystemSettings/DataSourceSynonymsSettings.php b/src/Settings/SynonymSettings.php similarity index 79% rename from src/Settings/SystemSettings/DataSourceSynonymsSettings.php rename to src/Settings/SynonymSettings.php index 03cb75e3..e952d97a 100644 --- a/src/Settings/SystemSettings/DataSourceSynonymsSettings.php +++ b/src/Settings/SynonymSettings.php @@ -20,30 +20,28 @@ declare(strict_types=1); -namespace App\Settings\SystemSettings; +namespace App\Settings; use App\Form\Type\DataSourceSynonymsCollectionType; use App\Services\ElementTypes; -use App\Settings\SettingsIcon; use Jbtronics\SettingsBundle\ParameterTypes\ArrayType; use Jbtronics\SettingsBundle\ParameterTypes\SerializeType; -use Jbtronics\SettingsBundle\ParameterTypes\StringType; use Jbtronics\SettingsBundle\Settings\Settings; use Jbtronics\SettingsBundle\Settings\SettingsParameter; use Jbtronics\SettingsBundle\Settings\SettingsTrait; use Symfony\Component\Translation\TranslatableMessage as TM; use Symfony\Component\Validator\Constraints as Assert; -#[Settings(label: new TM("settings.system.data_source_synonyms"))] +#[Settings(label: new TM("settings.system.synonyms"), description: "settings.system.synonyms.help")] #[SettingsIcon("fa-language")] -class DataSourceSynonymsSettings +class SynonymSettings { use SettingsTrait; #[SettingsParameter( ArrayType::class, - label: new TM("settings.system.data_source_synonyms.configuration"), - description: new TM("settings.system.data_source_synonyms.configuration.help"), + label: new TM("settings.system.synonyms.type_synonyms"), + description: new TM("settings.system.synonyms.type_synonyms.help"), options: ['type' => SerializeType::class], formType: DataSourceSynonymsCollectionType::class, formOptions: [ @@ -53,7 +51,7 @@ class DataSourceSynonymsSettings #[Assert\Type('array')] #[Assert\All([new Assert\Type('array')])] /** - * @var array> $customTypeLabels + * @var array> $typeSynonyms * An array of the form: [ * 'category' => [ * 'en' => ['singular' => 'Category', 'plural' => 'Categories'], @@ -64,7 +62,7 @@ class DataSourceSynonymsSettings * ], * ] */ - public array $customTypeLabels = []; + public array $typeSynonyms = []; /** * Checks if there is any synonym defined for the given type (no matter which language). @@ -73,7 +71,7 @@ class DataSourceSynonymsSettings */ public function isSynonymDefinedForType(ElementTypes $type): bool { - return isset($this->customTypeLabels[$type->value]); + return isset($this->typeSynonyms[$type->value]); } /** @@ -84,7 +82,7 @@ class DataSourceSynonymsSettings */ public function getSingularSynonymForType(ElementTypes $type, string $locale): ?string { - return $this->customTypeLabels[$type->value][$locale]['singular'] ?? null; + return $this->typeSynonyms[$type->value][$locale]['singular'] ?? null; } /** @@ -95,8 +93,8 @@ class DataSourceSynonymsSettings */ public function getPluralSynonymForType(ElementTypes $type, ?string $locale): ?string { - return $this->customTypeLabels[$type->value][$locale]['plural'] - ?? $this->customTypeLabels[$type->value][$locale]['singular'] + return $this->typeSynonyms[$type->value][$locale]['plural'] + ?? $this->typeSynonyms[$type->value][$locale]['singular'] ?? null; } } diff --git a/src/Settings/SystemSettings/SystemSettings.php b/src/Settings/SystemSettings/SystemSettings.php index 2e887116..8cbeb560 100644 --- a/src/Settings/SystemSettings/SystemSettings.php +++ b/src/Settings/SystemSettings/SystemSettings.php @@ -33,8 +33,7 @@ class SystemSettings #[EmbeddedSettings()] public ?LocalizationSettings $localization = null; - #[EmbeddedSettings] - public ?DataSourceSynonymsSettings $dataSourceSynonyms = null; + #[EmbeddedSettings()] public ?CustomizationSettings $customization = null; diff --git a/templates/settings/settings.html.twig b/templates/settings/settings.html.twig index 5ddbd900..96e0f209 100644 --- a/templates/settings/settings.html.twig +++ b/templates/settings/settings.html.twig @@ -36,7 +36,7 @@ {% for section_widget in tab_widget %} {% set settings_object = section_widget.vars.value %} - {% if section_widget.vars.compound ?? false %} + {% if section_widget.vars.embedded_settings_metadata is defined %} {# Check if we have nested embedded settings or not #}
diff --git a/translations/messages.cs.xlf b/translations/messages.cs.xlf index cefc9bb3..7a15bbe7 100644 --- a/translations/messages.cs.xlf +++ b/translations/messages.cs.xlf @@ -12813,60 +12813,6 @@ Vezměte prosím na vědomí, že se nemůžete vydávat za uživatele se zakáz Jazyky, které se zobrazují v uživatelské rozbalovací nabídce - - - settings.system.data_source_synonyms - Synonyma zdrojů dat - - - - - settings.system.data_source_synonyms.configuration - Zdroj - - - - - settings.system.data_source_synonyms.configuration.help - Definujte vlastní synonyma pro zadané zdroje dat. Volně přidávat zdroj dat, jazyk a překlady; Jazyky, které se nepoužívají, zůstávají prázdné. - - - - - settings.behavior.data_source_synonyms.category - Kategorie - - - - - settings.behavior.data_source_synonyms.storagelocation - Skladové umístění - - - - - settings.behavior.data_source_synonyms.footprint - Pouzdro - - - - - settings.behavior.data_source_synonyms.manufacturer - Výrobce - - - - - settings.behavior.data_source_synonyms.supplier - Dodavatel - - - - - settings.behavior.data_source_synonyms.project - Projekt - - settings.behavior.data_source_synonyms.collection.add_entry diff --git a/translations/messages.de.xlf b/translations/messages.de.xlf index 646281a5..8d6f2a54 100644 --- a/translations/messages.de.xlf +++ b/translations/messages.de.xlf @@ -12881,60 +12881,6 @@ Bitte beachten Sie, dass Sie sich nicht als deaktivierter Benutzer ausgeben kön Bitte beachten Sie, dass die Währungen bei einer Änderung dieses Wertes nicht umgerechnet werden. Wenn Sie also die Basiswährung ändern, nachdem Sie bereits Preisinformationen hinzugefügt haben, führt dies zu falschen Preisen!]]> - - - settings.system.data_source_synonyms - Datenquellen-Synonyme - - - - - settings.system.data_source_synonyms.configuration - Quelle - - - - - settings.system.data_source_synonyms.configuration.help - Definieren Sie Ihre eigenen Synonyme für die angegebenen Datenquellen. Datenquelle, Sprache und Übersetzungen frei hinzufügen; Nicht verwendete Sprachen bleiben leer. - - - - - settings.behavior.data_source_synonyms.category - Kategorie - - - - - settings.behavior.data_source_synonyms.storagelocation - Lagerort - - - - - settings.behavior.data_source_synonyms.footprint - Footprint - - - - - settings.behavior.data_source_synonyms.manufacturer - Hersteller - - - - - settings.behavior.data_source_synonyms.supplier - Lieferant - - - - - settings.behavior.data_source_synonyms.project - Projekt - - settings.behavior.data_source_synonyms.collection.add_entry diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index c148db2a..43159587 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -12816,60 +12816,6 @@ Please note, that you can not impersonate a disabled user. If you try you will g Please note that the currencies are not converted, when changing this value. So changing the default currency after you already added price information, will result in wrong prices!]]> - - - settings.system.data_source_synonyms - Data source synonyms - - - - - settings.system.data_source_synonyms.configuration - Source - - - - - settings.system.data_source_synonyms.configuration.help - Define your own synonyms for the given data sources. Add data source, language and translations freely; unused languages remain empty. - - - - - settings.behavior.data_source_synonyms.category - Category - - - - - settings.behavior.data_source_synonyms.storagelocation - Storage location - - - - - settings.behavior.data_source_synonyms.footprint - Footprint - - - - - settings.behavior.data_source_synonyms.manufacturer - Manufacturer - - - - - settings.behavior.data_source_synonyms.supplier - Supplier - - - - - settings.behavior.data_source_synonyms.project - Project - - settings.behavior.data_source_synonyms.collection.add_entry @@ -14515,5 +14461,30 @@ You can do this in the provider info list. Groups + + + settings.system.synonyms + Synonyms + + + + + settings.system.synonyms.help + The synonyms systems allow overriding how Part-DB call certain things. This can be useful, especially if Part-DB is used in a different context than electronics. +Please note that this system is currently experimental, and the synonyms defined here might not show up at all places. + + + + + settings.system.synonyms.type_synonyms + Type synonyms + + + + + settings.system.synonyms.type_synonyms.help + Type synonyms allow you to replace the labels of built-in data types. For example, you can rename "Footprint" to something else. + +