本文整理汇总了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']);
}
}
}
示例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;
}
示例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');
}
示例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;
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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'));
}
}
示例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;
}
示例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;
}
示例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 '';
}
}
示例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;
}
示例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;
}
示例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);
}