Copied to clipboard

Flag this post as spam?

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


  • Julien Morvan 8 posts 39 karma points
    Nov 09, 2014 @ 22:48
    Julien Morvan
    0

    Macro In translated RTE property

    Hi,

    I am trying to translate some content in RTE, somehow my Macro gets commented out to:

    <!--?UMBRACO_MACRO macroAlias="ConferencePlanning" /-->
    

    Any ideas?

    (Umbraco V7)

  • dimi309 245 posts 579 karma points
    Nov 10, 2014 @ 07:26
    dimi309
    0

    Hi Julien,

    Thanks for reporting this. I have found out what is wrong. As a quick solution, could you try replacing the code in the MacroScripts/PropertyTranslation.cshtml file with the code below and let me know if it works for you? I will perform some tests myself and publish a new version of Polyglot as soon as possible.

    Best regards,

    Dimitri

     

    @*
        PropertyTranslation.cshtml
        Part of the Polyglot package.
    *@
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using umbraco.MacroEngines;
    @{
    
        string selectedLanguage = RenderPage("SelectedLanguage.cshtml").ToString().Trim();
        string selectedLanguageNoDash = selectedLanguage.Replace("-", string.Empty);
    
        DynamicNode page = Model;
    
        var contentFound = false;
    
        if (page.HasProperty(Parameter.Property + selectedLanguageNoDash) && !string.IsNullOrEmpty(page.GetPropertyValue(Parameter.Property + selectedLanguageNoDash)))
        {
            contentFound = true;
            @Html.Raw(Umbraco.Web.Templates.TemplateUtilities.ParseInternalLinks(library.RenderMacroContent(page.GetPropertyValue(Parameter.Property + selectedLanguageNoDash), page.Id)))
        }
    
        if (!contentFound)
        {
            foreach (DynamicNode child in page.GetChildrenAsList)
            {
                if (child.NodeTypeAlias == page.NodeTypeAlias + "TranslationFolder")
                {
                    foreach (DynamicNode translation in child.GetChildrenAsList)
                    {
                        var language = translation.GetPropertyValue("language");
    
                        if (language != null && language.ToString().ToLower() == selectedLanguage.ToLower())
                        {
                            if (translation.HasProperty(Parameter.Property) && !string.IsNullOrEmpty(translation.GetPropertyValue(Parameter.Property)))
                            {
                                contentFound = true;
                                @Html.Raw(Umbraco.Web.Templates.TemplateUtilities.ParseInternalLinks(library.RenderMacroContent(translation.GetPropertyValue(Parameter.Property), translation.Id)))
                            }
                        }
                    }
                }
            }
        }
    
        if (!contentFound)
        {
    
            if (page.HasProperty(Parameter.Property) && !string.IsNullOrEmpty(page.GetPropertyValue(Parameter.Property)))
            {
                @Html.Raw(Umbraco.Web.Templates.TemplateUtilities.ParseInternalLinks(library.RenderMacroContent(page.GetPropertyValue(Parameter.Property), page.Id)))
            }
        }
    }
    
  • dimi309 245 posts 579 karma points
    Nov 10, 2014 @ 21:01
    dimi309
    100

    Hi Julien, I have just released version 2.04 of the package, which corrects this problem. If you need more help, please let me know.

     

     

  • Julien Morvan 8 posts 39 karma points
    Nov 11, 2014 @ 00:05
    Julien Morvan
    1

    Hi Dim,

    Sorry I could not get back to you, and thank you for your quick replies and patch.

    unfortunatly I was in a hurry so i implemented a dirty hack for this and since the site is up and I dont want to mess with it, I shall leave it like this for now.

    Just in case someone is in my situation, my very dirty hack:

    @functions {
    
        string getLocalizedPropertyValue(dynamic obj, string prop){
    
            var locPropName = prop + RenderPage("/macroScripts/SelectedLanguage.cshtml").ToString().Trim();
    
            if (obj[locPropName] == null || obj[locPropName].ToString() == "")
            {
                locPropName = prop;
            }
            return obj[locPropName].ToString();
        }
    
    }
    

    I will try your update net time i version the site, and I'll post here in case of issues.

    thank you!

  • dimi309 245 posts 579 karma points
    Nov 11, 2014 @ 05:17
    dimi309
    0

    Hi Julien,

    You're welcome and, no worries! I'm glad you got it to work either way. Thank you very much for sharing your solution. I don't think it's just a hack. I'll keep it in mind because I think that it might be faster than the way I'm usually doing things in Polyglot. Maybe I'll use it someday, if I run into performance problems :)

    Cheers,

    Dimitri

Please Sign in or register to post replies

Write your reply to:

Draft