Exemplo n.º 1
0
 * Inflector configuration examples.  If your application has custom singular or plural rules, or
 * extra non-ASCII characters to transliterate, you can configure that by uncommenting the lines
 * below.
 */
// Inflector::rules('singular', array('rules' => array('/rata/' => '\1ratus')));
// Inflector::rules('singular', array('irregular' => array('foo' => 'bar')));
//
// Inflector::rules('plural', array('rules' => array('/rata/' => '\1ratum')));
// Inflector::rules('plural', array('irregular' => array('bar' => 'foo')));
//
// Inflector::rules('transliteration', array('/É|Ê/' => 'E'));
//
// Inflector::rules('uninflected', 'bord');
// Inflector::rules('uninflected', array('bord', 'baird'));
/**
 * Integration with `View`. Embeds message translation short-hands into the `View`
 * class (or other content handler, if specified) when content is rendered. This
 * enables short-hand translation functions, i.e. `<?=$t("Translated content"); ?>`.
 */
Media::applyFilter('_handle', function ($self, $params, $chain) {
    $params['handler'] += array('outputFilters' => array());
    $params['handler']['outputFilters'] += Message::shortHands();
    return $chain->next($self, $params, $chain);
});
/**
 * Integration with `Validator`. You can load locale dependent rules into the `Validator`
 * by specifying them manually or retrieving them with the `Catalog` class.
 */
Validator::add('phone', Catalog::read('validation.phone', 'en_US'));
Validator::add('postalCode', Catalog::read('validation.postalCode', 'en_US'));
Validator::add('ssn', Catalog::read('validation.ssn', 'en_US'));
Exemplo n.º 2
0
 public function testShortHandsAsymmetry()
 {
     $filters = Message::shortHands();
     $t = $filters['t'];
     $tn = $filters['tn'];
     $expected = Message::translate('house', array('locale' => 'de'));
     $result = $t('house', array('locale' => 'de'));
     $this->assertNotEqual($expected, $result);
     $expected = Message::translate('house', array('locale' => 'de', 'count' => 3));
     $result = $tn('house', 'houses', array('locale' => 'de'));
     $this->assertNotEqual($expected, $result);
 }