diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
index 2c86675589..e2b0df0820 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
@@ -189,5 +189,10 @@
+
+
+
+ %validator.translation_domain%
+
diff --git a/src/Symfony/Component/Form/Extension/Validator/Type/UploadValidatorExtension.php b/src/Symfony/Component/Form/Extension/Validator/Type/UploadValidatorExtension.php
new file mode 100644
index 0000000000..6f0fa60afd
--- /dev/null
+++ b/src/Symfony/Component/Form/Extension/Validator/Type/UploadValidatorExtension.php
@@ -0,0 +1,58 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Form\Extension\Validator\Type;
+
+use Symfony\Component\Form\AbstractTypeExtension;
+use Symfony\Component\OptionsResolver\Options;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+use Symfony\Component\Translation\TranslatorInterface;
+
+/**
+ * @author Abdellatif Ait boudad
+ * @author David Badura
+ */
+class UploadValidatorExtension extends AbstractTypeExtension
+{
+ private $translator;
+ private $translationDomain;
+
+ /**
+ * @param TranslatorInterface $translator The translator for translating error messages
+ * @param null|string $translationDomain The translation domain for translating
+ */
+ public function __construct(TranslatorInterface $translator, $translationDomain = null)
+ {
+ $this->translator = $translator;
+ $this->translationDomain = $translationDomain;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $translator = $this->translator;
+ $translationDomain = $this->translationDomain;
+
+ $resolver->setNormalizer('post_max_size_message', function (Options $options, $errorMessage) use ($translator, $translationDomain) {
+ return $translator->trans($errorMessage, array(), $translationDomain);
+ });
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getExtendedType()
+ {
+ return 'form';
+ }
+}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php
new file mode 100644
index 0000000000..95a11a78c7
--- /dev/null
+++ b/src/Symfony/Component/Form/Tests/Extension/Validator/Type/UploadValidatorExtensionTest.php
@@ -0,0 +1,38 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Form\Tests\Extension\Validator\Type;
+
+use Symfony\Component\Form\Extension\Validator\Type\UploadValidatorExtension;
+use Symfony\Component\OptionsResolver\OptionsResolver;
+
+class UploadValidatorExtensionTest extends TypeTestCase
+{
+ public function testPostMaxSizeTranslation()
+ {
+ $translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface');
+
+ $translator->expects($this->any())
+ ->method('trans')
+ ->with($this->equalTo('old max {{ max }}!'))
+ ->willReturn('translated max {{ max }}!');
+
+ $extension = new UploadValidatorExtension($translator);
+
+ $resolver = new OptionsResolver();
+ $resolver->setDefault('post_max_size_message', 'old max {{ max }}!');
+
+ $extension->configureOptions($resolver);
+ $options = $resolver->resolve();
+
+ $this->assertEquals('translated max {{ max }}!', $options['post_max_size_message']);
+ }
+}