Developer forum

Forum » Templates » XSLT Global translations tags

XSLT Global translations tags

Mikkel Høst
Reply
Hello.

I'm using a XSLT template, in CartV1 on step1. We need some of the translations tags to be global, but i cant seem to find any information about it. I know how get the translations from the Global translations file but i dont understand how to tell DW that a translations is global ?

please help :)

<xsl:variable name="translationfile" select="document('/Files/Templates/Translations.xml')/translations" />  

<xsl:call-template name="translate">
		    <xsl:with-param name="translationkey" select="'cartHeader'" />
		    <xsl:with-param name="defaulttranslation" select="'Checkout'" />		    
		</xsl:call-template>   

 <xsl:template name="translate">  		
    <xsl:param name="translationkey" />
    <xsl:param name="defaulttranslation" />
    <xsl:variable name="currentlanguage" select="/Template/GlobalTags/Global.Area.LongLang" />  
    <xsl:variable name="translation" select="$translationfile/key[@name=$translationkey]/translation[@culture=$currentlanguage]"/>
   <xsl:choose>
   <xsl:when test="string-length($translation) != 0">
	   <xsl:value-of select="$translation"/>       
    </xsl:when>
    <xsl:otherwise>
       <xsl:value-of select="$defaulttranslation" />
    </xsl:otherwise>
 </xsl:choose>
</xsl:template>
 

Replies

 
Mikkel Høst
Reply
This post has been marked as an answer
 And i will answer :)

You need to add 

 <xsl:with-param name="translationMode" select="'global'" />

And then i just load the global translation file




 <xsl:variable name="translationfileGlobal" select="document('/Files/Templates/Translations.xml')/translations" />

And make my temaplte respond if global parameter is present :)


<xsl:template name="translate">
    <xsl:param name="translationkey" />
    <xsl:param name="defaulttranslation" />
    <xsl:param name="translationMode" />
    <xsl:choose>
      <xsl:when test="$translationMode='global'">
        <xsl:variable name="currentlanguage" select="/Template/GlobalTags/Global.Area.LongLang" />
        <xsl:variable name="translation" select="$translationfileGlobal/key[@name=$translationkey]/translation[@culture=$currentlanguage]"/>
        <xsl:choose>
          <xsl:when test="string-length($translation) != 0">
            <xsl:value-of select="$translation"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$defaulttranslation" />
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <xsl:variable name="currentlanguage" select="/Template/GlobalTags/Global.Area.LongLang" />
        <xsl:variable name="translation" select="$translationfile/key[@name=$translationkey]/translation[@culture=$currentlanguage]"/>
        <xsl:choose>
          <xsl:when test="string-length($translation) != 0">
            <xsl:value-of select="$translation"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$defaulttranslation" />
          </xsl:otherwise>
        </xsl:choose>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

Votes for this answer: 0

 

You must be logged in to post in the forum