src/Controller/ShuntRequestController.php
public function language($language = null) {
		$this->getRequest()->allowMethod(['post']);

		$allowedLanguages = (array)Configure::read('Config.allowedLanguages');
		if (!$language) {
			$language = Configure::read('Config.defaultLanguage');
		}
		if (!$language) {
			$keys = array_keys($allowedLanguages);
			$language = $allowedLanguages[array_shift($keys)];
		}

		if (!array_key_exists($language, $allowedLanguages)) {
			throw new RuntimeException('Invalid Language');
		}
		$language = $allowedLanguages[$language];

		$this->getRequest()->getSession()->write('Config.language', $language['locale']);
		I18n::setLocale($language['locale']);
		$this->Flash->success(__d('tools', 'Language switched to {0}', $language['name']));
		return $this->redirect($this->referer('/', true));
	}
public function language($language = null) {
		$this->getRequest()->allowMethod(['post']);

		$allowedLanguages = (array)Configure::read('Config.allowedLanguages');
		if (!$language) {
			$language = Configure::read('Config.defaultLanguage');
		}
		if (!$language) {
			$keys = array_keys($allowedLanguages);
			$language = $allowedLanguages[array_shift($keys)];
		}

		if (!array_key_exists($language, $allowedLanguages)) {
			throw new RuntimeException('Invalid Language');
		}
		$language = $allowedLanguages[$language];

		$this->getRequest()->getSession()->write('Config.language', $language['locale']);
		I18n::setLocale($language['locale']);
		$this->Flash->success(__d('tools', 'Language switched to {0}', $language['name']));
		return $this->redirect($this->referer('/', true));
	}
public function language ( $ language = null ) { $ this -> getRequest ( ) -> allowMethod ( [ 'post' ] ) ; $ allowedLanguages = ( array ) Configure :: read ( 'Config.allowedLanguages' ) ; if ( ! $ language ) { $ language = Configure :: read ( 'Config.defaultLanguage' ) ; } if ( ! $ language ) { $ keys = array_keys ( $ allowedLanguages ) ; $ language = $ allowedLanguages [ array_shift ( $ keys ) ] ; } if ( ! array_key_exists ( $ language , $ allowedLanguages ) ) { throw new RuntimeException ( 'Invalid Language' ) ; } $ language = $ allowedLanguages [ $ language ] ; $ this -> getRequest ( ) -> getSession ( ) -> write ( 'Config.language' , $ language [ 'locale' ] ) ; I18n :: setLocale ( $ language [ 'locale' ] ) ; $ this -> Flash -> success ( __d ( 'tools' , 'Language switched to {0}' , $ language [ 'name' ] ) ) ; return $ this -> redirect ( $ this -> referer ( '/' , true ) ) ; }
Switch language as post link.

@param string|null $language
@return \Cake\Http\Response
@throws \RuntimeException
Switch language as post link .