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


PHP TranslatorInterface::transChoice方法代码示例

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


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

示例1: format

 public function format(DateDiffResult $result)
 {
     if ($result->getKey() === DateDiffResult::FULL_DATE) {
         return $result->getRequest()->getDate()->format($this->dateFormat);
     }
     return $this->translatorInterface->transChoice($result->getKey(), $result->getValue(), $this->getPlaceholders($result), $this->domain);
 }
开发者ID:wookieb,项目名称:relative-date,代码行数:7,代码来源:TranslatorFormatter.php

示例2: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     if (empty($options['data_class'])) {
         return;
     }
     $className = $options['data_class'];
     if (!$this->doctrineHelper->isManageableEntity($className)) {
         return;
     }
     if (!$this->entityConfigProvider->hasConfig($className)) {
         return;
     }
     $uniqueKeys = $this->entityConfigProvider->getConfig($className)->get('unique_key');
     if (empty($uniqueKeys)) {
         return;
     }
     /* @var \Symfony\Component\Validator\Mapping\ClassMetadata $validatorMetadata */
     $validatorMetadata = $this->validator->getMetadataFor($className);
     foreach ($uniqueKeys['keys'] as $uniqueKey) {
         $fields = $uniqueKey['key'];
         $labels = array_map(function ($fieldName) use($className) {
             $label = $this->entityConfigProvider->getConfig($className, $fieldName)->get('label');
             return $this->translator->trans($label);
         }, $fields);
         $constraint = new UniqueEntity(['fields' => $fields, 'errorPath' => '', 'message' => $this->translator->transChoice('oro.entity.validation.unique_field', sizeof($fields), ['%field%' => implode(', ', $labels)])]);
         $validatorMetadata->addConstraint($constraint);
     }
 }
开发者ID:ramunasd,项目名称:platform,代码行数:31,代码来源:UniqueEntityExtension.php

示例3: translateMessage

 private function translateMessage(TranslatableNotificationMessage $message)
 {
     if ($message->number !== null) {
         return $this->translator->transChoice($message->message, (int) $message->number, $message->translationParams, $message->domain);
     }
     return $this->translator->trans($message->message, $message->translationParams, $message->domain);
 }
开发者ID:yed30,项目名称:PlatformUIBundle,代码行数:7,代码来源:NotificationPool.php

