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; }
private void CreateTranslator() { var changedLanguage = _nccLanguageDetector.GetCurrentLanguage(); if (string.IsNullOrEmpty(changedLanguage)) { changedLanguage = "en"; } if (string.IsNullOrEmpty(CurrentLanguage)) { CurrentLanguage = changedLanguage; } if (!CurrentLanguage.Equals(changedLanguage) || _nccTranslator == null) { _nccTranslator = new NccTranslator(changedLanguage); CurrentLanguage = changedLanguage; } }