Skip to content

Commit

Permalink
Removed usage of Site.Culture. Fixes #1845
Browse files Browse the repository at this point in the history
  • Loading branch information
tidyui committed Apr 5, 2022
1 parent 8dd2928 commit 88133ab
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
8 changes: 6 additions & 2 deletions core/Piranha.AspNetCore/Http/RoutingMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,13 @@ public override async Task Invoke(HttpContext context, IApi api, IApplicationSer

if (site != null)
{
// Get the selected language
var language = await api.Languages.GetByIdAsync(site.LanguageId)
.ConfigureAwait(false);

// Update application service
service.Site.Id = site.Id;
service.Site.Culture = site.Culture;
service.Site.Culture = language?.Culture;
service.Site.Sitemap = await api.Sites.GetSitemapAsync(site.Id);

// Set preferred hostname & prefix
Expand All @@ -130,7 +134,7 @@ public override async Task Invoke(HttpContext context, IApi api, IApplicationSer
}

// Set current culture if specified in site
if (!string.IsNullOrEmpty(site.Culture))
if (!string.IsNullOrEmpty(service.Site.Culture))
{
var cultureInfo = new CultureInfo(service.Site.Culture);
CultureInfo.CurrentCulture = CultureInfo.CurrentUICulture = cultureInfo;
Expand Down
4 changes: 3 additions & 1 deletion core/Piranha.AspNetCore/Services/ApplicationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ public async Task InitAsync(HttpContext context)
// Store the current site id & get the sitemap
if (site != null)
{
var language = await Api.Languages.GetByIdAsync(site.LanguageId);

Site.Id = site.Id;
Site.LanguageId = site.LanguageId;
Site.Culture = site.Culture;
Site.Culture = language?.Culture;
Site.Sitemap = await Api.Sites.GetSitemapAsync(Site.Id);

var siteHost = GetFirstHost(site);
Expand Down
2 changes: 0 additions & 2 deletions core/Piranha.Manager/Services/SiteService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ public async Task Save(SiteEditModel model)
site.LanguageId = model.LanguageId;
site.Title = model.Title;
site.InternalId = model.InternalId;
site.Culture = model.Culture;
site.Hostnames = model.Hostnames;
site.Description = model.Description;
site.Logo = model.Logo;
Expand Down Expand Up @@ -224,7 +223,6 @@ private SiteEditModel Transform(Site site)
LanguageId = site.LanguageId,
Title = site.Title,
InternalId = site.InternalId,
Culture = site.Culture,
Description = site.Description,
Logo = site.Logo,
Hostnames = site.Hostnames,
Expand Down
1 change: 1 addition & 0 deletions core/Piranha/Models/Site.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public sealed class Site
/// Gets/sets the optional culture for the site.
/// </summary>
[StringLength(6)]
[Obsolete("Please refer to the culture of the selected language of the site", true)]
public string Culture { get; set; }

/// <summary>
Expand Down
5 changes: 0 additions & 5 deletions data/Piranha.Data.EF/Repositories/SiteRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public SiteRepository(IDb db, IContentServiceFactory factory)
Logo = site.LogoId.HasValue ? site.LogoId.Value : new ImageField(),
Hostnames = site.Hostnames,
IsDefault = site.IsDefault,
Culture = site.Culture,
ContentLastModified = site.ContentLastModified,
Created = site.Created,
LastModified = site.LastModified
Expand Down Expand Up @@ -111,7 +110,6 @@ public SiteRepository(IDb db, IContentServiceFactory factory)
Logo = site.LogoId.HasValue ? site.LogoId.Value : new ImageField(),
Hostnames = site.Hostnames,
IsDefault = site.IsDefault,
Culture = site.Culture,
ContentLastModified = site.ContentLastModified,
Created = site.Created,
LastModified = site.LastModified
Expand Down Expand Up @@ -151,7 +149,6 @@ public SiteRepository(IDb db, IContentServiceFactory factory)
Logo = site.LogoId.HasValue ? site.LogoId.Value : new ImageField(),
Hostnames = site.Hostnames,
IsDefault = site.IsDefault,
Culture = site.Culture,
ContentLastModified = site.ContentLastModified,
Created = site.Created,
LastModified = site.LastModified
Expand Down Expand Up @@ -190,7 +187,6 @@ public SiteRepository(IDb db, IContentServiceFactory factory)
Logo = site.LogoId.HasValue ? site.LogoId.Value : new ImageField(),
Hostnames = site.Hostnames,
IsDefault = site.IsDefault,
Culture = site.Culture,
ContentLastModified = site.ContentLastModified,
Created = site.Created,
LastModified = site.LastModified
Expand Down Expand Up @@ -293,7 +289,6 @@ public async Task Save(Models.Site model)
site.Description = model.Description;
site.LogoId = model.Logo?.Id;
site.Hostnames = model.Hostnames;
site.Culture = model.Culture;
site.IsDefault = model.IsDefault;
site.ContentLastModified = model.ContentLastModified;
site.LastModified = DateTime.Now;
Expand Down

0 comments on commit 88133ab

Please sign in to comment.