Copied to clipboard

Flag this post as spam?

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


  • Nigel 29 posts 52 karma points
    Jul 19, 2013 @ 18:38
    Nigel
    0

    I wonder if you could post an example for use on a razor .cshtml page.

    I've tried to copy the code within TranslateNavigation.cshtml but haven't got very far.

    It very simple in xslt but I'm new to razor

    @{
        string selectedLanguage = RenderPage("~/macroScripts/SelectedLanguage.cshtml").ToString().Trim();
        string translatedTitle = RenderPage("~/macroScripts/PropertyReferenceTranslation.cshtml", Model.Content.Id, "'bodyText", selectedLanguage).ToString();

    @Html.Raw(@translatedTitle)
    }

     

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE xsl:stylesheet [
      <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library"
                    xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes"
                    xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions"
                    xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
                    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
      <xsl:output method="xml" omit-xml-declaration="yes" />
      <xsl:param name="currentPage" />
      <xsl:include href="../xslt/LanguageParameter.xslt" />
      <xsl:include href="../xslt/PropertyReferenceTranslation.xslt" />
      <xsl:template match="/">
         

          <xsl:call-template name="PropertyReferenceTranslation">
              <xsl:with-param name="nodeId" select="$currentPage/@id" />
              <xsl:with-param name="Property" select="'bodyText'" />
              <xsl:with-param name="langISO" select="$langISO" />
          </xsl:call-template>
             
      </xsl:template>
    </xsl:stylesheet>

  • dimi309 244 posts 578 karma points
    Jul 19, 2013 @ 20:29
    dimi309
    0

    Hi Nigel! The only problem I see is that @Html.Raw(@translatedTitle) should be @Html.Raw(translatedTitle) When sending output using Razor like that, you only need to use the @ sign once, in the beginning of the first method or variable, not for each one used as a parameter. Let me know if this works for you, or if you need more help! Best regards, Dimitri

  • Nigel 29 posts 52 karma points
    Jul 22, 2013 @ 12:17
    Nigel
    0

    Thanks Dimitri

    No joy with @Html.Raw(translatedTitle) - I've also tried

    @Umbraco.RenderMacro("PropertyReferenceTranslation",  new {nodeId = Model.Content.Id, Property = "bodyText", langISO = selectedLanguage})

    but it always returns : umbraco.MacroEngines.PropertyResult

     

    For the record

    @Umbraco.RenderMacro("PropertyTranslation",  new {Property = "bodyText"})

    does work and so does

    @Umbraco.RenderMacro("PropertyReferenceTranslation",  new {nodeId = Model.Content.Id, Property = "bodyText", langISO = selectedLanguage})

    if I add the following to the xslt file' PropertyReferenceTranslation.xslt'

      <xsl:param name="nodeId" select="macro/nodeId" />
      <xsl:param name="Property" select="macro/Property"/>
      <xsl:param name="langISO" select="macro/langISO"/>

     

     

     



  • dimi309 244 posts 578 karma points
    Jul 22, 2013 @ 18:09
    dimi309
    0

    Hi Nigel,

    If you are using Polyglot with an Umbraco version equal to or higher than 4.7.1, have you applied the razor script patch? It is necessary for the razor version of the package. Please see here: http://polyglot.codeplex.com/releases/view/108426

    Let me know if this resolves the problem. If you are still encountering difficulties, I will run some tests. I was on holiday and I did not have my development environment with me, but I am back now :)

    Best regards,

    Dimitri

  • dimi309 244 posts 578 karma points
    Aug 03, 2013 @ 19:49
    dimi309
    0

    Hi everyone!

    This is just a note for whomever is reading this conversation. Things have recently changed. A razor script patch is now required for Umbraco versions 4.7.0 or earlier. The razor script version of the Polyglot package is now built to work properly with the latest versions of Umbraco by default and not the other way around.

    Best regards,

    Dimitri

Please Sign in or register to post replies

Write your reply to:

Draft