<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>TranslatePlural Helper &mdash; Zend Framework 2 2.3.0dev documentation</title>
    
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.3.0dev',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="Zend Framework 2 2.3.0dev documentation" href="../index.html" />
<style type="text/css">
    /* Styles for floating Edit on GitHub box */
    #editor-trap {
        padding: 1em;
        border: 1px solid white;
        width: 250px;

        display: none;
        color: white;
        background: #3f454b;
        position: fixed;
        bottom: 5px;
        left: 175px;
        font-size: 85%;
        text-align: left;
        z-index: 2;

        box-shadow: 0 4px 6px #333;
        -moz-box-shadow: 0 4px 6px #333;
        -webkit-box-shadow: 0 4px 6px #333;
        
        cursor: pointer;
    }

    #editor-trap h3 {
        margin: 0 0 0.5em 0;
        padding: 0;
    }

    #editor-trap h3 > span {
        padding: 0 6px;
        border: solid white;
        border-width: 0 1px 4px 1px;
        font-size: 10px;
    }

    #editor-trap a {
        color: #98DBCC;
    }

    #editor-trap ol {
        margin: 0;
        padding: 0 0 0 2em;
    }

    /* Hide trick */
    #editor-trap.toggled > * {
        display: none;
    }


    #editor-trap.toggled > h3 {
        display: block;
    }

    #editor-trap.toggled > h3 > span {
        border-width: 6px 1px 0 1px;
    }
    
    #edit-button {
        position: fixed;
        bottom: 5px;
        left: 5px;
        z-index: 2;
        width: 162px;
        height: 42px;
    }
</style>

  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li><a href="../index.html">Zend Framework 2 2.3.0dev documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="translateplural-helper">
<span id="zend-i18n-view-helper-translate-plural"></span><h1>TranslatePlural Helper<a class="headerlink" href="#translateplural-helper" title="Permalink to this headline">¶</a></h1>
<p>The <tt class="docutils literal"><span class="pre">TranslatePlural</span></tt> view helper can be used to translate words which take into account numeric meanings.
English, for example, has a singular definition of &#8220;car&#8221;, for one car. And has the plural definition, &#8220;cars&#8221;,
meaning zero &#8220;cars&#8221; or more than one car. Other languages like Russian or Polish have more plurals with different
rules.</p>
<p>The viewhelper acts as a wrapper for the <tt class="docutils literal"><span class="pre">Zend\I18n\Translator\Translator</span></tt> class.</p>
<p id="zend-i18n-view-helper-translate-plural-setup"><strong>Setup</strong></p>
<p>Before using the <tt class="docutils literal"><span class="pre">TranslatePlural</span></tt> view helper, you must have first created a <tt class="docutils literal"><span class="pre">Translator</span></tt> object and
have attached it to the view helper. If you use the <tt class="docutils literal"><span class="pre">Zend\View\HelperPluginManager</span></tt> to invoke the view helper,
this will be done automatically for you.</p>
<p id="zend-i18n-view-helper-translate-plural-usage"><strong>Basic Usage</strong></p>
<div class="highlight-php"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3
4
5
6
7
8</pre></div></td><td class="code"><div class="highlight"><pre><span class="c1">// Within your view</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">translatePlural</span><span class="p">(</span><span class="s2">&quot;car&quot;</span><span class="p">,</span> <span class="s2">&quot;cars&quot;</span><span class="p">,</span> <span class="nv">$num</span><span class="p">);</span>

<span class="c1">// Use a custom domain</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">translatePlural</span><span class="p">(</span><span class="s2">&quot;monitor&quot;</span><span class="p">,</span> <span class="s2">&quot;monitors&quot;</span><span class="p">,</span> <span class="nv">$num</span><span class="p">,</span> <span class="s2">&quot;customDomain&quot;</span><span class="p">);</span>

