Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
+25 -9
View File
@@ -15,6 +15,7 @@ use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
use Symfony\Component\Translation\Translator as BaseTranslator;
use Symfony\Component\Translation\MessageSelector;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Translation\Exception\InvalidArgumentException;
/**
* Translator.
@@ -37,6 +38,14 @@ class Translator extends BaseTranslator implements WarmableInterface
*/
private $resourceLocales;
/**
* Holds parameters from addResource() calls so we can defer the actual
* parent::addResource() calls until initialize() is executed.
*
* @var array
*/
private $resources = array();
/**
* Constructor.
*
@@ -51,7 +60,7 @@ class Translator extends BaseTranslator implements WarmableInterface
* @param array $loaderIds An array of loader Ids
* @param array $options An array of options
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public function __construct(ContainerInterface $container, MessageSelector $selector, $loaderIds = array(), array $options = array())
{
@@ -60,14 +69,12 @@ class Translator extends BaseTranslator implements WarmableInterface
// check option names
if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
throw new \InvalidArgumentException(sprintf('The Translator does not support the following options: \'%s\'.', implode('\', \'', $diff)));
throw new InvalidArgumentException(sprintf('The Translator does not support the following options: \'%s\'.', implode('\', \'', $diff)));
}
$this->options = array_merge($this->options, $options);
$this->resourceLocales = array_keys($this->options['resource_files']);
if (null !== $this->options['cache_dir'] && $this->options['debug']) {
$this->loadResources();
}
$this->addResourceFiles($this->options['resource_files']);
parent::__construct($container->getParameter('kernel.default_locale'), $selector, $this->options['cache_dir'], $this->options['debug']);
}
@@ -93,6 +100,11 @@ class Translator extends BaseTranslator implements WarmableInterface
}
}
public function addResource($format, $resource, $locale, $domain = null)
{
$this->resources[] = array($format, $resource, $locale, $domain);
}
/**
* {@inheritdoc}
*/
@@ -104,7 +116,12 @@ class Translator extends BaseTranslator implements WarmableInterface
protected function initialize()
{
$this->loadResources();
foreach ($this->resources as $key => $params) {
list($format, $resource, $locale, $domain) = $params;
parent::addResource($format, $resource, $locale, $domain);
}
$this->resources = array();
foreach ($this->loaderIds as $id => $aliases) {
foreach ($aliases as $alias) {
$this->addLoader($alias, $this->container->get($id));
@@ -112,14 +129,13 @@ class Translator extends BaseTranslator implements WarmableInterface
}
}
private function loadResources()
private function addResourceFiles($filesByLocale)
{
foreach ($this->options['resource_files'] as $locale => $files) {
foreach ($filesByLocale as $locale => $files) {
foreach ($files as $key => $file) {
// filename is domain.locale.format
list($domain, $locale, $format) = explode('.', basename($file), 3);
$this->addResource($format, $file, $locale, $domain);
unset($this->options['resource_files'][$locale][$key]);
}
}
}