Here are my thoughts (before this, I did not face, so only thoughts =)):
Translation file:
$messages = array (
'text_hello' => 'Hello, this is text',
'%apple% apple' => array('%apple% apple', '%apple% apples', '%apple% apples')
);
PHP code:
/**
* public function query($index, $placeholders=null, $isPlural=false){ }
**/
$translate = new \Phalcon\Translate\Adapter\NativeArray(array(
"content" => $messages
));
echo $translate->query('%apple% apple', array('apple'=>3), true);
Look at plural of ZF style - https://github.com/zendframework/zf1/blob/master/library/Zend/Translate/Plural.php .
Maybe we must have a function that will set this condition, for example:
$translate = new \Phalcon\Translate\Adapter\NativeArray(array(
"content" => $messages,
"plural" => function($number){
return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2); // this returns plural ID (plural_1, plural_2, etc)
}
));
P.S. Btw, i think that sprintf style of placeholders is better (just example for placeholders, don't think about plural):
echo $translate->query('I have %s apple %d hours ago', 3, 15);