Get locale from authenticated user

@return string
434848
public function getLocaleFromAuthenticatedUser()
    {

        $user = $this->findAuthenticatedUser();

        return (null !== $user && $user->getLocale()) ? $user->getLocale() : 'es';
    }
884865
private function getLanguage()
    {
        $wpLang = (function_exists('get_locale')) ? get_locale() : null;
        $browserLang = null;
        if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
            $browserLang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
        }

        return  substr($wpLang ?: $browserLang ?: 'en', 0, 2);
    }
22416
public static function getClientTimezone($user = null) {

		if (isset(self::$timezone)) {
			return self::$timezone;
		}

		$preferred = array();

		$preferred[] = get_input('timezone');

		if ($user == null) {
			$user = elgg_get_logged_in_user_entity();
		}
		
		if ($user) {
			$preferred[] = $user->timezone;
		}

		if (defined('ELGG_SITE_TIMEZONE')) {
			$preferred[] = ELGG_SITE_TIMEZONE;
		}

		$preferred[] = date('e');

		foreach ($preferred as $id) {
			if (self::isValidTimezone($id)) {
				self::$timezone = $id;
				return $id;
			}
		}

		return Util::UTC;
	}
943768
public function getUser(): ?string
    {
        return $this->encodeComponent($this->user, self::NO_ENCODING, self::REGEXP_USERINFO_ENCODING);
    }
286240
private function getLocale() : string
  {
    $locale = ($this->locale ?? config('faker.locale.default'));

    if (
      $locale !== null &&
      is_array(config('faker.locale.supported')) &&
      in_array(config('faker.locale.default'), config('faker.locale.supported'))
    ) {
      return $locale;
    }

    return 'en_US';
  }
172781
public function getCountryNameLocalized()
    {
        $result = '';
        if ($this->countryCode !== '') {
            $localized = Territory::getName($this->countryCode);
            if ($localized !== $this->countryCode) {
                $result = $localized;
            }
        }
        if ($result === '') {
            $result = $this->countryName;
        }

        return $result;
    }
37259
public function getIntegrationLanguage() {
        // Get and format the user language
        $userLanguage = $this->localeResolver->getLocale();
        $userLanguage = strtoupper(str_replace('_', '-', $userLanguage));

        // Get and format the supported languages
        $supportedLanguages = [];
        foreach (self::getSupportedLanguages() as $arr) {
            $supportedLanguages[] = $arr['value'];
        }

        // Get the fallback language
        $fallbackLanguage = $this->getValue(
            self::KEY_FALLBACK_LANGUAGE,
            $this->storeManager->getStore()
        );

        // Compare user language with supported
        if (in_array($userLanguage, $supportedLanguages)) {
            return $userLanguage;
        }
        else {
            return ($fallbackLanguage) ? $fallbackLanguage : 'EN-EN';
        }
    }
1174185
protected function getPrimaryLocale() {
		$primaryLanguage = Configure::read('Config.defaultLanguage');
		if (Configure::read('Config.defaultLocale')) {
			return Configure::read('Config.defaultLocale');
		}

		$primaryLocale = Configure::read('Config.allowedLanguages.' . $primaryLanguage . '.locale');
		return $primaryLocale;
	}
162057
public function locale()
    {
        $accept_language = $this->getHeader('accept_language');

        $tmp = explode(';', $accept_language)[0];

        preg_match('/^([a-z]+(?:-|_)?[a-z]+)/i', $tmp, $match);

        return end($match);
    }
1026576
async def get_locale(self) -> Text:
        

        if self._locale_override:
            return self._locale_override
        else:
            return await self.user.get_locale()
765895
protected function getCurrentLanguage()
    {
        $request = $this->requestStack->getCurrentRequest();

        return $this->localeConverter->convertToEz($request->get('_locale'));
    }
7163
protected function readCookie()
    {
        if (isset($_COOKIE[self::$identifier])) {
            $storedSettings = explode(',', $_COOKIE[self::$identifier]);

            // locale
            if ($this->isValidLocaleCode($storedSettings[0]) &&
                $this->isValidLocaleCode($storedSettings[2]) &&
                $this->isValidLocaleCode($storedSettings[3])
            ) {
                $locale = [
                    'locale'   => $storedSettings[0],
                    'weight'   => (double) $storedSettings[1],
                    'language' => $storedSettings[2],
                    'country'  => $storedSettings[3],
                ];
            } else {
                $locale = null;
            }
        }

        // Return result
        return (isset($locale)) ? $locale : null;
    }
585035
public function retrieveLocale(UserInterface $user = null, $requestLocale = null)
    {
        // Use request locale if defined.
        if ($requestLocale && is_string($requestLocale)) {
            return $requestLocale;
        }

        if ($user && $user->getLocale()) {
            return $user->getLocale();
        }

        return $this->fallbackLocale;
    }
1111944
public function getLocale()
    {
      $value = sprintf("%02d-%02d-%04d", $this->day, $this->month, $this->year);
      
      return $value;
    }
666766
public function authenticatedUser()
	{
		if ($this->IsAuthenticated())
		{
			$user = UserContext::getInstance()->userInfo();
            return $user[$this->getUsersDatabase()->getUserTable()->username];
		}
		else
		{
			return "";
		}
	}
447929
public function getRespondentLanguage()
    {
        if (! isset($this->_gemsData['grs_iso_lang'])) {
            $this->_ensureRespondentData();

            if (! isset($this->_gemsData['grs_iso_lang'])) {
                // Still not set in a project? The it is single language
                $this->_gemsData['grs_iso_lang'] = $this->locale->getLanguage();
            }
        }

        return $this->_gemsData['grs_iso_lang'];
    }
1107442
@Override
    public Locale getLocale() {
        if (null == this.locales) {
            this.locales = connection.getEncodingUtils().getLocales(this.request.getHeader("Accept-Language"));
        }
        if (this.locales.isEmpty()) {
            return null;
        }
        return this.locales.get(0);
    }