Beispiel #1
0
 /**
  * make new translate
  */
 protected function __construct()
 {
     $options = array('log' => Log::Log(), 'logUntranslated' => false);
     $locale = L10n::getInstance();
     $supported = $locale->getBrowser();
     arsort($supported, SORT_NUMERIC);
     $file = '';
     foreach ($supported as $loc => $val) {
         if (file_exists(LOCALE_PATH . '/' . $loc . '/locale.php')) {
             $file = LOCALE_PATH . '/' . $loc . '/locale.php';
             $locale->setLocale($loc);
             break;
         }
     }
     if ($file == '' && file_exists(LOCALE_PATH . '/en_US/locale.php')) {
         $file = LOCALE_PATH . '/en_US/locale.php';
         $locale->setLocale('en_US');
     }
     if ($file != '') {
         $this->translate = new Zend_Translate(Zend_Translate::AN_ARRAY, $file, $locale->getLanguage(), $options);
         #Log::Log()->debug('locale ' . $locale->getLanguage() . '_' .$locale->getRegion() . ' loaded');
     } else {
         throw new Exception(__METHOD__ . ': no translation files available');
     }
 }
Beispiel #2
0
 function translateSpaceName($space_name)
 {
     global $charset;
     $_this =& L10n::getInstance();
     if (preg_match('/[\\x80-\\xff]./', $space_name)) {
         //Convert To Kanji Pinyin.
         $space_name = preg_replace('/\\s(?=\\s)/', '', $space_name);
         $space_name = iconv($charset, "gb2312", $space_name);
         require LOCALE_PATH . "topinyin.class.php";
         $cn = new ChineseSpell();
         return str_replace(" ", "", $_this->normalize($cn->getFullSpell($space_name)));
     } else {
         return $_this->normalize($space_name);
     }
 }
Beispiel #3
0
 /**
  * make singleton L10n (localization) object (set locale, convert date and
  * number formats)
  */
 public function _initL10n()
 {
     $this->bootstrap('Config');
     $L10n = L10n::getInstance();
 }