Skip to content

Remove locale middleware #341

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

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/common/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Yiisoft\Router\Route;

return [
Group::create('/{_language}')
Group::create()
->routes(
Route::get('/')->action([SiteController::class, 'index'])->name('home'),
),
Expand Down
6 changes: 0 additions & 6 deletions config/web/di/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,4 @@
'fallbackHandler' => Reference::to(NotFoundHandler::class),
],
],
\Yiisoft\Yii\Middleware\Locale::class => [
'__construct()' => [
'supportedLocales' => $params['locale']['locales'],
'ignoredRequestUrlPatterns' => $params['locale']['ignoredRequests'],
],
],
];
4 changes: 0 additions & 4 deletions config/web/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@

declare(strict_types=1);

use App\EventHandler\SetLocaleEventHandler;
use Yiisoft\Yii\Middleware\Event\SetLocaleEvent;

return [
SetLocaleEvent::class => [[SetLocaleEventHandler::class, 'handle']],
];
11 changes: 0 additions & 11 deletions config/web/params.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,11 @@
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' => ['en' => 'en-US', 'ru' => 'ru-RU', 'de' => 'de-DE'],
'ignoredRequests' => [
'/gii**',
'/debug**',
'/inspect**',
],
],
];
24 changes: 0 additions & 24 deletions src/EventHandler/SetLocaleEventHandler.php

This file was deleted.

8 changes: 0 additions & 8 deletions tests/Acceptance/HomeCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,4 @@ public function testIndexPage(AcceptanceTester $I): void
$I->expectTo('see page home.');
$I->see('Hello!');
}

public function testIndexPageRu(AcceptanceTester $I): void
{
$I->wantTo('home page works.');
$I->amOnPage('/ru/');
$I->expectTo('see page home.');
$I->see('Привет!');
}
}
4 changes: 2 additions & 2 deletions tests/Acceptance/NotFoundHandlerCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function about(AcceptanceTester $I): void
$I->amOnPage('/about');
$I->wantTo('see about page.');
$I->see('404');
$I->see('The page /en/about not found.');
$I->see('The page /about not found.');
$I->see('The above error occurred while the Web server was processing your request.');
$I->see('Please contact us if you think this is a server error. Thank you.');
}
Expand All @@ -23,7 +23,7 @@ public function aboutReturnHome(AcceptanceTester $I): void
$I->amOnPage('/about');
$I->wantTo('see about page.');
$I->see('404');
$I->see('The page /en/about not found.');
$I->see('The page /about not found.');
$I->see('The above error occurred while the Web server was processing your request.');
$I->see('Please contact us if you think this is a server error. Thank you.');
$I->click('Go Back Home');
Expand Down
Loading