From 866c306dc860b6b5bf436d9dc9a67c5764bfe504 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 24 Sep 2010 16:34:58 +0200 Subject: [PATCH] removed the message interpolator system in the Validator component (i18n management should be done globally, not in a specific component) --- .../FrameworkExtension.php | 13 - .../Resources/config/validator.xml | 6 - .../Form/Resources/config/validation.xml | 10 +- .../Form/Resources/i18n/messages.en.xml | 23 - .../Validator/ConstraintViolation.php | 27 +- .../Validator/Constraints/AssertFalse.php | 2 +- .../Validator/Constraints/AssertTrue.php | 2 +- .../Validator/Constraints/AssertType.php | 2 +- .../Component/Validator/Constraints/Blank.php | 2 +- .../Validator/Constraints/Choice.php | 6 +- .../Validator/Constraints/Collection.php | 4 +- .../Component/Validator/Constraints/Date.php | 2 +- .../Validator/Constraints/DateTime.php | 2 +- .../Component/Validator/Constraints/Email.php | 2 +- .../Component/Validator/Constraints/File.php | 8 +- .../Component/Validator/Constraints/Max.php | 2 +- .../Validator/Constraints/MaxLength.php | 2 +- .../Component/Validator/Constraints/Min.php | 2 +- .../Validator/Constraints/MinLength.php | 2 +- .../Validator/Constraints/NotBlank.php | 2 +- .../Validator/Constraints/NotNull.php | 2 +- .../Component/Validator/Constraints/Null.php | 2 +- .../Component/Validator/Constraints/Regex.php | 2 +- .../Component/Validator/Constraints/Time.php | 2 +- .../Component/Validator/Constraints/Url.php | 2 +- .../Component/Validator/Constraints/Valid.php | 2 +- .../Component/Validator/GraphWalker.php | 5 +- .../MessageInterpolatorInterface.php | 15 - .../XliffMessageInterpolator.php | 103 - .../dic/xliff-core/xliff-core-1.2-strict.xsd | 2223 ----------------- .../schema/dic/xliff-core/xml.xsd | 309 --- .../Validator/Resources/i18n/messages.en.xml | 115 - .../Component/Validator/ValidationContext.php | 9 +- src/Symfony/Component/Validator/Validator.php | 8 +- .../Constraints/AllValidatorTest.php | 3 +- .../Constraints/ChoiceValidatorTest.php | 3 +- .../Constraints/CollectionValidatorTest.php | 3 +- .../Constraints/ValidValidatorTest.php | 3 +- .../Component/Validator/GraphWalkerTest.php | 12 +- .../XliffMessageInterpolatorTest.php | 39 - .../Validator/MessageInterpolator/xliff.xml | 11 - .../Validator/MessageInterpolator/xliff2.xml | 11 - 42 files changed, 69 insertions(+), 2936 deletions(-) delete mode 100644 src/Symfony/Component/Form/Resources/i18n/messages.en.xml delete mode 100644 src/Symfony/Component/Validator/MessageInterpolator/MessageInterpolatorInterface.php delete mode 100644 src/Symfony/Component/Validator/MessageInterpolator/XliffMessageInterpolator.php delete mode 100644 src/Symfony/Component/Validator/MessageInterpolator/schema/dic/xliff-core/xliff-core-1.2-strict.xsd delete mode 100644 src/Symfony/Component/Validator/MessageInterpolator/schema/dic/xliff-core/xml.xsd delete mode 100644 src/Symfony/Component/Validator/Resources/i18n/messages.en.xml delete mode 100644 tests/Symfony/Tests/Component/Validator/MessageInterpolator/XliffMessageInterpolatorTest.php delete mode 100644 tests/Symfony/Tests/Component/Validator/MessageInterpolator/xliff.xml delete mode 100644 tests/Symfony/Tests/Component/Validator/MessageInterpolator/xliff2.xml diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 1d0ba8a309..e5f9f9b193 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -344,12 +344,9 @@ class FrameworkExtension extends Extension $xmlMappingFiles = array(); $yamlMappingFiles = array(); - $messageFiles = array(); // default entries by the framework $xmlMappingFiles[] = __DIR__.'/../../../Component/Form/Resources/config/validation.xml'; - $messageFiles[] = __DIR__ . '/../../../Component/Validator/Resources/i18n/messages.en.xml'; - $messageFiles[] = __DIR__ . '/../../../Component/Form/Resources/i18n/messages.en.xml'; foreach ($container->getParameter('kernel.bundles') as $className) { $tmp = dirname(str_replace('\\', '/', $className)); @@ -363,11 +360,6 @@ class FrameworkExtension extends Extension if (file_exists($file = $dir.'/'.$bundle.'/Resources/config/validation.yml')) { $yamlMappingFiles[] = realpath($file); } - - // TODO do we really want the message files of all cultures? - foreach (glob($dir.'/'.$bundle.'/Resources/i18n/messages.*.xml') as $file) { - $messageFiles[] = realpath($file); - } } } @@ -383,7 +375,6 @@ class FrameworkExtension extends Extension $container->setDefinition('validator.mapping.loader.xml_files_loader', $xmlFilesLoader); $container->setDefinition('validator.mapping.loader.yaml_files_loader', $yamlFilesLoader); - $container->setParameter('validator.message_interpolator.files', $messageFiles); foreach ($xmlMappingFiles as $file) { $container->addResource(new FileResource($file)); @@ -393,10 +384,6 @@ class FrameworkExtension extends Extension $container->addResource(new FileResource($file)); } - foreach ($messageFiles as $file) { - $container->addResource(new FileResource($file)); - } - if (isset($config['validation']['annotations']) && $config['validation']['annotations'] === true) { $annotationLoader = new Definition($container->getParameter('validator.mapping.loader.annotation_loader.class')); $container->setDefinition('validator.mapping.loader.annotation_loader', $annotationLoader); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml index de62cb120c..dc152a4b4a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml @@ -7,7 +7,6 @@ Symfony\Component\Validator\Validator Symfony\Component\Validator\Extension\DependencyInjectionValidatorFactory - Symfony\Component\Validator\MessageInterpolator\XliffMessageInterpolator Symfony\Component\Validator\Mapping\ClassMetadataFactory Symfony\Component\Validator\Mapping\Loader\LoaderChain Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader @@ -23,7 +22,6 @@ - - - %validator.message_interpolator.files% - - diff --git a/src/Symfony/Component/Form/Resources/config/validation.xml b/src/Symfony/Component/Form/Resources/config/validation.xml index b09b2ff34c..8795dd041a 100644 --- a/src/Symfony/Component/Form/Resources/config/validation.xml +++ b/src/Symfony/Component/Form/Resources/config/validation.xml @@ -10,7 +10,7 @@ - + @@ -21,12 +21,12 @@ - + - + @@ -34,8 +34,8 @@ - + - \ No newline at end of file + diff --git a/src/Symfony/Component/Form/Resources/i18n/messages.en.xml b/src/Symfony/Component/Form/Resources/i18n/messages.en.xml deleted file mode 100644 index eccf989f1e..0000000000 --- a/src/Symfony/Component/Form/Resources/i18n/messages.en.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - Symfony.Form.FieldGroup.extraFieldsMessage - This field group should not contain extra fields - - - Symfony.Form.Form.postMaxSizeMessage - The uploaded file was too large. Please try to upload a smaller file. - - - Symfony.Form.Form.csrfInvalidMessage - The CSRF token is invalid - - - Symfony.Form.RepeatedField.invalidMessage - The two values should be equal - - - - \ No newline at end of file diff --git a/src/Symfony/Component/Validator/ConstraintViolation.php b/src/Symfony/Component/Validator/ConstraintViolation.php index 9042118af2..b5c9a1349b 100644 --- a/src/Symfony/Component/Validator/ConstraintViolation.php +++ b/src/Symfony/Component/Validator/ConstraintViolation.php @@ -4,22 +4,41 @@ namespace Symfony\Component\Validator; class ConstraintViolation { - protected $message; + protected $messageTemplate; + protected $messageParameters; protected $root; protected $propertyPath; protected $invalidValue; - public function __construct($message, $root, $propertyPath, $invalidValue) + public function __construct($messageTemplate, array $messageParameters, $root, $propertyPath, $invalidValue) { - $this->message = $message; + $this->messageTemplate = $messageTemplate; + $this->messageParameters = $messageParameters; $this->root = $root; $this->propertyPath = $propertyPath; $this->invalidValue = $invalidValue; } + public function getMessageTemplate() + { + return $this->messageTemplate; + } + + public function getMessageParameters() + { + return $this->messageParameters; + } + public function getMessage() { - return $this->message; + $sources = array(); + $targets = array(); + foreach ($this->messageParameters as $key => $value) { + $sources[] = '%'.$key.'%'; + $targets[] = (string) $value; + } + + return str_replace($sources, $targets, $this->messageTemplate); } public function getRoot() diff --git a/src/Symfony/Component/Validator/Constraints/AssertFalse.php b/src/Symfony/Component/Validator/Constraints/AssertFalse.php index faa00e98f8..a894acc01a 100644 --- a/src/Symfony/Component/Validator/Constraints/AssertFalse.php +++ b/src/Symfony/Component/Validator/Constraints/AssertFalse.php @@ -4,5 +4,5 @@ namespace Symfony\Component\Validator\Constraints; class AssertFalse extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.AssertFalse.message'; + public $message = 'This value should be false'; } diff --git a/src/Symfony/Component/Validator/Constraints/AssertTrue.php b/src/Symfony/Component/Validator/Constraints/AssertTrue.php index 1b5098878b..1a51801f5c 100644 --- a/src/Symfony/Component/Validator/Constraints/AssertTrue.php +++ b/src/Symfony/Component/Validator/Constraints/AssertTrue.php @@ -4,5 +4,5 @@ namespace Symfony\Component\Validator\Constraints; class AssertTrue extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.AssertTrue.message'; + public $message = 'This value should be true'; } diff --git a/src/Symfony/Component/Validator/Constraints/AssertType.php b/src/Symfony/Component/Validator/Constraints/AssertType.php index 2248c4e116..a2da3f8008 100644 --- a/src/Symfony/Component/Validator/Constraints/AssertType.php +++ b/src/Symfony/Component/Validator/Constraints/AssertType.php @@ -4,7 +4,7 @@ namespace Symfony\Component\Validator\Constraints; class AssertType extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.AssertType.message'; + public $message = 'This value should be of type %type%'; public $type; /** diff --git a/src/Symfony/Component/Validator/Constraints/Blank.php b/src/Symfony/Component/Validator/Constraints/Blank.php index 2d00ada8cc..714a731ae2 100644 --- a/src/Symfony/Component/Validator/Constraints/Blank.php +++ b/src/Symfony/Component/Validator/Constraints/Blank.php @@ -4,5 +4,5 @@ namespace Symfony\Component\Validator\Constraints; class Blank extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.Blank.message'; + public $message = 'This value should be blank'; } diff --git a/src/Symfony/Component/Validator/Constraints/Choice.php b/src/Symfony/Component/Validator/Constraints/Choice.php index 7bc9814e00..e6cb9cf4ff 100644 --- a/src/Symfony/Component/Validator/Constraints/Choice.php +++ b/src/Symfony/Component/Validator/Constraints/Choice.php @@ -17,9 +17,9 @@ class Choice extends \Symfony\Component\Validator\Constraint public $multiple = false; public $min = null; public $max = null; - public $message = 'Symfony.Validator.Choice.message'; - public $minMessage = 'Symfony.Validator.Choice.minMessage'; - public $maxMessage = 'Symfony.Validator.Choice.maxMessage'; + public $message = 'This value should be one of the given choices'; + public $minMessage = 'You should select at least %limit% choices'; + public $maxMessage = 'You should select at most %limit% choices'; /** * {@inheritDoc} diff --git a/src/Symfony/Component/Validator/Constraints/Collection.php b/src/Symfony/Component/Validator/Constraints/Collection.php index 4d1241f660..cdef716762 100644 --- a/src/Symfony/Component/Validator/Constraints/Collection.php +++ b/src/Symfony/Component/Validator/Constraints/Collection.php @@ -7,8 +7,8 @@ class Collection extends \Symfony\Component\Validator\Constraint public $fields; public $allowExtraFields = false; public $allowMissingFields = false; - public $extraFieldsMessage = 'Symfony.Validator.Collection.extraFieldsMessage'; - public $missingFieldsMessage = 'Symfony.Validator.Collection.missingFieldsMessage'; + public $extraFieldsMessage = 'The fields %fields% were not expected'; + public $missingFieldsMessage = 'The fields %fields% are missing'; public function requiredOptions() { diff --git a/src/Symfony/Component/Validator/Constraints/Date.php b/src/Symfony/Component/Validator/Constraints/Date.php index bc79d6b8b8..b3391d795d 100644 --- a/src/Symfony/Component/Validator/Constraints/Date.php +++ b/src/Symfony/Component/Validator/Constraints/Date.php @@ -4,5 +4,5 @@ namespace Symfony\Component\Validator\Constraints; class Date extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.Date.message'; + public $message = 'This value is not a valid date'; } \ No newline at end of file diff --git a/src/Symfony/Component/Validator/Constraints/DateTime.php b/src/Symfony/Component/Validator/Constraints/DateTime.php index 2dc6917f18..fe326d0c52 100644 --- a/src/Symfony/Component/Validator/Constraints/DateTime.php +++ b/src/Symfony/Component/Validator/Constraints/DateTime.php @@ -4,5 +4,5 @@ namespace Symfony\Component\Validator\Constraints; class DateTime extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.DateTime.message'; + public $message = 'This value is not a valid datetime'; } \ No newline at end of file diff --git a/src/Symfony/Component/Validator/Constraints/Email.php b/src/Symfony/Component/Validator/Constraints/Email.php index c4e2016038..c86335b54e 100644 --- a/src/Symfony/Component/Validator/Constraints/Email.php +++ b/src/Symfony/Component/Validator/Constraints/Email.php @@ -4,6 +4,6 @@ namespace Symfony\Component\Validator\Constraints; class Email extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.Email.message'; + public $message = 'This value is not a valid email address'; public $checkMX = false; } \ No newline at end of file diff --git a/src/Symfony/Component/Validator/Constraints/File.php b/src/Symfony/Component/Validator/Constraints/File.php index 950b652c4e..73c1896544 100644 --- a/src/Symfony/Component/Validator/Constraints/File.php +++ b/src/Symfony/Component/Validator/Constraints/File.php @@ -6,8 +6,8 @@ class File extends \Symfony\Component\Validator\Constraint { public $maxSize = null; public $mimeTypes = array(); - public $notFoundMessage = 'Symfony.Validator.File.notFoundMessage'; - public $notReadableMessage = 'Symfony.Validator.File.notReadableMessage'; - public $maxSizeMessage = 'Symfony.Validator.File.maxSizeMessage'; - public $mimeTypesMessage = 'Symfony.Validator.File.mimeTypesMessage'; + public $notFoundMessage = 'The file could not be found'; + public $notReadableMessage = 'The file is not readable'; + public $maxSizeMessage = 'The file is too large (%size%). Allowed maximum size is %limit%'; + public $mimeTypesMessage = 'The mime type of the file is invalid (%type%). Allowed mime types are %types%'; } diff --git a/src/Symfony/Component/Validator/Constraints/Max.php b/src/Symfony/Component/Validator/Constraints/Max.php index 5fff7cd315..e1e62e660b 100644 --- a/src/Symfony/Component/Validator/Constraints/Max.php +++ b/src/Symfony/Component/Validator/Constraints/Max.php @@ -4,7 +4,7 @@ namespace Symfony\Component\Validator\Constraints; class Max extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.Max.message'; + public $message = 'This value should be %limit% or less'; public $limit; /** diff --git a/src/Symfony/Component/Validator/Constraints/MaxLength.php b/src/Symfony/Component/Validator/Constraints/MaxLength.php index fd3c68aa47..554356d6db 100644 --- a/src/Symfony/Component/Validator/Constraints/MaxLength.php +++ b/src/Symfony/Component/Validator/Constraints/MaxLength.php @@ -4,7 +4,7 @@ namespace Symfony\Component\Validator\Constraints; class MaxLength extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.MaxLength.message'; + public $message = 'This value is too long. It should have %limit% characters or less'; public $limit; public $charset = 'UTF-8'; diff --git a/src/Symfony/Component/Validator/Constraints/Min.php b/src/Symfony/Component/Validator/Constraints/Min.php index 72482b122a..6b1edc05c3 100644 --- a/src/Symfony/Component/Validator/Constraints/Min.php +++ b/src/Symfony/Component/Validator/Constraints/Min.php @@ -4,7 +4,7 @@ namespace Symfony\Component\Validator\Constraints; class Min extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.Min.message'; + public $message = 'This value should be %limit% or more'; public $limit; /** diff --git a/src/Symfony/Component/Validator/Constraints/MinLength.php b/src/Symfony/Component/Validator/Constraints/MinLength.php index eefdd865d4..368aa24519 100644 --- a/src/Symfony/Component/Validator/Constraints/MinLength.php +++ b/src/Symfony/Component/Validator/Constraints/MinLength.php @@ -4,7 +4,7 @@ namespace Symfony\Component\Validator\Constraints; class MinLength extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.MinLength.message'; + public $message = 'This value is too short. It should have %limit% characters or more'; public $limit; public $charset = 'UTF-8'; diff --git a/src/Symfony/Component/Validator/Constraints/NotBlank.php b/src/Symfony/Component/Validator/Constraints/NotBlank.php index 5eec10ade6..9fab3b7163 100644 --- a/src/Symfony/Component/Validator/Constraints/NotBlank.php +++ b/src/Symfony/Component/Validator/Constraints/NotBlank.php @@ -4,5 +4,5 @@ namespace Symfony\Component\Validator\Constraints; class NotBlank extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.NotBlank.message'; + public $message = 'This value should not be blank'; } diff --git a/src/Symfony/Component/Validator/Constraints/NotNull.php b/src/Symfony/Component/Validator/Constraints/NotNull.php index 06963ef5a2..816ace17d5 100644 --- a/src/Symfony/Component/Validator/Constraints/NotNull.php +++ b/src/Symfony/Component/Validator/Constraints/NotNull.php @@ -4,5 +4,5 @@ namespace Symfony\Component\Validator\Constraints; class NotNull extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.NotNull.message'; + public $message = 'This value should not be null'; } diff --git a/src/Symfony/Component/Validator/Constraints/Null.php b/src/Symfony/Component/Validator/Constraints/Null.php index cabaef1e7d..c042a4277b 100644 --- a/src/Symfony/Component/Validator/Constraints/Null.php +++ b/src/Symfony/Component/Validator/Constraints/Null.php @@ -4,5 +4,5 @@ namespace Symfony\Component\Validator\Constraints; class Null extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.Null.message'; + public $message = 'This value should be null'; } diff --git a/src/Symfony/Component/Validator/Constraints/Regex.php b/src/Symfony/Component/Validator/Constraints/Regex.php index 2022f824e9..af74749d94 100644 --- a/src/Symfony/Component/Validator/Constraints/Regex.php +++ b/src/Symfony/Component/Validator/Constraints/Regex.php @@ -4,7 +4,7 @@ namespace Symfony\Component\Validator\Constraints; class Regex extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.Regex.message'; + public $message = 'This value is not valid'; public $pattern; public $match = true; diff --git a/src/Symfony/Component/Validator/Constraints/Time.php b/src/Symfony/Component/Validator/Constraints/Time.php index 03d841e1f9..26e07cefab 100644 --- a/src/Symfony/Component/Validator/Constraints/Time.php +++ b/src/Symfony/Component/Validator/Constraints/Time.php @@ -4,5 +4,5 @@ namespace Symfony\Component\Validator\Constraints; class Time extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.Time.message'; + public $message = 'This value is not a valid time'; } \ No newline at end of file diff --git a/src/Symfony/Component/Validator/Constraints/Url.php b/src/Symfony/Component/Validator/Constraints/Url.php index 359c6a15b3..080dd5e02d 100644 --- a/src/Symfony/Component/Validator/Constraints/Url.php +++ b/src/Symfony/Component/Validator/Constraints/Url.php @@ -4,6 +4,6 @@ namespace Symfony\Component\Validator\Constraints; class Url extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.Url.message'; + public $message = 'This value is not a valid URL'; public $protocols = array('http', 'https', 'ftp', 'ftps'); } \ No newline at end of file diff --git a/src/Symfony/Component/Validator/Constraints/Valid.php b/src/Symfony/Component/Validator/Constraints/Valid.php index fc6b2f03a8..7e610d7bb1 100644 --- a/src/Symfony/Component/Validator/Constraints/Valid.php +++ b/src/Symfony/Component/Validator/Constraints/Valid.php @@ -4,6 +4,6 @@ namespace Symfony\Component\Validator\Constraints; class Valid extends \Symfony\Component\Validator\Constraint { - public $message = 'Symfony.Validator.Valid.message'; + public $message = 'This value should be instance of class %class%'; public $class; } \ No newline at end of file diff --git a/src/Symfony/Component/Validator/GraphWalker.php b/src/Symfony/Component/Validator/GraphWalker.php index 4f273294ca..87578b1574 100644 --- a/src/Symfony/Component/Validator/GraphWalker.php +++ b/src/Symfony/Component/Validator/GraphWalker.php @@ -10,7 +10,6 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\MemberMetadata; -use Symfony\Component\Validator\MessageInterpolator\MessageInterpolatorInterface; class GraphWalker { @@ -18,9 +17,9 @@ class GraphWalker protected $validatorFactory; protected $metadataFactory; - public function __construct($root, ClassMetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $factory, MessageInterpolatorInterface $messageInterpolator) + public function __construct($root, ClassMetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $factory) { - $this->context = new ValidationContext($root, $this, $metadataFactory, $messageInterpolator); + $this->context = new ValidationContext($root, $this, $metadataFactory); $this->validatorFactory = $factory; $this->metadataFactory = $metadataFactory; } diff --git a/src/Symfony/Component/Validator/MessageInterpolator/MessageInterpolatorInterface.php b/src/Symfony/Component/Validator/MessageInterpolator/MessageInterpolatorInterface.php deleted file mode 100644 index 3534252526..0000000000 --- a/src/Symfony/Component/Validator/MessageInterpolator/MessageInterpolatorInterface.php +++ /dev/null @@ -1,15 +0,0 @@ -parseFile($file); - $xml->registerXPathNamespace('xliff', 'urn:oasis:names:tc:xliff:document:1.2'); - - foreach ($xml->xpath('//xliff:trans-unit') as $translation) { - $this->translations[(string)$translation->source] = (string)$translation->target; - } - } - } - - /** - * {@inheritDoc} - */ - public function interpolate($text, array $parameters = array()) - { - if (isset($this->translations[$text])) { - $text = $this->translations[$text]; - } - - $sources = array(); - $targets = array(); - - foreach ($parameters as $key => $value) { - $sources[] = '%'.$key.'%'; - $targets[] = (string)$value; - } - - return str_replace($sources, $targets, $text); - } - - /** - * Validates and parses the given file into a SimpleXMLElement - * - * @param string $file - * @return SimpleXMLElement - */ - protected function parseFile($file) - { - $dom = new \DOMDocument(); - $current = libxml_use_internal_errors(true); - if (!@$dom->load($file, LIBXML_COMPACT)) { - throw new \Exception(implode("\n", $this->getXmlErrors())); - } - - $parts = explode('/', str_replace('\\', '/', __DIR__).'/schema/dic/xliff-core/xml.xsd'); - $drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts).'/' : ''; - $location = 'file:///'.$drive.implode('/', array_map('rawurlencode', $parts)); - - $source = file_get_contents(__DIR__.'/schema/dic/xliff-core/xliff-core-1.2-strict.xsd'); - $source = str_replace('http://www.w3.org/2001/xml.xsd', $location, $source); - - if (!@$dom->schemaValidateSource($source)) { - throw new \Exception(implode("\n", $this->getXmlErrors())); - } - $dom->validateOnParse = true; - $dom->normalizeDocument(); - libxml_use_internal_errors($current); - - return simplexml_import_dom($dom); - } - - /** - * Returns the XML errors of the internal XML parser - * - * @return array An array of errors - */ - protected function getXmlErrors() - { - $errors = array(); - foreach (libxml_get_errors() as $error) { - $errors[] = sprintf('[%s %s] %s (in %s - line %d, column %d)', - LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR', - $error->code, - trim($error->message), - $error->file ? $error->file : 'n/a', - $error->line, - $error->column - ); - } - - libxml_clear_errors(); - libxml_use_internal_errors(false); - - return $errors; - } -} \ No newline at end of file diff --git a/src/Symfony/Component/Validator/MessageInterpolator/schema/dic/xliff-core/xliff-core-1.2-strict.xsd b/src/Symfony/Component/Validator/MessageInterpolator/schema/dic/xliff-core/xliff-core-1.2-strict.xsd deleted file mode 100644 index 056f5f9593..0000000000 --- a/src/Symfony/Component/Validator/MessageInterpolator/schema/dic/xliff-core/xliff-core-1.2-strict.xsd +++ /dev/null @@ -1,2223 +0,0 @@ - - - - - - - - - - - - - - - Values for the attribute 'context-type'. - - - - - Indicates a database content. - - - - - Indicates the content of an element within an XML document. - - - - - Indicates the name of an element within an XML document. - - - - - Indicates the line number from the sourcefile (see context-type="sourcefile") where the <source> is found. - - - - - Indicates a the number of parameters contained within the <source>. - - - - - Indicates notes pertaining to the parameters in the <source>. - - - - - Indicates the content of a record within a database. - - - - - Indicates the name of a record within a database. - - - - - Indicates the original source file in the case that multiple files are merged to form the original file from which the XLIFF file is created. This differs from the original <file> attribute in that this sourcefile is one of many that make up that file. - - - - - - - Values for the attribute 'count-type'. - - - - - Indicates the count units are items that are used X times in a certain context; example: this is a reusable text unit which is used 42 times in other texts. - - - - - Indicates the count units are translation units existing already in the same document. - - - - - Indicates a total count. - - - - - - - Values for the attribute 'ctype' when used other elements than <ph> or <x>. - - - - - Indicates a run of bolded text. - - - - - Indicates a run of text in italics. - - - - - Indicates a run of underlined text. - - - - - Indicates a run of hyper-text. - - - - - - - Values for the attribute 'ctype' when used with <ph> or <x>. - - - - - Indicates a inline image. - - - - - Indicates a page break. - - - - - Indicates a line break. - - - - - - - - - - - - Values for the attribute 'datatype'. - - - - - Indicates Active Server Page data. - - - - - Indicates C source file data. - - - - - Indicates Channel Definition Format (CDF) data. - - - - - Indicates ColdFusion data. - - - - - Indicates C++ source file data. - - - - - Indicates C-Sharp data. - - - - - Indicates strings from C, ASM, and driver files data. - - - - - Indicates comma-separated values data. - - - - - Indicates database data. - - - - - Indicates portions of document that follows data and contains metadata. - - - - - Indicates portions of document that precedes data and contains metadata. - - - - - Indicates data from standard UI file operations dialogs (e.g., Open, Save, Save As, Export, Import). - - - - - Indicates standard user input screen data. - - - - - Indicates HyperText Markup Language (HTML) data - document instance. - - - - - Indicates content within an HTML document’s <body> element. - - - - - Indicates Windows INI file data. - - - - - Indicates Interleaf data. - - - - - Indicates Java source file data (extension '.java'). - - - - - Indicates Java property resource bundle data. - - - - - Indicates Java list resource bundle data. - - - - - Indicates JavaScript source file data. - - - - - Indicates JScript source file data. - - - - - Indicates information relating to formatting. - - - - - Indicates LISP source file data. - - - - - Indicates information relating to margin formats. - - - - - Indicates a file containing menu. - - - - - Indicates numerically identified string table. - - - - - Indicates Maker Interchange Format (MIF) data. - - - - - Indicates that the datatype attribute value is a MIME Type value and is defined in the mime-type attribute. - - - - - Indicates GNU Machine Object data. - - - - - Indicates Message Librarian strings created by Novell's Message Librarian Tool. - - - - - Indicates information to be displayed at the bottom of each page of a document. - - - - - Indicates information to be displayed at the top of each page of a document. - - - - - Indicates a list of property values (e.g., settings within INI files or preferences dialog). - - - - - Indicates Pascal source file data. - - - - - Indicates Hypertext Preprocessor data. - - - - - Indicates plain text file (no formatting other than, possibly, wrapping). - - - - - Indicates GNU Portable Object file. - - - - - Indicates dynamically generated user defined document. e.g. Oracle Report, Crystal Report, etc. - - - - - Indicates Windows .NET binary resources. - - - - - Indicates Windows .NET Resources. - - - - - Indicates Rich Text Format (RTF) data. - - - - - Indicates Standard Generalized Markup Language (SGML) data - document instance. - - - - - Indicates Standard Generalized Markup Language (SGML) data - Document Type Definition (DTD). - - - - - Indicates Scalable Vector Graphic (SVG) data. - - - - - Indicates VisualBasic Script source file. - - - - - Indicates warning message. - - - - - Indicates Windows (Win32) resources (i.e. resources extracted from an RC script, a message file, or a compiled file). - - - - - Indicates Extensible HyperText Markup Language (XHTML) data - document instance. - - - - - Indicates Extensible Markup Language (XML) data - document instance. - - - - - Indicates Extensible Markup Language (XML) data - Document Type Definition (DTD). - - - - - Indicates Extensible Stylesheet Language (XSL) data. - - - - - Indicates XUL elements. - - - - - - - Values for the attribute 'mtype'. - - - - - Indicates the marked text is an abbreviation. - - - - - ISO-12620 2.1.8: A term resulting from the omission of any part of the full term while designating the same concept. - - - - - ISO-12620 2.1.8.1: An abbreviated form of a simple term resulting from the omission of some of its letters (e.g. 'adj.' for 'adjective'). - - - - - ISO-12620 2.1.8.4: An abbreviated form of a term made up of letters from the full form of a multiword term strung together into a sequence pronounced only syllabically (e.g. 'radar' for 'radio detecting and ranging'). - - - - - ISO-12620: A proper-name term, such as the name of an agency or other proper entity. - - - - - ISO-12620 2.1.18.1: A recurrent word combination characterized by cohesion in that the components of the collocation must co-occur within an utterance or series of utterances, even though they do not necessarily have to maintain immediate proximity to one another. - - - - - ISO-12620 2.1.5: A synonym for an international scientific term that is used in general discourse in a given language. - - - - - Indicates the marked text is a date and/or time. - - - - - ISO-12620 2.1.15: An expression used to represent a concept based on a statement that two mathematical expressions are, for instance, equal as identified by the equal sign (=), or assigned to one another by a similar sign. - - - - - ISO-12620 2.1.7: The complete representation of a term for which there is an abbreviated form. - - - - - ISO-12620 2.1.14: Figures, symbols or the like used to express a concept briefly, such as a mathematical or chemical formula. - - - - - ISO-12620 2.1.1: The concept designation that has been chosen to head a terminological record. - - - - - ISO-12620 2.1.8.3: An abbreviated form of a term consisting of some of the initial letters of the words making up a multiword term or the term elements making up a compound term when these letters are pronounced individually (e.g. 'BSE' for 'bovine spongiform encephalopathy'). - - - - - ISO-12620 2.1.4: A term that is part of an international scientific nomenclature as adopted by an appropriate scientific body. - - - - - ISO-12620 2.1.6: A term that has the same or nearly identical orthographic or phonemic form in many languages. - - - - - ISO-12620 2.1.16: An expression used to represent a concept based on mathematical or logical relations, such as statements of inequality, set relationships, Boolean operations, and the like. - - - - - ISO-12620 2.1.17: A unit to track object. - - - - - Indicates the marked text is a name. - - - - - ISO-12620 2.1.3: A term that represents the same or a very similar concept as another term in the same language, but for which interchangeability is limited to some contexts and inapplicable in others. - - - - - ISO-12620 2.1.17.2: A unique alphanumeric designation assigned to an object in a manufacturing system. - - - - - Indicates the marked text is a phrase. - - - - - ISO-12620 2.1.18: Any group of two or more words that form a unit, the meaning of which frequently cannot be deduced based on the combined sense of the words making up the phrase. - - - - - Indicates the marked text should not be translated. - - - - - ISO-12620 2.1.12: A form of a term resulting from an operation whereby non-Latin writing systems are converted to the Latin alphabet. - - - - - Indicates that the marked text represents a segment. - - - - - ISO-12620 2.1.18.2: A fixed, lexicalized phrase. - - - - - ISO-12620 2.1.8.2: A variant of a multiword term that includes fewer words than the full form of the term (e.g. 'Group of Twenty-four' for 'Intergovernmental Group of Twenty-four on International Monetary Affairs'). - - - - - ISO-12620 2.1.17.1: Stock keeping unit, an inventory item identified by a unique alphanumeric designation assigned to an object in an inventory control system. - - - - - ISO-12620 2.1.19: A fixed chunk of recurring text. - - - - - ISO-12620 2.1.13: A designation of a concept by letters, numerals, pictograms or any combination thereof. - - - - - ISO-12620 2.1.2: Any term that represents the same or a very similar concept as the main entry term in a term entry. - - - - - ISO-12620 2.1.18.3: Phraseological unit in a language that expresses the same semantic content as another phrase in that same language. - - - - - Indicates the marked text is a term. - - - - - ISO-12620 2.1.11: A form of a term resulting from an operation whereby the characters of one writing system are represented by characters from another writing system, taking into account the pronunciation of the characters converted. - - - - - ISO-12620 2.1.10: A form of a term resulting from an operation whereby the characters of an alphabetic writing system are represented by characters from another alphabetic writing system. - - - - - ISO-12620 2.1.8.5: An abbreviated form of a term resulting from the omission of one or more term elements or syllables (e.g. 'flu' for 'influenza'). - - - - - ISO-12620 2.1.9: One of the alternate forms of a term. - - - - - - - Values for the attribute 'restype'. - - - - - Indicates a Windows RC AUTO3STATE control. - - - - - Indicates a Windows RC AUTOCHECKBOX control. - - - - - Indicates a Windows RC AUTORADIOBUTTON control. - - - - - Indicates a Windows RC BEDIT control. - - - - - Indicates a bitmap, for example a BITMAP resource in Windows. - - - - - Indicates a button object, for example a BUTTON control Windows. - - - - - Indicates a caption, such as the caption of a dialog box. - - - - - Indicates the cell in a table, for example the content of the <td> element in HTML. - - - - - Indicates check box object, for example a CHECKBOX control in Windows. - - - - - Indicates a menu item with an associated checkbox. - - - - - Indicates a list box, but with a check-box for each item. - - - - - Indicates a color selection dialog. - - - - - Indicates a combination of edit box and listbox object, for example a COMBOBOX control in Windows. - - - - - Indicates an initialization entry of an extended combobox DLGINIT resource block. (code 0x1234). - - - - - Indicates an initialization entry of a combobox DLGINIT resource block (code 0x0403). - - - - - Indicates a UI base class element that cannot be represented by any other element. - - - - - Indicates a context menu. - - - - - Indicates a Windows RC CTEXT control. - - - - - Indicates a cursor, for example a CURSOR resource in Windows. - - - - - Indicates a date/time picker. - - - - - Indicates a Windows RC DEFPUSHBUTTON control. - - - - - Indicates a dialog box. - - - - - Indicates a Windows RC DLGINIT resource block. - - - - - Indicates an edit box object, for example an EDIT control in Windows. - - - - - Indicates a filename. - - - - - Indicates a file dialog. - - - - - Indicates a footnote. - - - - - Indicates a font name. - - - - - Indicates a footer. - - - - - Indicates a frame object. - - - - - Indicates a XUL grid element. - - - - - Indicates a groupbox object, for example a GROUPBOX control in Windows. - - - - - Indicates a header item. - - - - - Indicates a heading, such has the content of <h1>, <h2>, etc. in HTML. - - - - - Indicates a Windows RC HEDIT control. - - - - - Indicates a horizontal scrollbar. - - - - - Indicates an icon, for example an ICON resource in Windows. - - - - - Indicates a Windows RC IEDIT control. - - - - - Indicates keyword list, such as the content of the Keywords meta-data in HTML, or a K footnote in WinHelp RTF. - - - - - Indicates a label object. - - - - - Indicates a label that is also a HTML link (not necessarily a URL). - - - - - Indicates a list (a group of list-items, for example an <ol> or <ul> element in HTML). - - - - - Indicates a listbox object, for example an LISTBOX control in Windows. - - - - - Indicates an list item (an entry in a list). - - - - - Indicates a Windows RC LTEXT control. - - - - - Indicates a menu (a group of menu-items). - - - - - Indicates a toolbar containing one or more tope level menus. - - - - - Indicates a menu item (an entry in a menu). - - - - - Indicates a XUL menuseparator element. - - - - - Indicates a message, for example an entry in a MESSAGETABLE resource in Windows. - - - - - Indicates a calendar control. - - - - - Indicates an edit box beside a spin control. - - - - - Indicates a catch all for rectangular areas. - - - - - Indicates a standalone menu not necessarily associated with a menubar. - - - - - Indicates a pushbox object, for example a PUSHBOX control in Windows. - - - - - Indicates a Windows RC PUSHBUTTON control. - - - - - Indicates a radio button object. - - - - - Indicates a menuitem with associated radio button. - - - - - Indicates raw data resources for an application. - - - - - Indicates a row in a table. - - - - - Indicates a Windows RC RTEXT control. - - - - - Indicates a user navigable container used to show a portion of a document. - - - - - Indicates a generic divider object (e.g. menu group separator). - - - - - Windows accelerators, shortcuts in resource or property files. - - - - - Indicates a UI control to indicate process activity but not progress. - - - - - Indicates a splitter bar. - - - - - Indicates a Windows RC STATE3 control. - - - - - Indicates a window for providing feedback to the users, like 'read-only', etc. - - - - - Indicates a string, for example an entry in a STRINGTABLE resource in Windows. - - - - - Indicates a layers of controls with a tab to select layers. - - - - - Indicates a display and edits regular two-dimensional tables of cells. - - - - - Indicates a XUL textbox element. - - - - - Indicates a UI button that can be toggled to on or off state. - - - - - Indicates an array of controls, usually buttons. - - - - - Indicates a pop up tool tip text. - - - - - Indicates a bar with a pointer indicating a position within a certain range. - - - - - Indicates a control that displays a set of hierarchical data. - - - - - Indicates a URI (URN or URL). - - - - - Indicates a Windows RC USERBUTTON control. - - - - - Indicates a user-defined control like CONTROL control in Windows. - - - - - Indicates the text of a variable. - - - - - Indicates version information about a resource like VERSIONINFO in Windows. - - - - - Indicates a vertical scrollbar. - - - - - Indicates a graphical window. - - - - - - - Values for the attribute 'size-unit'. - - - - - Indicates a size in 8-bit bytes. - - - - - Indicates a size in Unicode characters. - - - - - Indicates a size in columns. Used for HTML text area. - - - - - Indicates a size in centimeters. - - - - - Indicates a size in dialog units, as defined in Windows resources. - - - - - Indicates a size in 'font-size' units (as defined in CSS). - - - - - Indicates a size in 'x-height' units (as defined in CSS). - - - - - Indicates a size in glyphs. A glyph is considered to be one or more combined Unicode characters that represent a single displayable text character. Sometimes referred to as a 'grapheme cluster' - - - - - Indicates a size in inches. - - - - - Indicates a size in millimeters. - - - - - Indicates a size in percentage. - - - - - Indicates a size in pixels. - - - - - Indicates a size in point. - - - - - Indicates a size in rows. Used for HTML text area. - - - - - - - Values for the attribute 'state'. - - - - - Indicates the terminating state. - - - - - Indicates only non-textual information needs adaptation. - - - - - Indicates both text and non-textual information needs adaptation. - - - - - Indicates only non-textual information needs review. - - - - - Indicates both text and non-textual information needs review. - - - - - Indicates that only the text of the item needs to be reviewed. - - - - - Indicates that the item needs to be translated. - - - - - Indicates that the item is new. For example, translation units that were not in a previous version of the document. - - - - - Indicates that changes are reviewed and approved. - - - - - Indicates that the item has been translated. - - - - - - - Values for the attribute 'state-qualifier'. - - - - - Indicates an exact match. An exact match occurs when a source text of a segment is exactly the same as the source text of a segment that was translated previously. - - - - - Indicates a fuzzy match. A fuzzy match occurs when a source text of a segment is very similar to the source text of a segment that was translated previously (e.g. when the difference is casing, a few changed words, white-space discripancy, etc.). - - - - - Indicates a match based on matching IDs (in addition to matching text). - - - - - Indicates a translation derived from a glossary. - - - - - Indicates a translation derived from existing translation. - - - - - Indicates a translation derived from machine translation. - - - - - Indicates a translation derived from a translation repository. - - - - - Indicates a translation derived from a translation memory. - - - - - Indicates the translation is suggested by machine translation. - - - - - Indicates that the item has been rejected because of incorrect grammar. - - - - - Indicates that the item has been rejected because it is incorrect. - - - - - Indicates that the item has been rejected because it is too long or too short. - - - - - Indicates that the item has been rejected because of incorrect spelling. - - - - - Indicates the translation is suggested by translation memory. - - - - - - - Values for the attribute 'unit'. - - - - - Refers to words. - - - - - Refers to pages. - - - - - Refers to <trans-unit> elements. - - - - - Refers to <bin-unit> elements. - - - - - Refers to glyphs. - - - - - Refers to <trans-unit> and/or <bin-unit> elements. - - - - - Refers to the occurrences of instances defined by the count-type value. - - - - - Refers to characters. - - - - - Refers to lines. - - - - - Refers to sentences. - - - - - Refers to paragraphs. - - - - - Refers to segments. - - - - - Refers to placeables (inline elements). - - - - - - - Values for the attribute 'priority'. - - - - - Highest priority. - - - - - High priority. - - - - - High priority, but not as important as 2. - - - - - High priority, but not as important as 3. - - - - - Medium priority, but more important than 6. - - - - - Medium priority, but less important than 5. - - - - - Low priority, but more important than 8. - - - - - Low priority, but more important than 9. - - - - - Low priority. - - - - - Lowest priority. - - - - - - - - - This value indicates that all properties can be reformatted. This value must be used alone. - - - - - This value indicates that no properties should be reformatted. This value must be used alone. - - - - - - - - - - - - - This value indicates that all information in the coord attribute can be modified. - - - - - This value indicates that the x information in the coord attribute can be modified. - - - - - This value indicates that the y information in the coord attribute can be modified. - - - - - This value indicates that the cx information in the coord attribute can be modified. - - - - - This value indicates that the cy information in the coord attribute can be modified. - - - - - This value indicates that all the information in the font attribute can be modified. - - - - - This value indicates that the name information in the font attribute can be modified. - - - - - This value indicates that the size information in the font attribute can be modified. - - - - - This value indicates that the weight information in the font attribute can be modified. - - - - - This value indicates that the information in the css-style attribute can be modified. - - - - - This value indicates that the information in the style attribute can be modified. - - - - - This value indicates that the information in the exstyle attribute can be modified. - - - - - - - - - - - - - Indicates that the context is informational in nature, specifying for example, how a term should be translated. Thus, should be displayed to anyone editing the XLIFF document. - - - - - Indicates that the context-group is used to specify where the term was found in the translatable source. Thus, it is not displayed. - - - - - Indicates that the context information should be used during translation memory lookups. Thus, it is not displayed. - - - - - - - - - Represents a translation proposal from a translation memory or other resource. - - - - - Represents a previous version of the target element. - - - - - Represents a rejected version of the target element. - - - - - Represents a translation to be used for reference purposes only, for example from a related product or a different language. - - - - - Represents a proposed translation that was used for the translation of the trans-unit, possibly modified. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Values for the attribute 'coord'. - - - - - - - - Version values: 1.0 and 1.1 are allowed for backward compatibility. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Symfony/Component/Validator/MessageInterpolator/schema/dic/xliff-core/xml.xsd b/src/Symfony/Component/Validator/MessageInterpolator/schema/dic/xliff-core/xml.xsd deleted file mode 100644 index 282cb5be90..0000000000 --- a/src/Symfony/Component/Validator/MessageInterpolator/schema/dic/xliff-core/xml.xsd +++ /dev/null @@ -1,309 +0,0 @@ - - - - - - -
-

