src/RawPHP/RawRouter/LEController.php
public function loadLanguage( $controller, $language = 'en_US', $return = FALSE )
    {
        $langDirEvent = new GetLanguageDirEvent();

        $this->dispatcher->fire( Events::EVENT_GET_LANG_DIR, $langDirEvent );

        $langDir = $langDirEvent->getLangDir();

        $retVal = FALSE;

        if ( NULL === $langDir )
        {
            $retVal = FALSE;
        }
        else
        {
            $file = $langDir . $controller . DS . $language . '_lang.php';

            if ( !file_exists( $file ) )
            {
                $defaultLangEvent = new GetDefaultLanguageEvent();

                $this->dispatcher->fire( Events::EVENT_GET_DEFAULT_LANG, $defaultLangEvent );

                $defaultLang = $defaultLangEvent->getDefaultLanguage();

                if ( NULL === $defaultLang )
                {
                    $retval = FALSE;
                }
                else
                {
                    $file = $langDir
                        . $controller . DS
                        . $defaultLang
                        . '_lang.php';
                }
            }

            if ( NULL === $file )
            {
                throw new RawException( 'Failed to load language file for ' . $controller );
            }

            $lang = include_once $file;

            $this->language = array_merge( $this->language, $lang );

            $retVal = $lang;
        }

        return $retVal;
    }
public function loadLanguage( $controller, $language = 'en_US', $return = FALSE )
    {
        $langDirEvent = new GetLanguageDirEvent();

        $this->dispatcher->fire( Events::EVENT_GET_LANG_DIR, $langDirEvent );

        $langDir = $langDirEvent->getLangDir();

        $retVal = FALSE;

        if ( NULL === $langDir )
        {
            $retVal = FALSE;
        }
        else
        {
            $file = $langDir . $controller . DS . $language . '_lang.php';

            if ( !file_exists( $file ) )
            {
                $defaultLangEvent = new GetDefaultLanguageEvent();

                $this->dispatcher->fire( Events::EVENT_GET_DEFAULT_LANG, $defaultLangEvent );

                $defaultLang = $defaultLangEvent->getDefaultLanguage();

                if ( NULL === $defaultLang )
                {
                    $retval = FALSE;
                }
                else
                {
                    $file = $langDir
                        . $controller . DS
                        . $defaultLang
                        . '_lang.php';
                }
            }

            if ( NULL === $file )
            {
                throw new RawException( 'Failed to load language file for ' . $controller );
            }

            $lang = include_once $file;

            $this->language = array_merge( $this->language, $lang );

            $retVal = $lang;
        }

        return $retVal;
    }
Loads a language file for a controller.

This method requires that LEController::ON_GET_LANG_DIR_FILTER hook has
a valid callback that sets the language directory for the controller.

It also requires that LEController::ON_GET_DEFAULT_LANG_FILTER hook has
a valid callback that sets the default language to be used if the requested
language file is not found.

@param string $controller the controller name
@param string $language   the language to load
@param bool   $return     whether to return the translations or to send them
to the view

@return array returns the language array

@throws RawException if there is something wrong with loading the language