public function retrieveLocale(UserInterface $user = null, $requestLocale = null)
    {
        $checkedLocale = null;

        // When request locale is defined, check if we can use it.
        if ($requestLocale && is_string($requestLocale)) {
            $checkedLocale = $this->checkLocale($requestLocale);
        }

        if (!$checkedLocale && $user && $user->getLocale()) {
            $checkedLocale = $this->checkLocale($user->getLocale());
        }

        if ($checkedLocale) {
            return $checkedLocale;
        }

        return $this->configuration['fallback_locale'];
    }