示例4: formatData

 /**
  * @param float|integer $value
  * @param ProductUnit $unit
  * @param boolean $isShort
  * @return string
  */
 protected function formatData($value, ProductUnit $unit, $isShort = false)
 {
     if (!is_numeric($value)) {
         throw new \InvalidArgumentException(sprintf('The parameter "value" must be a numeric, but it is of type %s.', gettype($value)));
     }
     $translationKey = sprintf('orob2b.product_unit.%s.value.' . ($isShort ? 'short' : 'full'), $unit->getCode());
     return $this->translator->transChoice($translationKey, $value, ['%count%' => $value]);
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:14,代码来源:ProductUnitValueFormatter.php

示例5: getSuccessMessage

 /**
  * @param int $shoppingListId
  * @param int $entitiesCount
  * @param null|string $transChoiceKey
  * @return string
  */
 public function getSuccessMessage($shoppingListId = null, $entitiesCount = 0, $transChoiceKey = null)
 {
     $message = $this->translator->transChoice($transChoiceKey ?: 'orob2b.shoppinglist.actions.add_success_message', $entitiesCount, ['%count%' => $entitiesCount]);
     if ($shoppingListId && $entitiesCount > 0) {
         $message = sprintf('%s (<a href="%s">%s</a>).', $message, $this->router->generate('orob2b_shopping_list_frontend_view', ['id' => $shoppingListId]), $linkTitle = $this->translator->trans('orob2b.shoppinglist.actions.view'));
     }
     return $message;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:14,代码来源:MessageGenerator.php

示例6: formatCommaSeparatedWithLimit

 /**
  * @param $collection
  * @param $limit
  * @param $count
  *
  * @return string
  */
 private function formatCommaSeparatedWithLimit($collection, $limit, $count)
 {
     $display = array_map(function ($element) {
         return (string) $element;
     }, array_slice($collection, 0, $limit));
     $moreCount = $count - count($display);
     return $this->translator->transChoice('comma_separated_with_limit', $moreCount, array('%list%' => implode(', ', $display), '%count%' => $moreCount), $this->catalogue);
 }
开发者ID:pushpesh4u,项目名称:php-humanizer,代码行数:15,代码来源:Formatter.php

示例7: getResponse

 protected function getResponse(MassActionHandlerArgs $args, $count = 0)
 {
     $massAction = $args->getMassAction();
     $responseMessage = $massAction->getOptions()->offsetGetByPath('[messages][success]', $this->responseMessage);
     $successful = $count > 0;
     $options = ['count' => $count];
     return new MassActionResponse($successful, $this->translator->transChoice($responseMessage, $count, ['%count%' => $count]), $options);
 }
开发者ID:northdakota,项目名称:diamantedesk-application,代码行数:8,代码来源:ResetPasswordMassActionHandler.php

示例8: formatDifference

 /**
  * @param PreciseDifference $difference
  * @param string            $locale
  *
  * @return string
  */
 public function formatDifference(PreciseDifference $difference, $locale = 'en')
 {
     $diff = array();
     foreach ($difference->getCompoundResults() as $result) {
         $diff[] = $this->translator->transChoice('compound.' . $result->getUnit()->getName(), $result->getQuantity(), array('%count%' => $result->getQuantity()), 'difference', $locale);
     }
     return $this->translator->trans('compound.' . ($difference->isPast() ? 'past' : 'future'), array('%value%' => implode(', ', $diff)), 'difference', $locale);
 }
开发者ID:camigreen,项目名称:php-humanizer,代码行数:14,代码来源:PreciseFormatter.php

示例9: trans

 private function trans($context, $args, $count, $bundle, $locale)
 {
     if (is_null($count)) {
         $trans = $this->translator->trans($context, $args, $bundle, $locale);
     } else {
         $trans = $this->translator->transChoice($context, $count, $args, $bundle, $locale);
     }
     return $trans;
 }
开发者ID:jayS-de,项目名称:HandlebarsBundle,代码行数:9,代码来源:TranslationHelper.php

示例10: formatDifference

 /**
  * @param PreciseDifference $difference
  * @param string $locale
  * @return string
  */
 public function formatDifference(PreciseDifference $difference, $locale = 'en')
 {
     $diff = array();
     foreach ($difference->getCompoundResults() as $result) {
         $diff[] = $this->translator->transChoice("compound." . $result->getUnit()->getName(), $result->getQuantity(), array('%count%' => $result->getQuantity()), 'difference', $locale);
     }
     $suffix = $difference->isPast() ? 'compound.ago' : 'compound.from_now';
     return join(", ", $diff) . ' ' . $this->translator->trans($suffix, array(), 'difference', $locale);
 }
开发者ID:noscripter,项目名称:php-humanizer,代码行数:14,代码来源:PreciseFormatter.php

示例11: getAgeAsString

 /**
  * Get translated age string.
  *
  * @param string|\DateTime $date
  * @param array $options
  * @return string
  */
 public function getAgeAsString($date, $options)
 {
     $dateDiff = $this->getDateDiff($date, $options);
     if (!$dateDiff->invert) {
         $age = $dateDiff->y;
         return $this->translator->transChoice('oro.age', $age, array('%count%' => $age), 'messages');
     } else {
         return isset($options['default']) ? $options['default'] : '';
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:17,代码来源:DateExtension.php

示例12: transChoice

 /**
  * {@inheritdoc}
  */
 public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
 {
     $possibleIds = $this->getPossibleIds($id);
     foreach ($possibleIds as $possibleId) {
         $translation = $this->translator->transChoice($possibleId, $number, $parameters, $domain, $locale);
         if ($translation !== $possibleId) {
             return $translation;
         }
     }
     return $id;
 }
开发者ID:benakacha,项目名称:Sylius,代码行数:14,代码来源:Translator.php

示例13: getPluralizedInterval

 protected function getPluralizedInterval($count, $invert, $unit)
 {
     if ($this->translator) {
         $id = sprintf('diff.%s.%s', $invert ? 'in' : 'ago', $unit);
         return $this->translator->transChoice($id, $count, array('%count%' => $count), 'date');
     }
     if (1 !== $count) {
         $unit .= 's';
     }
     return $invert ? "in {$count} {$unit}" : "{$count} {$unit} ago";
 }
开发者ID:kstefanini,项目名称:ep-plugin,代码行数:11,代码来源:Date.php

示例14: visitMenuItem

 public function visitMenuItem(MenuItem $item)
 {
     $domain = $item->getExtra('translation_domain');
     $parameters = $item->getExtra('translation_parameters');
     if (false === $parameters) {
         return;
     } elseif (!is_array($parameters)) {
         $parameters = [];
     }
     $id = $item->getLabel();
     if (null !== ($number = $item->getExtra('translation_number'))) {
         $item->setLabel($this->translator->transChoice($id, $number, $parameters, $domain));
     } else {
         $item->setLabel($this->translator->trans($id, $parameters, $domain));
     }
 }
开发者ID:wemakecustom,项目名称:menu-part-bundle,代码行数:16,代码来源:L10nVisitor.php

示例15: getInfoMessage

 /**
  * @param object $entity
  * @param string $scope
  * @return string|null
  */
 public function getInfoMessage($entity, $scope = EntityPaginationManager::VIEW_SCOPE)
 {
     $entityName = ClassUtils::getClass($entity);
     // info message should be shown only once for each scope
     if (false !== $this->storage->isInfoMessageShown($entityName, $scope)) {
         return null;
     }
     $viewCount = $this->navigation->getTotalCount($entity, EntityPaginationManager::VIEW_SCOPE);
     $editCount = $this->navigation->getTotalCount($entity, EntityPaginationManager::EDIT_SCOPE);
     if (!$viewCount || !$editCount || $viewCount == $editCount) {
         return null;
     }
     $message = '';
     $count = null;
     // if scope is changing from "view" to "edit" and number of entities is decreased
     if ($scope == EntityPaginationManager::EDIT_SCOPE) {
         if ($editCount < $viewCount) {
             $message .= $this->translator->trans('oro.entity_pagination.message.stats_changed_view_to_edit') . ' ';
         }
         $count = $editCount;
     } elseif ($scope == EntityPaginationManager::VIEW_SCOPE) {
         $count = $viewCount;
     }
     if (!$count) {
         return null;
     }
     $message .= $this->translator->transChoice($this->getStatsMessage($scope), $count, ['%count%' => $count]);
     $this->storage->setInfoMessageShown($entityName, $scope);
     return $message;
 }
开发者ID:ramunasd,项目名称:platform,代码行数:35,代码来源:MessageManager.php


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