aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2018-03-12 11:31:21 +0000
committerDave Arter <davea@mysociety.org>2018-03-29 16:04:31 +0100
commitfed75f471279cda99b877a6015024a5c59eeeafd (patch)
tree5fa74b1c1e951ac0099d335d7e911f9a1661fda1 /perllib/FixMyStreet
parentecb18f343e14918ed0bd916ac87969df445f64da (diff)
Improve wording/grammar when report is sent to more than two bodies
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm24
1 files changed, 14 insertions, 10 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index fac0fc7ef..f67e0b0f8 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -660,16 +660,20 @@ sub body {
}
} else {
my $bodies = $problem->bodies;
- $body = join( _(' and '),
- map {
- my $name = $_->name;
- if ($c and FixMyStreet->config('AREA_LINKS_FROM_PROBLEMS')) {
- '<a href="' . $_->url($c) . '">' . $name . '</a>';
- } else {
- $name;
- }
- } values %$bodies
- );
+ my @body_names = sort map {
+ my $name = $_->name;
+ if ($c and FixMyStreet->config('AREA_LINKS_FROM_PROBLEMS')) {
+ '<a href="' . $_->url($c) . '">' . $name . '</a>';
+ } else {
+ $name;
+ }
+ } values %$bodies;
+ if ( scalar @body_names > 2 ) {
+ $body = join( ', ', splice @body_names, 0, -1);
+ $body = join( ',' . _(' and '), ($body, $body_names[-1]));
+ } else {
+ $body = join( _(' and '), @body_names);
+ }
}
return $body;
}