composer update
This commit is contained in:
@@ -12,11 +12,13 @@
|
||||
namespace Symfony\Component\Translation;
|
||||
|
||||
use Symfony\Component\Translation\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
|
||||
*/
|
||||
class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInterface
|
||||
class DataCollectorTranslator implements LegacyTranslatorInterface, TranslatorInterface, TranslatorBagInterface
|
||||
{
|
||||
const MESSAGE_DEFINED = 0;
|
||||
const MESSAGE_MISSING = 1;
|
||||
@@ -32,8 +34,11 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
|
||||
/**
|
||||
* @param TranslatorInterface $translator The translator must implement TranslatorBagInterface
|
||||
*/
|
||||
public function __construct(TranslatorInterface $translator)
|
||||
public function __construct($translator)
|
||||
{
|
||||
if (!$translator instanceof LegacyTranslatorInterface && !$translator instanceof TranslatorInterface) {
|
||||
throw new \TypeError(sprintf('Argument 1 passed to %s() must be an instance of %s, %s given.', __METHOD__, TranslatorInterface::class, \is_object($translator) ? \get_class($translator) : \gettype($translator)));
|
||||
}
|
||||
if (!$translator instanceof TranslatorBagInterface) {
|
||||
throw new InvalidArgumentException(sprintf('The Translator "%s" must implement TranslatorInterface and TranslatorBagInterface.', \get_class($translator)));
|
||||
}
|
||||
@@ -54,11 +59,18 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated since Symfony 4.2, use the trans() method instead with a %count% parameter
|
||||
*/
|
||||
public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null)
|
||||
{
|
||||
if ($this->translator instanceof TranslatorInterface) {
|
||||
$trans = $this->translator->trans($id, array('%count%' => $number) + $parameters, $domain, $locale);
|
||||
}
|
||||
|
||||
$trans = $this->translator->transChoice($id, $number, $parameters, $domain, $locale);
|
||||
$this->collectMessage($locale, $domain, $id, $trans, $parameters, $number);
|
||||
|
||||
$this->collectMessage($locale, $domain, $id, $trans, array('%count%' => $number) + $parameters);
|
||||
|
||||
return $trans;
|
||||
}
|
||||
@@ -90,7 +102,7 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
|
||||
/**
|
||||
* Gets the fallback locales.
|
||||
*
|
||||
* @return array $locales The fallback locales
|
||||
* @return array The fallback locales
|
||||
*/
|
||||
public function getFallbackLocales()
|
||||
{
|
||||
@@ -106,7 +118,7 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
return \call_user_func_array(array($this->translator, $method), $args);
|
||||
return $this->translator->{$method}(...$args);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,9 +135,8 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
|
||||
* @param string $id
|
||||
* @param string $translation
|
||||
* @param array|null $parameters
|
||||
* @param int|null $number
|
||||
*/
|
||||
private function collectMessage($locale, $domain, $id, $translation, $parameters = array(), $number = null)
|
||||
private function collectMessage($locale, $domain, $id, $translation, $parameters = array())
|
||||
{
|
||||
if (null === $domain) {
|
||||
$domain = 'messages';
|
||||
@@ -158,8 +169,8 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
|
||||
'id' => $id,
|
||||
'translation' => $translation,
|
||||
'parameters' => $parameters,
|
||||
'transChoiceNumber' => $number,
|
||||
'state' => $state,
|
||||
'transChoiceNumber' => isset($parameters['%count%']) && is_numeric($parameters['%count%']) ? $parameters['%count%'] : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user