Simple configuration on locale.
composer require qbbr/locale-configurator-bundle
// config/bundles.php
return [
// ...
Qbbr\LocaleConfiguratorBundle\LocaleConfiguratorBundle::class => ['all' => true],
];
config/locale_configurator/
├── _default.yaml
├── en.yaml
├── ru.yaml
└── ...
logic: config = merge(_default.yaml, locale.yaml)
u can override it.
parameters:
qbbr.locale_configurator.config_dir: '%kernel.project_dir%/config/locale_configurator'
qbbr.locale_configurator.raise_not_found_param_exception: false
use Qbbr\LocaleConfiguratorBundle\Configurator\LocaleConfigurator;
class SomeService
{
private LocaleConfigurator $lc;
public function __construct(
LocaleConfigurator $lc
) {
$this->lc = $lc;
}
public function something()
{
// $this->lc->setLocale('ru');
$param1 = $this->lc->get('param1');
}
}
has lc_has
/lc_get
fn.
{% if lc_has('param1') %}
...
{% endif %}
{% set param1 = lc_get('param1') %}
./vendor/bin/phpunit Tests/ -v --testdox