Skip to content

Commit

Permalink
Set current locale for WebView
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Oct 26, 2023
1 parent 42c82ad commit aed8adf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/EventHandler/SetLocaleEventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
namespace App\EventHandler;

use Yiisoft\Translator\TranslatorInterface;
use Yiisoft\View\WebView;
use Yiisoft\Yii\Middleware\Event\SetLocaleEvent;

final class SetLocaleEventHandler
{
public function __construct(
private TranslatorInterface $translator
private TranslatorInterface $translator,
private WebView $webView
) {
}

public function handle(SetLocaleEvent $event): void
{
$this->translator->setLocale($event->getLocale());
$this->webView->setLocale($event->getLocale());
}
}

0 comments on commit aed8adf

Please sign in to comment.