Attempts to detect the locale from the request

@return \Nails\Common\Factory\Locale|null
174682
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();
    }
307994
public function getLocale(): string
    {
        if (is_null($this->locale)) {
            $this->locale = \Locale::getDefault();
        }

        return $this->locale;
    }
684300
public function getDefaultLocale()
    {
        try {
            return $this->entityManager->getRepository(Locale::class)->findOneBy(['msIsDefault' => true]);
        } catch (TableNotFoundException $e) {
            return null;
        }
    }
1252596
public function getLocale()
    {
        $locale = $this->requestStack->getCurrentRequest() instanceof Request
            ? $this->requestStack->getCurrentRequest()->getLocale()
            : $this->defaultLocale;

        return Locale::create($locale);
    }
1251589
@Override
    public Locale getLocale() {
        ServletRESTRequestImpl ret = castRequest();
        if (ret != null)
            return ret.getLocale();
        return null;
    }
290389
public function getLocale()
	{
		if (!$this->locale) {
            $locale = self::getStaticLocale();
            if (!$locale) {
                $locale = StdLocale::getDefault();
            }

            $this->setLocale($locale);
		}
		
		return $this->locale;
	}
857262
public function find()
    {
        if (null === static::$locale) {
            /**
             * 1. resolve locale
             * 2. find resolved locale using provider
             * 3. if not found resolved locale => fetch default locale using provider
             */
            if (! ($resolved = $this->resolver->resolve()) ||
                ! ($locale = $this->provider->find($resolved))
            ) {
                $resolved = config('app.fallback_locale');
                if (! $locale = $this->provider->find($resolved)) {
                    $locale = $this->getDefault();
                }
            }

            static::$locale = $locale;
        }

        return static::$locale;
    }
831669
public function getLocale()
    {
        if (empty($this->locale)) {
            $this->locale = $this->getSettings()->locale->default;
        }

        return $this->locale;
    }
64060
public function determineLocale(Request $request)
    {
        return $this->hostMapping->flip()->get($request->getHost(), $this->fallback);
    }
476315
public static function setLocale($locale = null) {
        $app = app();
        $currentLocale = $app->config->get('app.locale');
        if (empty($locale) || !is_string($locale)) {
            // If the locale has not been passed through the function
            // it tries to get it from the first segment of the url
            $locale = $app->request->segment(1);
        }
        if (!in_array($locale, $app->config->get('sirgrimorum.crudgenerator.list_locales'))) {
            $locale = $currentLocale;
        }

        //if (!empty($this->supportedLocales[$locale])) {
        $currentLocale = $locale;
        //}

        $app->setLocale($currentLocale);

        return $currentLocale;
    }
1222199
public function getLocale() : ?string 
    {
        if ( ! $this->hasLocale()) {
            $this->setLocale($this->getDefaultLocale());
        }
        return $this->locale;
    }
924960
public static Locale getLocale() {
        final Locale ret = LOCALE.get();
        if (null == ret) {
            return Latkes.getLocale();
        }

        return ret;
    }
308773
public function detectLocale(HTTPRequest $request)
    {
        // Given multiple canditates, narrow down the final result using the client's preferred languages
        $inputLocales = $request->getHeader('Accept-Language');
        if (empty($inputLocales)) {
            return null;
        }

        // Generate mapping of priority => list of locales at this priority
        // break up string into pieces (languages and q factors)
        preg_match_all(
            '/(?<code>[a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(?<priority>1|0\.[0-9]+))?/i',
            $inputLocales,
            $parsedLocales
        );

        $prioritisedLocales = [];
        if (count($parsedLocales['code'])) {
            // create a list like "en" => 0.8
            $parsedLocales = array_combine($parsedLocales['code'], $parsedLocales['priority']);

            // Generate nested list of priorities => [locales]
            foreach ($parsedLocales as $locale => $priority) {
                $priority = empty($priority) ? "1.0" : (string)floatval($priority);
                if (empty($prioritisedLocales[$priority])) {
                    $prioritisedLocales[$priority] = [];
                }
                $prioritisedLocales[$priority][] = $locale;
            }

            // sort list based on value
            krsort($prioritisedLocales, SORT_NUMERIC);
        }

        // Check each requested locale against loaded locales
        $locales = Locale::getLocales(true);
        foreach ($prioritisedLocales as $priority => $parsedLocales) {
            foreach ($parsedLocales as $browserLocale) {
                foreach ($locales as $localeObj) {
                    /** @var Locale $localeObj */
                    if ($localeObj->isLocale($browserLocale)) {
                        return $localeObj;
                    }
                }
            }
        }
        return null;
    }
1111944
public function getLocale()
    {
      $value = sprintf("%02d-%02d-%04d", $this->day, $this->month, $this->year);
      
      return $value;
    }
640019
public static function getLocale()
    {
        if (empty(self::$locale)) {
            self::$locale = new StringType(\locale_get_default());
        }

        return self::$locale;
    }
705328
public function uri($locale = null)
    {
        $locale = $locale ?: config('app.locale');
        $uri = $this->translate('uri', $locale);
        if (
            config('app.fallback_locale') != $locale ||
            config('typicms.main_locale_in_url')
        ) {
            $uri = $uri ? $locale.'/'.$uri : $locale;
        }

        return $uri ?: '/';
    }
118918
public function translate($locale = null)
    {
        if (!$locale) {
            $locale = \localizer\locale()->id();
        } else {
            $locale = (int)$locale;
        }

        return $this->getTranslation($locale);
    }