public static function extractLocaleSegmentFromParameters(Scope $scope, string $routeKey, array &$parameters = [])
    {
        $localeSegment = null;

        // If none given, we should be returning the current active locale segment
        // If value is explicitly null, we assume the current locale is expected
        if (!array_key_exists($routeKey, $parameters) || is_null($parameters[$routeKey])) {
            return $scope->activeSegment();
        }

        if ($scope->validateSegment($parameters[$routeKey])) {
            $localeSegment = $parameters[$routeKey];
        }

        // If locale segment parameter is not a 'real' parameter, we ignore this value and use the current locale instead
        // The 'wrong' parameter will be passed along but without key
        if ($localeSegment != $parameters[$routeKey]) {
            $parameters[] = $parameters[$routeKey];
        }

        unset($parameters[$routeKey]);

        return $localeSegment;
    }