About the XML namespace

- -
-

- - This schema document describes the XML namespace, in a form - suitable for import by other schema documents. -

-

- See - http://www.w3.org/XML/1998/namespace.html and - - http://www.w3.org/TR/REC-xml for information - about this namespace. -

- -

- Note that local names in this namespace are intended to be - defined only by the World Wide Web Consortium or its subgroups. - The names currently defined in this namespace are listed below. - They should not be used with conflicting semantics by any Working - Group, specification, or document instance. -

-

- See further below in this document for more information about how to refer to this schema document from your own - XSD schema documents and about the - namespace-versioning policy governing this schema document. -

-
-
- -
-
- - - - -
- -

lang (as an attribute name)

-

- - denotes an attribute whose value - is a language code for the natural language of the content of - any element; its value is inherited. This name is reserved - by virtue of its definition in the XML specification.

- -
-
-

Notes

-

- Attempting to install the relevant ISO 2- and 3-letter - codes as the enumerated possible values is probably never - going to be a realistic possibility. -

-

- - See BCP 47 at - http://www.rfc-editor.org/rfc/bcp/bcp47.txt - and the IANA language subtag registry at - - http://www.iana.org/assignments/language-subtag-registry - for further information. -

-

- - The union allows for the 'un-declaration' of xml:lang with - the empty string. -

