src/SYSLang/SYSLang.php
public function getUserLanguages()
    {
        $acceptLanguage = (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
            ? explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'])
            : [];
        $userLanguages = [];

        /**
         * Accept-Language: <language>
         * Accept-Language: <locale>
         * Accept-Language: *
         *
         * // Multiple types, weighted with the quality value syntax:
         * Accept-Language: fr-FR, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5
         *
         * CHROME : Array ( [0] => fr-FR [1] => fr;q=0.8    [2] => en-US;q=0.6 [3] => en;q=0.4 )
         * FIREFO : Array ( [0] => fr    [1] => fr-FR;q=0.8 [2] => en-US;q=0.5 [3] => en;q=0.3 )
         * OPERA  : Array ( [0] => fr-FR [1] => fr;q=0.8    [2] => en-US;q=0.6 [3] => en;q=0.4 )
         * SAFARI : Array ( [0] => fr-FR )
         * IE     : Array ( [0] => fr-FR )
         */
        foreach ($acceptLanguage as $key => $language) {
            $language = trim($language);

            if(!preg_match('#^[a-z]{2}#', $language)) continue;

            preg_match_all('#^[a-z]{2}(-[A-Z]{2})?#', $language, $matches);

            $code = $matches[0][0];
            if(preg_match("/^[a-z]{2}$/", $code)) $code .= '-' . strtoupper($code);

            if (!in_array($code, $userLanguages)) $userLanguages[] = $code;
        }

        /**
         * Si aucune langue n'à pu être trouvée, alors utilisé la langue définie dans le fichier de config.
         */
        if (count($userLanguages) === 0) {
            $this->useLanguage = $this->defaultLanguage;
        } else {
            $useDefault = true;

            foreach ($userLanguages as $key => $language) {
                if ($this->isRegistered($language)) {
                    $this->setLanguage($language);
                    $useDefault = false;
                    break;
                }
            }

            if ($useDefault) $this->useLanguage = $this->defaultLanguage;
        }
    }
public function getUserLanguages()
    {
        $acceptLanguage = (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
            ? explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'])
            : [];
        $userLanguages = [];

        /**
         * Accept-Language: <language>
         * Accept-Language: <locale>
         * Accept-Language: *
         *
         * // Multiple types, weighted with the quality value syntax:
         * Accept-Language: fr-FR, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5
         *
         * CHROME : Array ( [0] => fr-FR [1] => fr;q=0.8    [2] => en-US;q=0.6 [3] => en;q=0.4 )
         * FIREFO : Array ( [0] => fr    [1] => fr-FR;q=0.8 [2] => en-US;q=0.5 [3] => en;q=0.3 )
         * OPERA  : Array ( [0] => fr-FR [1] => fr;q=0.8    [2] => en-US;q=0.6 [3] => en;q=0.4 )
         * SAFARI : Array ( [0] => fr-FR )
         * IE     : Array ( [0] => fr-FR )
         */
        foreach ($acceptLanguage as $key => $language) {
            $language = trim($language);

            if(!preg_match('#^[a-z]{2}#', $language)) continue;

            preg_match_all('#^[a-z]{2}(-[A-Z]{2})?#', $language, $matches);

            $code = $matches[0][0];
            if(preg_match("/^[a-z]{2}$/", $code)) $code .= '-' . strtoupper($code);

            if (!in_array($code, $userLanguages)) $userLanguages[] = $code;
        }

        /**
         * Si aucune langue n'à pu être trouvée, alors utilisé la langue définie dans le fichier de config.
         */
        if (count($userLanguages) === 0) {
            $this->useLanguage = $this->defaultLanguage;
        } else {
            $useDefault = true;

            foreach ($userLanguages as $key => $language) {
                if ($this->isRegistered($language)) {
                    $this->setLanguage($language);
                    $useDefault = false;
                    break;
                }
            }

            if ($useDefault) $this->useLanguage = $this->defaultLanguage;
        }
    }
Traite les paramètres de langue de l'utilisateur pour définir la langue à utilisée.
Si les paramètres ne sont pas compatible, la langue par défaut est utilisée.