Skip to content

Instantly share code, notes, and snippets.

@netsi1964
Created June 24, 2012 20:41
Show Gist options
  • Save netsi1964/2984824 to your computer and use it in GitHub Desktop.
Save netsi1964/2984824 to your computer and use it in GitHub Desktop.
Dynamicweb XSLT Translate method
<xsl:variable name="translationfile" select="document(concat('http://',/Template/GlobalTags/Global.Request.Host,'/Files/Templates/Translations.xml'))" />
<xsl:variable name="currentlanguage" select="/Template/GlobalTags/Global.Area.LongLang" />
<xsl:template name="translate">
<xsl:param name="translationkey" />
<xsl:param name="defaulttranslation" />
<xsl:choose>
<xsl:when test="$translationfile/translations/key[@name=$translationkey]"><xsl:value-of select="$translationfile/translations/key[@name=$translationkey]/translation[@culture=string($currentlanguage)]" /></xsl:when>
<xsl:otherwise><xsl:value-of select="$defaulttranslation" /></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:call-template name="translate">
<xsl:with-param name="translationkey" select="'YourKeyName'" />
<xsl:with-param name="defaulttranslation" select="'Default value'" />
</xsl:call-template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment