function test_english() { $choice = new ChoiceFormat(); $string = '[0] none |{n: n % 10 == 1} 1st |{n: n % 10 == 2} 2nd |{n: n % 10 == 3} 3rd |{n:n} th'; $wants = array('none' => array(0), '1st' => array(1, 11, 21), '2nd' => array(2, 12, 22), '3rd' => array(3, 13, 23), 'th' => array(4, 5, 6, 7, 14, 15)); foreach ($wants as $want => $numbers) { foreach ($numbers as $n) { $this->assertEquals($want, $choice->format($string, $n)); } } }
/** * Display the choosen translated string. * Overrides the parent method, also calls parent's renderBody to * translate. */ protected function translateText($text, $subs) { $text = parent::translateText($text, $subs); $choice = new ChoiceFormat(); $value = $this->getValue(); $string = $choice->format($text, $value); if ($string) { return strtr($string, array('{Value}' => $value)); } }