public static function getLocaleHandler() { if (self::$locale_handler === NULL) { require_once 'I18Nv2.php'; // If first param is not NULL, (eg 'en_US') then I18n throws php notices on debian/ubuntu. //Set second param (paranoid) to TRUE so it doesn't break FPDF/TCPDF self::$locale_handler =& I18Nv2::createLocale(NULL, TRUE); } return self::$locale_handler; }
/** * Method to return the default language * @access public * @return default site language */ public function currentLanguage() { try { $this->objConfig = $this->getObject('altconfig', 'config'); $ab = strtolower($this->objConfig->getdefaultLanguageAbbrev()); $country = $this->objConfig->getCountry(); $country = $ab . "_" . $country . ".1252"; if (isset($_POST['Languages'])) { $_SESSION["language"] = $_POST['Languages']; $var = $_POST['Languages']; @($this->locale =& I18Nv2::createLocale("{$country}")); $this->lang->setLang("{$var}"); } else { if (isset($_SESSION["language"])) { $var = strtolower($_SESSION["language"]); $country = $this->objConfig->getCountry(); $country = $var . "_" . $country . ".1252"; @($this->locale =& I18Nv2::createLocale("{$country}")); $this->lang->setLang("{$var}"); } else { $var = strtolower($this->objConfig->getdefaultLanguageAbbrev()); $this->lang->setLang("{$var}"); } } return $var; } catch (Exception $e) { $this->errorCallback($this->languageText('word_caught_exception') . $e->getMessage()); exit; } }
<?php /** * Using I18Nv2_Locale * =================== * * I18Nv2_Locale is a formatter object that provides functionality to format * dates, times, numbers and currencies in locale dependent conventions. * * $Id: using_I18Nv2_Locale.php,v 1.2 2005/01/05 09:26:18 mike Exp $ */ require_once 'I18Nv2.php'; $locale =& I18Nv2::createLocale('de_AT'); echo "de_AT\n=====\n"; echo "Format a currency value of 2000: ", $locale->formatCurrency(2000, I18Nv2_CURRENCY_INTERNATIONAL), "\n"; echo "Format todays date: ", $locale->formatDate(null, I18Nv2_DATETIME_FULL), "\n"; echo "Format current time: ", $locale->formatTime(null, I18Nv2_DATETIME_SHORT), "\n"; $locale->setLocale('en_GB'); echo "\nen_GB\n=====\n"; echo "Format a currency value of 2000: ", $locale->formatCurrency(2000, I18Nv2_CURRENCY_INTERNATIONAL), "\n"; echo "Format todays date: ", $locale->formatDate(null, I18Nv2_DATETIME_FULL), "\n"; echo "Format current time: ", $locale->formatTime(null, I18Nv2_DATETIME_SHORT), "\n";