-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot set default locale with language switcher #66
Labels
Comments
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
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());
}
} |
arogachev
added
status:to be verified
Needs to be reproduced and validated.
type:bug
Bug
labels
Jan 15, 2024
Are you using Locale middleware? Could you show its config? |
Yes,
<?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**',
],
],
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
If I call my website url without language the german website is show as expected.
If I switch to English the german website is shown again without 'en'. (website)
If I switch to German the german website is shown but with the 'de'
(website/de)
The text was updated successfully, but these errors were encountered: