Skip to content

Commit

Permalink
Remove locale middleware (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark authored Feb 5, 2025
1 parent 7e3746a commit dac04b1
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 56 deletions.
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

0 comments on commit dac04b1

Please sign in to comment.