From 6dc4e2d2aee61963c8f993ca05048ea687a82599 Mon Sep 17 00:00:00 2001 From: Per Ploug Date: Thu, 24 Sep 2015 15:30:08 +0200 Subject: [PATCH] U4-4761 Member translation Makes all trees translateable, does not break the current titles set on atttributes, but for trees that does not have a title set, the tree wil try to look up a treeheader. --- src/Umbraco.Web/Trees/MemberTreeController.cs | 2 +- src/Umbraco.Web/Trees/TreeAttribute.cs | 2 +- src/Umbraco.Web/Trees/TreeController.cs | 21 ++++++++++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web/Trees/MemberTreeController.cs b/src/Umbraco.Web/Trees/MemberTreeController.cs index e80cabecfa..8c86793485 100644 --- a/src/Umbraco.Web/Trees/MemberTreeController.cs +++ b/src/Umbraco.Web/Trees/MemberTreeController.cs @@ -27,7 +27,7 @@ namespace Umbraco.Web.Trees Constants.Applications.Media, Constants.Applications.Members)] [LegacyBaseTree(typeof (loadMembers))] - [Tree(Constants.Applications.Members, Constants.Trees.Members, "Members")] + [Tree(Constants.Applications.Members, Constants.Trees.Members)] [PluginController("UmbracoTrees")] [CoreTree] public class MemberTreeController : TreeController diff --git a/src/Umbraco.Web/Trees/TreeAttribute.cs b/src/Umbraco.Web/Trees/TreeAttribute.cs index 72ae4044e9..67543085c1 100644 --- a/src/Umbraco.Web/Trees/TreeAttribute.cs +++ b/src/Umbraco.Web/Trees/TreeAttribute.cs @@ -20,7 +20,7 @@ namespace Umbraco.Web.Trees /// The sort order. public TreeAttribute(string appAlias, string alias, - string title, + string title = "", string iconClosed = "icon-folder", string iconOpen = "icon-folder-open", bool initialize = true, diff --git a/src/Umbraco.Web/Trees/TreeController.cs b/src/Umbraco.Web/Trees/TreeController.cs index 14a25b6f02..2f3bc8efb6 100644 --- a/src/Umbraco.Web/Trees/TreeController.cs +++ b/src/Umbraco.Web/Trees/TreeController.cs @@ -1,8 +1,12 @@ using System; using System.Collections.Concurrent; +using System.Globalization; using System.Linq; using System.Net.Http.Formatting; +using System.Threading; +using System.Web.Security; using Umbraco.Core; +using Umbraco.Core.Models; using Umbraco.Web.Models.Trees; using Umbraco.Web.Mvc; @@ -37,7 +41,22 @@ namespace Umbraco.Web.Trees /// public override string RootNodeDisplayName { - get { return _attribute.Title; } + get + { + //if title is defined, return that + if(string.IsNullOrEmpty(_attribute.Title) == false) + return _attribute.Title; + + + //try to look up a tree header matching the tree alias + var culture = CultureInfo.GetCultureInfo(Security.CurrentUser.Language.Replace("_", "-")); + var localizedLabel = Services.TextService.Localize("treeHeaders/" + _attribute.Alias, culture); + if (string.IsNullOrEmpty(localizedLabel) == false) + return localizedLabel; + + //is returned to signal that a label was not found + return "[" + _attribute.Alias + "]"; + } } ///