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


PHP Translation\Translator类代码示例

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


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

示例1: __construct

 public function __construct(Loader $loader, EventDispatcherInterface $eventDispatcher, Translator $translator)
 {
     $this->loader = $loader;
     $this->eventDispatcher = $eventDispatcher;
     $this->translator = $translator;
     $translator->addLoader('array', new ArrayLoader());
 }
开发者ID:rodmen,项目名称:TranslationBundle,代码行数:7,代码来源:InitListener.php

示例2: getTranslator

 public function getTranslator($loader, $options = array())
 {
     $translator = new Translator($this->getContainer($loader), $this->getMock('Symfony\\Component\\Translation\\MessageSelector'), array('loader' => 'loader'), $options);
     $translator->addResource('loader', 'foo', 'fr');
     $translator->addResource('loader', 'foo', 'en');
     return $translator;
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:7,代码来源:TranslatorTest.php

示例3: createMainMenu

 public function createMainMenu(Request $request, Translator $translator, SecurityContext $securityContext)
 {
     $menu = $this->factory->createItem('root');
     $menu->setCurrentUri($request->getRequestUri());
     $menu->addChild('bundles', array('route' => 'bundle_list'))->setLabel($translator->trans('menu.bundles'));
     $menu->addChild('users', array('route' => 'user_list'))->setLabel($translator->trans('menu.users'));
     $menu->addChild('evolution', array('route' => 'evolution'))->setLabel($translator->trans('menu.evolution'));
     $menu->addChild('add-bundle', array('route' => 'add_bundle'))->setLabel($translator->trans('menu.addBundleManually'));
     return $menu;
 }
开发者ID:ruian,项目名称:KnpBundles,代码行数:10,代码来源:MenuBuilder.php

示例4: getConstraints

 /**
  * @param PersistentCollection $key
  *
  * @return array|mixed
  */
 public function getConstraints(Attachment $attachment, DimensionContainer $dimensionContainer)
 {
     $constraints = array();
     foreach ($this->constraints as $constraintClass) {
         $constraintClass->setup($attachment, $dimensionContainer);
         $validate = $constraintClass->validate();
         if ($validate && $validate instanceof TranslatorObject) {
             $constraints[] = $this->translator->trans($validate->getId(), $validate->getData());
         }
     }
     if (count($constraints) == 0) {
         return;
     }
     return $constraints;
 }
开发者ID:bigfishcmf,项目名称:bigfishcmf,代码行数:20,代码来源:ConstraintChain.php

示例5: setUp

 /**
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 protected function setUp()
 {
     $this->formatter = $this->getMockBuilder('Oro\\Bundle\\LocaleBundle\\Formatter\\DateTimeFormatter')->disableOriginalConstructor()->setMethods(array('getPattern'))->getMock();
     $this->formatter->expects($this->any())->method('getPattern')->will($this->returnValueMap($this->localFormatMap));
     $this->translator = $this->getMockBuilder('Symfony\\Bundle\\FrameworkBundle\\Translation\\Translator')->disableOriginalConstructor()->getMock();
     $this->translator->method('trans')->will($this->returnCallback(function ($one, $two, $tree, $locale) {
         if ($locale == self::LOCALE_EN) {
             return 'MMM d';
         }
         if ($locale == self::LOCALE_RU) {
             return 'd.MMM';
         }
         return '';
     }));
     $this->converter = $this->createFormatConverter();
 }
开发者ID:antrampa,项目名称:platform,代码行数:19,代码来源:AbstractFormatConverterTestCase.php

示例6: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber(new CleanFormSubscriber());
     $builder->addEventSubscriber(new FormExitSubscriber('user.user', $options));
     $builder->add('username', 'text', array('label' => 'mautic.core.username', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'preaddon' => 'fa fa-user', 'autocomplete' => 'off')));
     $builder->add('firstName', 'text', array('label' => 'mautic.core.firstname', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control')));
     $builder->add('lastName', 'text', array('label' => 'mautic.core.lastname', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control')));
     $positions = $this->model->getLookupResults('position', null, 0, true);
     $builder->add('position', 'text', array('label' => 'mautic.core.position', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-options' => json_encode($positions)), 'required' => false));
     $builder->add('email', 'email', array('label' => 'mautic.core.type.email', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'preaddon' => 'fa fa-envelope')));
     $existing = !empty($options['data']) && $options['data']->getId();
     $placeholder = $existing ? $this->translator->trans('mautic.user.user.form.passwordplaceholder') : '';
     $required = $existing ? false : true;
     $builder->add('plainPassword', 'repeated', array('first_name' => 'password', 'first_options' => array('label' => 'mautic.core.password', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'placeholder' => $placeholder, 'tooltip' => 'mautic.user.user.form.help.passwordrequirements', 'preaddon' => 'fa fa-lock', 'autocomplete' => 'off'), 'required' => $required, 'error_bubbling' => false), 'second_name' => 'confirm', 'second_options' => array('label' => 'mautic.user.user.form.passwordconfirm', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'placeholder' => $placeholder, 'tooltip' => 'mautic.user.user.form.help.passwordrequirements', 'preaddon' => 'fa fa-lock', 'autocomplete' => 'off'), 'required' => $required, 'error_bubbling' => false), 'type' => 'password', 'invalid_message' => 'mautic.user.user.password.mismatch', 'required' => $required, 'error_bubbling' => false));
     $builder->add('timezone', 'timezone', array('label' => 'mautic.core.timezone', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'multiple' => false, 'empty_value' => 'mautic.user.user.form.defaulttimezone'));
     $builder->add('locale', 'choice', array('choices' => $this->supportedLanguages, 'label' => 'mautic.core.language', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'multiple' => false, 'empty_value' => 'mautic.user.user.form.defaultlocale'));
     if (empty($options['in_profile'])) {
         $builder->add($builder->create('role', 'entity', array('label' => 'mautic.user.role', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'class' => 'MauticUserBundle:Role', 'property' => 'name', 'query_builder' => function (EntityRepository $er) {
             return $er->createQueryBuilder('r')->where('r.isPublished = true')->orderBy('r.name', 'ASC');
         })));
         $builder->add('isPublished', 'yesno_button_group');
         $builder->add('buttons', 'form_buttons');
     } else {
         $builder->add('buttons', 'form_buttons', array('save_text' => 'mautic.core.form.apply', 'apply_text' => false));
     }
     if (!empty($options["action"])) {
         $builder->setAction($options["action"]);
     }
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:32,代码来源:UserType.php

示例7: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     // Build a list of columns
     $builder->add('column', 'choice', array('choices' => $options['columnList'], 'expanded' => false, 'multiple' => false, 'label' => 'mautic.report.report.label.filtercolumn', 'label_attr' => array('class' => 'control-label'), 'empty_value' => false, 'required' => false, 'attr' => array('class' => 'form-control filter-columns')));
     // Direction
     $builder->add('direction', 'choice', array('choices' => array('ASC' => $this->translator->trans('mautic.report.report.label.tableorder_dir.asc'), 'DESC' => $this->translator->trans('mautic.report.report.label.tableorder_dir.desc')), 'expanded' => false, 'multiple' => false, 'label' => 'mautic.core.order', 'label_attr' => array('class' => 'control-label'), 'empty_value' => false, 'required' => false, 'attr' => array('class' => 'form-control not-chosen')));
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:10,代码来源:TableOrderType.php

示例8: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
         return;
     }
     $request = $event->getRequest();
     $fc_form = $this->form_service->guessFcForm($request);
     if (!$fc_form instanceof FcForm) {
         return;
     }
     if ($fc_form->getAction()) {
         return;
     }
     /** @var FormInterface $form */
     $form = $this->form_service->create($fc_form);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $data = $form->getData();
         $this->form_service->clear($fc_form, array('template' => $data['_template'], 'data' => $this->form_service->initData($data)));
         if ($fc_form->getIsAjax()) {
             return;
         }
         if ($fc_form->getMessage()) {
             $message = $fc_form->getMessage();
         } else {
             $message = $this->translator->trans('fc.message.form.is_valid', array(), 'FenrizbesFormConstructorBundle');
         }
         // TODO: Связывать сообщение с конкретной формой и подчищать старые
         $this->session->getFlashBag()->add('fc_form.success', $message);
         $response = new RedirectResponse($this->router->generate($request->get('_route'), $request->get('_route_params')));
         $event->setResponse($response);
     }
 }
