Symfony\Component\HttpFoundation\Session::setLocale PHP Method

setLocale() public method

Sets the locale.
public setLocale ( string $locale )
$locale string
    public function setLocale($locale)
    {
        if (false === $this->started) {
            $this->start();
        }

        $this->setPhpDefaultLocale($this->locale = $locale);
    }

Usage Example

 public function testPathWithLocale()
 {
     $matcher = new RequestMatcher();
     $request = Request::create('/en/login');
     $session = new Session(new ArraySessionStorage());
     $session->setLocale('en');
     $request->setSession($session);
     $matcher->matchPath('^/{_locale}/login$');
     $this->assertTrue($matcher->matches($request));
     $session->setLocale('de');
     $this->assertFalse($matcher->matches($request));
 }