diff options
author | Dave Arter <davea@mysociety.org> | 2018-03-12 11:31:21 +0000 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2018-03-29 16:04:31 +0100 |
commit | fed75f471279cda99b877a6015024a5c59eeeafd (patch) | |
tree | 5fa74b1c1e951ac0099d335d7e911f9a1661fda1 | |
parent | ecb18f343e14918ed0bd916ac87969df445f64da (diff) |
Improve wording/grammar when report is sent to more than two bodies
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 24 | ||||
-rw-r--r-- | templates/web/base/report/_item.html | 3 |
2 files changed, 16 insertions, 11 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; } diff --git a/templates/web/base/report/_item.html b/templates/web/base/report/_item.html index 8179139ca..b1fa8fcad 100644 --- a/templates/web/base/report/_item.html +++ b/templates/web/base/report/_item.html @@ -66,7 +66,8 @@ [% IF include_sentinfo %] [% IF c.cobrand.is_council && !c.cobrand.owns_problem( problem ) %] (sent to [% problem.body %]) - [% ELSIF problem.bodies_str_ids.size > 1 %] [% loc('(sent to both)') %] + [% ELSIF problem.bodies_str_ids.size > 2 %] [% loc('(sent to all)') %] + [% ELSIF problem.bodies_str_ids.size == 2 %] [% loc('(sent to both)') %] [% ELSIF problem.bodies_str_ids.size == 0 %] [% loc('(not sent to council)') %] [% END %] [% END %] |