开发者ID:it-blaster,项目名称:form-constructor-bundle,代码行数:33,代码来源:RequestListener.php

示例9: returnAjaxError

 /**
  * Permet de retourner une erreur ajax avec le bon message en fonction du code erreur envoyé
  * @param $errorCode
  * @param string $notificationType
  * @param null $infos
  * @param null $specificMessage
  * @return Response
  */
 public function returnAjaxError($errorCode, $notificationType = 'error', $infos = null, $specificMessage = null)
 {
     switch ($errorCode) {
         case 103:
             $message = 'La recherche est vide';
             break;
         case 130:
         case 131:
         case 132:
             $message = 'Vous n\'êtes pas autorisé à accéder à cette page (seulement ROLE_SUPER_ADMIN)';
             break;
         case 200:
             $message = 'Tout a fonctionné correctement';
             break;
         default:
             $message = $this->translator->trans('bo.global.errorProcessing', array(), 'messages');
             break;
     }
     $message .= ' - ' . $errorCode;
     if (null !== $infos) {
         $message .= ' (' . $infos . ')';
     }
     if (null !== $specificMessage) {
         $message = $specificMessage;
     }
     $return = json_encode(array('responseCode' => $errorCode, 'message' => $message, 'notification' => $notificationType));
     return new Response($return, 200, array('Content-Type' => 'application/json'));
 }
开发者ID:GregHubs,项目名称:GestionRessources,代码行数:36,代码来源:Helper.php

