From 730a2f7768185d718a2fc0223ae43e73d0b38ba8 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Wed, 13 Feb 2019 08:11:01 +0100 Subject: [PATCH] Localize content app names --- src/Umbraco.Web.UI/Umbraco/config/lang/da.xml | 4 ++++ src/Umbraco.Web.UI/Umbraco/config/lang/en.xml | 4 ++++ .../Umbraco/config/lang/en_us.xml | 4 ++++ .../Models/Mapping/ContentAppResolver.cs | 23 ++++++++++++++++--- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml index a507366b56..09ea57e176 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/da.xml @@ -77,6 +77,10 @@ Tillad adgang til at gemme en node Tillad adgang til at oprette en indholdsskabelon + + Indhold + Info + Tilladelse nægtet. Tilføj nyt domæne diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml index 548d6932a6..b41752ae36 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en.xml @@ -78,6 +78,10 @@ Allow access to save a node Allow access to create a Content Template + + Content + Info + Permission denied. Add new Domain diff --git a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml index 7dcd101aff..7551ebe6a3 100644 --- a/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml @@ -78,6 +78,10 @@ Allow access to save a node Allow access to create a Content Template + + Content + Info + Permission denied. Add new Domain diff --git a/src/Umbraco.Web/Models/Mapping/ContentAppResolver.cs b/src/Umbraco.Web/Models/Mapping/ContentAppResolver.cs index ee3e991f89..6d9ae77009 100644 --- a/src/Umbraco.Web/Models/Mapping/ContentAppResolver.cs +++ b/src/Umbraco.Web/Models/Mapping/ContentAppResolver.cs @@ -1,7 +1,10 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Linq; using AutoMapper; using Umbraco.Core.Models; using Umbraco.Core.Models.ContentEditing; +using Umbraco.Core.Services; using Umbraco.Web.ContentApps; using Umbraco.Web.Models.ContentEditing; @@ -12,15 +15,29 @@ namespace Umbraco.Web.Models.Mapping internal class ContentAppResolver : IValueResolver> { private readonly ContentAppFactoryCollection _contentAppDefinitions; + private readonly ILocalizedTextService _localizedTextService; - public ContentAppResolver(ContentAppFactoryCollection contentAppDefinitions) + public ContentAppResolver(ContentAppFactoryCollection contentAppDefinitions, ILocalizedTextService localizedTextService) { _contentAppDefinitions = contentAppDefinitions; + _localizedTextService = localizedTextService; } public IEnumerable Resolve(IContent source, ContentItemDisplay destination, IEnumerable destMember, ResolutionContext context) { - return _contentAppDefinitions.GetContentAppsFor(source); + var apps = _contentAppDefinitions.GetContentAppsFor(source).ToArray(); + + // localize content app names + foreach (var app in apps) + { + var localizedAppName = _localizedTextService.Localize($"apps/{app.Alias}"); + if (localizedAppName.Equals($"[{app.Alias}]", StringComparison.OrdinalIgnoreCase) == false) + { + app.Name = localizedAppName; + } + } + + return apps; } } }