qbbr / locale-configurator-bundle
Simple configuration on locale
Installs: 10
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.4|^8.0
- symfony/framework-bundle: ^4.4|^5.0|^6.0
- symfony/http-foundation: ^4.4|^5.0|^6.0
- symfony/twig-bundle: ^4.4|^5.0|^6.0
- symfony/yaml: ^4.4|^5.0|^6.0
Requires (Dev)
- phpunit/phpunit: ^9.5
README
Simple configuration on locale.
Installation
Step 1: Download the Bundle
composer require qbbr/locale-configurator-bundle
Step 2: Enable the Bundle
// config/bundles.php return [ // ... Qbbr\LocaleConfiguratorBundle\LocaleConfiguratorBundle::class => ['all' => true], ];
Configuration
Config structure
config/locale_configurator/
├── _default.yaml
├── en.yaml
├── ru.yaml
└── ...
logic: config = merge(_default.yaml, locale.yaml)
Parameters by default
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
Usage
PHP
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'); } }
Twig
has lc_has
/lc_get
fn.
{% if lc_has('param1') %} ... {% endif %} {% set param1 = lc_get('param1') %}
Tests
./vendor/bin/phpunit Tests/ -v --testdox