本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Translation\Translator::transChoice方法的典型用法代码示例。如果您正苦于以下问题:PHP Translator::transChoice方法的具体用法?PHP Translator::transChoice怎么用?PHP Translator::transChoice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Translation\Translator
的用法示例。
在下文中一共展示了Translator::transChoice方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getClientBillStatusText
public function getClientBillStatusText(User $client, $year, $quarter)
{
$status = $this->getClientBillStatus($client, $year, $quarter);
if ($status < 0) {
return $this->translator->transChoice('bill.accounts_require_attention', -$status, array('%count%' => -$status));
}
return $this->translator->trans('bill.status' . $status);
}
示例2: textualDateFilter
/**
* Converts dates into relative textual dates
*
* Ex: x days ago, yesterday, tomorrow, in x days
*
* @param \DateTime $date
*
* @throws \InvalidArgumentException
* @return string
*/
public function textualDateFilter($date)
{
if (!$date instanceof \DateTime) {
throw new \InvalidArgumentException('Textual Date Filter expects input to be a instance of DateTime');
}
$now = new \DateTime('now');
$diff = $now->diff($date);
$diffUnit = $this->getHighestDiffUnitAndValue($diff);
$temporalModifier = $diff->invert ? 'ago' : 'next';
$translationString = $temporalModifier . '.' . $diffUnit['unit'];
// Override yesterday and tomorrow
if ($diffUnit['unit'] == 'd' && $diffUnit['value'] == 1) {
$translationString = $diff->invert ? 'date.yesterday' : 'date.tomorrow';
}
// Override "just.now"
if ($diffUnit['unit'] == 'now') {
$translationString = 'date.just_now';
}
return $this->translator->transChoice($translationString, $diffUnit['value'], array('%value%' => $diffUnit['value']), 'date');
}
示例3: transChoice
/**
* @see \Symfony\Component\Translation\Translator::transChoice()
*/
public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null)
{
if (null === $locale) {
$locale = $this->getLocale();
}
if (!isset($this->selector)) {
$this->selector = new MessageSelector();
}
$message = $this->getMessage($id, $domain, $parameters, $locale);
if ($message->getContent()) {
// return entity translation
return strtr($this->selector->choose($message->getContent(), (int) $number, $locale), $parameters);
}
// else return translation handled by sf
return parent::transChoice($id, $number, $parameters, $domain, $locale);
}
示例4: trans
/**
* @param string $string
* @param string array $params
* @param string $domain
* @param int $number
* @return string
*/
private function trans($string, array $params = [], $domain, $number = 1)
{
return $this->translator->transChoice($string, $number, $params, $domain);
}