Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function transChoice(string $id, $number, array $parameters = [], string $domain = 'messages') : string
 {
     if (is_array($number) || $number instanceof Countable) {
         $number = count($number);
     }
     if (preg_match("/^(.*?)\\[(.*?)\\]\$/", $id, $match)) {
         $id = $match[1];
     }
     $trans = strtr($this->selector->choose($this->catalogue->get($id, $domain), $number, $this->locale), $parameters);
     $trans = $this->applyFilters($trans);
     $trans = $this->applyHelpers(empty($match) ? $trans : $trans . '[' . $match[2] . ']');
     if ($this->logger !== null) {
         $this->log($id, $domain);
     }
     return $trans;
 }
Exemplo n.º 2
0
 /**
  * Creat new Translation instance.
  *
  * @param \Viserio\Contracts\Translation\PluralizationRules $pluralization
  * @param \Viserio\Contracts\Translation\MessageSelector    $messageSelector
  */
 public function __construct(PluralizationRulesContract $pluralization, MessageSelectorContract $messageSelector)
 {
     $this->pluralization = $pluralization;
     $messageSelector->setPluralization($pluralization);
     $this->messageSelector = $messageSelector;
 }