Copied to clipboard

Flag this post as spam?

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


  • Jeremy Holland 20 posts 103 karma points
    Oct 27, 2016 @ 16:55
    Jeremy Holland
    0

    umbraco.ui is obsolete

    Hi,

    I'm trying to use some code from a blog that adds the refresh action to a menu in a custom section like this:

    menu.Items.Add<RefreshNode, ActionRefresh>(umbraco.ui.Text("actions", ActionRefresh.Instance.Alias), true);
    

    But Visual Studio complains that umbraco.ui is obsolete and to "use ILocalizedTextService instead which is on the ApplicationContext.Services.TextService". I tried a few things with that class but I couldn't figure it out. Can someone lend me their expertise? I'm a little unsure what VS wants me to do, and how the refactored code should look.

    Here is the blog I got the code from for context: http://www.nibble.be/?p=440

  • Sebastiaan Janssen 5061 posts 15544 karma points MVP admin hq
    Oct 27, 2016 @ 17:18
    Sebastiaan Janssen
    101

    So what this is doing is it looks in the translation file for the area actions for the key refreshNode (because ActionRefresh.Instance.Alias returns refreshNode):

    <area alias="actions">
        <key alias="refreshNode">Reload</key>
    </area>
    

    This can be done using the testService as well:

    var textService = ApplicationContext.Current.Services.TextService;
    var refreshNodeText = textService.Localize("actions/refreshNode");
    menu.Items.Add<RefreshNode, ActionRefresh>(refreshNodeText, true);
    

    You may need to add a using: using Umbraco.Core.Services;

    Of course it's better to keep using the constant value:

    var refreshNodeText = textService.Localize(string.Format("actions/{0}", ActionRefresh.Instance.Alias));
    

    Hope that helps!

  • Jeremy Holland 20 posts 103 karma points
    Oct 27, 2016 @ 17:35
    Jeremy Holland
    0

    Thanks for the quick reply! Perfect solution! :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies