aliases() public static method

They can be embedded as content filters in the template layer using a filter for Media::_handle() or be used in other places where needed. Usage: $t('bike'); $tn('bike', 'bikes', 3); Using in a method: public function index() { extract(Message::aliases()); $notice = $t('look'); }
See also: lithium\net\http\Media::_handle()
public static aliases ( ) : array
return array Named aliases (`'t'` and `'tn'`) for translation functions.
Example #1
0
 /**
  * Renders view element
  * @return object
  */
 protected function renderView()
 {
     if (!isset($this->_view)) {
         $this->_view = new View(array('paths' => array('element' => '{:library}/views/elements/{:template}.{:type}.php'), 'outputFilters' => Message::aliases()));
     }
     return $this->_view;
 }
Example #2
0
 /**
  * Perform initialization.
  *
  * @return void
  */
 protected function _init()
 {
     Object::_init();
     extract(Message::aliases());
     $type = isset($this->_config['type']) ? $this->_config['type'] : null;
     if ($type === 'text') {
         $h = function ($data) {
             return $data;
         };
     } else {
         $encoding = 'UTF-8';
         if ($this->_message) {
             $encoding =& $this->_message->charset;
         }
         $h = function ($data) use(&$encoding) {
             return htmlspecialchars((string) $data, ENT_QUOTES, $encoding);
         };
     }
     $this->outputFilters += compact('h', 't') + $this->_config['outputFilters'];
     foreach (array('loader', 'renderer') as $key) {
         if (is_object($this->_config[$key])) {
             $this->{'_' . $key} = $this->_config[$key];
             continue;
         }
         $class = $this->_config[$key];
         $config = array('view' => $this) + $this->_config;
         $path = 'adapter.template.mail';
         $instance = Libraries::instance($path, $class, $config);
         $this->{'_' . $key} = $instance;
     }
 }
Example #3
0
//
// 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 aliases into the `View`
 * class (or other content handler, if specified) when content is rendered. This
 * enables translation functions, i.e. `<?=$t("Translated content"); ?>`.
 */
Media::applyFilter('_handle', function ($self, $params, $chain) {
    $params['handler'] += array('outputFilters' => array());
    $params['handler']['outputFilters'] += Message::aliases();
    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.
 */
foreach (array('phone', 'postalCode', 'ssn') as $name) {
    Validator::add($name, Catalog::read(true, "validation.{$name}", 'en_US'));
}
/**
 * Intercepts dispatching processes in order to set the effective locale by using
 * the locale of the request or if that is not available retrieving a locale preferred
 * by the client.
 */
ActionDispatcher::applyFilter('_callable', function ($self, $params, $chain) {
Example #4
0
<?php

use lithium\g11n\Message;
extract(Message::aliases());
?>
<h3><?php 
echo $t('Welcome');
?>
 <?php 
echo $compact['data']['email'];
?>
,</h3>
<h4><?php 
echo $t('This email communication is CONFIDENTIAL. All the information given in the document is financial sensitive.');
?>
</h4>


<p><?php 
echo $t('You have today created your own XGC wallet. This is the second confidential email you are receiving regarding your new account.');
?>
</p>

<p><?php 
echo $t('Enclosed is a PDF document which contains a password recovery, public and private keys of XGC in PDF document.');
?>
</p>

<h4><?php 
echo $t('Print the PDF document and keep it in a safe place.');
?>
Example #5
0
 public function testAliasesAsymmetry()
 {
     $filters = Message::aliases();
     $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);
 }