-
-
-
- - - - - - - - - - -
- - - - - -
- -

space (as an attribute name)

-

- denotes an attribute whose - value is a keyword indicating what whitespace processing - discipline is intended for the content of the element; its - value is inherited. This name is reserved by virtue of its - definition in the XML specification.

- -
-
-
- - - - - - - -
- - - - -
- -

base (as an attribute name)

-

- denotes an attribute whose value - provides a URI to be used as the base for interpreting any - relative URIs in the scope of the element on which it - appears; its value is inherited. This name is reserved - by virtue of its definition in the XML Base specification.

- -

- See http://www.w3.org/TR/xmlbase/ - for information about this attribute. -

- -
-
-
-
- - - - -
- -

id (as an attribute name)

-

- - denotes an attribute whose value - should be interpreted as if declared to be of type ID. - This name is reserved by virtue of its definition in the - xml:id specification.

- -

- See http://www.w3.org/TR/xml-id/ - for information about this attribute. -

-
-
-
- -
- - - - - - - - - - - -
- -

Father (in any context at all)

- -
-

- denotes Jon Bosak, the chair of - the original XML Working Group. This name is reserved by - the following decision of the W3C XML Plenary and - XML Coordination groups: -

-
-

- - In appreciation for his vision, leadership and - dedication the W3C XML Plenary on this 10th day of - February, 2000, reserves for Jon Bosak in perpetuity - the XML name "xml:Father". -

