Esempio n. 1
0
 /**
  * Initialize
  *
  * @access  public
  * @return  void
  */
 function initialize($locale)
 {
     $this->initialized = $locale;
     $this->usedLocale = I18Nv2::setLocale($locale);
     $jan = $mon = mktime(1, 1, 1, 1, 1, 1990);
     $feb = $tue = mktime(1, 1, 1, 2, 6, 1990);
     $mar = $wed = mktime(1, 1, 1, 3, 7, 1990);
     $apr = $thu = mktime(1, 1, 1, 4, 5, 1990);
     $may = $fri = mktime(1, 1, 1, 5, 4, 1990);
     $jun = $sat = mktime(1, 1, 1, 6, 2, 1990);
     $jul = $sun = mktime(1, 1, 1, 7, 1, 1990);
     $aug = mktime(1, 1, 1, 8, 1, 1990);
     $sep = mktime(1, 1, 1, 9, 1, 1990);
     $oct = mktime(1, 1, 1, 10, 1, 1990);
     $nov = mktime(1, 1, 1, 11, 1, 1990);
     $dec = mktime(1, 1, 1, 12, 1, 1990);
     if (!$this->loadCache($this->usedLocale)) {
         $this->days = array(strftime('%A', $sun), strftime('%A', $mon), strftime('%A', $tue), strftime('%A', $wed), strftime('%A', $thu), strftime('%A', $fri), strftime('%A', $sat));
         $this->abbrDays = array(strftime('%a', $sun), strftime('%a', $mon), strftime('%a', $tue), strftime('%a', $wed), strftime('%a', $thu), strftime('%a', $fri), strftime('%a', $sat));
         $this->months = array(strftime('%B', $jan), strftime('%B', $feb), strftime('%B', $mar), strftime('%B', $apr), strftime('%B', $may), strftime('%B', $jun), strftime('%B', $jul), strftime('%B', $aug), strftime('%B', $sep), strftime('%B', $oct), strftime('%B', $nov), strftime('%B', $dec));
         $this->abbrMonths = array(strftime('%b', $jan), strftime('%b', $feb), strftime('%b', $mar), strftime('%b', $apr), strftime('%b', $may), strftime('%b', $jun), strftime('%b', $jul), strftime('%b', $aug), strftime('%b', $sep), strftime('%b', $oct), strftime('%b', $nov), strftime('%b', $dec));
         $info = I18Nv2::getInfo();
         /*
          * The currency symbol is old shit on Win2k, though.
          * Some get extended/overwritten with other local conventions.
          */
         $this->currencyFormats = array(I18Nv2_CURRENCY_LOCAL => array($info['currency_symbol'], $info['int_frac_digits'], $info['mon_decimal_point'], $info['mon_thousands_sep'], $info['negative_sign'], $info['positive_sign'], $info['n_cs_precedes'], $info['p_cs_precedes'], $info['n_sep_by_space'], $info['p_sep_by_space'], $info['n_sign_posn'], $info['p_sign_posn']), I18Nv2_CURRENCY_INTERNATIONAL => array($info['int_curr_symbol'], $info['int_frac_digits'], $info['mon_decimal_point'], $info['mon_thousands_sep'], $info['negative_sign'], $info['positive_sign'], $info['n_cs_precedes'], $info['p_cs_precedes'], true, true, $info['n_sign_posn'], $info['p_sign_posn']));
         $this->numberFormats = array(I18Nv2_NUMBER_FLOAT => array($info['frac_digits'], $info['decimal_point'], $info['thousands_sep']), I18Nv2_NUMBER_INTEGER => array('0', $info['decimal_point'], $info['thousands_sep']));
         $this->loadExtension();
         if (!count($this->dateTimeFormats)) {
             $this->dateTimeFormats = array(I18Nv2_DATETIME_SHORT => $this->dateFormats[I18Nv2_DATETIME_SHORT] . ', ' . $this->timeFormats[I18Nv2_DATETIME_SHORT], I18Nv2_DATETIME_MEDIUM => $this->dateFormats[I18Nv2_DATETIME_MEDIUM] . ', ' . $this->timeFormats[I18Nv2_DATETIME_MEDIUM], I18Nv2_DATETIME_DEFAULT => $this->dateFormats[I18Nv2_DATETIME_DEFAULT] . ', ' . $this->timeFormats[I18Nv2_DATETIME_DEFAULT], I18Nv2_DATETIME_LONG => $this->dateFormats[I18Nv2_DATETIME_LONG] . ', ' . $this->timeFormats[I18Nv2_DATETIME_LONG], I18Nv2_DATETIME_FULL => $this->dateFormats[I18Nv2_DATETIME_FULL] . ', ' . $this->timeFormats[I18Nv2_DATETIME_FULL]);
         }
         $this->updateCache($this->usedLocale);
     }
     $this->setDefaults();
     if ($this->paranoid) {
         setlocale(LC_ALL, 'C');
     }
     return $this->usedLocale;
 }
<?php

/**
* Retrieving locale conventions
* =============================
*
* I18Nv2 holds locale conventions returned by localeConv() stored statically, 
* so they are easily accessible through I18Nv2::getInfo(). Have a look at
* the documentation of PHPs localeConv() for all available information.
* 
* $Id: retrieving_locale_conventions.php,v 1.1 2004/05/03 15:02:17 mike Exp $
*/
require_once 'I18Nv2.php';
I18Nv2::setLocale('fr');
$dec_point = I18Nv2::getInfo('decimal_point');
echo "The decimal point for the french locale is '{$dec_point}'.\n";
echo "I18Nv2::getInfo() called without parameter returns all available information:\n";
print_r(I18Nv2::getInfo());