Copied to clipboard

Flag this post as spam?

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


  • Andy Blyth 9 posts 120 karma points
    Sep 15, 2015 @ 15:08
    Andy Blyth
    0

    Square Brackets for admin application

    I am using Services.SectionService.MakeNew inside a IPackageAction, but always get [] until I update the the section in en.xml file, is there a way to do this automatically? I am guessing it it something to do with the TextService, but can't find much about it.

  • Andy Blyth 9 posts 120 karma points
    Sep 22, 2015 @ 11:28
    Andy Blyth
    100

    I did this by writing a little method to handle it, don't know if it is the right way, but it works.

    private static void UpdateLocale(string en)
        {
            XmlDocument languageFile = XmlHelper.OpenAsXmlDocument(en);
            XmlNode rootNode = languageFile.SelectSingleNode("//area[@alias='sections']");
            if (rootNode.SelectNodes("key[@alias='aliasValue']").Count == 0)
            {
                XmlNode newNode = (XmlNode)languageFile.CreateElement("key");
                newNode.Attributes.Append(XmlHelper.AddAttribute(languageFile, "alias", "aliasValue"));
                newNode.InnerText = "Nice String";
                rootNode.AppendChild(newNode);
                languageFile.Save(System.Web.HttpContext.Current.Server.MapPath(en));
            }
        }
    

    This is called like this UpdateLocale("/umbraco/Config/Lang/en.xml");

Please Sign in or register to post replies

Write your reply to:

Draft