當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Translate::getMessages方法代碼示例

本文整理匯總了PHP中Zend_Translate::getMessages方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Translate::getMessages方法的具體用法?PHP Zend_Translate::getMessages怎麽用?PHP Zend_Translate::getMessages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Translate的用法示例。


在下文中一共展示了Zend_Translate::getMessages方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _getGettextFileData

 /**
  * get translation with Zend_Translate_Adapter_Gettext
  *
  * @see Zend_Translate_Adapter_Gettext
  * @param string $file
  * @return array
  */
 protected function _getGettextFileData($file)
 {
     $data = array();
     if (file_exists($file)) {
         $gettextTranslator = new Zend_Translate(array('adapter' => 'Zend_Translate_Adapter_Gettext', 'content' => $file));
         $data = $gettextTranslator->getMessages();
     }
     return $data;
 }
開發者ID:hhirsch,項目名稱:LocaleFallback,代碼行數:16,代碼來源:Translate.php

示例2: getJsTranslation

 public function getJsTranslation()
 {
     if (!$this->_jstranslation) {
         try {
             $locale = Mage::app()->getLocale()->getLocaleCode();
             $translator = new Zend_Translate(array('adapter' => 'csv', 'content' => Mage::getBaseDir('locale') . '/' . $locale . '/' . 'Mirasvit_Helpdesk.csv', 'locale' => substr($locale, 0, 2), 'delimiter' => ','));
             $this->_jstranslation = json_encode($translator->getMessages());
         } catch (Exception $e) {
             // If we had unexpected exception (non-standard locale, for example), return empty
             return array();
         }
     }
     return $this->_jstranslation;
 }
開發者ID:cesarfelip3,項目名稱:clevermage_new,代碼行數:14,代碼來源:Mirasvit_Helpdesk_Helper_Data.php

示例3: testGettingAllMessages

 /**
  * Tests getting of all messages
  */
 public function testGettingAllMessages()
 {
     $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1', 'msg2' => 'Message 2'), 'en');
     $lang->addTranslation(array('msg1' => 'Message 1 (ru)'), 'ru');
     $this->assertEquals(array('msg1' => 'Message 1 (ru)'), $lang->getMessages());
     $this->assertEquals(array('msg1' => 'Message 1', 'msg2' => 'Message 2'), $lang->getMessages('en'));
     $this->assertEquals(array('en' => array('msg1' => 'Message 1', 'msg2' => 'Message 2'), 'ru' => array('msg1' => 'Message 1 (ru)')), $lang->getMessages('all'));
 }
開發者ID:sasezaki,項目名稱:mirror-zf1-tests,代碼行數:11,代碼來源:TranslateTest.php

示例4: _loadTranslations

 /** Try to load current translations */
 protected function _loadTranslations($locale, $module, $adapter)
 {
     $profile = $this->_getProfile();
     $path = $this->_getLocalesPath($locale, $module);
     $content = $path . '/' . $module . '.' . $this->_adapters[$adapter];
     try {
         $translate = new Zend_Translate(array('adapter' => $adapter, 'content' => $content, 'locale' => $locale, 'disableNotices' => true));
     } catch (Exception $e) {
         if (!file_exists($content)) {
             return array();
             // The file will be created later
         }
         throw $e;
         // File exists, but consist from unkown format
     }
     // Translation file can be empty, thus this check
     if ($messageIds = $translate->getMessageIds()) {
         return array_combine($messageIds, $translate->getMessages());
     }
     return array();
 }
開發者ID:kblomqvist,項目名稱:kblom-zf1,代碼行數:22,代碼來源:Locale.php

示例5: array

}
// Timezone
date_default_timezone_set($conf->general->timezone);
$locale = $conf->general->locale;
if (!file_exists(APPLICATION_DIRECTORY . "/Joobsbox/Languages/{$locale}")) {
    $locale = "en";
}
try {
    // Translation
    $translate = new Zend_Translate('gettext', APPLICATION_DIRECTORY . '/Joobsbox/Languages/' . $locale . '/LC_MESSAGES/main.mo', $locale, array('disableNotices' => true));
    Zend_Registry::set("Zend_Locale", new Zend_Locale($locale));
} catch (Exception $e) {
    Zend_Registry::set("Zend_Locale", new Zend_Locale("en"));
    $translate = new Zend_Translate('gettext', APPLICATION_DIRECTORY . '/Joobsbox/Languages/en/LC_MESSAGES/main.mo', 'en');
}
Zend_Registry::set("Translation_Hash", $translate->getMessages());
Zend_Registry::set('Zend_Translate', $translate);
// Database parameters
if (file_exists(APPLICATION_DIRECTORY . '/config/db.xml')) {
    try {
        $dbconf = new Zend_Config_Xml(APPLICATION_DIRECTORY . '/config/db.xml', 'zend_db');
        $db = Zend_Db::factory($dbconf->dbadapter, $dbconf);
        Zend_Db_Table_Abstract::setDefaultAdapter($db);
        Zend_Registry::set("db", $db);
        if (strlen($dbconf->start)) {
            $db->query($dbconf->start);
        }
    } catch (Exception $e) {
        @rename(APPLICATION_DIRECTORY . "/config/db.xml", APPLICATION_DIRECTORY . "/config/db.xml.bak");
        throw $e;
        exit;
開發者ID:ntulip,項目名稱:joobsbox-php,代碼行數:31,代碼來源:config.php

示例6: mergeTranslationFile

 /**
  * Reads a translation file (gettext) and merges it to the messages array
  *
  * @param string $file
  * @param array $messages
  */
 private function mergeTranslationFile($file, &$messages)
 {
     if (file_exists($file)) {
         $translate = new Zend_Translate('gettext', $file, $this->locale);
         $new_messages = $translate->getMessages();
         if (is_array($new_messages)) {
             $messages = array_merge($messages, $new_messages);
         }
     }
 }
開發者ID:eliudiaz,項目名稱:p4a,代碼行數:16,代碼來源:p4a_i18n.php


注:本文中的Zend_Translate::getMessages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。