Skip to content
Merged
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
12 changes: 12 additions & 0 deletions en/core-libraries/internationalization-and-localization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,18 @@ Automatically Choosing the Locale Based on Request Data
By using the ``LocaleSelectorFilter`` in your application, CakePHP will
automatically set the locale based on the current user::

// in src/Application.php
use Cake\I18n\Middleware\LocaleSelectorMiddleware;

// Update the middleware function, adding the new middleware
public function middleware($middleware)
{
// Add middleware and set the valid locales
$middleware->add(new LocaleSelectorMiddleware(['en_US', 'fr_FR']));
}


// Prior to 3.3.0, use the DispatchFilter
// in config/bootstrap.php
DispatcherFactory::add('LocaleSelector');

Expand Down