[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/helper/ -> I18NHelper.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the symfony package.
   5   * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
   6   * 
   7   * For the full copyright and license information, please view the LICENSE
   8   * file that was distributed with this source code.
   9   */
  10  
  11  /**
  12   * I18NHelper.
  13   *
  14   * @package    symfony
  15   * @subpackage helper
  16   * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
  17   * @version    SVN: $Id: I18NHelper.php 3056 2006-12-16 16:08:24Z fabien $
  18   */
  19  
  20  function __($text, $args = array(), $catalogue = 'messages')
  21  {
  22    static $i18n;
  23  
  24    if (sfConfig::get('sf_i18n'))
  25    {
  26      if (!isset($i18n))
  27      {
  28        $i18n = sfContext::getInstance()->getI18N();
  29      }
  30  
  31      return $i18n->__($text, $args, $catalogue);
  32    }
  33    else
  34    {
  35      // replace object with strings
  36      foreach ($args as $key => $value)
  37      {
  38        if (is_object($value) && method_exists($value, '__toString'))
  39        {
  40          $args[$key] = $value->__toString();
  41        }
  42      }
  43  
  44      return strtr($text, $args);
  45    }
  46  }
  47  
  48  function format_number_choice($text, $args = array(), $number, $catalogue = 'messages')
  49  {
  50    $translated = __($text, $args, $catalogue);
  51  
  52    $choice = new sfChoiceFormat();
  53  
  54    $retval = $choice->format($translated, $number);
  55  
  56    if ($retval === false)
  57    {
  58      $error = sprintf('Unable to parse your choice "%s"', $translated);
  59      throw new sfException($error);
  60    }
  61  
  62    return $retval;
  63  }
  64  
  65  function format_country($country_iso, $culture = null)
  66  {
  67    $c = new sfCultureInfo($culture === null ? sfContext::getInstance()->getUser()->getCulture() : $culture);
  68    $countries = $c->getCountries();
  69  
  70    return isset($countries[$country_iso]) ? $countries[$country_iso] : '';
  71  }
  72  
  73  function format_language($language_iso, $culture = null)
  74  {
  75    $c = new sfCultureInfo($culture === null ? sfContext::getInstance()->getUser()->getCulture() : $culture);
  76    $languages = $c->getLanguages();
  77  
  78    return isset($languages[$language_iso]) ? $languages[$language_iso] : '';
  79  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7