update patch 1

This commit is contained in:
fiqhpratama
2024-12-02 01:18:34 +07:00
parent 453d9bb470
commit 25026b0a85
3380 changed files with 103529 additions and 363623 deletions
+12 -16
View File
@@ -54,12 +54,6 @@ class Translator implements TranslatorInterface, TranslatorBagInterface, LocaleA
private MessageFormatterInterface $formatter;
private ?string $cacheDir;
private bool $debug;
private array $cacheVary;
private ?ConfigCacheFactoryInterface $configCacheFactory;
private array $parentLocales;
@@ -69,14 +63,16 @@ class Translator implements TranslatorInterface, TranslatorBagInterface, LocaleA
/**
* @throws InvalidArgumentException If a locale contains invalid characters
*/
public function __construct(string $locale, ?MessageFormatterInterface $formatter = null, ?string $cacheDir = null, bool $debug = false, array $cacheVary = [])
{
public function __construct(
string $locale,
?MessageFormatterInterface $formatter = null,
private ?string $cacheDir = null,
private bool $debug = false,
private array $cacheVary = [],
) {
$this->setLocale($locale);
$this->formatter = $formatter ??= new MessageFormatter();
$this->cacheDir = $cacheDir;
$this->debug = $debug;
$this->cacheVary = $cacheVary;
$this->hasIntlFormatter = $formatter instanceof IntlFormatterInterface;
}
@@ -272,7 +268,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface, LocaleA
$this->initializeCatalogue($locale);
$fallbackContent = $this->getFallbackContent($this->catalogues[$locale]);
$content = sprintf(<<<EOF
$content = \sprintf(<<<EOF
<?php
use Symfony\Component\Translation\MessageCatalogue;
@@ -303,7 +299,7 @@ EOF
$fallbackSuffix = ucfirst(preg_replace($replacementPattern, '_', $fallback));
$currentSuffix = ucfirst(preg_replace($replacementPattern, '_', $current));
$fallbackContent .= sprintf(<<<'EOF'
$fallbackContent .= \sprintf(<<<'EOF'
$catalogue%s = new MessageCatalogue('%s', %s);
$catalogue%s->addFallbackCatalogue($catalogue%s);
@@ -338,10 +334,10 @@ EOF
foreach ($this->resources[$locale] as $resource) {
if (!isset($this->loaders[$resource[0]])) {
if (\is_string($resource[1])) {
throw new RuntimeException(sprintf('No loader is registered for the "%s" format when loading the "%s" resource.', $resource[0], $resource[1]));
throw new RuntimeException(\sprintf('No loader is registered for the "%s" format when loading the "%s" resource.', $resource[0], $resource[1]));
}
throw new RuntimeException(sprintf('No loader is registered for the "%s" format.', $resource[0]));
throw new RuntimeException(\sprintf('No loader is registered for the "%s" format.', $resource[0]));
}
$this->catalogues[$locale]->addCatalogue($this->loaders[$resource[0]]->load($resource[1], $locale, $resource[2]));
}
@@ -415,7 +411,7 @@ EOF
protected function assertValidLocale(string $locale): void
{
if (!preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) {
throw new InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale));
throw new InvalidArgumentException(\sprintf('Invalid "%s" locale.', $locale));
}
}