-
-
-
-
-
- - - - -
-

About this schema document

- -
-

- This schema defines attributes and an attribute group suitable - for use by schemas wishing to allow xml:base, - xml:lang, xml:space or - xml:id attributes on elements they define. -

- -

- To enable this, such a schema must import this schema for - the XML namespace, e.g. as follows: -

-
-          <schema . . .>
-           . . .
-           <import namespace="http://www.w3.org/XML/1998/namespace"
-                      schemaLocation="http://www.w3.org/2001/xml.xsd"/>
-     
-

- or -

-
-
-           <import namespace="http://www.w3.org/XML/1998/namespace"
-                      schemaLocation="http://www.w3.org/2009/01/xml.xsd"/>
-     
-

- Subsequently, qualified reference to any of the attributes or the - group defined below will have the desired effect, e.g. -

-
-          <type . . .>
-           . . .
-           <attributeGroup ref="xml:specialAttrs"/>
-     
-

- will define a type which will schema-validate an instance element - with any of those attributes. -

- -
-
-
-
- - - -
-

Versioning policy for this schema document

- -
-

- In keeping with the XML Schema WG's standard versioning - policy, this schema document will persist at - - http://www.w3.org/2009/01/xml.xsd. -

-

- At the date of issue it can also be found at - - http://www.w3.org/2001/xml.xsd. -