<span class="c1">// Change locale</span>
<span class="k">echo</span> <span class="nv">$this</span><span class="o">-&gt;</span><span class="na">translatePlural</span><span class="p">(</span><span class="s2">&quot;locale&quot;</span><span class="p">,</span> <span class="s2">&quot;locales&quot;</span><span class="p">,</span> <span class="nv">$num</span><span class="p">,</span> <span class="s2">&quot;default&quot;</span><span class="p">,</span> <span class="s2">&quot;de_DE&quot;</span><span class="p">);</span>
</pre></div>
</td></tr></table></div>
<dl class="function">
<dt>
<tt class="descname">translatePlural</tt><big>(</big><em>string $singular</em>, <em>string $plural</em>, <em>int $number</em><span class="optional">[</span>, <em>string $textDomain</em><span class="optional">[</span>, <em>string $locale</em><span class="optional">]</span><span class="optional">]</span><big>)</big></dt>
<dd><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>$singular</strong> &#8211; The singular message to be translated.</li>
<li><strong>$plural</strong> &#8211; The plural message to be translated.</li>
<li><strong>$number</strong> &#8211; The number to evaluate and determine which message to use.</li>
<li><strong>$textDomain</strong> &#8211; (Optional) The text domain where this translation lives. Defaults to the value &#8220;default&#8221;.</li>
<li><strong>$locale</strong> &#8211; (Optional) Locale in which the message would be translated (locale name, e.g. en_US). If unset, it will use the default locale (<tt class="docutils literal"><span class="pre">Locale::getDefault()</span></tt>)</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<p id="zend-i18n-view-helper-translate-plural-methods"><strong>Public Methods</strong></p>
<dl class="docutils">
<dt>Public methods for setting a <tt class="docutils literal"><span class="pre">Zend\I18n\Translator\Translator</span></tt> and a default text domain are inherited from</dt>
<dd><a class="reference internal" href="zend.i18n.view.helpers.html#zend-i18n-view-helper-abstract-translator-helper-methods"><em>Zend\I18n\View\Helper\AbstractTranslatorHelper</em></a>.</dd>
</dl>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../index.html">
              <img class="logo" src="../_static/zf2_logo.png" alt="Logo"/>
            </a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li>
        <!--<a href="../_sources/modules/zend.i18n.view.helper.translate.plural.txt"-->
        <a href="https://github.com/zendframework/zf2-documentation/blob/master/docs/languages/en/modules/zend.i18n.view.helper.translate.plural.rst"
           rel="nofollow">Show Source</a></li>
    <li><a href="https://github.com/zendframework/zf2-documentation/edit/master/docs/languages/en/modules/zend.i18n.view.helper.translate.plural.rst"
           rel="nofollow">Edit Source</a>
    </li>
  </ul>
        <p style="font-size: 12px">
            Note: You need to stay logged into your <a href="http://www.github.com">GitHub account</a> to contribute to the documentation.
        </p>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li><a href="../index.html">Zend Framework 2 2.3.0dev documentation</a> &raquo;</li> 
      </ul>
    </div>

    <div class="footer">
        &copy; Copyright 2013, Zend Technologies Ltd..
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2b3.
    </div>
<div id="edit-button">
    <img src="../_static/edit.gif" alt="Edit this document" title="Edit this document" onclick="javascript:$('#editor-trap').toggle();">
</div>
     
<div id="editor-trap">
    <h3>Edit this document</h3>

    <p>
        The source code of this file is hosted on GitHub. Everyone can
        update and fix errors in this document with few clicks -
        no downloads needed.
    <p>

    <ol>

        <li>
            Login with your <a href="http://www.github.com">GitHub</a> account.
        </li>

        <li>
            Go to
            <a href="https://github.com/zendframework/zf2-documentation/edit/master/docs/languages/en/modules/zend.i18n.view.helper.translate.plural.rst">
                TranslatePlural Helper
            </a> on GitHub.
        </li>

        <li>
            Edit file contents using GitHub's text editor in your web browser
        </li>

        <li>
            Fill in the <b>Commit message</b> text box at the end of the page telling <i>why</i>
            you did the changes. Press <b>Propose file change</b> button next to it when done.
        </li>


        <li>
            On <i>Send a pull request</i> page you don't need to fill in text anymore. Just
            press <b>Send pull request</b> button.
        </li>

        <li>
            Your changes are now queued for review under project's <a href="https://github.com/zendframework/zf2-documentation/pulls">Pull requests</a> tab on GitHub.
        </li>
    </ol>

</div>


  </body>
</html>