Prado\I18N\core\HTTPNegotiator::getLanguages PHP Method

getLanguages() public method

Get a list of languages acceptable by the client browser
public getLanguages ( ) : array
return array languages ordered in the user browser preferences.
    function getLanguages()
    {
        if ($this->languages !== null) {
            return $this->languages;
        }
        $this->languages = array();
        if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
            return $this->languages;
        }
        //$basedir = CultureInfo::dataDir();
        //$ext = CultureInfo::fileExt();
        $info = new CultureInfo();
        foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $lang) {
            // Cut off any q-value that might come after a semi-colon
            if ($pos = strpos($lang, ';')) {
                $lang = trim(substr($lang, 0, $pos));
            }
            if (strstr($lang, '-')) {
                $codes = explode('-', $lang);
                if ($codes[0] == 'i') {
                    // Language not listed in ISO 639 that are not variants
                    // of any listed language, which can be registerd with the
                    // i-prefix, such as i-cherokee
                    if (count($codes) > 1) {
                        $lang = $codes[1];
                    }
                } else {
                    for ($i = 0, $k = count($codes); $i < $k; ++$i) {
                        if ($i == 0) {
                            $lang = strtolower($codes[0]);
                        } else {
                            $lang .= '_' . strtoupper($codes[$i]);
                        }
                    }
                }
            }
            if ($info->validCulture($lang)) {
                $this->languages[] = $lang;
            }
        }
        return $this->languages;
    }