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


PHP Translator::trans方法代码示例

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


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

示例1: onNavigationConfigure

 /**
  * @param ConfigureMenuEvent $event
  */
 public function onNavigationConfigure(ConfigureMenuEvent $event)
 {
     $menu = $event->getMenu();
     $children = array();
     $entitiesMenuItem = $menu->getChild('system_tab')->getChild('entities_list');
     if ($entitiesMenuItem) {
         /** @var ConfigProvider $entityConfigProvider */
         $entityConfigProvider = $this->configManager->getProvider('entity');
         /** @var ConfigProvider $entityExtendProvider */
         $entityExtendProvider = $this->configManager->getProvider('extend');
         $extendConfigs = $entityExtendProvider->getConfigs();
         foreach ($extendConfigs as $extendConfig) {
             if ($this->checkAvailability($extendConfig)) {
                 $config = $entityConfigProvider->getConfig($extendConfig->getId()->getClassname());
                 if (!class_exists($config->getId()->getClassName()) || !$this->securityFacade->hasLoggedUser() || !$this->securityFacade->isGranted('VIEW', 'entity:' . $config->getId()->getClassName())) {
                     continue;
                 }
                 $children[$config->get('label')] = array('label' => $this->translator->trans($config->get('label')), 'options' => array('route' => 'oro_entity_index', 'routeParameters' => array('entityName' => str_replace('\\', '_', $config->getId()->getClassName())), 'extras' => array('safe_label' => true, 'routes' => array('oro_entity_*'))));
             }
         }
         sort($children);
         foreach ($children as $child) {
             $entitiesMenuItem->addChild($child['label'], $child['options']);
         }
     }
 }
开发者ID:xamin123,项目名称:platform,代码行数:29,代码来源:NavigationListener.php

示例2: handle

 public function handle(FormInterface $form, Request $request)
 {
     $form->handleRequest($request);
     if (!$form->isValid()) {
         return false;
     }
     $data = $form->getData();
     if ($form->isSubmitted()) {
         $user = $this->userManager->findUserByEmail($data['email']);
         if (is_null($user)) {
             $form->addError(new FormError($this->translator->trans('security.resetting.request.errors.email_not_found')));
             return false;
         }
         if ($user->isPasswordRequestNonExpired($this->tokenTll)) {
             $form->addError(new FormError($this->translator->trans('security.resetting.request.errors.password_already_requested')));
             return false;
         }
         if ($user->getConfirmationToken() === null) {
             $user->setConfirmationToken($this->tokenGenerator->generateToken());
         }
         $user->setPasswordRequestedAt(new \DateTime());
         $this->userManager->resettingRequest($user);
     }
     return true;
 }
开发者ID:neandher,项目名称:Symfony-Multiple-Authentication,代码行数:25,代码来源:ResettingRequestFormHandler.php

示例3: buildForm

 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $section = $this->section;
     $builder->add('prenom', "text")->add('nom', "text")->add('email', 'email')->add('sexe', 'choice', array('choices' => array('m' => $this->translator->trans('label.male'), 'f' => $this->translator->trans('label.female'))))->add('dob', 'date', array('required' => false, 'input' => 'datetime', 'widget' => 'single_text', 'format' => 'dd/MM/yyyy'))->add('nbmentee', 'choice', array('required' => true, 'multiple' => false, 'empty_value' => $this->translator->trans('label.nbmentee'), 'choices' => array("1" => 1, "2" => 2, "3" => 3)))->add('submit', "submit")->add('password', 'repeated', array('type' => 'password', 'invalid_message' => 'Le mot de passe doit être indentique à sa confirmation.', 'required' => true))->add('conditionGenerale', 'checkbox', array('required' => true, 'label' => "J'accepte les conditions générales d'utilisations"))->add('nationalite', 'entity', array('label' => 'Status Name', 'required' => true, 'empty_value' => $this->translator->trans('label.form.nationality'), 'class' => 'BuddySystem\\MembersBundle\\Entity\\Nationality', 'property' => 'nationality'))->add('universite', 'entity', array('label' => 'Status Name', 'empty_value' => 'crud.form.university', 'class' => 'BuddySystem\\MembersBundle\\Entity\\Univercity', 'query_builder' => function (UniversityRepository $ur) use($section) {
         return $ur->getUniversitiesBySection($section, true);
     }, 'required' => false))->add('comment');
 }
开发者ID:ESNFranceG33kTeam,项目名称:sf_buddysystem,代码行数:7,代码来源:MentorType.php

