// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <RequestLocalizationOptions>(options => { var cultures = new AppSupportedCultures(); options.DefaultRequestCulture = new RequestCulture(culture: cultures.GetCultureTabForNeutralCulture(), uiCulture: cultures.GetDefaultUiCultureTab()); options.SupportedCultures = cultures.GetSupportedCulturesInfo(); options.SupportedUICultures = cultures.GetSupportedCulturesInfo(); //options.FallBackToParentCultures = true; //default to true - if en-US isn't in list of SupportedCultures then fall-back to en //options.FallBackToParentUICultures = true; //default to true - if en-US isn't in list of SupportedUICultures then fall-back to en options.AddInitialRequestCultureProvider(new AppRequestCultureProvider(options)); }); services.AddHttpContextAccessor(); services.AddRazorPages(); if (Env.IsDevelopment() == false) { services.AddHsts(options => { options.Preload = true; options.IncludeSubDomains = true; options.MaxAge = TimeSpan.FromDays(60); //options.ExcludedHosts.Add("example.com"); //options.ExcludedHosts.Add("www.example.com"); }); services.AddHttpsRedirection(options => { options.RedirectStatusCode = StatusCodes.Status307TemporaryRedirect; options.HttpsPort = 5001; }); } }
public void DefaultSelectedTest() { var cultures = new AppSupportedCultures(); Assert.Equal(AppSupportedCultures.EnGb, cultures.Selected); Assert.Equal(AppSupportedCultures.EnGb, cultures.GetCultureTabForNeutralCulture()); Assert.Equal(AppSupportedCultures.En, cultures.GetDefaultUiCultureTab()); }