- -

- The schema document at that URI may however change in the future, - in order to remain compatible with the latest version of XML - Schema itself, or with the XML namespace itself. In other words, - if the XML Schema or XML namespaces change, the version of this - document at - http://www.w3.org/2001/xml.xsd - - will change accordingly; the version at - - http://www.w3.org/2009/01/xml.xsd - - will not change. -

-

- - Previous dated (and unchanging) versions of this schema - document are at: -

- -
-
-
-
- -
diff --git a/src/Symfony/Component/Validator/Resources/i18n/messages.en.xml b/src/Symfony/Component/Validator/Resources/i18n/messages.en.xml deleted file mode 100644 index f98003a747..0000000000 --- a/src/Symfony/Component/Validator/Resources/i18n/messages.en.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - Symfony.Validator.AssertFalse.message - This value should be false - - - Symfony.Validator.AssertTrue.message - This value should be true - - - Symfony.Validator.AssertType.message - This value should be of type %type% - - - Symfony.Validator.Blank.message - This value should be blank - - - Symfony.Validator.Choice.message - This value should be one of the given choices - - - Symfony.Validator.Choice.minMessage - You should select at least %limit% choices - - - Symfony.Validator.Choice.maxMessage - You should select at most %limit% choices - - - Symfony.Validator.Collection.extraFieldsMessage - The fields %fields% were not expected - - - Symfony.Validator.Collection.missingFieldsMessage - The fields %fields% are missing - - - Symfony.Validator.Date.message - This value is not a valid date - - - Symfony.Validator.DateTime.message - This value is not a valid datetime - - - Symfony.Validator.Email.message - This value is not a valid email address - - - Symfony.Validator.File.notFoundMessage - The file could not be found - - - Symfony.Validator.File.notReadableMessage - The file is not readable - - - Symfony.Validator.File.maxSizeMessage - The file is too large (%size%). Allowed maximum size is %limit% - - - Symfony.Validator.File.mimeTypesMessage - The mime type of the file is invalid (%type%). Allowed mime types are %types% - - - Symfony.Validator.Max.message - This value should be %limit% or less - - - Symfony.Validator.MaxLength.message - This value is too long. It should have %limit% characters or less - - - Symfony.Validator.Min.message - This value should be %limit% or more - - - Symfony.Validator.MinLength.message - This value is too short. It should have %limit% characters or more - - - Symfony.Validator.NotBlank.message - This value should not be blank - - - Symfony.Validator.NotNull.message - This value should not be null - - - Symfony.Validator.Null.message - This value should be null - - - Symfony.Validator.Regex.message - This value is not valid - - - Symfony.Validator.Time.message - This value is not a valid time - - - Symfony.Validator.Url.message - This value is not a valid URL - - - Symfony.Validator.Valid.message - This value should be instance of class %class% - - - - diff --git a/src/Symfony/Component/Validator/ValidationContext.php b/src/Symfony/Component/Validator/ValidationContext.php index 16d013faf7..d3e6b005e3 100644 --- a/src/Symfony/Component/Validator/ValidationContext.php +++ b/src/Symfony/Component/Validator/ValidationContext.php @@ -2,7 +2,6 @@ namespace Symfony\Component\Validator; -use Symfony\Component\Validator\MessageInterpolator\MessageInterpolatorInterface; use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface; class ValidationContext @@ -15,18 +14,15 @@ class ValidationContext protected $violations; protected $graphWalker; protected $metadataFactory; - protected $messageInterpolator; public function __construct( $root, GraphWalker $graphWalker, - ClassMetadataFactoryInterface $metadataFactory, - MessageInterpolatorInterface $messageInterpolator + ClassMetadataFactoryInterface $metadataFactory ) { $this->root = $root; $this->graphWalker = $graphWalker; - $this->messageInterpolator = $messageInterpolator; $this->metadataFactory = $metadataFactory; $this->violations = new ConstraintViolationList(); } @@ -39,7 +35,8 @@ class ValidationContext public function addViolation($message, array $params, $invalidValue) { $this->violations->add(new ConstraintViolation( - $this->messageInterpolator->interpolate($message, $params), + $message, + $params, $this->root, $this->propertyPath, $invalidValue diff --git a/src/Symfony/Component/Validator/Validator.php b/src/Symfony/Component/Validator/Validator.php index abed625403..885d65e25d 100644 --- a/src/Symfony/Component/Validator/Validator.php +++ b/src/Symfony/Component/Validator/Validator.php @@ -5,23 +5,19 @@ namespace Symfony\Component\Validator; use Symfony\Component\Validator\Mapping\ElementMetadata; use Symfony\Component\Validator\Mapping\ClassMetadata; use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface; -use Symfony\Component\Validator\MessageInterpolator\MessageInterpolatorInterface; class Validator implements ValidatorInterface { protected $metadataFactory; protected $validatorFactory; - protected $messageInterpolator; public function __construct( ClassMetadataFactoryInterface $metadataFactory, - ConstraintValidatorFactoryInterface $validatorFactory, - MessageInterpolatorInterface $messageInterpolator + ConstraintValidatorFactoryInterface $validatorFactory ) { $this->metadataFactory = $metadataFactory; $this->validatorFactory = $validatorFactory; - $this->messageInterpolator = $messageInterpolator; } public function validate($object, $groups = null) @@ -73,7 +69,7 @@ class Validator implements ValidatorInterface protected function validateGraph($root, \Closure $closure, GroupChain $groupChain) { - $walker = new GraphWalker($root, $this->metadataFactory, $this->validatorFactory, $this->messageInterpolator); + $walker = new GraphWalker($root, $this->metadataFactory, $this->validatorFactory); foreach ($groupChain->getGroups() as $group) { $closure($walker, $group); diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/AllValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/AllValidatorTest.php index 5b227d6f8e..b96d2e5d4d 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/AllValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/AllValidatorTest.php @@ -17,9 +17,8 @@ class AllValidatorTest extends \PHPUnit_Framework_TestCase { $this->walker = $this->getMock('Symfony\Component\Validator\GraphWalker', array(), array(), '', false); $metadataFactory = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface'); - $messageInterpolator = $this->getMock('Symfony\Component\Validator\MessageInterpolator\MessageInterpolatorInterface'); - $this->context = new ValidationContext('Root', $this->walker, $metadataFactory, $messageInterpolator); + $this->context = new ValidationContext('Root', $this->walker, $metadataFactory); $this->validator = new AllValidator(); $this->validator->initialize($this->context); diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/ChoiceValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/ChoiceValidatorTest.php index 23aed6aed5..fd1b95946d 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/ChoiceValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/ChoiceValidatorTest.php @@ -22,10 +22,9 @@ class ChoiceValidatorTest extends \PHPUnit_Framework_TestCase public function setUp() { - $interpolator = $this->getMock('Symfony\Component\Validator\MessageInterpolator\MessageInterpolatorInterface'); $walker = $this->getMock('Symfony\Component\Validator\GraphWalker', array(), array(), '', false); $factory = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface'); - $context = new ValidationContext('root', $walker, $factory, $interpolator); + $context = new ValidationContext('root', $walker, $factory); $context->setCurrentClass(__CLASS__); $this->validator = new ChoiceValidator(); $this->validator->initialize($context); diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/CollectionValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/CollectionValidatorTest.php index b3f895aedf..b0527e566e 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/CollectionValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/CollectionValidatorTest.php @@ -17,9 +17,8 @@ class CollectionValidatorTest extends \PHPUnit_Framework_TestCase { $this->walker = $this->getMock('Symfony\Component\Validator\GraphWalker', array(), array(), '', false); $metadataFactory = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface'); - $messageInterpolator = $this->getMock('Symfony\Component\Validator\MessageInterpolator\MessageInterpolatorInterface'); - $this->context = new ValidationContext('Root', $this->walker, $metadataFactory, $messageInterpolator); + $this->context = new ValidationContext('Root', $this->walker, $metadataFactory); $this->validator = new CollectionValidator(); $this->validator->initialize($this->context); diff --git a/tests/Symfony/Tests/Component/Validator/Constraints/ValidValidatorTest.php b/tests/Symfony/Tests/Component/Validator/Constraints/ValidValidatorTest.php index 788247d6e9..a3971cd201 100644 --- a/tests/Symfony/Tests/Component/Validator/Constraints/ValidValidatorTest.php +++ b/tests/Symfony/Tests/Component/Validator/Constraints/ValidValidatorTest.php @@ -22,9 +22,8 @@ class ValidValidatorTest extends \PHPUnit_Framework_TestCase { $this->walker = $this->getMock('Symfony\Component\Validator\GraphWalker', array(), array(), '', false); $this->factory = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface'); - $messageInterpolator = $this->getMock('Symfony\Component\Validator\MessageInterpolator\MessageInterpolatorInterface'); - $this->context = new ValidationContext('Root', $this->walker, $this->factory, $messageInterpolator); + $this->context = new ValidationContext('Root', $this->walker, $this->factory); $this->validator = new ValidValidator(); $this->validator->initialize($this->context); diff --git a/tests/Symfony/Tests/Component/Validator/GraphWalkerTest.php b/tests/Symfony/Tests/Component/Validator/GraphWalkerTest.php index 618fc11d75..1efcfd96d1 100644 --- a/tests/Symfony/Tests/Component/Validator/GraphWalkerTest.php +++ b/tests/Symfony/Tests/Component/Validator/GraphWalkerTest.php @@ -22,15 +22,13 @@ class GraphWalkerTest extends \PHPUnit_Framework_TestCase { const CLASSNAME = 'Symfony\Tests\Component\Validator\Fixtures\Entity'; - protected $interpolator; protected $factory; protected $metadata; public function setUp() { - $this->interpolator = $this->getMock('Symfony\Component\Validator\MessageInterpolator\MessageInterpolatorInterface'); $this->factory = $this->getMock('Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface'); - $this->walker = new GraphWalker('Root', $this->factory, new ConstraintValidatorFactory(), $this->interpolator); + $this->walker = new GraphWalker('Root', $this->factory, new ConstraintValidatorFactory()); $this->metadata = new ClassMetadata(self::CLASSNAME); } @@ -74,16 +72,12 @@ class GraphWalkerTest extends \PHPUnit_Framework_TestCase { $constraint = new ConstraintA(); - $this->interpolator->expects($this->once()) - ->method('interpolate') - ->with($this->equalTo('message'), $this->equalTo(array('param' => 'value'))) - ->will($this->returnValue('interpolated text')); - $this->walker->walkConstraint($constraint, 'foobar', 'Default', 'firstName.path'); $violations = new ConstraintViolationList(); $violations->add(new ConstraintViolation( - 'interpolated text', + 'message', + array('param' => 'value'), 'Root', 'firstName.path', 'foobar' diff --git a/tests/Symfony/Tests/Component/Validator/MessageInterpolator/XliffMessageInterpolatorTest.php b/tests/Symfony/Tests/Component/Validator/MessageInterpolator/XliffMessageInterpolatorTest.php deleted file mode 100644 index 1a6a54f8ed..0000000000 --- a/tests/Symfony/Tests/Component/Validator/MessageInterpolator/XliffMessageInterpolatorTest.php +++ /dev/null @@ -1,39 +0,0 @@ -interpolate('original', array('param' => 'foobar')); - - $this->assertEquals('translation with param foobar', $text); - } - - public function testInterpolateFromMultipleFiles() - { - $interpolator = new XliffMessageInterpolator(array( - __DIR__.'/xliff.xml', - __DIR__.'/xliff2.xml', - )); - - $text1 = $interpolator->interpolate('original', array('param' => 'foobar')); - $text2 = $interpolator->interpolate('second', array('param' => 'baz')); - - $this->assertEquals('translation with param foobar', $text1); - $this->assertEquals('second translation with param baz', $text2); - } - - public function testConvertParamsToStrings() - { - $interpolator = new XliffMessageInterpolator(__DIR__.'/xliff.xml'); - $text = $interpolator->interpolate('original', array('param' => array())); - - $this->assertEquals('translation with param Array', $text); - } -} - diff --git a/tests/Symfony/Tests/Component/Validator/MessageInterpolator/xliff.xml b/tests/Symfony/Tests/Component/Validator/MessageInterpolator/xliff.xml deleted file mode 100644 index 1e4a4f0e7f..0000000000 --- a/tests/Symfony/Tests/Component/Validator/MessageInterpolator/xliff.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - original - translation with param %param% - - - - \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/Validator/MessageInterpolator/xliff2.xml b/tests/Symfony/Tests/Component/Validator/MessageInterpolator/xliff2.xml deleted file mode 100644 index 0d6ba385d3..0000000000 --- a/tests/Symfony/Tests/Component/Validator/MessageInterpolator/xliff2.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - second - second translation with param %param% - - - - \ No newline at end of file