public override async Task <ProviderCultureResult> DetermineProviderCultureResult(HttpContext httpContext) { //Go away and do a bunch of work to find out what culture we should do. await Task.Yield(); var httpContextAccessor = new HttpContextAccessor(); httpContextAccessor.HttpContext = httpContext; var langDetector = new NccLanguageDetector(httpContextAccessor); var lang = langDetector.GetCurrentLanguage(); //Return a provider culture result. return(new ProviderCultureResult(lang)); //In the event I can't work out what culture I should use. Return null. //Code will fall to other providers in the list OR use the default. //return null; }
public NccStringLocalizer(IStringLocalizerFactory factory, IHttpContextAccessor httpContextAccessor) : base(factory) { _nccLanguageDetector = new NccLanguageDetector(httpContextAccessor); CreateTranslator(); }