updated packages
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Translation;
|
||||
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
|
||||
use Symfony\Component\Translation\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface;
|
||||
use Symfony\Contracts\Translation\LocaleAwareInterface;
|
||||
@@ -19,7 +20,7 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
/**
|
||||
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
|
||||
*/
|
||||
class DataCollectorTranslator implements LegacyTranslatorInterface, TranslatorInterface, TranslatorBagInterface
|
||||
class DataCollectorTranslator implements LegacyTranslatorInterface, TranslatorInterface, TranslatorBagInterface, WarmableInterface
|
||||
{
|
||||
const MESSAGE_DEFINED = 0;
|
||||
const MESSAGE_MISSING = 1;
|
||||
@@ -30,7 +31,7 @@ class DataCollectorTranslator implements LegacyTranslatorInterface, TranslatorIn
|
||||
*/
|
||||
private $translator;
|
||||
|
||||
private $messages = array();
|
||||
private $messages = [];
|
||||
|
||||
/**
|
||||
* @param TranslatorInterface $translator The translator must implement TranslatorBagInterface
|
||||
@@ -50,7 +51,7 @@ class DataCollectorTranslator implements LegacyTranslatorInterface, TranslatorIn
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function trans($id, array $parameters = array(), $domain = null, $locale = null)
|
||||
public function trans($id, array $parameters = [], $domain = null, $locale = null)
|
||||
{
|
||||
$trans = $this->translator->trans($id, $parameters, $domain, $locale);
|
||||
$this->collectMessage($locale, $domain, $id, $trans, $parameters);
|
||||
@@ -63,15 +64,15 @@ class DataCollectorTranslator implements LegacyTranslatorInterface, TranslatorIn
|
||||
*
|
||||
* @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)
|
||||
public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
|
||||
{
|
||||
if ($this->translator instanceof TranslatorInterface) {
|
||||
$trans = $this->translator->trans($id, array('%count%' => $number) + $parameters, $domain, $locale);
|
||||
$trans = $this->translator->trans($id, ['%count%' => $number] + $parameters, $domain, $locale);
|
||||
}
|
||||
|
||||
$trans = $this->translator->transChoice($id, $number, $parameters, $domain, $locale);
|
||||
|
||||
$this->collectMessage($locale, $domain, $id, $trans, array('%count%' => $number) + $parameters);
|
||||
$this->collectMessage($locale, $domain, $id, $trans, ['%count%' => $number] + $parameters);
|
||||
|
||||
return $trans;
|
||||
}
|
||||
@@ -100,6 +101,16 @@ class DataCollectorTranslator implements LegacyTranslatorInterface, TranslatorIn
|
||||
return $this->translator->getCatalogue($locale);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function warmUp($cacheDir)
|
||||
{
|
||||
if ($this->translator instanceof WarmableInterface) {
|
||||
$this->translator->warmUp($cacheDir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fallback locales.
|
||||
*
|
||||
@@ -111,7 +122,7 @@ class DataCollectorTranslator implements LegacyTranslatorInterface, TranslatorIn
|
||||
return $this->translator->getFallbackLocales();
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +148,7 @@ class DataCollectorTranslator implements LegacyTranslatorInterface, TranslatorIn
|
||||
* @param string $translation
|
||||
* @param array|null $parameters
|
||||
*/
|
||||
private function collectMessage($locale, $domain, $id, $translation, $parameters = array())
|
||||
private function collectMessage($locale, $domain, $id, $translation, $parameters = [])
|
||||
{
|
||||
if (null === $domain) {
|
||||
$domain = 'messages';
|
||||
@@ -164,7 +175,7 @@ class DataCollectorTranslator implements LegacyTranslatorInterface, TranslatorIn
|
||||
$state = self::MESSAGE_MISSING;
|
||||
}
|
||||
|
||||
$this->messages[] = array(
|
||||
$this->messages[] = [
|
||||
'locale' => $locale,
|
||||
'domain' => $domain,
|
||||
'id' => $id,
|
||||
@@ -172,6 +183,6 @@ class DataCollectorTranslator implements LegacyTranslatorInterface, TranslatorIn
|
||||
'parameters' => $parameters,
|
||||
'state' => $state,
|
||||
'transChoiceNumber' => isset($parameters['%count%']) && is_numeric($parameters['%count%']) ? $parameters['%count%'] : null,
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user