diff --git a/src/Symfony/Bridge/Twig/Node/TransNode.php b/src/Symfony/Bridge/Twig/Node/TransNode.php index a68c101ab0..924f2b9298 100644 --- a/src/Symfony/Bridge/Twig/Node/TransNode.php +++ b/src/Symfony/Bridge/Twig/Node/TransNode.php @@ -95,22 +95,10 @@ class TransNode extends \Twig_Node preg_match_all('/(?=')) { - foreach ($matches[1] as $var) { - $key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getLine()); - if (!$vars->hasElement($key)) { - $vars->addElement(new \Twig_Node_Expression_Name($var, $body->getLine()), $key); - } - } - } else { - $current = array(); - foreach ($vars as $name => $var) { - $current[$name] = true; - } - foreach ($matches[1] as $var) { - if (!isset($current['%'.$var.'%'])) { - $vars->setNode('%'.$var.'%', new \Twig_Node_Expression_Name($var, $body->getLine())); - } + foreach ($matches[1] as $var) { + $key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getLine()); + if (!$vars->hasElement($key)) { + $vars->addElement(new \Twig_Node_Expression_Name($var, $body->getLine()), $key); } } diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php index e39e8fe06f..c2e6089dbd 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/TranslationExtensionTest.php @@ -43,6 +43,33 @@ class TranslationExtensionTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $this->getTemplate($template)->render($variables)); } + /** + * @expectedException \Twig_Error_Syntax + * @expectedExceptionMessage Unexpected token. Twig was looking for the "with", "from", or "into" keyword in "index" at line 3. + */ + public function testTransUnknownKeyword() + { + $output = $this->getTemplate("{% trans \n\nfoo %}{% endtrans %}")->render(); + } + + /** + * @expectedException \Twig_Error_Syntax + * @expectedExceptionMessage A message inside a trans tag must be a simple text in "index" at line 2. + */ + public function testTransComplexBody() + { + $output = $this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render(); + } + + /** + * @expectedException \Twig_Error_Syntax + * @expectedExceptionMessage A message inside a transchoice tag must be a simple text in "index" at line 2. + */ + public function testTransChoiceComplexBody() + { + $output = $this->getTemplate("{% transchoice count %}\n{{ 1 + 2 }}{% endtranschoice %}")->render(); + } + public function getTransTests() { return array( diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php index be8ac5cfaa..1c75d8bb85 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php @@ -64,7 +64,7 @@ class TransChoiceTokenParser extends TransTokenParser $body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true); if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) { - throw new \Twig_Error_Syntax('A message must be a simple text.'); + throw new \Twig_Error_Syntax('A message inside a transchoice tag must be a simple text.', $body->getLine(), $stream->getFilename()); } $stream->expect(\Twig_Token::BLOCK_END_TYPE); diff --git a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php index a11681c249..86f9579cf6 100644 --- a/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php +++ b/src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php @@ -55,7 +55,7 @@ class TransTokenParser extends \Twig_TokenParser $stream->next(); $locale = $this->parser->getExpressionParser()->parseExpression(); } elseif (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) { - throw new \Twig_Error_Syntax('Unexpected token. Twig was looking for the "with" or "from" keyword.'); + throw new \Twig_Error_Syntax('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getFilename()); } } @@ -64,7 +64,7 @@ class TransTokenParser extends \Twig_TokenParser $body = $this->parser->subparse(array($this, 'decideTransFork'), true); if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) { - throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text'); + throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text.', $body->getLine(), $stream->getFilename()); } $stream->expect(\Twig_Token::BLOCK_END_TYPE); diff --git a/src/Symfony/Component/DependencyInjection/services10.xml b/src/Symfony/Component/DependencyInjection/services10.xml deleted file mode 100644 index 824d8b5d75..0000000000 --- a/src/Symfony/Component/DependencyInjection/services10.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - diff --git a/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php b/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php index 794e966ac6..987b78b5c7 100644 --- a/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php +++ b/src/Symfony/Component/DomCrawler/Field/TextareaFormField.php @@ -33,7 +33,7 @@ class TextareaFormField extends FormField $this->value = null; foreach ($this->node->childNodes as $node) { - $this->value .= $this->document->saveXML($node); + $this->value .= $node->wholeText; } } } diff --git a/src/Symfony/Component/DomCrawler/Tests/Field/TextareaFormFieldTest.php b/src/Symfony/Component/DomCrawler/Tests/Field/TextareaFormFieldTest.php index a33c44f230..5d4d003826 100644 --- a/src/Symfony/Component/DomCrawler/Tests/Field/TextareaFormFieldTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/Field/TextareaFormFieldTest.php @@ -29,5 +29,18 @@ class TextareaFormFieldTest extends FormFieldTestCase } catch (\LogicException $e) { $this->assertTrue(true, '->initialize() throws a \LogicException if the node is not a textarea'); } + + // Ensure that valid HTML can be used on a textarea. + $node = $this->createNode('textarea', 'foo bar

Baz

'); + $field = new TextareaFormField($node); + + $this->assertEquals('foo bar

Baz

', $field->getValue(), '->initialize() sets the value of the field to the textarea node value'); + + // Ensure that we don't do any DOM manipulation/validation by passing in + // "invalid" HTML. + $node = $this->createNode('textarea', 'foo bar

Baz

'); + $field = new TextareaFormField($node); + + $this->assertEquals('foo bar

Baz

', $field->getValue(), '->initialize() sets the value of the field to the textarea node value'); } } diff --git a/src/Symfony/Component/Form/FormInterface.php b/src/Symfony/Component/Form/FormInterface.php index 5a852e864f..7a77e0f3f4 100644 --- a/src/Symfony/Component/Form/FormInterface.php +++ b/src/Symfony/Component/Form/FormInterface.php @@ -39,7 +39,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable public function getParent(); /** - * Adds a child to the form. + * Adds or replaces a child to the form. * * @param FormInterface|string|integer $child The FormInterface instance or the name of the child. * @param string|null $type The child's type, if a name was passed. diff --git a/src/Symfony/Component/Security/Resources/translations/security.id.xlf b/src/Symfony/Component/Security/Resources/translations/security.id.xlf new file mode 100644 index 0000000000..ab1153b8a2 --- /dev/null +++ b/src/Symfony/Component/Security/Resources/translations/security.id.xlf @@ -0,0 +1,71 @@ + + + + + + An authentication exception occurred. + Terjadi sebuah pengecualian otentikasi. + + + Authentication credentials could not be found. + Kredensial otentikasi tidak bisa ditemukan. + + + Authentication request could not be processed due to a system problem. + Permintaan otentikasi tidak bisa diproses karena masalah sistem. + + + Invalid credentials. + Kredensial salah. + + + Cookie has already been used by someone else. + Cookie sudah digunakan oleh orang lain. + + + Not privileged to request the resource. + Tidak berhak untuk meminta sumber daya. + + + Invalid CSRF token. + Token CSRF salah. + + + Digest nonce has expired. + Digest nonce telah berakhir. + + + No authentication provider found to support the authentication token. + Tidak ditemukan penyedia otentikasi untuk mendukung token otentikasi. + + + No session available, it either timed out or cookies are not enabled. + Tidak ada sesi yang tersedia, mungkin waktu sudah habis atau cookie tidak diaktifkan + + + No token could be found. + Tidak ada token yang bisa ditemukan. + + + Username could not be found. + Username tidak bisa ditemukan. + + + Account has expired. + Akun telah berakhir. + + + Credentials have expired. + Kredensial telah berakhir. + + + Account is disabled. + Akun dinonaktifkan. + + + Account is locked. + Akun terkunci. + + + + diff --git a/src/Symfony/Component/Security/Resources/translations/security.zh_CN.xlf b/src/Symfony/Component/Security/Resources/translations/security.zh_CN.xlf new file mode 100644 index 0000000000..2d6affecec --- /dev/null +++ b/src/Symfony/Component/Security/Resources/translations/security.zh_CN.xlf @@ -0,0 +1,71 @@ + + + + + + An authentication exception occurred. + 身份验证发生异常。 + + + Authentication credentials could not be found. + 没有找到身份验证的凭证。 + + + Authentication request could not be processed due to a system problem. + 由于系统故障,身份验证的请求无法被处理。 + + + Invalid credentials. + 无效的凭证。 + + + Cookie has already been used by someone else. + Cookie 已经被其他人使用。 + + + Not privileged to request the resource. + 没有权限请求此资源。 + + + Invalid CSRF token. + 无效的 CSRF token 。 + + + Digest nonce has expired. + 摘要随机串(digest nonce)已过期。 + + + No authentication provider found to support the authentication token. + 没有找到支持此 token 的身份验证服务提供方。 + + + No session available, it either timed out or cookies are not enabled. + Session 不可用。会话超时或没有启用 cookies 。 + + + No token could be found. + 找不到 token 。 + + + Username could not be found. + 找不到用户名。 + + + Account has expired. + 帐号已过期。 + + + Credentials have expired. + 凭证已过期。 + + + Account is disabled. + 帐号已被禁用。 + + + Account is locked. + 帐号已被锁定。 + + + + diff --git a/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php index 8deea4eba8..9b5093e1bd 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php @@ -36,10 +36,10 @@ abstract class AbstractLoader implements LoaderInterface /** * Creates a new constraint instance for the given constraint name. * - * @param string $name The constraint name. Either a constraint relative - * to the default constraint namespace, or a fully - * qualified class name - * @param array $options The constraint options + * @param string $name The constraint name. Either a constraint relative + * to the default constraint namespace, or a fully + * qualified class name + * @param mixed $options The constraint options * * @return Constraint * diff --git a/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php b/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php index cad247e883..3f157c9241 100644 --- a/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/Validator/Mapping/Loader/XmlFileLoader.php @@ -105,7 +105,7 @@ class XmlFileLoader extends FileLoader $options = null; } - $constraints[] = $this->newConstraint($node['name'], $options); + $constraints[] = $this->newConstraint((string) $node['name'], $options); } return $constraints; diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf index 8bad4fb45f..ff6efdd135 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.zh_CN.xlf @@ -4,223 +4,279 @@ This value should be false. - 该变量的值应为 false. + 该变量的值应为 false 。 This value should be true. - 该变量的值应为 true. + 该变量的值应为 true 。 This value should be of type {{ type }}. - 该变量的类型应为 {{ type }}. + 该变量的类型应为 {{ type }} 。 This value should be blank. - 该变量值应为空. + 该变量值应为空。 The value you selected is not a valid choice. - 选定变量的值不是有效的选项. + 选定变量的值不是有效的选项。 You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. - 您至少要选择 {{ limit }} 个选项. + 您至少要选择 {{ limit }} 个选项。 You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. - 您最多能选择 {{ limit }} 个选项. + 您最多能选择 {{ limit }} 个选项。 One or more of the given values is invalid. - 一个或者多个给定的值无效. + 一个或者多个给定的值无效。 The fields {{ fields }} were not expected. - 非预期字段 {{ fields }}. + 非预期字段 {{ fields }} 。 The fields {{ fields }} are missing. - 遗漏字段 {{ fields }}. + 遗漏字段 {{ fields }} 。 This value is not a valid date. - 该值不是一个有效日期(date). + 该值不是一个有效的日期(date)。 This value is not a valid datetime. - 该值不是一个有效日期时间(datetime). + 该值不是一个有效的日期时间(datetime)。 This value is not a valid email address. - 该值不是一个有效邮件地址. + 该值不是一个有效的邮件地址。 The file could not be found. - 文件未找到. + 文件未找到。 The file is not readable. - 文件不可读. + 文件不可读。 The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}. - 文件太大 ({{ size }} {{ suffix }}). 文件大小不可以超过 {{ limit }} {{ suffix }}. + 文件太大 ({{ size }} {{ suffix }})。文件大小不可以超过 {{ limit }} {{ suffix }} 。 The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}. - 文件类型不合法 ({{ type }}). 合法的文件类型有 {{ types }}. + 无效的文件类型 ({{ type }}) 。允许的文件类型有 {{ types }} 。 This value should be {{ limit }} or less. - 这个变量的值应该小于或等于 {{ limit }}. + 这个变量的值应该小于或等于 {{ limit }}。 This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less. - 字符串太长, 长度不可超过 {{ limit }} 个字符. + 字符串太长,长度不可超过 {{ limit }} 个字符。 This value should be {{ limit }} or more. - 该变量的值应该大于或等于 {{ limit }}. + 该变量的值应该大于或等于 {{ limit }}。 This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. - 字符串太短, 长度不可少于 {{ limit }} 个字符. + 字符串太短,长度不可少于 {{ limit }} 个字符。 This value should not be blank. - 该变量不应为空. + 该变量不应为空。 This value should not be null. - 该变量不应为 null. + 该变量不应为 null 。 This value should be null. - 该变量应为空 null. + 该变量应为空 null 。 This value is not valid. - 该变量值无效. + 该变量值无效 。 This value is not a valid time. - 该值不是一个有效时间. + 该值不是一个有效的时间。 This value is not a valid URL. - 该值不是一个有效的 URL 地址. + 该值不是一个有效的 URL 。 The two values should be equal. - 该两个变量的值应该相同. + 这两个变量的值应该相等。 The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}. - 文件太大, 文件大小不可以超过 {{ limit }} {{ suffix }}. + 文件太大,文件大小不可以超过 {{ limit }} {{ suffix }}。 The file is too large. - 文件太大. + 文件太大。 The file could not be uploaded. - 文件不可被上传. + 无法上传此文件。 This value should be a valid number. - 该值应该为有效的数字. + 该值应该为有效的数字。 This value is not a valid country. - 该值不是有效的国家名. + 该值不是有效的国家名。 This file is not a valid image. - 该文件不是有效的图片. + 该文件不是有效的图片。 This is not a valid IP address. - 该值不是有效的IP地址. + 该值不是有效的IP地址。 This value is not a valid language. - 该值不是有效的语言名. + 该值不是有效的语言名。 This value is not a valid locale. - 该值不是有效的区域值. + 该值不是有效的区域值(locale)。 This value is already used. - 该值已经被使用了. + 该值已经被使用。 The size of the image could not be detected. - 不能解析图片大小. + 不能解析图片大小。 The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px. - 图片太宽 ({{ width }}px),最大宽度为 {{ max_width }}px. + 图片太宽 ({{ width }}px),最大宽度为 {{ max_width }}px 。 The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px. - 图片宽度不够 ({{ width }}px),最小宽度为 {{ min_width }}px. + 图片宽度不够 ({{ width }}px),最小宽度为 {{ min_width }}px 。 The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px. - 图片太高 ({{ height }}px),最大高度为 {{ max_height }}px. + 图片太高 ({{ height }}px),最大高度为 {{ max_height }}px 。 The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px. - 图片高度不够 ({{ height }}px),最小高度为 {{ min_height }}px. + 图片高度不够 ({{ height }}px),最小高度为 {{ min_height }}px 。 This value should be the user current password. - 该变量应为用户当前的密码. + 该变量的值应为用户当前的密码。 This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. - 该变量应为 {{ limit }} 个字符. + 该变量应为 {{ limit }} 个字符。 The file was only partially uploaded. - 该文件的上传不完整. + 该文件的上传不完整。 No file was uploaded. - 没有上传任何文件. + 没有上传任何文件。 No temporary folder was configured in php.ini. - php.ini里没有配置临时文件目录. + php.ini 里没有配置临时文件目录。 Cannot write temporary file to disk. - 临时文件写入磁盘失败. + 临时文件写入磁盘失败。 A PHP extension caused the upload to fail. - 某个PHP扩展造成上传失败. + 某个 PHP 扩展造成上传失败。 This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. - 该集合最少应包含 {{ limit }} 个元素. + 该集合最少应包含 {{ limit }} 个元素。 This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less. - 该集合最多包含 {{ limit }} 个元素. + 该集合最多包含 {{ limit }} 个元素。 This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements. - 该集合应包含正好 {{ limit }} 个元素element. + 该集合应包含 {{ limit }} 个元素 element 。 Invalid card number. - 无效的信用卡号. + 无效的信用卡号。 Unsupported card type or invalid card number. - 不支持的信用卡类型或无效的信用卡号. + 不支持的信用卡类型或无效的信用卡号。 + + + This is not a valid International Bank Account Number (IBAN). + 该值不是有效的国际银行帐号(IBAN)。 + + + This value is not a valid ISBN-10. + 该值不是有效的10位国际标准书号(ISBN-10)。 + + + This value is not a valid ISBN-13. + 该值不是有效的13位国际标准书号(ISBN-13)。 + + + This value is neither a valid ISBN-10 nor a valid ISBN-13. + 该值不是有效的国际标准书号(ISBN-10 或 ISBN-13)。 + + + This value is not a valid ISSN. + 该值不是有效的国际标准期刊号(ISSN)。 + + + This value is not a valid currency. + 该值不是有效的货币名(currency)。 + + + This value should be equal to {{ compared_value }}. + 该值应等于 {{ compared_value }} 。 + + + This value should be greater than {{ compared_value }}. + 该值应大于 {{ compared_value }} 。 + + + This value should be greater than or equal to {{ compared_value }}. + 该值应大于或等于 {{ compared_value }} 。 + + + This value should be identical to {{ compared_value_type }} {{ compared_value }}. + 该值应与 {{ compared_value_type }} {{ compared_value }} 相同。 + + + This value should be less than {{ compared_value }}. + 该值应小于 {{ compared_value }} 。 + + + This value should be less than or equal to {{ compared_value }}. + 该值应小于或等于 {{ compared_value }} 。 + + + This value should not be equal to {{ compared_value }}. + 该值不应先等于 {{ compared_value }} 。 + + + This value should not be identical to {{ compared_value_type }} {{ compared_value }}. + 该值不应与 {{ compared_value_type }} {{ compared_value }} 相同。