Exemple #1
0
 /**
  * This one gets called automatically
  *
  * @ignore
  * @static
  * @internal
  * @access  private
  * @return  void
  */
 function _main()
 {
     // initialize the locale stack
     $last =& I18Nv2::getStaticProperty('last');
     $last = array();
     // map of "fully qualified locale" codes
     $locales =& I18Nv2::getStaticProperty('locales');
     $locales = array('af' => 'af_ZA', 'de' => 'de_DE', 'en' => 'en_US', 'fr' => 'fr_FR', 'it' => 'it_IT', 'es' => 'es_ES', 'pt' => 'pt_PT', 'sv' => 'sv_SE', 'nb' => 'nb_NO', 'nn' => 'nn_NO', 'no' => 'no_NO', 'fi' => 'fi_FI', 'is' => 'is_IS', 'da' => 'da_DK', 'nl' => 'nl_NL', 'pl' => 'pl_PL', 'sl' => 'sl_SI', 'hu' => 'hu_HU', 'ru' => 'ru_RU', 'cs' => 'cs_CZ');
     // define locale fallbacks
     $fallbacks =& I18Nv2::getStaticProperty('fallbacks');
     $fallbacks = array('no_NO' => 'nb_NO', 'nb_NO' => 'no_NO');
     // include Win32 locale codes
     if (I18Nv2_WIN) {
         include_once 'I18Nv2/Locale/Windows.php';
     }
 }
Exemple #2
0
 public static function tryLocale($locale)
 {
     if (!is_array($locale)) {
         $locale = (array) $locale;
     }
     //Try each Locale in array to see which one works.
     if (OPERATING_SYSTEM == 'LINUX') {
         //setLocale supports passing it an array, so thats easy.
         $valid_locale = setlocale(LC_ALL, $locale);
     } else {
         //Add caching here if we find this loop is too slow.
         self::getLocaleHandler();
         //Include I18Nv2 files.
         $windows_locales = I18Nv2::getStaticProperty('windows');
         $valid_locale = 'en_US';
         foreach ($locale as $tmp_locale) {
             //This is setting the locale
             //Match the windows locales directly, because if we use self::getLocaleHandler()->setLocale( $tmp_locale, 'LC_ALL'); instead
             //it will actually change the locale out from under us causing strange problems, and also circumventing the locale cache
             //in setLocale() (that prevents changing to the same locale we are already in)
             //
             //On windows sometimes its using 127 digits after the decimal because after setLocale() is called, localeconv() returns
             //an array that is basically empty or uses 127 for everything.
             //This is fixed in Pear::I18Nv2->setLocale(), so it defaults to english values if it fails.
             if (isset($windows_locales[$tmp_locale])) {
                 Debug::Text('Found valid windows locale: ' . $windows_locales[$tmp_locale] . ' Linux locale: ' . $tmp_locale, __FILE__, __LINE__, __METHOD__, 10);
                 $valid_locale = $tmp_locale;
                 break;
             }
             /*
             $windows_locale = self::getLocaleHandler()->setLocale( $tmp_locale, 'LC_ALL');
             if ( $windows_locale !== FALSE ) {
             	Debug::Text('Found valid windows locale: '. $windows_locale .' Linux locale: '. $tmp_locale,  __FILE__, __LINE__, __METHOD__,10);
             	//Returning $windows_locale appears to fix issues with some systems, but then it causes problems with language selection since its a long locale name that doens't match pt_PT for example.
             	$valid_locale = $tmp_locale;
             	break;
             }
             */
         }
     }
     if ($valid_locale != '') {
         Debug::Text('Found valid locale: ' . $valid_locale, __FILE__, __LINE__, __METHOD__, 10);
         return $valid_locale;
     }
     Debug::Text('FAILED TRYING LOCALE: ' . self::getLocaleArrayAsString($locale), __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
<?php

/**
* $Id: Windows.php,v 1.4 2004/06/01 17:55:04 mike Exp $
*/
$windows =& I18Nv2::getStaticProperty('windows');
$windows = array('de_DE' => 'deu', 'de_AT' => 'dea', 'de_CH' => 'des', 'en_US' => 'enu', 'en_GB' => 'eng', 'en_AU' => 'ena', 'en_BZ' => 'enb', 'en_CA' => 'enc', 'en_IE' => 'eni', 'en_JM' => 'enj', 'en_PH' => 'enp', 'en_ZA' => 'ens', 'en_NZ' => 'enz', 'fr_FR' => 'fra', 'fr_CH' => 'frs', 'fr_BE' => 'frb', 'fr_CA' => 'frc', 'fr_LU' => 'frl', 'fr_MC' => 'frm', 'it_IT' => 'ita', 'it_CH' => 'its', 'es_ES' => 'esp', 'es_PA' => 'esa', 'es_BO' => 'esb', 'es_DO' => 'esd', 'es_SV' => 'ese', 'es_EC' => 'esf', 'es_GT' => 'esg', 'es_HN' => 'esh', 'es_NI' => 'esi', 'es_CL' => 'esl', 'es_MX' => 'esm', 'es_CO' => 'eso', 'es_PE' => 'esr', 'es_AR' => 'ess', 'es_VE' => 'esv', 'es_UY' => 'esy', 'es_PY' => 'esz', 'pt_PT' => 'ptg', 'pt_BR' => 'ptb', 'sv_SE' => 'sve', 'sv_FI' => 'svf', 'no_NO' => 'nor', 'nb_NO' => 'nor', 'nn_NO' => 'non', 'fi_FI' => 'fin', 'is_IS' => 'isl', 'da_DK' => 'dan', 'nl_NL' => 'nld', 'nl_BE' => 'nlb', 'ru_RU' => 'rus', 'hu_HU' => 'hun', 'ru_RU' => 'rus', 'af_ZA' => 'afk', 'sl_SI' => 'slv', 'pl_PL' => 'plk', 'cs_CZ' => 'csy');