core/Language/Lang.php
public function reload( string $language ): bool
	{
		$language = trim( $language );
		if( ! self::valid($language) )
		{
			return false;
		}

		if( $this->language === $language && $this->lang_init )
		{
			return true;
		}

		$packages = is_null($this->lang) ? [] : $this->lang->packages();
		$this->language = $language;
		$this->lang = null;
		$this->lang_init = true;
		$this->proxy = [];

		$event = new LanguageLoadEvent($this);
		EventManager::dispatch(
			$event,
			function( $result ) use($event) {
				if( $result instanceof Language )
				{
					$this->lang = $result;
					$event->stopPropagation();
				}
			});

		if( is_null($this->lang) )
		{
			$this->lang = new LanguageFiles($language);
		}

		$this->lang_i18 = $this->lang instanceof I18Interface;
		$this->lang_transliteration = $this->lang instanceof TransliterationInterface;
		$this->lang_text = $this->lang instanceof TextInterface;
		$this->lang_is_default = $this->lang === $this->lang_default;

		foreach($packages as $package)
		{
			$this->lang->load($package);
		}

		return true;
	}
public function reload( string $language ): bool
	{
		$language = trim( $language );
		if( ! self::valid($language) )
		{
			return false;
		}

		if( $this->language === $language && $this->lang_init )
		{
			return true;
		}

		$packages = is_null($this->lang) ? [] : $this->lang->packages();
		$this->language = $language;
		$this->lang = null;
		$this->lang_init = true;
		$this->proxy = [];

		$event = new LanguageLoadEvent($this);
		EventManager::dispatch(
			$event,
			function( $result ) use($event) {
				if( $result instanceof Language )
				{
					$this->lang = $result;
					$event->stopPropagation();
				}
			});

		if( is_null($this->lang) )
		{
			$this->lang = new LanguageFiles($language);
		}

		$this->lang_i18 = $this->lang instanceof I18Interface;
		$this->lang_transliteration = $this->lang instanceof TransliterationInterface;
		$this->lang_text = $this->lang instanceof TextInterface;
		$this->lang_is_default = $this->lang === $this->lang_default;

		foreach($packages as $package)
		{
			$this->lang->load($package);
		}

		return true;
	}
public function reload ( string $ language ) : bool { $ language = trim ( $ language ) ; if ( ! self :: valid ( $ language ) ) { return false ; } if ( $ this -> language === $ language && $ this -> lang_init ) { return true ; } $ packages = is_null ( $ this -> lang ) ? [ ] : $ this -> lang -> packages ( ) ; $ this -> language = $ language ; $ this -> lang = null ; $ this -> lang_init = true ; $ this -> proxy = [ ] ; $ event = new LanguageLoadEvent ( $ this ) ; EventManager :: dispatch ( $ event , function ( $ result ) use ( $ event ) { if ( $ result instanceof Language ) { $ this -> lang = $ result ; $ event -> stopPropagation ( ) ; } } ) ; if ( is_null ( $ this -> lang ) ) { $ this -> lang = new LanguageFiles ( $ language ) ; } $ this -> lang_i18 = $ this -> lang instanceof I18Interface ; $ this -> lang_transliteration = $ this -> lang instanceof TransliterationInterface ; $ this -> lang_text = $ this -> lang instanceof TextInterface ; $ this -> lang_is_default = $ this -> lang === $ this -> lang_default ; foreach ( $ packages as $ package ) { $ this -> lang -> load ( $ package ) ; } return true ; }
Set new language key and reload all packages

@param string $language
@return bool
Set new language key and reload all packages