mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Moved default language, default timezone and base currency settings to new settings system
This commit is contained in:
parent
463812fb3d
commit
2ab2b7f77d
27 changed files with 211 additions and 83 deletions
6
.env
6
.env
|
@ -32,11 +32,11 @@ DATABASE_EMULATE_NATURAL_SORT=0
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
# The language to use serverwide as default (en, de, ru, etc.)
|
# The language to use serverwide as default (en, de, ru, etc.)
|
||||||
DEFAULT_LANG="en"
|
#DEFAULT_LANG="en"
|
||||||
# The default timezone to use serverwide (e.g. Europe/Berlin)
|
# The default timezone to use serverwide (e.g. Europe/Berlin)
|
||||||
DEFAULT_TIMEZONE="Europe/Berlin"
|
#DEFAULT_TIMEZONE="Europe/Berlin"
|
||||||
# The currency that is used inside the DB (and is assumed when no currency is set). This can not be changed later, so be sure to set it the currency used in your country
|
# The currency that is used inside the DB (and is assumed when no currency is set). This can not be changed later, so be sure to set it the currency used in your country
|
||||||
BASE_CURRENCY="EUR"
|
#BASE_CURRENCY="EUR"
|
||||||
|
|
||||||
# The public reachable URL of this Part-DB installation. This is used for generating links in SAML and email templates
|
# The public reachable URL of this Part-DB installation. This is used for generating links in SAML and email templates
|
||||||
# This must end with a slash!
|
# This must end with a slash!
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
framework:
|
framework:
|
||||||
default_locale: '%partdb.locale%'
|
default_locale: 'en'
|
||||||
# Just enable the locales we need for performance reasons.
|
# Just enable the locales we need for performance reasons.
|
||||||
enabled_locale: '%partdb.locale_menu%'
|
enabled_locale: '%partdb.locale_menu%'
|
||||||
translator:
|
translator:
|
||||||
default_path: '%kernel.project_dir%/translations'
|
default_path: '%kernel.project_dir%/translations'
|
||||||
fallbacks:
|
fallbacks:
|
||||||
- '%partdb.locale%'
|
|
||||||
- 'en'
|
- 'en'
|
||||||
providers:
|
providers:
|
||||||
# crowdin:
|
# crowdin:
|
||||||
|
|
|
@ -6,7 +6,6 @@ twig:
|
||||||
'%kernel.project_dir%/assets/css': css
|
'%kernel.project_dir%/assets/css': css
|
||||||
|
|
||||||
globals:
|
globals:
|
||||||
default_currency: '%partdb.default_currency%'
|
|
||||||
allow_email_pw_reset: '%partdb.users.email_pw_reset%'
|
allow_email_pw_reset: '%partdb.users.email_pw_reset%'
|
||||||
locale_menu: '%partdb.locale_menu%'
|
locale_menu: '%partdb.locale_menu%'
|
||||||
attachment_manager: '@App\Services\Attachments\AttachmentManager'
|
attachment_manager: '@App\Services\Attachments\AttachmentManager'
|
||||||
|
|
|
@ -5,12 +5,9 @@ parameters:
|
||||||
######################################################################################################################
|
######################################################################################################################
|
||||||
# Common
|
# Common
|
||||||
######################################################################################################################
|
######################################################################################################################
|
||||||
partdb.locale: '%env(string:DEFAULT_LANG)%' # The default language to use serverwide
|
|
||||||
partdb.timezone: '%env(string:DEFAULT_TIMEZONE)%' # The default timezone
|
|
||||||
|
|
||||||
# This is used as workaround for places where we can not access the settings directly (like the 2FA application names)
|
# This is used as workaround for places where we can not access the settings directly (like the 2FA application names)
|
||||||
partdb.title: '%env(string:settings:customization:instanceName)%' # The title shown inside of Part-DB (e.g. in the navbar and on homepage)
|
partdb.title: '%env(string:settings:customization:instanceName)%' # The title shown inside of Part-DB (e.g. in the navbar and on homepage)
|
||||||
partdb.default_currency: '%env(string:BASE_CURRENCY)%' # The currency that is used inside the DB (and is assumed when no currency is set). This can not be changed later, so be sure to set it the currency used in your country
|
|
||||||
partdb.locale_menu: ['en', 'de', 'it', 'fr', 'ru', 'ja', 'cs', 'da', 'zh'] # The languages that are shown in user drop down menu
|
partdb.locale_menu: ['en', 'de', 'it', 'fr', 'ru', 'ja', 'cs', 'da', 'zh'] # The languages that are shown in user drop down menu
|
||||||
|
|
||||||
partdb.default_uri: '%env(string:DEFAULT_URI)%' # The default URI to use for the Part-DB instance (e.g. https://part-db.example.com/). This is used for generating links in emails
|
partdb.default_uri: '%env(string:DEFAULT_URI)%' # The default URI to use for the Part-DB instance (e.g. https://part-db.example.com/). This is used for generating links in emails
|
||||||
|
@ -103,11 +100,6 @@ parameters:
|
||||||
# Env default values
|
# Env default values
|
||||||
######################################################################################################################
|
######################################################################################################################
|
||||||
|
|
||||||
env(DEFAULT_LANG): 'en'
|
|
||||||
env(DEFAULT_TIMEZONE): 'Europe/Berlin'
|
|
||||||
env(INSTANCE_NAME): 'Part-DB'
|
|
||||||
env(BASE_CURRENCY): 'EUR'
|
|
||||||
|
|
||||||
env(REDIRECT_TO_HTTPS): 0
|
env(REDIRECT_TO_HTTPS): 0
|
||||||
|
|
||||||
env(ERROR_PAGE_ADMIN_EMAIL): ''
|
env(ERROR_PAGE_ADMIN_EMAIL): ''
|
||||||
|
|
|
@ -17,7 +17,6 @@ services:
|
||||||
bool $gdpr_compliance: '%partdb.gdpr_compliance%'
|
bool $gdpr_compliance: '%partdb.gdpr_compliance%'
|
||||||
bool $kernel_debug_enabled: '%kernel.debug%'
|
bool $kernel_debug_enabled: '%kernel.debug%'
|
||||||
string $kernel_cache_dir: '%kernel.cache_dir%'
|
string $kernel_cache_dir: '%kernel.cache_dir%'
|
||||||
string $base_currency: '%partdb.default_currency%'
|
|
||||||
|
|
||||||
_instanceof:
|
_instanceof:
|
||||||
App\Services\LabelSystem\PlaceholderProviders\PlaceholderProviderInterface:
|
App\Services\LabelSystem\PlaceholderProviders\PlaceholderProviderInterface:
|
||||||
|
@ -137,29 +136,6 @@ services:
|
||||||
tags:
|
tags:
|
||||||
- { name: doctrine.orm.entity_listener }
|
- { name: doctrine.orm.entity_listener }
|
||||||
|
|
||||||
####################################################################################################################
|
|
||||||
# Price system
|
|
||||||
####################################################################################################################
|
|
||||||
App\Command\Currencies\UpdateExchangeRatesCommand:
|
|
||||||
arguments:
|
|
||||||
$base_current: '%partdb.default_currency%'
|
|
||||||
|
|
||||||
App\Form\Type\CurrencyEntityType:
|
|
||||||
arguments:
|
|
||||||
$base_currency: '%partdb.default_currency%'
|
|
||||||
|
|
||||||
App\Services\Parts\PricedetailHelper:
|
|
||||||
arguments:
|
|
||||||
$base_currency: '%partdb.default_currency%'
|
|
||||||
|
|
||||||
App\Services\Formatters\MoneyFormatter:
|
|
||||||
arguments:
|
|
||||||
$base_currency: '%partdb.default_currency%'
|
|
||||||
|
|
||||||
App\Services\Tools\ExchangeRateUpdater:
|
|
||||||
arguments:
|
|
||||||
$base_currency: '%partdb.default_currency%'
|
|
||||||
|
|
||||||
###################################################################################################################
|
###################################################################################################################
|
||||||
# User system
|
# User system
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
|
@ -167,10 +143,6 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
$demo_mode: '%partdb.demo_mode%'
|
$demo_mode: '%partdb.demo_mode%'
|
||||||
|
|
||||||
App\EventSubscriber\UserSystem\SetUserTimezoneSubscriber:
|
|
||||||
arguments:
|
|
||||||
$default_timezone: '%partdb.timezone%'
|
|
||||||
|
|
||||||
App\Controller\SecurityController:
|
App\Controller\SecurityController:
|
||||||
arguments:
|
arguments:
|
||||||
$allow_email_pw_reset: '%partdb.users.email_pw_reset%'
|
$allow_email_pw_reset: '%partdb.users.email_pw_reset%'
|
||||||
|
@ -261,8 +233,6 @@ services:
|
||||||
App\State\PartDBInfoProvider:
|
App\State\PartDBInfoProvider:
|
||||||
arguments:
|
arguments:
|
||||||
$default_uri: '%partdb.default_uri%'
|
$default_uri: '%partdb.default_uri%'
|
||||||
$global_locale: '%partdb.locale%'
|
|
||||||
$global_timezone: '%partdb.timezone%'
|
|
||||||
|
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
# EDA system
|
# EDA system
|
||||||
|
@ -294,7 +264,6 @@ services:
|
||||||
####################################################################################################################
|
####################################################################################################################
|
||||||
App\Controller\RedirectController:
|
App\Controller\RedirectController:
|
||||||
arguments:
|
arguments:
|
||||||
$default_locale: '%partdb.locale%'
|
|
||||||
$enforce_index_php: '%env(bool:NO_URL_REWRITE_AVAILABLE)%'
|
$enforce_index_php: '%env(bool:NO_URL_REWRITE_AVAILABLE)%'
|
||||||
|
|
||||||
App\Doctrine\Purger\ResetAutoIncrementPurgerFactory:
|
App\Doctrine\Purger\ResetAutoIncrementPurgerFactory:
|
||||||
|
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Command\Currencies;
|
namespace App\Command\Currencies;
|
||||||
|
|
||||||
|
use App\Settings\SystemSettings\LocalizationSettings;
|
||||||
use Symfony\Component\Console\Attribute\AsCommand;
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
use App\Services\Tools\ExchangeRateUpdater;
|
use App\Services\Tools\ExchangeRateUpdater;
|
||||||
|
@ -39,7 +40,7 @@ use function strlen;
|
||||||
#[AsCommand('partdb:currencies:update-exchange-rates|partdb:update-exchange-rates|app:update-exchange-rates', 'Updates the currency exchange rates.')]
|
#[AsCommand('partdb:currencies:update-exchange-rates|partdb:update-exchange-rates|app:update-exchange-rates', 'Updates the currency exchange rates.')]
|
||||||
class UpdateExchangeRatesCommand extends Command
|
class UpdateExchangeRatesCommand extends Command
|
||||||
{
|
{
|
||||||
public function __construct(protected string $base_current, protected EntityManagerInterface $em, protected ExchangeRateUpdater $exchangeRateUpdater)
|
public function __construct(protected EntityManagerInterface $em, protected ExchangeRateUpdater $exchangeRateUpdater, private readonly LocalizationSettings $localizationSettings)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
@ -54,13 +55,13 @@ class UpdateExchangeRatesCommand extends Command
|
||||||
$io = new SymfonyStyle($input, $output);
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
//Check for valid base current
|
//Check for valid base current
|
||||||
if (3 !== strlen($this->base_current)) {
|
if (3 !== strlen($this->localizationSettings->baseCurrency)) {
|
||||||
$io->error('Chosen Base current is not valid. Check your settings!');
|
$io->error('Chosen Base current is not valid. Check your settings!');
|
||||||
|
|
||||||
return Command::FAILURE;
|
return Command::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$io->note('Update currency exchange rates with base currency: '.$this->base_current);
|
$io->note('Update currency exchange rates with base currency: '.$this->localizationSettings->baseCurrency);
|
||||||
|
|
||||||
//Check what currencies we need to update:
|
//Check what currencies we need to update:
|
||||||
$iso_code = $input->getArgument('iso_code');
|
$iso_code = $input->getArgument('iso_code');
|
||||||
|
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
|
use App\Settings\SystemSettings\LocalizationSettings;
|
||||||
use function function_exists;
|
use function function_exists;
|
||||||
use function in_array;
|
use function in_array;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
@ -35,7 +36,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
*/
|
*/
|
||||||
class RedirectController extends AbstractController
|
class RedirectController extends AbstractController
|
||||||
{
|
{
|
||||||
public function __construct(protected string $default_locale, protected TranslatorInterface $translator, protected bool $enforce_index_php)
|
public function __construct(private readonly LocalizationSettings $localizationSettings, protected TranslatorInterface $translator, protected bool $enforce_index_php)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ class RedirectController extends AbstractController
|
||||||
public function addLocalePart(Request $request): RedirectResponse
|
public function addLocalePart(Request $request): RedirectResponse
|
||||||
{
|
{
|
||||||
//By default, we use the global default locale
|
//By default, we use the global default locale
|
||||||
$locale = $this->default_locale;
|
$locale = $this->localizationSettings->locale;
|
||||||
|
|
||||||
//Check if a user has set a preferred language setting:
|
//Check if a user has set a preferred language setting:
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
|
|
|
@ -197,7 +197,7 @@ class User extends AttachmentContainingDBElement implements UserInterface, HasPe
|
||||||
/**
|
/**
|
||||||
* @var string|null The language/locale the user prefers
|
* @var string|null The language/locale the user prefers
|
||||||
*/
|
*/
|
||||||
#[Assert\Language]
|
#[Assert\Locale]
|
||||||
#[Groups(['full', 'import', 'user:read'])]
|
#[Groups(['full', 'import', 'user:read'])]
|
||||||
#[ORM\Column(name: 'config_language', type: Types::STRING, nullable: true)]
|
#[ORM\Column(name: 'config_language', type: Types::STRING, nullable: true)]
|
||||||
protected ?string $language = '';
|
protected ?string $language = '';
|
||||||
|
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||||
namespace App\EventSubscriber\UserSystem;
|
namespace App\EventSubscriber\UserSystem;
|
||||||
|
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
|
use App\Settings\SystemSettings\LocalizationSettings;
|
||||||
use Symfony\Bundle\SecurityBundle\Security;
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\ControllerEvent;
|
use Symfony\Component\HttpKernel\Event\ControllerEvent;
|
||||||
|
@ -33,7 +34,7 @@ use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
*/
|
*/
|
||||||
final class SetUserTimezoneSubscriber implements EventSubscriberInterface
|
final class SetUserTimezoneSubscriber implements EventSubscriberInterface
|
||||||
{
|
{
|
||||||
public function __construct(private readonly string $default_timezone, private readonly Security $security)
|
public function __construct(private readonly LocalizationSettings $localizationSettings, private readonly Security $security)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +49,8 @@ final class SetUserTimezoneSubscriber implements EventSubscriberInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
//Fill with default value if needed
|
//Fill with default value if needed
|
||||||
if (null === $timezone && $this->default_timezone !== '') {
|
if (null === $timezone && $this->localizationSettings !== '') {
|
||||||
$timezone = $this->default_timezone;
|
$timezone = $this->localizationSettings->timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
//If timezone was configured anywhere set it, otherwise just use the one from php.ini
|
//If timezone was configured anywhere set it, otherwise just use the one from php.ini
|
||||||
|
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\AdminPages;
|
namespace App\Form\AdminPages;
|
||||||
|
|
||||||
|
use App\Settings\SystemSettings\LocalizationSettings;
|
||||||
use Symfony\Bundle\SecurityBundle\Security;
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
use App\Entity\Base\AbstractNamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Form\Type\BigDecimalMoneyType;
|
use App\Form\Type\BigDecimalMoneyType;
|
||||||
|
@ -32,7 +33,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class CurrencyAdminForm extends BaseEntityAdminForm
|
class CurrencyAdminForm extends BaseEntityAdminForm
|
||||||
{
|
{
|
||||||
public function __construct(Security $security, EventCommentNeededHelper $eventCommentNeededHelper, private readonly string $base_currency)
|
public function __construct(Security $security, EventCommentNeededHelper $eventCommentNeededHelper, private readonly LocalizationSettings $localizationSettings)
|
||||||
{
|
{
|
||||||
parent::__construct($security, $eventCommentNeededHelper);
|
parent::__construct($security, $eventCommentNeededHelper);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +52,7 @@ class CurrencyAdminForm extends BaseEntityAdminForm
|
||||||
$builder->add('exchange_rate', BigDecimalMoneyType::class, [
|
$builder->add('exchange_rate', BigDecimalMoneyType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'label' => 'currency.edit.exchange_rate',
|
'label' => 'currency.edit.exchange_rate',
|
||||||
'currency' => $this->base_currency,
|
'currency' => $this->localizationSettings->baseCurrency,
|
||||||
'scale' => 6,
|
'scale' => 6,
|
||||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form\AdminPages;
|
namespace App\Form\AdminPages;
|
||||||
|
|
||||||
|
use App\Settings\SystemSettings\LocalizationSettings;
|
||||||
use Symfony\Bundle\SecurityBundle\Security;
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
use App\Entity\Base\AbstractNamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
|
@ -32,7 +33,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
class SupplierForm extends CompanyForm
|
class SupplierForm extends CompanyForm
|
||||||
{
|
{
|
||||||
public function __construct(Security $security, EventCommentNeededHelper $eventCommentNeededHelper, protected string $base_currency)
|
public function __construct(Security $security, EventCommentNeededHelper $eventCommentNeededHelper, private readonly LocalizationSettings $localizationSettings)
|
||||||
{
|
{
|
||||||
parent::__construct($security, $eventCommentNeededHelper);
|
parent::__construct($security, $eventCommentNeededHelper);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +54,7 @@ class SupplierForm extends CompanyForm
|
||||||
|
|
||||||
$builder->add('shipping_costs', BigDecimalMoneyType::class, [
|
$builder->add('shipping_costs', BigDecimalMoneyType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'currency' => $this->base_currency,
|
'currency' => $this->localizationSettings->baseCurrency,
|
||||||
'scale' => 3,
|
'scale' => 3,
|
||||||
'label' => 'supplier.shipping_costs.label',
|
'label' => 'supplier.shipping_costs.label',
|
||||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace App\Form\Type;
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
use App\Form\Type\Helper\StructuralEntityChoiceHelper;
|
use App\Form\Type\Helper\StructuralEntityChoiceHelper;
|
||||||
use App\Services\Trees\NodesListBuilder;
|
use App\Services\Trees\NodesListBuilder;
|
||||||
|
use App\Settings\SystemSettings\LocalizationSettings;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\Intl\Currencies;
|
use Symfony\Component\Intl\Currencies;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
|
@ -36,7 +37,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
*/
|
*/
|
||||||
class CurrencyEntityType extends StructuralEntityType
|
class CurrencyEntityType extends StructuralEntityType
|
||||||
{
|
{
|
||||||
public function __construct(EntityManagerInterface $em, NodesListBuilder $builder, TranslatorInterface $translator, StructuralEntityChoiceHelper $choiceHelper, protected ?string $base_currency)
|
public function __construct(EntityManagerInterface $em, NodesListBuilder $builder, TranslatorInterface $translator, StructuralEntityChoiceHelper $choiceHelper, private readonly LocalizationSettings $localizationSettings)
|
||||||
{
|
{
|
||||||
parent::__construct($em, $builder, $translator, $choiceHelper);
|
parent::__construct($em, $builder, $translator, $choiceHelper);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +58,7 @@ class CurrencyEntityType extends StructuralEntityType
|
||||||
|
|
||||||
$resolver->setDefault('empty_message', function (Options $options) {
|
$resolver->setDefault('empty_message', function (Options $options) {
|
||||||
//By default, we use the global base currency:
|
//By default, we use the global base currency:
|
||||||
$iso_code = $this->base_currency;
|
$iso_code = $this->localizationSettings->baseCurrency;
|
||||||
|
|
||||||
if ($options['base_currency']) { //Allow to override it
|
if ($options['base_currency']) { //Allow to override it
|
||||||
$iso_code = $options['base_currency'];
|
$iso_code = $options['base_currency'];
|
||||||
|
|
53
src/Form/Type/LocaleSelectType.php
Normal file
53
src/Form/Type/LocaleSelectType.php
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?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\Form\Type;
|
||||||
|
|
||||||
|
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\LocaleType;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A locale select field that uses the preferred languages from the configuration.
|
||||||
|
|
||||||
|
*/
|
||||||
|
class LocaleSelectType extends AbstractType
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct(#[Autowire(param: 'partdb.locale_menu')] private readonly array $preferred_languages)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public function getParent(): string
|
||||||
|
{
|
||||||
|
return LocaleType::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'preferred_choices' => $this->preferred_languages,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form;
|
namespace App\Form;
|
||||||
|
|
||||||
|
use App\Form\Type\LocaleSelectType;
|
||||||
use Symfony\Bundle\SecurityBundle\Security;
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
use App\Entity\Base\AbstractNamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\UserSystem\Group;
|
use App\Entity\UserSystem\Group;
|
||||||
|
@ -35,7 +36,6 @@ use App\Form\Type\ThemeChoiceType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\LanguageType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ResetType;
|
use Symfony\Component\Form\Extension\Core\Type\ResetType;
|
||||||
|
@ -138,11 +138,10 @@ class UserAdminForm extends AbstractType
|
||||||
])
|
])
|
||||||
|
|
||||||
//Config section
|
//Config section
|
||||||
->add('language', LanguageType::class, [
|
->add('language', LocaleSelectType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'placeholder' => 'user_settings.language.placeholder',
|
'placeholder' => 'user_settings.language.placeholder',
|
||||||
'label' => 'user.language_select',
|
'label' => 'user.language_select',
|
||||||
'preferred_choices' => ['en', 'de'],
|
|
||||||
'disabled' => !$this->security->isGranted('change_user_settings', $entity),
|
'disabled' => !$this->security->isGranted('change_user_settings', $entity),
|
||||||
])
|
])
|
||||||
->add('timezone', TimezoneType::class, [
|
->add('timezone', TimezoneType::class, [
|
||||||
|
|
|
@ -22,6 +22,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Form;
|
namespace App\Form;
|
||||||
|
|
||||||
|
use App\Form\Type\LocaleSelectType;
|
||||||
use Symfony\Bundle\SecurityBundle\Security;
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use App\Form\Type\CurrencyEntityType;
|
use App\Form\Type\CurrencyEntityType;
|
||||||
|
@ -33,7 +34,6 @@ use Symfony\Component\Form\Event\PreSetDataEvent;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\LanguageType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ResetType;
|
use Symfony\Component\Form\Extension\Core\Type\ResetType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
@ -47,7 +47,7 @@ class UserSettingsType extends AbstractType
|
||||||
{
|
{
|
||||||
public function __construct(protected Security $security,
|
public function __construct(protected Security $security,
|
||||||
protected bool $demo_mode,
|
protected bool $demo_mode,
|
||||||
#[Autowire(param: 'partdb.locale_menu')] private readonly array $preferred_languages)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,12 +107,11 @@ class UserSettingsType extends AbstractType
|
||||||
'mode' => 'markdown-full',
|
'mode' => 'markdown-full',
|
||||||
'disabled' => !$this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
|
'disabled' => !$this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
|
||||||
])
|
])
|
||||||
->add('language', LanguageType::class, [
|
->add('language', LocaleSelectType::class, [
|
||||||
'disabled' => $this->demo_mode,
|
'disabled' => $this->demo_mode,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'placeholder' => 'user_settings.language.placeholder',
|
'placeholder' => 'user_settings.language.placeholder',
|
||||||
'label' => 'user.language_select',
|
'label' => 'user.language_select',
|
||||||
'preferred_choices' => $this->preferred_languages,
|
|
||||||
])
|
])
|
||||||
->add('timezone', TimezoneType::class, [
|
->add('timezone', TimezoneType::class, [
|
||||||
'disabled' => $this->demo_mode,
|
'disabled' => $this->demo_mode,
|
||||||
|
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||||
namespace App\Services\Formatters;
|
namespace App\Services\Formatters;
|
||||||
|
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
|
use App\Settings\SystemSettings\LocalizationSettings;
|
||||||
use Locale;
|
use Locale;
|
||||||
use NumberFormatter;
|
use NumberFormatter;
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ class MoneyFormatter
|
||||||
{
|
{
|
||||||
protected string $locale;
|
protected string $locale;
|
||||||
|
|
||||||
public function __construct(protected string $base_currency)
|
public function __construct(private readonly LocalizationSettings $localizationSettings)
|
||||||
{
|
{
|
||||||
$this->locale = Locale::getDefault();
|
$this->locale = Locale::getDefault();
|
||||||
}
|
}
|
||||||
|
@ -45,7 +46,7 @@ class MoneyFormatter
|
||||||
*/
|
*/
|
||||||
public function format(string|float $value, ?Currency $currency = null, int $decimals = 5, bool $show_all_digits = false): string
|
public function format(string|float $value, ?Currency $currency = null, int $decimals = 5, bool $show_all_digits = false): string
|
||||||
{
|
{
|
||||||
$iso_code = $this->base_currency;
|
$iso_code = $this->localizationSettings->baseCurrency;
|
||||||
if ($currency instanceof Currency && ($currency->getIsoCode() !== null && $currency->getIsoCode() !== '')) {
|
if ($currency instanceof Currency && ($currency->getIsoCode() !== null && $currency->getIsoCode() !== '')) {
|
||||||
$iso_code = $currency->getIsoCode();
|
$iso_code = $currency->getIsoCode();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ use App\Entity\Parts\Supplier;
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
use App\Entity\PriceInformations\Orderdetail;
|
use App\Entity\PriceInformations\Orderdetail;
|
||||||
use App\Entity\PriceInformations\Pricedetail;
|
use App\Entity\PriceInformations\Pricedetail;
|
||||||
|
use App\Settings\SystemSettings\LocalizationSettings;
|
||||||
use Brick\Math\BigDecimal;
|
use Brick\Math\BigDecimal;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\Intl\Currencies;
|
use Symfony\Component\Intl\Currencies;
|
||||||
|
@ -47,7 +48,7 @@ class PKPartImporter
|
||||||
{
|
{
|
||||||
use PKImportHelperTrait;
|
use PKImportHelperTrait;
|
||||||
|
|
||||||
public function __construct(EntityManagerInterface $em, PropertyAccessorInterface $propertyAccessor, private readonly string $base_currency)
|
public function __construct(EntityManagerInterface $em, PropertyAccessorInterface $propertyAccessor, private readonly LocalizationSettings $localizationSettings)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
$this->propertyAccessor = $propertyAccessor;
|
$this->propertyAccessor = $propertyAccessor;
|
||||||
|
@ -210,7 +211,7 @@ class PKPartImporter
|
||||||
$currency_iso_code = strtoupper($currency_iso_code);
|
$currency_iso_code = strtoupper($currency_iso_code);
|
||||||
|
|
||||||
//We do not have a currency for the base currency to be consistent with prices without currencies
|
//We do not have a currency for the base currency to be consistent with prices without currencies
|
||||||
if ($currency_iso_code === $this->base_currency) {
|
if ($currency_iso_code === $this->localizationSettings->baseCurrency) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ use App\Services\InfoProviderSystem\DTOs\ParameterDTO;
|
||||||
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
|
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
|
||||||
use App\Services\InfoProviderSystem\DTOs\PriceDTO;
|
use App\Services\InfoProviderSystem\DTOs\PriceDTO;
|
||||||
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
|
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
|
||||||
|
use App\Settings\SystemSettings\LocalizationSettings;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,8 +53,11 @@ final class DTOtoEntityConverter
|
||||||
private const TYPE_DATASHEETS_NAME = 'Datasheet';
|
private const TYPE_DATASHEETS_NAME = 'Datasheet';
|
||||||
private const TYPE_IMAGE_NAME = 'Image';
|
private const TYPE_IMAGE_NAME = 'Image';
|
||||||
|
|
||||||
public function __construct(private readonly EntityManagerInterface $em, private readonly string $base_currency)
|
private readonly string $base_currency;
|
||||||
|
|
||||||
|
public function __construct(private readonly EntityManagerInterface $em, LocalizationSettings $localizationSettings)
|
||||||
{
|
{
|
||||||
|
$this->base_currency = $localizationSettings->baseCurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace App\Services\Parts;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
use App\Entity\PriceInformations\Pricedetail;
|
use App\Entity\PriceInformations\Pricedetail;
|
||||||
|
use App\Settings\SystemSettings\LocalizationSettings;
|
||||||
use Brick\Math\BigDecimal;
|
use Brick\Math\BigDecimal;
|
||||||
use Brick\Math\RoundingMode;
|
use Brick\Math\RoundingMode;
|
||||||
use Doctrine\ORM\PersistentCollection;
|
use Doctrine\ORM\PersistentCollection;
|
||||||
|
@ -39,7 +40,7 @@ class PricedetailHelper
|
||||||
{
|
{
|
||||||
protected string $locale;
|
protected string $locale;
|
||||||
|
|
||||||
public function __construct(protected string $base_currency)
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->locale = Locale::getDefault();
|
$this->locale = Locale::getDefault();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,13 +23,14 @@ declare(strict_types=1);
|
||||||
namespace App\Services\Tools;
|
namespace App\Services\Tools;
|
||||||
|
|
||||||
use App\Entity\PriceInformations\Currency;
|
use App\Entity\PriceInformations\Currency;
|
||||||
|
use App\Settings\SystemSettings\LocalizationSettings;
|
||||||
use Brick\Math\BigDecimal;
|
use Brick\Math\BigDecimal;
|
||||||
use Brick\Math\RoundingMode;
|
use Brick\Math\RoundingMode;
|
||||||
use Swap\Swap;
|
use Swap\Swap;
|
||||||
|
|
||||||
class ExchangeRateUpdater
|
class ExchangeRateUpdater
|
||||||
{
|
{
|
||||||
public function __construct(private readonly string $base_currency, private readonly Swap $swap)
|
public function __construct(private LocalizationSettings $localizationSettings, private readonly Swap $swap)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ class ExchangeRateUpdater
|
||||||
public function update(Currency $currency): Currency
|
public function update(Currency $currency): Currency
|
||||||
{
|
{
|
||||||
//Currency pairs are always in the format "BASE/QUOTE"
|
//Currency pairs are always in the format "BASE/QUOTE"
|
||||||
$rate = $this->swap->latest($this->base_currency.'/'.$currency->getIsoCode());
|
$rate = $this->swap->latest($this->localizationSettings->baseCurrency.'/'.$currency->getIsoCode());
|
||||||
//The rate says how many quote units are worth one base unit
|
//The rate says how many quote units are worth one base unit
|
||||||
//So we need to invert it to get the exchange rate
|
//So we need to invert it to get the exchange rate
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace App\Settings;
|
||||||
use App\Settings\SystemSettings\AttachmentsSettings;
|
use App\Settings\SystemSettings\AttachmentsSettings;
|
||||||
use App\Settings\SystemSettings\CustomizationSettings;
|
use App\Settings\SystemSettings\CustomizationSettings;
|
||||||
use App\Settings\SystemSettings\HistorySettings;
|
use App\Settings\SystemSettings\HistorySettings;
|
||||||
|
use App\Settings\SystemSettings\LocalizationSettings;
|
||||||
use App\Settings\SystemSettings\PrivacySettings;
|
use App\Settings\SystemSettings\PrivacySettings;
|
||||||
use Jbtronics\SettingsBundle\Settings\EmbeddedSettings;
|
use Jbtronics\SettingsBundle\Settings\EmbeddedSettings;
|
||||||
use Jbtronics\SettingsBundle\Settings\Settings;
|
use Jbtronics\SettingsBundle\Settings\Settings;
|
||||||
|
@ -33,6 +34,9 @@ use Jbtronics\SettingsBundle\Settings\Settings;
|
||||||
#[Settings]
|
#[Settings]
|
||||||
class SystemSettings
|
class SystemSettings
|
||||||
{
|
{
|
||||||
|
#[EmbeddedSettings()]
|
||||||
|
public ?LocalizationSettings $localization = null;
|
||||||
|
|
||||||
#[EmbeddedSettings()]
|
#[EmbeddedSettings()]
|
||||||
public ?CustomizationSettings $customization = null;
|
public ?CustomizationSettings $customization = null;
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,14 @@ use Jbtronics\SettingsBundle\ParameterTypes\ArrayType;
|
||||||
use Jbtronics\SettingsBundle\ParameterTypes\EnumType;
|
use Jbtronics\SettingsBundle\ParameterTypes\EnumType;
|
||||||
use Jbtronics\SettingsBundle\Settings\Settings;
|
use Jbtronics\SettingsBundle\Settings\Settings;
|
||||||
use Jbtronics\SettingsBundle\Settings\SettingsParameter;
|
use Jbtronics\SettingsBundle\Settings\SettingsParameter;
|
||||||
|
use Jbtronics\SettingsBundle\Settings\SettingsTrait;
|
||||||
use Symfony\Component\Translation\TranslatableMessage as TM;
|
use Symfony\Component\Translation\TranslatableMessage as TM;
|
||||||
|
|
||||||
#[Settings(label: new TM("settings.system.history"))]
|
#[Settings(label: new TM("settings.system.history"))]
|
||||||
class HistorySettings
|
class HistorySettings
|
||||||
{
|
{
|
||||||
|
use SettingsTrait;
|
||||||
|
|
||||||
#[SettingsParameter(
|
#[SettingsParameter(
|
||||||
label: new TM("settings.system.history.saveChangedFields"),
|
label: new TM("settings.system.history.saveChangedFields"),
|
||||||
envVar: "bool:HISTORY_SAVE_CHANGED_FIELDS", envVarMode: EnvVarMode::OVERWRITE)]
|
envVar: "bool:HISTORY_SAVE_CHANGED_FIELDS", envVarMode: EnvVarMode::OVERWRITE)]
|
||||||
|
|
61
src/Settings/SystemSettings/LocalizationSettings.php
Normal file
61
src/Settings/SystemSettings/LocalizationSettings.php
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
<?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;
|
||||||
|
|
||||||
|
use App\Form\Type\LocaleSelectType;
|
||||||
|
use Jbtronics\SettingsBundle\Metadata\EnvVarMode;
|
||||||
|
use Jbtronics\SettingsBundle\Settings\Settings;
|
||||||
|
use Jbtronics\SettingsBundle\Settings\SettingsParameter;
|
||||||
|
use Jbtronics\SettingsBundle\Settings\SettingsTrait;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CurrencyType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TimezoneType;
|
||||||
|
use Symfony\Component\Translation\TranslatableMessage as TM;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
#[Settings(label: new TM("settings.system.localization"))]
|
||||||
|
class LocalizationSettings
|
||||||
|
{
|
||||||
|
use SettingsTrait;
|
||||||
|
|
||||||
|
#[Assert\Locale()]
|
||||||
|
#[Assert\NotBlank()]
|
||||||
|
#[SettingsParameter(label: new TM("settings.system.localization.locale"), formType: LocaleSelectType::class,
|
||||||
|
envVar: "string:DEFAULT_LANG", envVarMode: EnvVarMode::OVERWRITE)]
|
||||||
|
public string $locale = 'en';
|
||||||
|
|
||||||
|
#[Assert\Timezone()]
|
||||||
|
#[Assert\NotBlank()]
|
||||||
|
#[SettingsParameter(label: new TM("settings.system.localization.timezone"), formType: TimezoneType::class,
|
||||||
|
envVar: "string:DEFAULT_TIMEZONE", envVarMode: EnvVarMode::OVERWRITE)]
|
||||||
|
public string $timezone = 'Europe/Berlin';
|
||||||
|
|
||||||
|
#[Assert\Currency()]
|
||||||
|
#[Assert\NotBlank()]
|
||||||
|
#[SettingsParameter(label: new TM("settings.system.localization.base_currency"),
|
||||||
|
description: new TM("settings.system.localization.base_currency_description"),
|
||||||
|
formType: CurrencyType::class, formOptions: ['preferred_choices' => ['EUR', 'USD', 'GBP', "JPY", "CNY"], 'help_html' => true],
|
||||||
|
envVar: "string:BASE_CURRENCY", envVarMode: EnvVarMode::OVERWRITE
|
||||||
|
)]
|
||||||
|
public string $baseCurrency = 'EUR';
|
||||||
|
}
|
|
@ -29,7 +29,7 @@ use Jbtronics\SettingsBundle\Settings\SettingsParameter;
|
||||||
use Jbtronics\SettingsBundle\Settings\SettingsTrait;
|
use Jbtronics\SettingsBundle\Settings\SettingsTrait;
|
||||||
use Symfony\Component\Translation\TranslatableMessage as TM;
|
use Symfony\Component\Translation\TranslatableMessage as TM;
|
||||||
|
|
||||||
#[Settings]
|
#[Settings(label: new TM("settings.system.privacy"))]
|
||||||
class PrivacySettings
|
class PrivacySettings
|
||||||
{
|
{
|
||||||
use SettingsTrait;
|
use SettingsTrait;
|
||||||
|
|
|
@ -10,6 +10,7 @@ use App\ApiResource\PartDBInfo;
|
||||||
use App\Services\Misc\GitVersionInfo;
|
use App\Services\Misc\GitVersionInfo;
|
||||||
use App\Services\System\BannerHelper;
|
use App\Services\System\BannerHelper;
|
||||||
use App\Settings\SystemSettings\CustomizationSettings;
|
use App\Settings\SystemSettings\CustomizationSettings;
|
||||||
|
use App\Settings\SystemSettings\LocalizationSettings;
|
||||||
use Shivas\VersioningBundle\Service\VersionManagerInterface;
|
use Shivas\VersioningBundle\Service\VersionManagerInterface;
|
||||||
|
|
||||||
class PartDBInfoProvider implements ProviderInterface
|
class PartDBInfoProvider implements ProviderInterface
|
||||||
|
@ -17,11 +18,9 @@ class PartDBInfoProvider implements ProviderInterface
|
||||||
|
|
||||||
public function __construct(private readonly VersionManagerInterface $versionManager,
|
public function __construct(private readonly VersionManagerInterface $versionManager,
|
||||||
private readonly GitVersionInfo $gitVersionInfo,
|
private readonly GitVersionInfo $gitVersionInfo,
|
||||||
private readonly string $base_currency,
|
|
||||||
private readonly BannerHelper $bannerHelper,
|
private readonly BannerHelper $bannerHelper,
|
||||||
private readonly string $default_uri,
|
private readonly string $default_uri,
|
||||||
private readonly string $global_timezone,
|
private readonly LocalizationSettings $localizationSettings,
|
||||||
private readonly string $global_locale,
|
|
||||||
private readonly CustomizationSettings $customizationSettings,
|
private readonly CustomizationSettings $customizationSettings,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -37,9 +36,9 @@ class PartDBInfoProvider implements ProviderInterface
|
||||||
title: $this->customizationSettings->instanceName,
|
title: $this->customizationSettings->instanceName,
|
||||||
banner: $this->bannerHelper->getBanner(),
|
banner: $this->bannerHelper->getBanner(),
|
||||||
default_uri: $this->default_uri,
|
default_uri: $this->default_uri,
|
||||||
global_timezone: $this->global_timezone,
|
global_timezone: $this->localizationSettings->timezone,
|
||||||
base_currency: $this->base_currency,
|
base_currency: $this->localizationSettings->baseCurrency,
|
||||||
global_locale: $this->global_locale,
|
global_locale: $this->localizationSettings->locale,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12551,5 +12551,42 @@ Please note, that you can not impersonate a disabled user. If you try you will g
|
||||||
<target>Part-DB regularly checks if a new version is available on GitHub. Disable this here, if you do not want this or if your server can not connect to the internet.</target>
|
<target>Part-DB regularly checks if a new version is available on GitHub. Disable this here, if you do not want this or if your server can not connect to the internet.</target>
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
|
<unit id="_wYDoEy" name="settings.system.localization.locale">
|
||||||
|
<segment>
|
||||||
|
<source>settings.system.localization.locale</source>
|
||||||
|
<target>Default language / locale</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
|
<unit id="K8mVEEQ" name="settings.system.localization">
|
||||||
|
<segment>
|
||||||
|
<source>settings.system.localization</source>
|
||||||
|
<target>Localization</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
|
<unit id="fLOdzsf" name="settings.system.localization.timezone">
|
||||||
|
<segment>
|
||||||
|
<source>settings.system.localization.timezone</source>
|
||||||
|
<target>Default timezone</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
|
<unit id="gdx8h1U" name="settings.system.localization.base_currency">
|
||||||
|
<segment>
|
||||||
|
<source>settings.system.localization.base_currency</source>
|
||||||
|
<target>Base currency</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
|
<unit id="DhNnWlg" name="settings.system.localization.base_currency_description">
|
||||||
|
<segment>
|
||||||
|
<source>settings.system.localization.base_currency_description</source>
|
||||||
|
<target><![CDATA[The currency that is used to store price information and exchange rates in. This currency is assumed, when no currency is set for a price information.
|
||||||
|
<b>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!</b>]]></target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
|
<unit id="7BwmKFC" name="settings.system.privacy">
|
||||||
|
<segment>
|
||||||
|
<source>settings.system.privacy</source>
|
||||||
|
<target>Privacy</target>
|
||||||
|
</segment>
|
||||||
|
</unit>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
||||||
|
|
|
@ -354,7 +354,7 @@
|
||||||
</segment>
|
</segment>
|
||||||
</unit>
|
</unit>
|
||||||
<unit id="iXcU7ce" name="validator.invalid_range">
|
<unit id="iXcU7ce" name="validator.invalid_range">
|
||||||
<segment state="translated">
|
<segment>
|
||||||
<source>validator.invalid_range</source>
|
<source>validator.invalid_range</source>
|
||||||
<target>The given range is not valid!</target>
|
<target>The given range is not valid!</target>
|
||||||
</segment>
|
</segment>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue