Copied to clipboard

Flag this post as spam?

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


  • Sören Deger 733 posts 2844 karma points c-trib
    Jan 02, 2015 @ 22:18
    Sören Deger
    0

    How I can localize name of tree nodes in custom section?

    I have created a few nodes with a tree controller like this:

    protected TreeNodeCollection GetChildTreeNodes(string id, System.Net.Http.Formatting.FormDataCollection queryStrings)
            {
                var nodes = new TreeNodeCollection {
                        CreateTreeNode(id+"-1", id, queryStrings, "Settings", "icon-mail2cms-settingstwo-gearalt",false,"mail2CMS/mail2CMSTree/settings/" + id + "-1"),
                        CreateTreeNode(id+"-2", id, queryStrings, "Mapping", "icon-mail2cms-emailforwarders", false,"mail2CMS/mail2CMSTree/mapping/" + id + "-2"),
                        CreateTreeNode(id+"-3", id, queryStrings, "Blacklist and Whitelist", "icon-mail2cms-th-list", false, "mail2CMS/mail2CMSTree/blackwhitelist/" + id + "-3")
                    };
                return nodes;
            }

    How can I localize the name of tree nodes (here: "Settings", "Mapping", "Blacklist") ?

    My language file looks like this:

    <area alias="mail2cms">    
      <key alias="settings">My settings</key>
      <key alias="mapping">My mapping</key>
      <key alias="blacklist">My Blacklist</key>
    </area>

    Can anyone help me, please?

    Cheers
    Sören

  • Sören Deger 733 posts 2844 karma points c-trib
    Jan 02, 2015 @ 22:27
    Sören Deger
    100

    I have solved it with ui.Text(areaAlias,key)

    CreateTreeNode(id+"-1", id, queryStrings, ui.Text("mail2cms", "settings"), "icon-mail2cms-settingstwo-gearalt",false,"mail2CMS/mail2CMSTree/settings/" + id + "-1"),

     

    Sören

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Apr 14, 2016 @ 14:38
    Chris Houston
    0

    I think the following is depreciated:

    ui.Text("mail2cms", "settings")
    

    And you should be using the localizationService, however I am not sure of the syntax, maybe someone else can confirm the new syntax?

    Cheers,

    Chris

  • Comment author was deleted

    Apr 14, 2016 @ 15:10

    Think it's the TextService you need to use, that has a localize method

    (LocalizationService is for languages and dictionary items)

  • Comment author was deleted

    Apr 14, 2016 @ 15:13
  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Apr 14, 2016 @ 15:30
    Chris Houston
    2

    Thanks Tim,

    I am currently working on a 7.2.6 site and it seems the syntax is slightly different to the documentation you pointed to, so I thought I'd add a comment on here in case it is useful for someone else.

    In the version I am using, you also have to pass in a culture, I have slightly changed my code so it is trying to get the same key mentioned in the original question above:

    var textService = this.ApplicationContext.Services.TextService;
    textService.Localize("mail2cms/settings"), CultureInfo.CurrentCulture)
    

    I hope this thread helps someone else :)

    Cheers,

    Chris

Please Sign in or register to post replies

Write your reply to:

Draft