Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • jake williamson 207 posts 873 karma points
    Dec 01, 2022 @ 00:23
    jake williamson
    0

    is it possible to localise the 'TreeTitle' for a custom backoffice tree?!

    hey out there,

    this one has me scratching my head! the docs (ooh, new shiny docs!) talk about how to get the tree group name from a language file:

    tree groups

    but it makes no mention of how to set the tree title...

    i've been digging into the source code and found this in the Tree.cs file:

    public static string? GetRootNodeDisplayName(ITree tree, ILocalizedTextService textService)
    {
        var label = $"[{tree.TreeAlias}]";
    
        // try to look up a the localized tree header matching the tree alias
        var localizedLabel = textService.Localize("treeHeader", tree.TreeAlias);
    
        // if the localizedLabel returns [alias] then return the title if it's defined
        if (localizedLabel != null && localizedLabel.Equals(label, StringComparison.InvariantCultureIgnoreCase))
        {
            if (string.IsNullOrEmpty(tree.TreeTitle) == false)
            {
                label = tree.TreeTitle;
            }
        }
        else
        {
            // the localizedLabel translated into something that's not just [alias], so use the translation
            label = localizedLabel;
        }
    
        return label;
    }
    

    which looks to be that only the TreeAlias gets localised?

    so i had a dig through some of the tree uses in the core and found the StaticFilesTreeController.cs which has the following:

    [Tree(Constants.Applications.Settings, "staticFiles", TreeTitle = "Static Files", TreeUse = TreeUse.Dialog)]
    

    as the TreeTitle is set to Static Files and that text doesn't appear in the en_us.xml language file its making me think that localising the tree title isn't possible?!

    very confusing! if anyone can shed some light on this one it'd be great appreciated,

    cheers,

    jake

Please Sign in or register to post replies

Write your reply to:

Draft