当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Validate_Abstract::setDefaultTranslator方法代码示例

本文整理汇总了PHP中Zend_Validate_Abstract::setDefaultTranslator方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Validate_Abstract::setDefaultTranslator方法的具体用法?PHP Zend_Validate_Abstract::setDefaultTranslator怎么用?PHP Zend_Validate_Abstract::setDefaultTranslator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Validate_Abstract的用法示例。


在下文中一共展示了Zend_Validate_Abstract::setDefaultTranslator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _initLanguage

 protected function _initLanguage()
 {
     $locale = new Zend_Locale('de_AT');
     $translator = new Zend_Translate('array', APPLICATION_PATH . '/../resources/languages', 'de', array('scan' => Zend_Translate::LOCALE_DIRECTORY));
     Zend_Validate_Abstract::setDefaultTranslator($translator);
     Zend_Locale::setDefault($locale);
 }
开发者ID:ThalerR,项目名称:GEBL,代码行数:7,代码来源:Bootstrap.php

示例2: startLocale

 protected function startLocale()
 {
     require_once "Zend/Translate.php";
     // silenciando strict até arrumar zend_locale
     date_default_timezone_set("America/Sao_Paulo");
     $i18n = new Zend_Translate('gettext', $this->config->system->path->base . '/lang/pt_BR.mo', 'pt_BR');
     Zend_Registry::set('i18n', $i18n);
     $translation_files = $this->config->system->path->base . "/lang/";
     foreach (scandir($translation_files) as $filename) {
         // Todos os arquivos .php devem ser classes de descrição de modulos
         if (preg_match("/.*\\.mo\$/", $filename)) {
             $translation_id = basename($filename, '.mo');
             if ($translation_id != "pt_BR") {
                 $i18n->addTranslation($translation_files . "/{$filename}", $translation_id);
             }
         }
     }
     require_once "Zend/Locale.php";
     if (Zend_Locale::isLocale($this->config->system->locale)) {
         $locale = $this->config->system->locale;
     } else {
         $locale = "pt_BR";
     }
     Zend_Registry::set('Zend_Locale', new Zend_Locale($locale));
     Zend_Locale::setDefault($locale);
     Zend_Locale_Format::setOptions(array("locale" => $locale));
     $i18n->setLocale($locale);
     Zend_Registry::set("Zend_Translate", $i18n);
     $zend_validate_translator = new Zend_Translate_Adapter_Array($this->config->system->path->base . "/lang/Zend_Validate/{$locale}/Zend_Validate.php", $locale);
     Zend_Validate_Abstract::setDefaultTranslator($zend_validate_translator);
 }
开发者ID:rootzig,项目名称:SNEP,代码行数:31,代码来源:Bootstrap.php

示例3: _initTraslator

 protected function _initTraslator()
 {
     $siteOptions = $this->getOption('site');
     $translator = new Zend_Translate('array', APPLICATION_PATH . DIRECTORY_SEPARATOR . 'languages', $siteOptions['default']['language'], array('scan' => Zend_Translate::LOCALE_DIRECTORY));
     Zend_Validate_Abstract::setDefaultTranslator($translator);
     return $translator;
 }
开发者ID:romikring,项目名称:rcalex,代码行数:7,代码来源:Bootstrap.php

示例4: _initValidateMessages

 protected function _initValidateMessages()
 {
     if (!$this->hasPluginResource('message')) {
         return;
     }
     $this->bootstrap('message');
     Zend_Validate_Abstract::setDefaultTranslator($this->getResource('message'));
 }
开发者ID:sgdoc,项目名称:sgdoce-codigo,代码行数:8,代码来源:Bootstrap.php

示例5: _initTranslate

 public function _initTranslate()
 {
     try {
         $translate = new Zend_Translate('Array', APPLICATION_PATH . '/languages/es/Zend_Validate.php', 'pt_BR');
         Zend_Validate_Abstract::setDefaultTranslator($translate);
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
开发者ID:conectapb,项目名称:sysagroweb,代码行数:9,代码来源:Bootstrap.php

示例6: routeShutdown

 /**	@brief Changement de langue.
  * 
  * Exploitation du cache de l'application pour stocker l'instance de Zend_Translate correspondant.
  * Si le cache n'est pas présent, une nouvelle instance est créée, puis stockée dans le cache de Zend_Translate.
  * 
  * @see		Controller/Plugin/Zend_Controller_Plugin_Abstract::routeShutdown()
  * @throws	exception Projet_Exception en cas d'erreur au cours de la requête.
  * @return	void.
  */
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     parent::routeShutdown($request);
     // Récupération du paramètre de langue passée dans l'URL
     $sLocal = $this->getRequest()->getParam('language') ? $this->getRequest()->getParam('language') : self::DEFAULT_LANGUAGE;
     // Récupération du local dans une combinaison du type "fr_FR"
     $aLanguage = explode("_", $sLocal);
     $sLanguage = isset($aLanguage[0]) ? $aLanguage[0] : self::DEFAULT_LANGUAGE;
     # Récupération de "fr"
     $sCountry = isset($aLanguage[1]) ? $aLanguage[1] : self::DEFAULT_COUNTRY;
     # Récupération de "FR"
     // Fonctionnalité réalisée si le fichier de langue n'existe pas
     if (!file_exists(LANGUAGE_PATH . $sLanguage . '.ini')) {
         $sLanguage = self::DEFAULT_LANGUAGE;
     }
     // Récupération du cache de la langue en cours dans le cache de Zend_Translate
     if ((bool) APP_CACHE) {
         $oCacheTranslate = Zend_Translate::getCache();
         $oTranslate = $oCacheTranslate->load($sLanguage);
     } else {
         $oTranslate = null;
     }
     // Fonctionnalité réalisé si
     if (empty($oTranslate)) {
         // Initialisation de la langue
         try {
             // Chargement du Zend_Translate
             $oTranslate = new Zend_Translate(array('adapter' => 'ini', 'content' => LANGUAGE_PATH . $sLanguage . '.ini', 'locale' => $sLocal));
             $sFichier = LANGUAGE_PATH . $sLanguage . '.php';
             if (file_exists($sFichier)) {
                 //traduction des erreurs de formulaires
                 $oTranslate->addTranslation(array('content' => new Zend_Translate('array', $sFichier, $sLanguage)));
             }
             if ((bool) APP_CACHE) {
                 // Enregistrement de la langue dans le cache
                 $oCacheTranslate = Zend_Translate::getCache();
                 $oCacheTranslate->save($oTranslate, $sLanguage);
             }
         } catch (Exception $e) {
             if ((bool) APP_CACHE) {
                 // Suppression du cache
                 $oCacheTranslate->remove($sLanguage);
             }
             // Création d'une exception au niveau du projet
             die($e->getMessage());
             throw new Projet_Exception($e->getMessage(), __METHOD__, $e);
         }
     }
     // Enregistrement du Zend_Translate dans les fonctionnalités de l'application
     Zend_Registry::set("Zend_Locale", $sLocal);
     Zend_Registry::set("Zend_Translate", $oTranslate);
     // Potentiellement inutile vu la ligne précédente...
     Zend_Form::setDefaultTranslator($oTranslate);
     Zend_Validate_Abstract::setDefaultTranslator($oTranslate);
     // Language par défaut pour toutes les routes
     Zend_Controller_Front::getInstance()->getRouter()->setGlobalParam('language', $sLocal);
 }
开发者ID:netixx,项目名称:Stock,代码行数:66,代码来源:Translate.php

示例7: _initTranslation

 protected function _initTranslation()
 {
     $bootstrap = $this->getApplication();
     $bootstrap->bootstrap('translate');
     $translator = $bootstrap->getResource('translate');
     if (method_exists($this, 'connect')) {
         $translator->connect();
     }
     Zend_Validate_Abstract::setDefaultTranslator($translator);
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:10,代码来源:Bootstrap.php

示例8: _initLocale

 protected function _initLocale()
 {
     Zend_Loader::loadClass('Zend_Locale');
     Zend_Locale::setDefault('fr');
     $session = new Zend_Session_Namespace();
     $session->locale = !empty($session->locale) ? $session->locale : DEFAULT_LOCALE;
     $translator = new Zend_Translate(array('adapter' => 'array', 'content' => APPLICATION_PATH . '/languages/' . $session->locale . '.php', 'locale' => $session->locale));
     Zend_Validate_Abstract::setDefaultTranslator($translator);
     Zend_Form::setDefaultTranslator($translator);
     Zend_Validate::setDefaultTranslator($translator);
     Zend_Registry::set("Zend_Translate", $translator);
 }
开发者ID:esandre,项目名称:CoeurDeTruffes,代码行数:12,代码来源:Bootstrap.php

示例9: init

 /**
  * Defined by Zend_Application_Resource_Resource
  *
  * @return Zend_View
  */
 public function init()
 {
     // locale Options
     $language = null;
     if (Zend_Registry::isRegistered("Zend_Locale")) {
         $locale = Zend_Registry::get("Zend_Locale");
         $language = $locale->getLanguage() . "_" . $locale->getRegion();
     }
     $options = $this->getOptions();
     if (!is_null($language) and isset($options["translate"])) {
         $options["translate"]["locale"] = $language;
         $translator = new Zend_Translate($options["translate"]);
         Zend_Validate_Abstract::setDefaultTranslator($translator);
     }
     Zend_Validate::addDefaultNamespaces('ZLayer_Validate');
 }
开发者ID:BGCX261,项目名称:zlayer-svn-to-git,代码行数:21,代码来源:Validate.php

示例10: preDispatch

 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     parent::preDispatch($request);
     $Zrt = new Zend_Session_Namespace('Zrt');
     if (!isset($Zrt->config->lang)) {
         $zl = new Zend_Locale();
         $Zrt->config->lang = $zl->getLanguage();
     }
     if ($Zrt->config->lang !== 'en' && $Zrt->config->lang !== 'de' && $Zrt->config->lang !== 'es' && $Zrt->config->lang !== 'pl') {
         $Zrt->config->lang = 'en';
     }
     if (!isset($Zrt->config->idlang)) {
         $_idioma = new Zrt_Models_Bussines_Idioma();
         $Zrt->config->idlang = $_idioma->getByPrefijo($Zrt->config->lang)->id;
     }
     $translate = new Zend_Translate(Zend_Translate::AN_GETTEXT, APPLICATION_PATH . '/configs/locale/', $Zrt->config->lang, array('scan' => Zend_Translate::LOCALE_FILENAME), $Zrt->config->lang);
     Zend_Registry::set('Zend_Translate', $translate);
     /* translate para Zend_Validate */
     $translator = new Zend_Translate(Zend_Translate::AN_ARRAY, APPLICATION_PATH . '/configs/resources/languages/', $Zrt->config->lang, array('scan' => Zend_Translate::LOCALE_DIRECTORY));
     Zend_Validate_Abstract::setDefaultTranslator($translator);
     /*         * variables para la vista* */
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
     if (null === $viewRenderer->view) {
         $viewRenderer->initView();
     }
     $view = $viewRenderer->view;
     $view->assign('sessionZrt', $Zrt);
     /*         * variables para la vista* */
     /* translate para Zend_Validate */
     /* formulario idioma */
     /* fixme formulario idiomapais */
     //        $data = array( );
     //        if ( isset( $Zrt->config->lang ) )
     //            {
     //            if ( isset( $Zrt->config->idlang ) )
     //                {
     //                $data['idioma'] = $Zrt->config->idlang;
     //                }
     //            if ( isset( $Zrt->config->idpais ) )
     //                {
     //                $data['pais'] = $Zrt->config->idpais;
     //                }
     //            }
     /**/
     /* formulario idioma */
 }
开发者ID:josmel,项目名称:adminwap,代码行数:46,代码来源:LangSelector.php

示例11: _initDoctype

 protected function _initDoctype()
 {
     $this->bootstrap('view');
     $view = $this->getResource('view');
     $view->doctype('XHTML1_STRICT');
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
     Zend_Registry::set('config', $config);
     $db = Zend_Db::factory($config->resources->db);
     Zend_Registry::set('db', $db);
     $locale = new Zend_Locale($config->resources->locale->default);
     $translate = new Zend_Translate('array', APPLICATION_PATH . '/../data/locales/' . $locale->getLanguage($config->resources->locale->default) . '.php', $config->resources->locale->default, array('disableNotices' => TRUE));
     $languages = array('en' => 'en_US');
     Zend_Validate_Abstract::setDefaultTranslator($translate);
     Zend_Registry::set('db', $db);
     Zend_Registry::set('languages', $languages);
     Zend_Registry::set('Zend_Translate', $translate);
     Zend_Registry::set('Zend_Locale', $locale);
 }
开发者ID:ankuradhey,项目名称:laundry,代码行数:18,代码来源:Bootstrap.php

示例12: _initTranslate

 /**
  * Referência:
  * http://www.codeforest.net/multilanguage-support-in-zend-framework
  */
 protected function _initTranslate()
 {
     $locale = new Zend_Locale();
     if (!Zend_Locale::isLocale($locale, TRUE, FALSE)) {
         if (!Zend_Locale::isLocale($locale, FALSE, FALSE)) {
             throw new Zend_Locale_Exception("The locale '{$locale}' is no known locale");
         }
         $locale = new Zend_Locale($locale);
     }
     //$locale = "pt_BR";
     $translatorArray = new Zend_Translate(array('adapter' => 'array', 'content' => APPLICATION_PATH . '/../resources/languages', 'locale' => $locale, 'scan' => Zend_Translate::LOCALE_DIRECTORY));
     $translate = new Zend_Translate('gettext', APPLICATION_PATH . "/langs/", $locale, array('scan' => Zend_Translate::LOCALE_DIRECTORY));
     $translate->addTranslation($translatorArray);
     $registry = Zend_Registry::getInstance();
     $registry->set('Zend_Translate', $translate);
     Zend_Validate_Abstract::setDefaultTranslator($translate);
     Zend_Form::setDefaultTranslator($translate);
 }
开发者ID:jovanepires,项目名称:sige,代码行数:22,代码来源:Bootstrap.php

示例13: _initValidatorTranslation

    protected function _initValidatorTranslation()
    {
        // traduction des messages d'erreur de validation
        $french = array(
	        'notAlnum' => "'%value%' ne contient pas que des lettres et/ou des chiffres.",
	        'notAlpha' => "'%value%' ne contient pas que des lettres.",
	        'notBetween' => "'%value%' n'est pas compris entre %min% et %max% inclus.",
	        'notBetweenStrict' => "'%value%' n'est pas compris entre %min% et %max% exclus.",
			'notSame' 	=> "Les deux champs ne correspondent pas.",
	        'dateNotYYYY-MM-DD'=> "'%value%' n'est pas une date au format AAAA-MM-JJ (exemple : 2000-12-31).",
	        'dateInvalid' => "'%value%' n'est pas une date valide.",
	        'dateFalseFormat' => "'%value%' n'est pas une date valide au format JJ/MM/AAAA (exemple : 31/12/2000).",
	        'notDigits' => "'%value%' ne contient pas que des chiffres.",
	        'emailAddressInvalid' => "'%value%' n'est pas une adresse mail valide au format adresse@domaine.",
	        'emailAddressInvalidFormat' => "'%value%' n'est pas une adresse mail valide au format adresse@domaine.tld",
	        'emailAddressInvalidHostname' => "'%hostname%' n'est pas un nom d'hôte DNS valide.",
	        'emailAddressInvalidMxRecord' => "'%hostname%' n'accepte pas l'adresse mail '%value%'.",
	        'emailAddressDotAtom' => "'%localPart%' ne respecte pas le format dot-atom.",
	        'emailAddressQuotedString' => "'%localPart%' ne respecte pas le format quoted-string.",
	        'emailAddressInvalidLocalPart' => "'%localPart%' n'est pas une adresse individuelle valide.",
	        'notFloat' => "'%value%' n'est pas un nombre décimal.",
	        'notGreaterThan' => "'%value%' n'est pas strictement supérieur à '%min%'.",
	        'notInt'=> "'%value%' n'est pas un nombre entier.",
	        'notLessThan' => "'%value%' n'est pas strictement inférieur à '%max%'.",
	        'isEmpty' => "Ce champ est vide : vous devez le compléter.",
	        'stringEmpty' => "Ce champ est vide : vous devez le compléter.",
	        'regexNotMatch' => "'%value%' ne respecte pas le format '%pattern%'.",
	        'stringLengthTooShort' => "'%value%' fait moins de %min% caractères.",
	        'stringLengthTooLong' => "'%value%' fait plus de %max% caractères.",
			'postcodeInvalid' => "'%value%' n'est pas du type attendu.",
	        'postcodeNoMatch' => "'%value%' n'est pas un code postal valide.",
			'notPhoneNumber' => "'%value%' ne semble pas être un numéro de téléphone français valide",
			'notIpAddress' => "'%value%' ne semble pas être une addresse IP valide"
        );

        $translate = new Zend_Translate('array', $french, 'fr_FR');
		Zend_Registry::set( 'translator', $translate );
        Zend_Validate_Abstract::setDefaultTranslator($translate);
    }
开发者ID:neotok,项目名称:PROJET1,代码行数:39,代码来源:Bootstrap.php

示例14: _initTranslate

 /**
  * Initializes translator
  *
  * @return Zend_Translate_Adapter
  */
 public function _initTranslate()
 {
     $log = new Zend_Log();
     if (APPLICATION_ENV == 'development') {
         $log = new Zend_Log();
         $log->addWriter(new Zend_Log_Writer_Firebug());
         //$log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/translate.log'));
     } else {
         $log->addWriter(new Zend_Log_Writer_Null());
     }
     $params['log'] = $log;
     // Create the object and add a language
     $translate = new Zend_Translate('Array', APPLICATION_PATH . '/languages/vi/vi.php', 'vi_VN');
     // Add another translation
     $translate->addTranslation(APPLICATION_PATH . '/languages/en/en.php', 'en_US');
     // Set nb_NO as default translation
     $translate->setLocale('vi_VN');
     Zend_Registry::set('Zend_Translate', $translate);
     Zend_Validate_Abstract::setDefaultTranslator($translate);
     Zend_Form::setDefaultTranslator($translate);
     Zend_Controller_Router_Route::setDefaultTranslator($translate);
     return $translate;
 }
开发者ID:nhochong,项目名称:qlkh-sgu,代码行数:28,代码来源:Bootstrap.php

示例15: setDefaultTranslator

 /**
  * Set default translation object for all Zend validate objects.
  *
  * @throws iMSCP_Exception When $translator is not a Zend_Translate_Adapter instance
  * @param Zend_Translate_Adapter $translator Translator adapter
  * @return void
  */
 public function setDefaultTranslator($translator = null)
 {
     if (null === $translator) {
         $translator = new iMSCP_I18n_Adapter_Zend();
     } elseif (!$translator instanceof Zend_Translate_Adapter) {
         throw new iMSCP_Exception('$translator must be an instance of Zend_Translate_Adapter.');
     }
     Zend_Validate_Abstract::setDefaultTranslator($translator);
 }
开发者ID:svenjantzen,项目名称:imscp,代码行数:16,代码来源:Validate.php


注:本文中的Zend_Validate_Abstract::setDefaultTranslator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。