Skip to content

Instantly share code, notes, and snippets.

@xpathr
Created May 10, 2012 14:40
Show Gist options
  • Save xpathr/2653479 to your computer and use it in GitHub Desktop.
Save xpathr/2653479 to your computer and use it in GitHub Desktop.
Czech pluralizer by janiczek
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="sklonovani">
<xsl:param name="kolik" />
<xsl:param name="nula" />
<xsl:param name="jeden" />
<xsl:param name="dva" />
<xsl:param name="pet" />
<xsl:if test="$kolik = 0">
<xsl:value-of select="$nula" />
</xsl:if>
<xsl:if test="$kolik = 1">
<xsl:value-of select="$jeden" />
</xsl:if>
<xsl:if test="$kolik &gt; 1 and $kolik &lt; 5">
<xsl:value-of select="$kolik" />
<xsl:value-of select="$dva" />
</xsl:if>
<xsl:if test="$kolik &gt; 4">
<xsl:value-of select="$kolik" />
<xsl:value-of select="$pet" />
</xsl:if>
</xsl:template>
<!--
Example usage: 1) add this:
<xsl:template name="sklonovani-komentare">
<xsl:param name="kolik" />
<xsl:call-template name="sklonovani">
<xsl:with-param name="kolik" select="$kolik" />
<xsl:with-param name="nula" select="'Bez komentaru'" />
<xsl:with-param name="jeden" select="'1 komentar'" />
<xsl:with-param name="dva" select="' komentare'" />
<xsl:with-param name="pet" select="' komentaru'" />
</xsl:call-template>
</xsl:template>
2) and then call it:
<xsl:call-template name="sklonovani-komentare">
<xsl:with-param name="kolik" select="/XPath/.../" />
</xsl:call-template>
-->
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment