PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Traditional plural translations

People who worked with gettext in past will be more common with traditional plural translations. There is a own plural() method which can be used for plural translations.

Example 980. Example of traditional plural translations

The plural() method accepts 4 parameters. The first parameter is the singular messageId, the second is the plural messageId and the third is the number or amount.

The number will be used to detect the plural which has to be returned. A optional fourth parameter can be used to give a locale which will be used to return the translation.

<?php
$translate 
= new Zend_Translate(
    array(
        
'adapter' => 'gettext',
        
'content' => '/path/to/german.mo',
        
'locale'  => 'de'
    
)
);
$translate->plural('Car''Cars'$number);

Zend Framework