Open kmergen opened 9 months ago
Likely that's the issue of Locale middleware.
Actually... have you configured it?
params.php
'yiisoft/translator' => [
'locale' => 'de',
'fallbackLocale' => 'de',
'defaultCategory' => 'app',
],
With other words. I cannot switch to English language.
sourceLocale is always 'en' (How can i change this).
If i choose English the handle function in
src\EventHandler\SetLocaleEventHandler.php
is not called
final class SetLocaleEventHandler
{
public function __construct(
private TranslatorInterface $translator,
private WebView $webView
) {
}
public function handle(SetLocaleEvent $event): void
{
$this->translator->setLocale($event->getLocale());
$this->webView->setLocale($event->getLocale());
}
}
Yes,
config\web\params.php
<?php
declare(strict_types=1);
use Yiisoft\ErrorHandler\Middleware\ErrorCatcher;
use Yiisoft\Router\Middleware\Router;
use Yiisoft\Session\SessionMiddleware;
use Yiisoft\Yii\Middleware\Locale;
return [
'middlewares' => [
ErrorCatcher::class,
SessionMiddleware::class,
Locale::class,
Router::class,
],
'locale' => [
'locales' => ['de' => 'de-DE', 'en' => 'en-US', 'nl' => 'nl-NL', 'fr' => 'fr-FR'],
'ignoredRequests' => [
'/debug**',
],
],
];
What steps will reproduce the problem?
My default locaal is 'de'.
What is the expected result?
An url without 'de'
What do you get instead?
An url with 'de'
Additional info
I have this language switcher:
my config params.php