示例4: runJobs

 /**
  * @param $jobs
  * @throws UnauthorizedCommandException
  */
 protected function runJobs($jobs)
 {
     foreach ($jobs as $job) {
         /**
          * @var \WeavingTheWeb\Bundle\ApiBundle\Entity\Job $job
          */
         $command = $job->getValue();
         try {
             $this->validateCommand($command);
             $job->setStatus(JobInterface::STATUS_STARTED);
             $this->updateJob($job);
             $command = $this->getApplication()->get($command);
             $success = $command->run(new ArrayInput(['command' => $command, '--job' => $job->getId()]), $this->output);
             if (intval($success) === 0) {
                 $job->setStatus(JobInterface::STATUS_FINISHED);
             } else {
                 $job->setStatus(JobInterface::STATUS_FAILED);
             }
             $this->updateJob($job);
         } catch (UnauthorizedCommandException $exception) {
             $message = $this->translator->trans('job.run.unauthorized', ['{{ command }}' => $command], 'job');
             $this->logger->error($exception->getMessage());
             $this->output->writeln($message);
             $job->setStatus(JobInterface::STATUS_FAILED);
             $this->updateJob($job);
             continue;
         } catch (\Exception $exception) {
             $this->logger->error($exception->getMessage());
             continue;
         }
     }
 }
开发者ID:WeavingTheWeb,项目名称:devobs,代码行数:36,代码来源:RunJobCommand.php

示例5: get

 /**
  * @param FormView $formView
  *
  * @return string
  * @author Michaël VEROUX
  */
 public function get(FormView $formView)
 {
     $value = $formView->vars['value'];
     $display = array();
     $expanded = isset($formView->vars['expanded']) && $formView->vars['expanded'];
     $multiple = isset($formView->vars['multiple']) && $formView->vars['multiple'];
     if ($expanded && $multiple) {
         $value = array_filter($value, function ($val) {
             return $val;
         });
         $value = array_keys($value);
     }
     foreach ($formView->vars['choices'] as $key => $choiceView) {
         if ($multiple) {
             if ($expanded) {
                 $compare = $key;
             } else {
                 $compare = $choiceView->value;
             }
             if (in_array($compare, $value)) {
                 $display[] = $this->translator->trans($choiceView->label, array(), $formView->vars['translation_domain']);
             }
         } else {
             if ($value == $choiceView->value) {
                 return $this->translator->trans($choiceView->label, array(), $formView->vars['translation_domain']);
             }
         }
     }
     if (!count($display)) {
         return $formView->vars['placeholder'];
     }
     return implode(PHP_EOL, $display);
 }
开发者ID:phpmike,项目名称:MvExportFormBundle,代码行数:39,代码来源:ChoiceTypeDisplay.php

示例6: getMergeValues

 /**
  * Get values of merge modes with labels
  *
  * @param array $modes
  * @return array
  */
 protected function getMergeValues(array $modes)
 {
     $result = array();
     foreach ($modes as $mode) {
         $result[$mode] = $this->translator->trans('oro.entity_merge.merge_modes.' . $mode);
     }
     return $result;
 }
开发者ID:xamin123,项目名称:platform,代码行数:14,代码来源:MergeFieldType.php

示例7: loadUserByUsername

 /**
  * Loads the user for the given username.
  *
  * This method must throw UsernameNotFoundException if the user is not
  * found.
  *
  * @param string $username The username
  *
  * @return UserInterface
  *
  * @throws UsernameNotFoundException if the user is not found
  */
 public function loadUserByUsername($username)
 {
     $user = $this->userRepository->findOneBy(['username' => $username]);
     if (!$user) {
         throw new UsernameNotFoundException($this->translator->trans('Username %username% does not exist!', ['%username%' => $username]));
     }
     return $user;
 }
开发者ID:robertdumitrescu,项目名称:Interview-MusicCoursesApplication,代码行数:20,代码来源:UserProviderService.php

示例8: addBackendMenuItems

 public function addBackendMenuItems(MenuBuilderEvent $event)
 {
     $menu = $event->getMenu();
     if (isset($menu['content'])) {
         $menu['content']->addChild('webburza_sylius_articles', array('route' => 'webburza_article_index', 'labelAttributes' => array('icon' => 'glyphicon glyphicon-file')))->setLabel($this->translator->trans('webburza.sylius.article.backend.articles'));
         $menu['content']->addChild('webburza_sylius_article_categories', array('route' => 'webburza_article_category_index', 'labelAttributes' => array('icon' => 'glyphicon glyphicon-tags')))->setLabel($this->translator->trans('webburza.sylius.article_category.backend.article_categories'));
     }
 }
开发者ID:webburza,项目名称:sylius-article-bundle,代码行数:8,代码来源:MenuBuilderListener.php

