thirdparty/htmlpurifier-4.0.0-lite/library/HTMLPurifier/LanguageFactory.php
public function loadLanguage($code) {
        static $languages_seen = array(); // recursion guard

        // abort if we've already loaded it
        if (isset($this->cache[$code])) return;

        // generate filename
        $filename = $this->dir . '/Language/messages/' . $code . '.php';

        // default fallback : may be overwritten by the ensuing include
        $fallback = ($code != 'en') ? 'en' : false;

        // load primary localisation
        if (!file_exists($filename)) {
            // skip the include: will rely solely on fallback
            $filename = $this->dir . '/Language/messages/en.php';
            $cache = array();
        } else {
            include $filename;
            $cache = compact($this->keys);
        }

        // load fallback localisation
        if (!empty($fallback)) {

            // infinite recursion guard
            if (isset($languages_seen[$code])) {
                trigger_error('Circular fallback reference in language ' .
                    $code, E_USER_ERROR);
                $fallback = 'en';
            }
            $language_seen[$code] = true;

            // load the fallback recursively
            $this->loadLanguage($fallback);
            $fallback_cache = $this->cache[$fallback];

            // merge fallback with current language
            foreach ( $this->keys as $key ) {
                if (isset($cache[$key]) && isset($fallback_cache[$key])) {
                    if (isset($this->mergeable_keys_map[$key])) {
                        $cache[$key] = $cache[$key] + $fallback_cache[$key];
                    } elseif (isset($this->mergeable_keys_list[$key])) {
                        $cache[$key] = array_merge( $fallback_cache[$key], $cache[$key] );
                    }
                } else {
                    $cache[$key] = $fallback_cache[$key];
                }
            }

        }

        // save to cache for later retrieval
        $this->cache[$code] = $cache;

        return;
    }
public function loadLanguage($code) {
        static $languages_seen = array(); // recursion guard

        // abort if we've already loaded it
        if (isset($this->cache[$code])) return;

        // generate filename
        $filename = $this->dir . '/Language/messages/' . $code . '.php';

        // default fallback : may be overwritten by the ensuing include
        $fallback = ($code != 'en') ? 'en' : false;

        // load primary localisation
        if (!file_exists($filename)) {
            // skip the include: will rely solely on fallback
            $filename = $this->dir . '/Language/messages/en.php';
            $cache = array();
        } else {
            include $filename;
            $cache = compact($this->keys);
        }

        // load fallback localisation
        if (!empty($fallback)) {

            // infinite recursion guard
            if (isset($languages_seen[$code])) {
                trigger_error('Circular fallback reference in language ' .
                    $code, E_USER_ERROR);
                $fallback = 'en';
            }
            $language_seen[$code] = true;

            // load the fallback recursively
            $this->loadLanguage($fallback);
            $fallback_cache = $this->cache[$fallback];

            // merge fallback with current language
            foreach ( $this->keys as $key ) {
                if (isset($cache[$key]) && isset($fallback_cache[$key])) {
                    if (isset($this->mergeable_keys_map[$key])) {
                        $cache[$key] = $cache[$key] + $fallback_cache[$key];
                    } elseif (isset($this->mergeable_keys_list[$key])) {
                        $cache[$key] = array_merge( $fallback_cache[$key], $cache[$key] );
                    }
                } else {
                    $cache[$key] = $fallback_cache[$key];
                }
            }

        }

        // save to cache for later retrieval
        $this->cache[$code] = $cache;

        return;
    }
public function loadLanguage ( $ code ) { static $ languages_seen = array ( ) ; // recursion guard // abort if we've already loaded it if ( isset ( $ this -> cache [ $ code ] ) ) return ; // generate filename $ filename = $ this -> dir . '/Language/messages/' . $ code . '.php' ; // default fallback : may be overwritten by the ensuing include $ fallback = ( $ code != 'en' ) ? 'en' : false ; // load primary localisation if ( ! file_exists ( $ filename ) ) { // skip the include: will rely solely on fallback $ filename = $ this -> dir . '/Language/messages/en.php' ; $ cache = array ( ) ; } else { include $ filename ; $ cache = compact ( $ this -> keys ) ; } // load fallback localisation if ( ! empty ( $ fallback ) ) { // infinite recursion guard if ( isset ( $ languages_seen [ $ code ] ) ) { trigger_error ( 'Circular fallback reference in language ' . $ code , E_USER_ERROR ) ; $ fallback = 'en' ; } $ language_seen [ $ code ] = true ; // load the fallback recursively $ this -> loadLanguage ( $ fallback ) ; $ fallback_cache = $ this -> cache [ $ fallback ] ; // merge fallback with current language foreach ( $ this -> keys as $ key ) { if ( isset ( $ cache [ $ key ] ) && isset ( $ fallback_cache [ $ key ] ) ) { if ( isset ( $ this -> mergeable_keys_map [ $ key ] ) ) { $ cache [ $ key ] = $ cache [ $ key ] + $ fallback_cache [ $ key ] ; } elseif ( isset ( $ this -> mergeable_keys_list [ $ key ] ) ) { $ cache [ $ key ] = array_merge ( $ fallback_cache [ $ key ] , $ cache [ $ key ] ) ; } } else { $ cache [ $ key ] = $ fallback_cache [ $ key ] ; } } } // save to cache for later retrieval $ this -> cache [ $ code ] = $ cache ; return ; }
Loads language into the cache, handles message file and fallbacks
@param $code string language code
Loads language into the cache handles message file and fallbacks