Fixes U4-9095 - the textService.Localize always returns some string, either the translation or [alias] - so we need to make sure it actually translated something

This commit is contained in:
Sebastiaan Janssen
2018-08-09 14:36:08 +02:00
parent 50597b5715
commit fd888cab4b

View File

@@ -51,17 +51,24 @@ namespace Umbraco.Web.Trees
internal static string GetRootNodeDisplayName(this TreeAttribute attribute, ILocalizedTextService textService)
{
var label = $"[{attribute.Alias}]";
// try to look up a the localized tree header matching the tree alias
var localizedLabel = textService.Localize("treeHeaders/" + attribute.Alias);
if (string.IsNullOrEmpty(localizedLabel) == false)
return localizedLabel;
// otherwise return the header if it's defined
if (string.IsNullOrEmpty(attribute.Title) == false)
return attribute.Title;
// if all fails, return this to signal that a label was not found
return "[" + attribute.Alias + "]";
// if the localizedLabel returns [alias] then return the title attribute from the trees.config file, if it's defined
if (localizedLabel != null && localizedLabel.Equals(label, StringComparison.InvariantCultureIgnoreCase))
{
if (string.IsNullOrEmpty(attribute.Title) == false)
label = attribute.Title;
}
else
{
// the localizedLabel translated into something that's not just [alias], so use the translation
label = localizedLabel;
}
return label;
}
internal static Attempt<Type> TryGetControllerTree(this ApplicationTree appTree)