Author:
janiczek
Version:
1.0
Release Date:
22 Jan 2012
Category:
String Operations

Description

Czech pluralizer - based on phoque's pluralizer, but adjusted for Czech language - supports different words for 0, 1, 2-4 and 5+ things.

XSLT

View Raw
<?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>

Discuss this XSLT Utility

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details