X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Ftranslation%2FTranslator.php;h=5f8eb033040b7782ad00fa1438198a6b1edfdea3;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=0e3dd06c5d39f551d873cf7e80cd88a704c7c3ee;hpb=eba34333e3c89f208d2f72fa91351ad019a71583;p=yaffs-website diff --git a/vendor/symfony/translation/Translator.php b/vendor/symfony/translation/Translator.php index 0e3dd06c5..5f8eb0330 100644 --- a/vendor/symfony/translation/Translator.php +++ b/vendor/symfony/translation/Translator.php @@ -13,6 +13,8 @@ namespace Symfony\Component\Translation; use Symfony\Component\Translation\Loader\LoaderInterface; use Symfony\Component\Translation\Exception\NotFoundResourceException; +use Symfony\Component\Translation\Exception\InvalidArgumentException; +use Symfony\Component\Translation\Exception\RuntimeException; use Symfony\Component\Config\ConfigCacheInterface; use Symfony\Component\Config\ConfigCacheFactoryInterface; use Symfony\Component\Config\ConfigCacheFactory; @@ -32,7 +34,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface /** * @var string */ - protected $locale; + private $locale; /** * @var array @@ -77,7 +79,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface * @param string|null $cacheDir The directory to use for the cache * @param bool $debug Use cache in debug mode ? * - * @throws \InvalidArgumentException If a locale contains invalid characters + * @throws InvalidArgumentException If a locale contains invalid characters */ public function __construct($locale, MessageSelector $selector = null, $cacheDir = null, $debug = false) { @@ -116,7 +118,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface * @param string $locale The locale * @param string $domain The domain * - * @throws \InvalidArgumentException If the locale contains invalid characters + * @throws InvalidArgumentException If the locale contains invalid characters */ public function addResource($format, $resource, $locale, $domain = null) { @@ -152,28 +154,12 @@ class Translator implements TranslatorInterface, TranslatorBagInterface return $this->locale; } - /** - * Sets the fallback locale(s). - * - * @param string|array $locales The fallback locale(s) - * - * @throws \InvalidArgumentException If a locale contains invalid characters - * - * @deprecated since version 2.3, to be removed in 3.0. Use setFallbackLocales() instead - */ - public function setFallbackLocale($locales) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.3 and will be removed in 3.0. Use the setFallbackLocales() method instead.', E_USER_DEPRECATED); - - $this->setFallbackLocales(is_array($locales) ? $locales : array($locales)); - } - /** * Sets the fallback locales. * * @param array $locales The fallback locales * - * @throws \InvalidArgumentException If a locale contains invalid characters + * @throws InvalidArgumentException If a locale contains invalid characters */ public function setFallbackLocales(array $locales) { @@ -214,6 +200,10 @@ class Translator implements TranslatorInterface, TranslatorBagInterface */ public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null) { + $parameters = array_merge(array( + '%count%' => $number, + ), $parameters); + if (null === $domain) { $domain = 'messages'; } @@ -261,28 +251,6 @@ class Translator implements TranslatorInterface, TranslatorBagInterface return $this->loaders; } - /** - * Collects all messages for the given locale. - * - * @param string|null $locale Locale of translations, by default is current locale - * - * @return array[array] indexed by catalog - * - * @deprecated since version 2.8, to be removed in 3.0. Use TranslatorBagInterface::getCatalogue() method instead. - */ - public function getMessages($locale = null) - { - @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use TranslatorBagInterface::getCatalogue() method instead.', E_USER_DEPRECATED); - - $catalogue = $this->getCatalogue($locale); - $messages = $catalogue->all(); - while ($catalogue = $catalogue->getFallbackCatalogue()) { - $messages = array_replace_recursive($catalogue->all(), $messages); - } - - return $messages; - } - /** * @param string $locale */ @@ -323,10 +291,9 @@ class Translator implements TranslatorInterface, TranslatorBagInterface } $this->assertValidLocale($locale); - $self = $this; // required for PHP 5.3 where "$this" cannot be use()d in anonymous functions. Change in Symfony 3.0. $cache = $this->getConfigCacheFactory()->cache($this->getCatalogueCachePath($locale), - function (ConfigCacheInterface $cache) use ($self, $locale) { - $self->dumpCatalogue($locale, $cache); + function (ConfigCacheInterface $cache) use ($locale) { + $this->dumpCatalogue($locale, $cache); } ); @@ -339,12 +306,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface $this->catalogues[$locale] = include $cache->getPath(); } - /** - * This method is public because it needs to be callable from a closure in PHP 5.3. It should be made protected (or even private, if possible) in 3.0. - * - * @internal - */ - public function dumpCatalogue($locale, ConfigCacheInterface $cache) + private function dumpCatalogue($locale, ConfigCacheInterface $cache) { $this->initializeCatalogue($locale); $fallbackContent = $this->getFallbackContent($this->catalogues[$locale]); @@ -411,7 +373,7 @@ EOF if (isset($this->resources[$locale])) { foreach ($this->resources[$locale] as $resource) { if (!isset($this->loaders[$resource[0]])) { - throw new \RuntimeException(sprintf('The "%s" translation loader is not registered.', $resource[0])); + throw new RuntimeException(sprintf('The "%s" translation loader is not registered.', $resource[0])); } $this->catalogues[$locale]->addCatalogue($this->loaders[$resource[0]]->load($resource[1], $locale, $resource[2])); } @@ -459,12 +421,12 @@ EOF * * @param string $locale Locale to tests * - * @throws \InvalidArgumentException If the locale contains invalid characters + * @throws InvalidArgumentException If the locale contains invalid characters */ protected function assertValidLocale($locale) { if (1 !== preg_match('/^[a-z0-9@_\\.\\-]*$/i', $locale)) { - throw new \InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale)); + throw new InvalidArgumentException(sprintf('Invalid "%s" locale.', $locale)); } }