private string GetDefaultCultureCode(IStorage storage) { Culture defaultCulture = CultureManager.GetDefaultCulture(storage); if (defaultCulture == null) { return(DefaultCulture.Code); } return(defaultCulture.Code); }
public void Execute(IApplicationBuilder applicationBuilder, IServiceProvider serviceProvider) { RequestLocalizationOptions requestLocalizationOptions = new RequestLocalizationOptions(); IStorage storage = serviceProvider.GetService <IStorage>(); if (storage == null) { requestLocalizationOptions.DefaultRequestCulture = new RequestCulture(DefaultCulture.Code); requestLocalizationOptions.SupportedCultures = requestLocalizationOptions.SupportedUICultures = new CultureInfo[] { new CultureInfo(DefaultCulture.Code) }.ToList(); } else { Culture defaultCulture = CultureManager.GetDefaultCulture(storage); if (defaultCulture == null) { requestLocalizationOptions.DefaultRequestCulture = new RequestCulture(DefaultCulture.Code); } else { requestLocalizationOptions.DefaultRequestCulture = new RequestCulture(defaultCulture.Code); } if (CultureManager.GetNotNeutralCultures(storage).Count() == 0) { requestLocalizationOptions.SupportedCultures = requestLocalizationOptions.SupportedUICultures = new CultureInfo[] { new CultureInfo(DefaultCulture.Code) }.ToList(); } else { requestLocalizationOptions.SupportedCultures = requestLocalizationOptions.SupportedUICultures = CultureManager.GetNotNeutralCultures(storage).Select(c => new CultureInfo(c.Code)).ToList(); } if (this.MustSpecifyCultureInUrl(storage)) { requestLocalizationOptions.RequestCultureProviders.Insert(0, new RouteValueRequestCultureProvider(serviceProvider)); } } applicationBuilder.UseWhen( context => !context.Request.Path.StartsWithSegments(new PathString("/backend")), frontendApplicationBuilder => { frontendApplicationBuilder.UseRequestLocalization(requestLocalizationOptions); } ); }
private string GetDefaultCultureCode() { IStorage storage = this.serviceProvider.GetService <IStorage>(); Data.Entities.Culture defaultCulture = CultureManager.GetDefaultCulture(storage); if (defaultCulture == null) { return(DefaultCulture.Code); } return(defaultCulture.Code); }
public IEnumerable <string> GetDisplayProperties(Object @object) { List <string> properties = new List <string>(); Culture neutralCulture = CultureManager.GetNeutralCulture(this.requestHandler.Storage); Culture defaultCulture = CultureManager.GetDefaultCulture(this.requestHandler.Storage); if (defaultCulture != null) { foreach (Member member in this.requestHandler.Storage.GetRepository <IMemberRepository>().FilteredByClassIdInlcudingParentPropertyVisibleInList(@object.ClassId).ToList()) { Property property = this.requestHandler.Storage.GetRepository <IPropertyRepository>().WithObjectIdAndMemberId(@object.Id, member.Id); if (property == null) { properties.Add(string.Empty); } else { Localization localization = null; if (member.IsPropertyLocalizable == true && defaultCulture != null) { localization = this.requestHandler.Storage.GetRepository <ILocalizationRepository>().WithDictionaryIdAndCultureId((int)property.StringValueId, defaultCulture.Id); } else if (neutralCulture != null) { localization = this.requestHandler.Storage.GetRepository <ILocalizationRepository>().WithDictionaryIdAndCultureId((int)property.StringValueId, neutralCulture.Id); } if (localization == null) { properties.Add(string.Empty); } else { properties.Add(localization.Value); } } } } return(properties); }