8000 Allow new lines in Messages translated with transchoice() by azine · Pull Request #14867 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

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

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 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow new lines in Messages translated with transchoice()
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?
  • Loading branch information
azine committed Jun 4, 2015
commit 1dc01d0b41edf380870df0dcb43a4f59e57faca9
2 changes: 1 addition & 1 deletion src/Symfony/Component/Translation/MessageSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function choose($message, $number, $locale)
foreach ($parts as $part) {
$part = trim($part);

if (preg_match('/^(?P<interval>'.Interval::getIntervalRegexp().')\s*(?P<message>.*?)$/x', $part, $matches)) {
if (preg_match('/^(?P<interval>'.Interval::getIntervalRegexp().')\s*(?P<message>.*?)$/xs', $part, $matches)) {
$explicitRules[$matches['interval']] = $matches['message'];
} elseif (preg_match('/^\w+\:\s*(.*?)$/', $part, $matches)) {
$standardRules[] = $matches[1];
Expand Down
0