示例10: createBreadcrumbsMenu

 /**
  * Breadcrumbs
  *
  * @param Request $request
  *
  * @return mixed
  */
 public function createBreadcrumbsMenu(Request $request)
 {
     $menu = $this->factory->createItem('root');
     $menu->setUri($request->getRequestUri());
     $menu->addChild($this->translator->trans('Главная'), array('route' => 'homepage'));
     return $menu;
 }
开发者ID:alienpham,项目名称:portfolio,代码行数:14,代码来源:MenuBuilder.php

示例11: departmentLabel

 public function departmentLabel($code)
 {
     try {
         return $this->departements->getLabel($code, true);
     } catch (\InvalidArgumentException $e) {
         return $this->translator->trans('report.company_departement.unknown');
     }
 }
开发者ID:Volyz,项目名称:barometre,代码行数:8,代码来源:DepartmentExtension.php

示例12: sendWelcomeEmail

 public function sendWelcomeEmail(User $user)
 {
     $token = $this->tokenGenerator->generateToken();
     $link = $this->router->generate('fos_user_registration_register', array('token' => $token), true);
     $this->mailer->sendMail($this->translator->trans('jwkh.publishers.email.welcome.subject', array(), null, $user->getPublisher()->getCongregation()->getDefaultLocale()), 'territory@jwkh.com', $user->getEmail(), $this->translator->trans('jwkh.publishers.email.welcome.body', array('%link%' => $link), null, $user->getPublisher()->getCongregation()->getDefaultLocale()));
     $user->setConfirmationToken($token);
     $this->userManager->updateUser($user);
 }
开发者ID:Leonhart25,项目名称:JWKingdomHall,代码行数:8,代码来源:UserService.php

示例13: onPreAuthorizationProcess

 /**
  * @param OAuthEvent $event
  *
  * @throws AccessDeniedException
  */
 public function onPreAuthorizationProcess(OAuthEvent $event)
 {
     if ($user = $this->getUser($event)) {
         //check to see if user has api access
         if (!$this->mauticSecurity->isGranted('api:access:full')) {
             throw new AccessDeniedException($this->translator->trans('mautic.core.error.accessdenied', [], 'flashes'));
         }
         $client = $event->getClient();
         $event->setAuthorizedClient($client->isAuthorizedClient($user, $this->em));
     }
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:16,代码来源:OAuthEventListener.php

示例14: getNameDQL

 /**
  * Returns a DQL expression that can be used to get a text representation of the given type of entities.
  *
  * @param string      $format    The representation format, for example full, short, etc.
  * @param string|null $locale    The representation locale.
  * @param string      $className The FQCN of the entity
  * @param string      $alias     The alias in SELECT or JOIN statement
  *
  * @return string A DQL expression or FALSE if this provider cannot return reliable result
  */
 public function getNameDQL($format, $locale, $className, $alias)
 {
     if ($className === self::CLASS_NAME) {
         if ($format === self::SHORT) {
             return $alias . 'label';
         } else {
             return sprintf('CONCAT(%s.label, \' %s\')', $alias, $this->translator->trans('oro.email.mailbox.entity_label', [], null, $locale));
         }
     }
     return false;
 }
开发者ID:Maksold,项目名称:platform,代码行数:21,代码来源:MailboxEntityNameProvider.php

示例15: addEvent

 /**
  * Adds an action to the list of available .
  *
  * @param string $key - a unique identifier; it is recommended that it be namespaced i.e. lead.action
  * @param array $event - can contain the following keys:
  *  'label'           => (required) what to display in the list
  *  'description'     => (optional) short description of event
  *  'template'        => (optional) template to use for the action's HTML in the point builder
  *      i.e AcmeMyBundle:PointAction:theaction.html.php
  *  'formType'        => (optional) name of the form type SERVICE for the action
  *  'formTypeOptions' => (optional) array of options to pass to formType
  *  'callback'        => (required) callback function that will be passed when the action is triggered
  *      The callback function can receive the following arguments by name (via ReflectionMethod::invokeArgs())
  *          Mautic\CoreBundle\Factory\MauticFactory $factory
  *          Mautic\PointBundle\Entity\TriggerEvent  $event
  *          Mautic\LeadBundle\Entity\Lead           $lead
  *
  * @return void
  * @throws InvalidArgumentException
  */
 public function addEvent($key, array $event)
 {
     if (array_key_exists($key, $this->events)) {
         throw new InvalidArgumentException("The key, '{$key}' is already used by another action. Please use a different key.");
     }
     //check for required keys and that given functions are callable
     $this->verifyComponent(array('group', 'label', 'callback'), array('callback'), $event);
     $event['label'] = $this->translator->trans($event['label']);
     $event['group'] = $this->translator->trans($event['group']);
     $event['description'] = isset($event['description']) ? $this->translator->trans($event['description']) : '';
     $this->events[$key] = $event;
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:32,代码来源:TriggerBuilderEvent.php


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