updated core and modules

This commit is contained in:
Bachir Soussi Chiadmi
2017-09-09 16:27:51 +02:00
parent 027aa99b32
commit 41863f872c
7810 changed files with 318922 additions and 83631 deletions
@@ -83,7 +83,6 @@ abstract class AbstractOperation implements OperationInterface
$this->source = $source;
$this->target = $target;
$this->result = new MessageCatalogue($source->getLocale());
$this->domains = null;
$this->messages = array();
}
+3 -3
View File
@@ -17,7 +17,7 @@ namespace Symfony\Component\Translation\Catalogue;
* all = intersection ∪ (target ∖ intersection) = target
* new = all ∖ source = {x: x ∈ target ∧ x ∉ source}
* obsolete = source ∖ all = source ∖ target = {x: x ∈ source ∧ x ∉ target}
* Basically, the result contains messages from the target catalogue.
* Basically, the result contains messages from the target catalogue.
*
* @author Michael Lee <michael.lee@zerustech.com>
*/
@@ -34,12 +34,12 @@ class TargetOperation extends AbstractOperation
'obsolete' => array(),
);
// For 'all' messages, the code can't be simplified as ``$this->messages[$domain]['all'] = $target->all($domain);``,
// For 'all' messages, the code can't be simplified as ``$this->messages[$domain]['all'] = $target->all($domain);``,
// because doing so will drop messages like {x: x ∈ source ∧ x ∉ target.all ∧ x ∈ target.fallback}
//
// For 'new' messages, the code can't be simplied as ``array_diff_assoc($this->target->all($domain), $this->source->all($domain));``
// because doing so will not exclude messages like {x: x ∈ target ∧ x ∉ source.all ∧ x ∈ source.fallback}
//
//
// For 'obsolete' messages, the code can't be simplifed as ``array_diff_assoc($this->source->all($domain), $this->target->all($domain))``
// because doing so will not exclude messages like {x: x ∈ source ∧ x ∉ target.all ∧ x ∈ target.fallback}
+16 -2
View File
@@ -88,6 +88,20 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
return $this->translator->getCatalogue($locale);
}
/**
* Gets the fallback locales.
*
* @return array $locales The fallback locales
*/
public function getFallbackLocales()
{
if ($this->translator instanceof Translator) {
return $this->translator->getFallbackLocales();
}
return array();
}
/**
* Passes through all unknown calls onto the translator object.
*/
@@ -126,14 +140,14 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
} elseif ($catalogue->has($id, $domain)) {
$state = self::MESSAGE_EQUALS_FALLBACK;
$fallbackCatalogue = $catalogue->getFallBackCatalogue();
$fallbackCatalogue = $catalogue->getFallbackCatalogue();
while ($fallbackCatalogue) {
if ($fallbackCatalogue->defines($id, $domain)) {
$locale = $fallbackCatalogue->getLocale();
break;
}
$fallbackCatalogue = $fallbackCatalogue->getFallBackCatalogue();
$fallbackCatalogue = $fallbackCatalogue->getFallbackCatalogue();
}
} else {
$state = self::MESSAGE_MISSING;
+1 -1
View File
@@ -44,7 +44,7 @@ class IcuResFileDumper extends FileDumper
foreach ($messages->all($domain) as $source => $target) {
$indexes .= pack('v', strlen($data) + 28);
$data .= $source."\0";
$data .= $source."\0";
}
$data .= $this->writePadding($data);
+1 -1
View File
@@ -36,7 +36,7 @@ class MoFileDumper extends FileDumper
*/
public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
{
$output = $sources = $targets = $sourceOffsets = $targetOffsets = '';
$sources = $targets = $sourceOffsets = $targetOffsets = '';
$offsets = array();
$size = 0;
@@ -54,9 +54,9 @@ abstract class AbstractFileExtractor
/**
* @param string $file
*
* @throws \InvalidArgumentException
*
* @return bool
*
* @throws \InvalidArgumentException
*/
protected function isFile($file)
{
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2004-2016 Fabien Potencier
Copyright (c) 2004-2017 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+3 -3
View File
@@ -37,7 +37,7 @@ class MoFileLoader extends FileLoader
/**
* The size of the header of a MO file in bytes.
*
* @var int Number of bytes.
* @var int Number of bytes
*/
const MO_HEADER_SIZE = 28;
@@ -80,7 +80,7 @@ class MoFileLoader extends FileLoader
$messages = array();
for ($i = 0; $i < $count; ++$i) {
$singularId = $pluralId = null;
$pluralId = null;
$translated = null;
fseek($stream, $offsetId + $i * 8);
@@ -137,7 +137,7 @@ class MoFileLoader extends FileLoader
}
/**
* Reads an unsigned long from stream respecting endianess.
* Reads an unsigned long from stream respecting endianness.
*
* @param resource $stream
* @param bool $isBigEndian
+9
View File
@@ -160,20 +160,29 @@ class XliffFileLoader implements LoaderInterface
}
/**
* Validates and parses the given file into a DOMDocument.
*
* @param string $file
* @param \DOMDocument $dom
* @param string $schema source of the schema
*
* @throws \RuntimeException
* @throws InvalidResourceException
*/
private function validateSchema($file, \DOMDocument $dom, $schema)
{
$internalErrors = libxml_use_internal_errors(true);
$disableEntities = libxml_disable_entity_loader(false);
if (!@$dom->schemaValidateSource($schema)) {
libxml_disable_entity_loader($disableEntities);
throw new InvalidResourceException(sprintf('Invalid resource provided: "%s"; Errors: %s', $file, implode("\n", $this->getXmlErrors($internalErrors))));
}
libxml_disable_entity_loader($disableEntities);
$dom->normalizeDocument();
libxml_clear_errors();
+14
View File
@@ -88,6 +88,20 @@ class LoggingTranslator implements TranslatorInterface, TranslatorBagInterface
return $this->translator->getCatalogue($locale);
}
/**
* Gets the fallback locales.
*
* @return array $locales The fallback locales
*/
public function getFallbackLocales()
{
if ($this->translator instanceof Translator) {
return $this->translator->getFallbackLocales();
}
return array();
}
/**
* Passes through all unknown calls onto the translator object.
*/
+4
View File
@@ -178,6 +178,10 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf
if ($c->getLocale() === $catalogue->getLocale()) {
throw new \LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale()));
}
foreach ($catalogue->getResources() as $resource) {
$c->addResource($resource);
}
} while ($c = $c->parent);
$catalogue->parent = $this;
+3 -3
View File
@@ -105,7 +105,7 @@ interface MessageCatalogueInterface
*
* The two catalogues must have the same locale.
*
* @param MessageCatalogueInterface $catalogue A MessageCatalogueInterface instance
* @param self $catalogue
*/
public function addCatalogue(MessageCatalogueInterface $catalogue);
@@ -115,14 +115,14 @@ interface MessageCatalogueInterface
*
* This is used to provide default translations when they do not exist for the current locale.
*
* @param MessageCatalogueInterface $catalogue A MessageCatalogueInterface instance
* @param self $catalogue
*/
public function addFallbackCatalogue(MessageCatalogueInterface $catalogue);
/**
* Gets the fallback catalogue.
*
* @return MessageCatalogueInterface|null A MessageCatalogueInterface instance or null when no fallback has been set
* @return self|null A MessageCatalogueInterface instance or null when no fallback has been set
*/
public function getFallbackCatalogue();
+5 -5
View File
@@ -159,7 +159,7 @@ class Translator implements TranslatorInterface, TranslatorBagInterface
*
* @throws \InvalidArgumentException If a locale contains invalid characters
*
* @deprecated since version 2.3, to be removed in 3.0. Use setFallbackLocales() instead.
* @deprecated since version 2.3, to be removed in 3.0. Use setFallbackLocales() instead
*/
public function setFallbackLocale($locales)
{
@@ -380,9 +380,9 @@ EOF
$fallbackSuffix = ucfirst(preg_replace($replacementPattern, '_', $fallback));
$currentSuffix = ucfirst(preg_replace($replacementPattern, '_', $current));
$fallbackContent .= sprintf(<<<EOF
\$catalogue%s = new MessageCatalogue('%s', %s);
\$catalogue%s->addFallbackCatalogue(\$catalogue%s);
$fallbackContent .= sprintf(<<<'EOF'
$catalogue%s = new MessageCatalogue('%s', %s);
$catalogue%s->addFallbackCatalogue($catalogue%s);
EOF
,
@@ -424,7 +424,7 @@ EOF
foreach ($this->computeFallbackLocales($locale) as $fallback) {
if (!isset($this->catalogues[$fallback])) {
$this->doLoadCatalogue($fallback);
$this->loadCatalogue($fallback);
}
$fallbackCatalogue = new MessageCatalogue($fallback, $this->catalogues[$fallback]->all());
+2 -2
View File
@@ -23,9 +23,9 @@ interface TranslatorBagInterface
*
* @param string|null $locale The locale or null to use the default
*
* @throws \InvalidArgumentException If the locale contains invalid characters
*
* @return MessageCatalogueInterface
*
* @throws \InvalidArgumentException If the locale contains invalid characters
*/
public function getCatalogue($locale = null);
}
+4 -4
View File
@@ -26,9 +26,9 @@ interface TranslatorInterface
* @param string|null $domain The domain for the message or null to use the default
* @param string|null $locale The locale or null to use the default
*
* @throws \InvalidArgumentException If the locale contains invalid characters
*
* @return string The translated string
*
* @throws \InvalidArgumentException If the locale contains invalid characters
*/
public function trans($id, array $parameters = array(), $domain = null, $locale = null);
@@ -41,9 +41,9 @@ interface TranslatorInterface
* @param string|null $domain The domain for the message or null to use the default
* @param string|null $locale The locale or null to use the default
*
* @throws \InvalidArgumentException If the locale contains invalid characters
*
* @return string The translated string
*
* @throws \InvalidArgumentException If the locale contains invalid characters
*/
public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null);
+1 -1
View File
@@ -62,7 +62,7 @@ class ArrayConverter
* $tree['foo'] was string before we found array {bar: test2}.
* Treat new element as string too, e.g. add $tree['foo.bar'] = 'test2';
*/
$elem = &$elem[ implode('.', array_slice($parts, $i)) ];
$elem = &$elem[implode('.', array_slice($parts, $i))];
break;
}
$parentOfElem = &$elem;
+1 -1
View File
@@ -21,7 +21,7 @@
},
"require-dev": {
"symfony/config": "~2.8",
"symfony/intl": "~2.4|~3.0.0",
"symfony/intl": "~2.7.25|^2.8.18|~3.2.5",
"symfony/yaml": "~2.2|~3.0.0",
"psr/log": "~1.0"
},