Skip to content

Allow new lines in Messages translated with transchoice() (replacement for #14867) #14897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from

Conversation

azine
Copy link
Contributor

@azine azine commented Jun 6, 2015

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

@azine azine changed the title Allow new lines in Messages translated with transchoice() #14867 Allow new lines in Messages translated with transchoice() (replacement for #14867) Jun 6, 2015
@@ -93,6 +93,20 @@ public function getChooseTests()
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),
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),
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),

// Test texts with new-lines
array('This is text with a\n new-line in it. Selector = 0.', '{0}This is a text with a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\n is not evaluated when using single-quoted strings (see the failing tests).

azine added 4 commits June 9, 2015 21:19
As long as the interpreted string is the same, the new-lines work fine. But the following combination does not work:

key: "some text \n with a new line"
text: 'some text \n with a new line"

But I would say this is expected behavior.
@aitboudad
Copy link
Contributor

👍

1 similar comment
@xabbuh
Copy link
Member

xabbuh commented Jun 11, 2015

👍

@fabpot
Copy link
Member

fabpot commented Jun 11, 2015

Thank you @azine.

fabpot added a commit that referenced this pull request Jun 11, 2015
…(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)
@fabpot fabpot closed this Jun 11, 2015
@azine
Copy link
Contributor Author

azine commented Jun 11, 2015

@fabpot: my pleasure.

Will this change/feature be backported to Symfony 2.6 and 2.7 as well? Or should I open separate pull-requests for that?

Cheers,

@fabpot
Copy link
Member

fabpot commented Jun 11, 2015

This is a bug fix, so it was merged in 2.3 and will be merged into newest branches as well.

new-line in it. Selector = 0.|{1}This is a text with a
new-line in it. Selector = 1.|[1,Inf]This is a text with a
new-line in it. Selector > 1.', 1),
// with single-quotes and id split accros lines
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this case is strictly the same than the previous one (the quote style being used does not change the string value here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants