Created
May 13, 2017 13:11
-
-
Save enkelmedia/f3305ac3fb8cfd641f14edd98af820a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RpSurfaceController : SurfaceController | |
{ | |
protected override void Initialize(System.Web.Routing.RequestContext requestContext) | |
{ | |
var domains = ApplicationContext.Current.ApplicationCache.RuntimeCache.GetCacheItem<List<DomainInfoDto>>( | |
"GenericTempStore-Domains", | |
() => | |
{ | |
var sql = @"SELECT [domainName],[languageISOCode] FROM [umbracoDomains] as d INNER JOIN [umbracoLanguage] as l on d.[domainDefaultLanguage] = l.[id]"; | |
return ApplicationContext.Current.DatabaseContext.Database.Fetch<DomainInfoDto>(sql); | |
}); | |
if(requestContext?.HttpContext?.Request?.Url != null) | |
{ | |
var currentUrl = requestContext.HttpContext.Request.Url.AbsoluteUri; | |
foreach (var domain in domains) | |
{ | |
if (currentUrl.StartsWith(domain.DomainName)) | |
{ | |
System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(domain.LanguageISOCode); | |
} | |
} | |
} | |
base.Initialize(requestContext); | |
} | |
public class DomainInfoDto | |
{ | |
public string DomainName { get; set; } | |
public string LanguageISOCode { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment