As traditional plural translations are restricted to source code using English plurals
we added a new way for plural translations. It allows to use the same
translate() for standard and for plural translations.
To use plural translations with translate() you need to give
an array as messageId instead of an string. This array must have the original plural
messageId's, then the amount and at last an optional locale when your given messageId's
are not in English notation.
Example 962. Example of modern plural translations
When we want to translate the same plural definitions like in the previous our example would have to be defined like below.
<?php
$translate = new Zend_Translate(
array(
'adapter' => 'gettext',
'content' => '/path/to/german.mo',
'locale' => 'de'
)
);
$translate->translate(array('Car', 'Cars', $number));
Using modern plural translations it is also possible to use any language as source for messageId's.
Example 963. Example of modern plural translations using a different source language
Let's expect we want to use Russian and let's also expect that the given messageId's are Russian and not English.
<?php
$translate = new Zend_Translate(
array(
'adapter' => 'gettext',
'content' => '/path/to/german.mo',
'locale' => 'de'
)
);
$translate->translate(
array(
'Car',
'Cars first plural',
'Cars second plural',
$number,
'ru'
)
);
As you can see you can give more than just the one English plural. But you must give
the source language in this case so Zend_Translate knows which
plural rules it has to apply.
When you omit the plural language then English will be used per default and any additional plural definition will be ignored.




