Example #1
0
 /**
  * @param string $locale
  * @dataProvider switchBackendInterfaceLocaleDataProvider
  * @covers \Magento\Backend\Model\Locale\Manager::switchBackendInterfaceLocale
  */
 public function testSwitchBackendInterfaceLocale($locale)
 {
     $this->_model->switchBackendInterfaceLocale($locale);
     $userInterfaceLocale = $this->_authSession->getUser()->getInterfaceLocale();
     $this->assertEquals($userInterfaceLocale, $locale);
     $sessionLocale = $this->_session->getSessionLocale();
     $this->assertEquals($sessionLocale, null);
 }
Example #2
0
 /**
  * Set locale
  *
  * @param string $locale
  * @return $this
  */
 public function setLocale($locale = null)
 {
     $forceLocale = $this->_request->getParam('locale', null);
     if (!$this->_localeValidator->isValid($forceLocale)) {
         $forceLocale = false;
     }
     $sessionLocale = $this->_session->getSessionLocale();
     $userLocale = $this->_localeManager->getUserInterfaceLocale();
     $localeCodes = array_filter([$forceLocale, $sessionLocale, $userLocale]);
     if (count($localeCodes)) {
         $locale = reset($localeCodes);
     }
     return parent::setLocale($locale);
 }