示例9: onResettingRequestSuccess

 /**
  * @param UserEvent $event
  * @throws \Exception
  * @throws \Twig_Error
  */
 public function onResettingRequestSuccess(UserEvent $event)
 {
     $user = $event->getUser();
     $params = $event->getParams();
     $url = $this->router->generate($params[$event::PARAM_RESETTING_EMAIL_ROUTE], array('token' => $user->getConfirmationToken()), true);
     $message = \Swift_Message::newInstance()->setSubject($this->translator->trans('security.resetting.request.email.subject'))->setFrom($this->parameter->get($params[$event::PARAM_RESETTING_EMAIL_FROM]))->setTo($user->getEmail())->setBody($this->twigEngine->render($params[$event::PARAM_RESETTING_EMAIL_TEMPLATE], array('complete_name' => $event->getSecureArea()->getCompleteName(), 'url' => $url)));
     $this->mailer->send($message);
     $this->flashBag->add(FlashBagEvents::MESSAGE_TYPE_SUCCESS, $this->translator->trans('security.resetting.request.check_email', array('user_email' => $user->getObfuscatedEmail())));
 }
开发者ID:neandher,项目名称:Symfony-Multiple-Authentication,代码行数:14,代码来源:ResettingRequestSendEmailSubscriber.php

示例10: checkCredentials

 /**
  * {@inheritdoc}
  */
 public function checkCredentials($credentials, UserInterface $user)
 {
     $plainPassword = $credentials['password'];
     $encoder = $this->passwordEncoder;
     if (!$encoder->isPasswordValid($user, $plainPassword)) {
         throw new CustomUserMessageAuthenticationException($this->translator->trans($this->failMessage));
     }
     return true;
 }
开发者ID:busaev,项目名称:s3,代码行数:12,代码来源:FormAuthenticator.php

示例11: addTable

 /**
  * Add a table with the specified columns to the lookup.
  *
  * The data should be an associative array with the following data:
  * 'display_name' => The translation key to display in the select list
  * 'columns'      => An array containing the table's columns
  *
  * @param string $context   Context for data
  * @param array  $data      Data array for the table
  *
  * @return void
  */
 public function addTable($context, array $data)
 {
     foreach ($data['columns'] as &$d) {
         $d['label'] = $this->translator->trans($d['label']);
     }
     uasort($data['columns'], function ($a, $b) {
         return strnatcmp($a['label'], $b['label']);
     });
     $this->tableArray[$context] = $data;
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:22,代码来源:ReportBuilderEvent.php

示例12: getGlobalServiceStatusName

 /**
  * Get Status name use to get a status name a service.
  *
  * @param Service $service
  *
  * @return string
  */
 public function getGlobalServiceStatusName(Service $service)
 {
     switch ($service->getStatus()) {
         case Service::OPERATIONNAL:
             return $this->translator->trans('status_page.service.up');
         case Service::OUTAGE:
             return $this->translator->trans('status_page.service.down');
         default:
             return '';
     }
 }
开发者ID:hogosha,项目名称:hogosha,代码行数:18,代码来源:StatusExtension.php

示例13: handle

 public function handle(FormInterface $form, Request $request)
 {
     $form->handleRequest($request);
     if (!$form->isValid()) {
         return false;
     }
     $entity = $form->getData();
     $this->userManager->resettingReset($entity);
     $this->flashBag->add(FlashBagEvents::MESSAGE_TYPE_SUCCESS, $this->translator->trans('security.resetting.reset.success'));
     return true;
 }
开发者ID:neandher,项目名称:Symfony-Multiple-Authentication,代码行数:11,代码来源:ResettingResetFormHandler.php

示例14: reverseTransform

 /**
  * @param mixed $value The value in the transformed representation
  * @return mixed The value in the original representation
  * @throws TransformationFailedException When the transformation fails.
  */
 public function reverseTransform($username)
 {
     if (!$username) {
         return null;
     }
     $user = $this->registry->getRepository('AppBundle:User')->findOneBy(array('username' => $username));
     if (!$user) {
         throw new TransformationFailedException($this->translator->trans('user.unknownusername'));
     }
     return $user;
 }
开发者ID:amm0nite,项目名称:shared-budget,代码行数:16,代码来源:UserToStringTransformer.php

示例15: getDescription

 public function getDescription()
 {
     $this->translator = \Siciarek\AdRotatorBundle\SiciarekAdRotatorBundle::getContainer()->get('translator');
     $temp = array();
     if ($this->getMainpage() === true) {
         $temp[] = $this->translator->trans(self::MAINPAGE, array(), 'SiciarekAdRotator');
     }
     if ($this->getSubpages() === true) {
         $temp[] = $this->translator->trans(self::SUBPAGES, array(), 'SiciarekAdRotator');
     }
     return implode(' + ', $temp);
 }
开发者ID:siciarek,项目名称:ad-rotator-bundle,代码行数:12,代码来源:AdPrice.php


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