src/Common/Service/Locale.php
public function detect(): \Nails\Common\Factory\Locale
    {
        /**
         * Detect the locale from the request, weakest first
         * - Request headers
         * - Active user preference
         * - The URL (/{locale}/.*)
         * - A locale cookie
         * - Explicitly provided via $_GET['locale']
         */

        $oLocale = $this->getDefautLocale();
        if (static::ENABLE_SNIFF) {

            if (static::ENABLE_SNIFF_HEADER) {
                $this->sniffHeader($oLocale);
            }
            if (static::ENABLE_SNIFF_USER) {
                $this->sniffActiveUser($oLocale);
            }
            if (static::ENABLE_SNIFF_URL) {
                $this->sniffUrl($oLocale);
            }
            if (static::ENABLE_SNIFF_COOKIE) {
                $this->sniffCookie($oLocale);
            }
            if (static::ENABLE_SNIFF_QUERY) {
                $this->sniffQuery($oLocale);
            }

            if (!$this->isSupportedLocale($oLocale)) {
                $oLocale = $this->getDefautLocale();
            }

        }

        return $this
            ->set($oLocale)
            ->get();
    }
public function detect(): \Nails\Common\Factory\Locale
    {
        /**
         * Detect the locale from the request, weakest first
         * - Request headers
         * - Active user preference
         * - The URL (/{locale}/.*)
         * - A locale cookie
         * - Explicitly provided via $_GET['locale']
         */

        $oLocale = $this->getDefautLocale();
        if (static::ENABLE_SNIFF) {

            if (static::ENABLE_SNIFF_HEADER) {
                $this->sniffHeader($oLocale);
            }
            if (static::ENABLE_SNIFF_USER) {
                $this->sniffActiveUser($oLocale);
            }
            if (static::ENABLE_SNIFF_URL) {
                $this->sniffUrl($oLocale);
            }
            if (static::ENABLE_SNIFF_COOKIE) {
                $this->sniffCookie($oLocale);
            }
            if (static::ENABLE_SNIFF_QUERY) {
                $this->sniffQuery($oLocale);
            }

            if (!$this->isSupportedLocale($oLocale)) {
                $oLocale = $this->getDefautLocale();
            }

        }

        return $this
            ->set($oLocale)
            ->get();
    }
public function detect ( ) : \ Nails \ Common \ Factory \ Locale { /**
         * Detect the locale from the request, weakest first
         * - Request headers
         * - Active user preference
         * - The URL (/{locale}/.*)
         * - A locale cookie
         * - Explicitly provided via $_GET['locale']
         */ $ oLocale = $ this -> getDefautLocale ( ) ; if ( static :: ENABLE_SNIFF ) { if ( static :: ENABLE_SNIFF_HEADER ) { $ this -> sniffHeader ( $ oLocale ) ; } if ( static :: ENABLE_SNIFF_USER ) { $ this -> sniffActiveUser ( $ oLocale ) ; } if ( static :: ENABLE_SNIFF_URL ) { $ this -> sniffUrl ( $ oLocale ) ; } if ( static :: ENABLE_SNIFF_COOKIE ) { $ this -> sniffCookie ( $ oLocale ) ; } if ( static :: ENABLE_SNIFF_QUERY ) { $ this -> sniffQuery ( $ oLocale ) ; } if ( ! $ this -> isSupportedLocale ( $ oLocale ) ) { $ oLocale = $ this -> getDefautLocale ( ) ; } } return $ this -> set ( $ oLocale ) -> get ( ) ; }
Attempts to detect the locale from the request

@return \Nails\Common\Factory\Locale|null
Attempts to detect the locale from the request