Exemple #1
0
        protected virtual TblLanguages GetLanguageFromUrl()
        {
            if (HttpContext?.Request?.Url == null)
            {
                return(null);
            }

            var          currentPath = HttpContext?.Request.Url.PathAndQuery.TrimStart('/').Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
            TblLanguages language    = null;

            if (currentPath.Length >= 1 && currentPath[0].Length == 2)
            {
                var languageIso = currentPath[0];
                language = _languagesService.FindByIso(languageIso.Trim().ToLower());
            }

            if (language != null && language.Published)
            {
                return(language);
            }

            return(null);
        }