You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #14897 Allow new lines in Messages translated with transchoice() (replacement for #14867) (azine)
This PR was submitted for the 2.8 branch but it was merged into the 2.3 branch instead (closes#14897).
Discussion
----------
Allow new lines in Messages translated with transchoice() (replacement for #14867)
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
Hi,
I found that the MessageSelector does not handle new lines in messages very well.
I suggest adding the "s" modifier to the regexp used to identify the parts and ranges.
What do you think?
PS: would be nice to have this change also in Symfony 2.6 & 2.7
Commits
-------
786b8a6 Allow new lines in Messages translated with transchoice() (replacement for #14867)
Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Tests/MessageSelectorTest.php
+32Lines changed: 32 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,38 @@ public function getChooseTests()
93
93
array('There are no apples', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0),
94
94
array('There are no apples', '{0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0.0),
95
95
array('There are no apples', '{0.0} There are no apples|]0,1[There are %count% apples|{1} There is one apple|[1,Inf] There is more than one apple', 0),
96
+
97
+
// Test texts with new-lines
98
+
// with double-quotes and \n in id & double-quotes and actual newlines in text
99
+
array("This is a text with a\n new-line in it. Selector = 0.", "{0}This is a text with a
100
+
new-line in it. Selector = 0.|{1}This is a text with a
101
+
new-line in it. Selector = 1.|[1,Inf]This is a text with a
102
+
new-line in it. Selector > 1.", 0),
103
+
// with double-quotes and \n in id and single-quotes and actual newlines in text
104
+
array("This is a text with a\n new-line in it. Selector = 1.", '{0}This is a text with a
105
+
new-line in it. Selector = 0.|{1}This is a text with a
106
+
new-line in it. Selector = 1.|[1,Inf]This is a text with a
107
+
new-line in it. Selector > 1.', 1),
108
+
array("This is a text with a\n new-line in it. Selector > 1.", '{0}This is a text with a
109
+
new-line in it. Selector = 0.|{1}This is a text with a
110
+
new-line in it. Selector = 1.|[1,Inf]This is a text with a
111
+
new-line in it. Selector > 1.', 5),
112
+
// with double-quotes and id split accros lines
113
+
array("This is a text with a
114
+
new-line in it. Selector = 1.", '{0}This is a text with a
115
+
new-line in it. Selector = 0.|{1}This is a text with a
116
+
new-line in it. Selector = 1.|[1,Inf]This is a text with a
117
+
new-line in it. Selector > 1.', 1),
118
+
// with single-quotes and id split accros lines
119
+
array('This is a text with a
120
+
new-line in it. Selector > 1.', '{0}This is a text with a
121
+
new-line in it. Selector = 0.|{1}This is a text with a
122
+
new-line in it. Selector = 1.|[1,Inf]This is a text with a
123
+
new-line in it. Selector > 1.', 5),
124
+
// with single-quotes and \n in text
125
+
array('This is a text with a\nnew-line in it. Selector = 0.', '{0}This is a text with a\nnew-line in it. Selector = 0.|{1}This is a text with a\nnew-line in it. Selector = 1.|[1,Inf]This is a text with a\nnew-line in it. Selector > 1.', 0),
126
+
// with double-quotes and id split accros lines
127
+
array("This is a text with a\nnew-line in it. Selector = 1.", "{0}This is a text with a\nnew-line in it. Selector = 0.|{1}This is a text with a\nnew-line in it. Selector = 1.|[1,Inf]This is a text with a\nnew-line in it. Selector > 1.", 1),
0 commit comments