當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。