Localize content app names

This commit is contained in:
Kenn Jacobsen
2019-02-13 08:11:01 +01:00
parent 7f7afef976
commit 730a2f7768
4 changed files with 32 additions and 3 deletions

View File

@@ -77,6 +77,10 @@
<key alias="update">Tillad adgang til at gemme en node</key>
<key alias="createblueprint">Tillad adgang til at oprette en indholdsskabelon</key>
</area>
<area alias="apps">
<key alias="umbContent">Indhold</key>
<key alias="umbInfo">Info</key>
</area>
<area alias="assignDomain">
<key alias="permissionDenied">Tilladelse nægtet.</key>
<key alias="addNew">Tilføj nyt domæne</key>

View File

@@ -78,6 +78,10 @@
<key alias="update">Allow access to save a node</key>
<key alias="createblueprint">Allow access to create a Content Template</key>
</area>
<area alias="apps">
<key alias="umbContent">Content</key>
<key alias="umbInfo">Info</key>
</area>
<area alias="assignDomain">
<key alias="permissionDenied">Permission denied.</key>
<key alias="addNew">Add new Domain</key>

View File

@@ -78,6 +78,10 @@
<key alias="update">Allow access to save a node</key>
<key alias="createblueprint">Allow access to create a Content Template</key>
</area>
<area alias="apps">
<key alias="umbContent">Content</key>
<key alias="umbInfo">Info</key>
</area>
<area alias="assignDomain">
<key alias="permissionDenied">Permission denied.</key>
<key alias="addNew">Add new Domain</key>

View File

@@ -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<IContent, ContentItemDisplay, IEnumerable<ContentApp>>
{
private readonly ContentAppFactoryCollection _contentAppDefinitions;
private readonly ILocalizedTextService _localizedTextService;
public ContentAppResolver(ContentAppFactoryCollection contentAppDefinitions)
public ContentAppResolver(ContentAppFactoryCollection contentAppDefinitions, ILocalizedTextService localizedTextService)
{
_contentAppDefinitions = contentAppDefinitions;
_localizedTextService = localizedTextService;
}
public IEnumerable<ContentApp> Resolve(IContent source, ContentItemDisplay destination, IEnumerable<ContentApp> 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;
}
}
}