public CultureSelectorResult GetCulture(HttpContextBase context) { var culture = _UserCultureService.GetCulture(context); if (culture == null) { return(null); } return(new CultureSelectorResult { Priority = _UserCultureService.GetSettings().Priority, CultureName = culture }); }
public string GetCulture(HttpContextBase context) { if (context == null) { var workContext = _workContextAccessor.GetContext(); if (workContext != null) { context = workContext.HttpContext; } } if (context == null || context.Request == null || context.Request.RequestContext == null) { return(null); } var settings = GetSettings(); if (settings == null || !settings.Enabled) { return(null); } var controllerName = (string)context.Request.RequestContext.RouteData.Values["controller"]; // only for admin mode if ((!string.IsNullOrEmpty(controllerName) && !string.Equals(controllerName, "admin", StringComparison.InvariantCultureIgnoreCase)) || !AdminFilter.IsApplied(context.Request.RequestContext)) { return(null); } var culture = _userCultureService.GetCulture(context, false); if (!string.IsNullOrEmpty(culture)) { return(culture); } culture = settings.AdminCulture; if (string.IsNullOrEmpty(culture)) { return(null); } return(culture); }