mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-18 08:59:30 +00:00
Implementiere bevorzugte Sprachauswahl und Datenquellen-Synonyme
Die Spracheinstellungen/System-Settings wurden um die Möglichkeit ergänzt, bevorzugte Sprachen für die Dropdown-Menüs festzulegen. Zudem wurde ein Datenquellen-Synonymsystem implementiert, um benutzerfreundlichere Bezeichnungen anzuzeigen und zu personalisieren.
This commit is contained in:
parent
e53b72a8d1
commit
68e7ffa452
34 changed files with 648 additions and 44 deletions
73
src/Settings/BehaviorSettings/DataSourceSynonymsSettings.php
Normal file
73
src/Settings/BehaviorSettings/DataSourceSynonymsSettings.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Settings\BehaviorSettings;
|
||||
|
||||
use App\Form\Type\DataSourceJsonType;
|
||||
use App\Settings\SettingsIcon;
|
||||
use Jbtronics\SettingsBundle\ParameterTypes\ArrayType;
|
||||
use Jbtronics\SettingsBundle\ParameterTypes\StringType;
|
||||
use Jbtronics\SettingsBundle\Settings\Settings;
|
||||
use Jbtronics\SettingsBundle\Settings\SettingsParameter;
|
||||
use Jbtronics\SettingsBundle\Settings\SettingsTrait;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Translation\TranslatableMessage as TM;
|
||||
|
||||
#[Settings(label: new TM("settings.system.data_source_synonyms"))]
|
||||
#[SettingsIcon("fa-language")]
|
||||
class DataSourceSynonymsSettings
|
||||
{
|
||||
use SettingsTrait;
|
||||
|
||||
#[SettingsParameter(ArrayType::class,
|
||||
label: new TM("settings.system.data_source_synonyms.configuration"),
|
||||
description: new TM("settings.system.data_source_synonyms.configuration.help", ['%format%' => '{"en":"", "de":""}']),
|
||||
options: ['type' => StringType::class],
|
||||
formType: DataSourceJsonType::class,
|
||||
formOptions: [
|
||||
'required' => false,
|
||||
'data_sources' => [
|
||||
'category' => new TM("settings.behavior.data_source_synonyms.category"),
|
||||
'storagelocation' => new TM("settings.behavior.data_source_synonyms.storagelocation"),
|
||||
'footprint' => new TM("settings.behavior.data_source_synonyms.footprint"),
|
||||
'manufacturer' => new TM("settings.behavior.data_source_synonyms.manufacturer"),
|
||||
'supplier' => new TM("settings.behavior.data_source_synonyms.supplier"),
|
||||
'project' => new TM("settings.behavior.data_source_synonyms.project"),
|
||||
],
|
||||
'default_values' => [
|
||||
'category' => '{"en":"Categories", "de":"Kategorien"}',
|
||||
'storagelocation' => '{"en":"Storage locations", "de":"Lagerorte"}',
|
||||
'footprint' => '{"en":"Footprints", "de":"Footprints"}',
|
||||
'manufacturer' => '{"en":"Manufacturers", "de":"Hersteller"}',
|
||||
'supplier' => '{"en":"Suppliers", "de":"Lieferanten"}',
|
||||
'project' => '{"en":"Projects", "de":"Projekte"}',
|
||||
],
|
||||
],
|
||||
)]
|
||||
#[Assert\Type('array')]
|
||||
public array $dataSourceSynonyms = [
|
||||
'category' => '{"en":"Categories", "de":"Kategorien"}',
|
||||
'storagelocation' => '{"en":"Storage locations", "de":"Lagerorte"}',
|
||||
'footprint' => '{"en":"Footprints", "de":"Footprints"}',
|
||||
'manufacturer' => '{"en":"Manufacturers", "de":"Hersteller"}',
|
||||
'supplier' => '{"en":"Suppliers", "de":"Lieferanten"}',
|
||||
'project' => '{"en":"Projects", "de":"Projekte"}',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the synonyms data as a structured array.
|
||||
*
|
||||
* @return array<string, array<string, string>> The data source synonyms parsed from JSON to array.
|
||||
*/
|
||||
public function getSynonymsAsArray(): array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($this->dataSourceSynonyms as $key => $jsonString) {
|
||||
$result[$key] = json_decode($jsonString, true, 512, JSON_THROW_ON_ERROR) ?? [];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
37
src/Settings/SystemSettings/PreferredLocales.php
Normal file
37
src/Settings/SystemSettings/PreferredLocales.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 - 2024 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Settings\SystemSettings;
|
||||
|
||||
enum PreferredLocales: string
|
||||
{
|
||||
case EN = 'en';
|
||||
case DE = 'de';
|
||||
case IT = 'it';
|
||||
case FR = 'fr';
|
||||
case RU = 'ru';
|
||||
case JA = 'ja';
|
||||
case CS = 'cs';
|
||||
case DA = 'da';
|
||||
case ZH = 'zh';
|
||||
case PL = 'pl';
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||
namespace App\Settings\SystemSettings;
|
||||
|
||||
use Jbtronics\SettingsBundle\Settings\EmbeddedSettings;
|
||||
use App\Settings\BehaviorSettings\DataSourceSynonymsSettings;
|
||||
use Jbtronics\SettingsBundle\Settings\Settings;
|
||||
use Symfony\Component\Translation\TranslatableMessage as TM;
|
||||
|
||||
|
|
@ -33,6 +34,9 @@ class SystemSettings
|
|||
#[EmbeddedSettings()]
|
||||
public ?LocalizationSettings $localization = null;
|
||||
|
||||
#[EmbeddedSettings]
|
||||
public ?DataSourceSynonymsSettings $dataSourceSynonyms = null;
|
||||
|
||||
#[EmbeddedSettings()]
|
||||
public ?CustomizationSettings $customization = null;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue