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


PHP AbstractValidator::setDefaultTranslatorTextDomain方法代码示例

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


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

示例1: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $request = $e->getApplication()->getServiceManager()->get('Request');
     $moduleRouteListener->attach($eventManager);
     $adapter = $e->getApplication()->getServiceManager()->get('Zend\\Db\\Adapter\\Adapter');
     $config = $e->getApplication()->getServiceManager()->get('Configuration');
     $locale = null;
     $eventManager->attach(new UserRegisterListener($adapter));
     $eventManager->attach(new LogListener());
     // Add ACL information to the Navigation view helper
     $authorize = $e->getApplication()->getServiceManager()->get('BjyAuthorize\\Service\\Authorize');
     $acl = $authorize->getAcl();
     $role = $authorize->getIdentity();
     \Zend\View\Helper\Navigation::setDefaultAcl($acl);
     \Zend\View\Helper\Navigation::setDefaultRole($role);
     // translating system
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($config['session']);
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->start();
     $session = new Container('base');
     // Get the visitor language selection
     $translator = $e->getApplication()->getServiceManager()->get('translator');
     // get the locale from the cookie
     $headCookie = $request->getHeaders()->get('Cookie');
     if (!empty($headCookie) && array_key_exists('locale', get_object_vars($headCookie))) {
         $locale = $headCookie->locale;
     }
     if (empty($locale)) {
         // if there is not set any cookie
         $locale = $session->offsetGet('locale');
         // Get the locale from the session
         if (empty($locale)) {
             // if there is not any session set yet
             $headers = $request->getHeaders();
             if ($headers->has('Accept-Language')) {
                 $locales = $headers->get('Accept-Language')->getPrioritized();
                 $first = array_shift($locales);
                 $locale = $first->getLanguage();
                 if (!empty($locale) && 2 == strlen($locale)) {
                     $locale .= "_" . strtoupper($locale);
                 }
             }
             if (empty($locale)) {
                 // if the browser has no locale set, we have to get the default INTL global locale setting
                 $locale = \Locale::getPrimaryLanguage(\Locale::getDefault());
                 // Gets the default locale value from the INTL global 'default_locale'
             }
         }
     } else {
         #\Zend\Debug\debug::dump("Cookie set with locale: $locale");
     }
     $translator->setLocale(\Locale::acceptFromHttp($locale));
     $translator->setLocale($locale)->setFallbackLocale('en_US');
     \Zend\Validator\AbstractValidator::setDefaultTranslator($translator);
     \Zend\Validator\AbstractValidator::setDefaultTranslatorTextDomain();
 }
开发者ID:omusico,项目名称:Base,代码行数:59,代码来源:Module.php

示例2: onBootstrap

 /**
  * @internal
  */
 public function onBootstrap(\Zend\EventManager\EventInterface $e)
 {
     \Zend\Filter\StaticFilter::getPluginManager()->setInvokableClass('Library\\FixEncodingErrors', 'Library\\Filter\\FixEncodingErrors');
     $serviceManager = $e->getApplication()->getServiceManager();
     // Register form element view helpers
     $formElementHelper = $serviceManager->get('ViewHelperManager')->get('formElement');
     $formElementHelper->addClass('Library\\Form\\Element\\SelectSimple', 'formselectsimple');
     $formElementHelper->addType('select_untranslated', 'formselectuntranslated');
     if (\Locale::getPrimaryLanguage(\Locale::getDefault()) != 'en') {
         $mvcTranslator = $serviceManager->get('MvcTranslator');
         if (Application::isDevelopment()) {
             $translator = $mvcTranslator->getTranslator();
             $translator->enableEventManager();
             $translator->getEventManager()->attach(\Zend\I18n\Translator\Translator::EVENT_MISSING_TRANSLATION, array($this, 'onMissingTranslation'));
         }
         // Validators have no translator by default. Attach translator, but
         // use a different text domain to avoid warnings if the Zend
         // translations are not loaded. For custom messages, the text domain
         // must be reset manually to 'default' for individual validators.
         \Zend\Validator\AbstractValidator::setDefaultTranslator($mvcTranslator);
         \Zend\Validator\AbstractValidator::setDefaultTranslatorTextDomain('Zend');
     }
 }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:26,代码来源:Module.php


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