-
+
*
diff --git a/src/Umbraco.Web/Models/ContentEditing/ContentVariationDisplay.cs b/src/Umbraco.Web/Models/ContentEditing/ContentVariationDisplay.cs
index aff79d7b9d..2a2ec49002 100644
--- a/src/Umbraco.Web/Models/ContentEditing/ContentVariationDisplay.cs
+++ b/src/Umbraco.Web/Models/ContentEditing/ContentVariationDisplay.cs
@@ -24,6 +24,9 @@ namespace Umbraco.Web.Models.ContentEditing
[DataMember(Name = "name", IsRequired = true)]
public string Name { get; set; }
+ [DataMember(Name = "displayName")]
+ public string DisplayName { get; set; }
+
///
/// Defines the tabs containing display properties
///
diff --git a/src/Umbraco.Web/Models/Mapping/ContentMapDefinition.cs b/src/Umbraco.Web/Models/Mapping/ContentMapDefinition.cs
index c811c236d4..8c9b65e312 100644
--- a/src/Umbraco.Web/Models/Mapping/ContentMapDefinition.cs
+++ b/src/Umbraco.Web/Models/Mapping/ContentMapDefinition.cs
@@ -50,7 +50,7 @@ namespace Umbraco.Web.Models.Mapping
_tabsAndPropertiesMapper = new TabsAndPropertiesMapper
(localizedTextService);
_stateMapper = new ContentSavedStateMapper();
_basicStateMapper = new ContentBasicSavedStateMapper();
- _contentVariantMapper = new ContentVariantMapper(_localizationService);
+ _contentVariantMapper = new ContentVariantMapper(_localizationService, localizedTextService);
}
public void DefineMaps(UmbracoMapper mapper)
@@ -102,7 +102,7 @@ namespace Umbraco.Web.Models.Mapping
target.ContentDto.Properties = context.MapEnumerable(source.Properties);
}
- // Umbraco.Code.MapAll -Segment -Language
+ // Umbraco.Code.MapAll -Segment -Language -DisplayName
private void Map(IContent source, ContentVariantDisplay target, MapperContext context)
{
target.CreateDate = source.CreateDate;
diff --git a/src/Umbraco.Web/Models/Mapping/ContentVariantMapper.cs b/src/Umbraco.Web/Models/Mapping/ContentVariantMapper.cs
index 0ed8ffb80e..406c2090c2 100644
--- a/src/Umbraco.Web/Models/Mapping/ContentVariantMapper.cs
+++ b/src/Umbraco.Web/Models/Mapping/ContentVariantMapper.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Mapping;
@@ -13,10 +14,12 @@ namespace Umbraco.Web.Models.Mapping
internal class ContentVariantMapper
{
private readonly ILocalizationService _localizationService;
+ private readonly ILocalizedTextService _localizedTextService;
- public ContentVariantMapper(ILocalizationService localizationService)
+ public ContentVariantMapper(ILocalizationService localizationService, ILocalizedTextService localizedTextService)
{
_localizationService = localizationService ?? throw new ArgumentNullException(nameof(localizationService));
+ _localizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService));
}
public IEnumerable Map(IContent source, MapperContext context)
@@ -138,8 +141,31 @@ namespace Umbraco.Web.Models.Mapping
variantDisplay.Segment = segment;
variantDisplay.Language = language;
variantDisplay.Name = content.GetCultureName(language?.IsoCode);
+ variantDisplay.DisplayName = GetDisplayName(language, segment);
return variantDisplay;
}
+
+ private string GetDisplayName(Language language, string segment)
+ {
+ var isCultureVariant = language != null;
+ var isSegmentVariant = !segment.IsNullOrWhiteSpace();
+
+ if(!isCultureVariant && !isSegmentVariant)
+ {
+ return _localizedTextService.Localize("general/default");
+ }
+
+ var parts = new List();
+
+ if (isCultureVariant)
+ parts.Add(new CultureInfo(language.IsoCode).NativeName);
+
+ if (isSegmentVariant)
+ parts.Add(segment);
+
+ return string.Join(" - ", parts);
+
+ }
}
}