diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | cpanfile | 2 | ||||
-rw-r--r-- | cpanfile.snapshot | 16 | ||||
-rw-r--r-- | t/app/01app.t | 19 | ||||
-rw-r--r-- | templates/web/base/admin/index.html | 9 | ||||
-rw-r--r-- | templates/web/base/front/stats.html | 17 | ||||
-rw-r--r-- | templates/web/base/status/index.html | 9 | ||||
-rw-r--r-- | templates/web/base/status/stats.html | 28 | ||||
-rw-r--r-- | templates/web/emptyhomes/front/stats.html | 3 |
9 files changed, 71 insertions, 33 deletions
@@ -46,6 +46,7 @@ We've extracted all of the mobile apps from this repository into the - Bugfixes: - Default the Google map view to hybrid. #1293 - Prevent SVG chevron being stretched in Firefox. #1256 + - Better display/internationalisation of numbers. #1297 - Development improvements: - Add generic static route handler. #1235 - Store reports summary data by cobrand. #1290 @@ -80,7 +80,7 @@ requires 'Regexp::Common'; requires 'Scalar::Util'; requires 'Statistics::Distributions'; requires 'Storable'; -requires 'Template::Plugin::Comma'; +requires 'Template::Plugin::Number::Format'; requires 'Text::CSV'; requires 'URI'; requires 'URI::Escape'; diff --git a/cpanfile.snapshot b/cpanfile.snapshot index b1afdc867..7bf4bc0a7 100644 --- a/cpanfile.snapshot +++ b/cpanfile.snapshot @@ -4382,6 +4382,14 @@ DISTRIBUTIONS requirements: ExtUtils::MakeMaker 0 Test::More 0 + Number-Format-1.75 + pathname: W/WR/WRW/Number-Format-1.75.tar.gz + provides: + Number::Format 1.75 + requirements: + Carp 0 + ExtUtils::MakeMaker 0 + POSIX 0 Number-Tolerant-1.703 pathname: R/RJ/RJBS/Number-Tolerant-1.703.tar.gz provides: @@ -5172,14 +5180,14 @@ DISTRIBUTIONS Scalar::Util 1.14 Test::More 0.42 perl 5.005 - Template-Plugin-Comma-0.04 - pathname: M/MI/MIYAGAWA/Template-Plugin-Comma-0.04.tar.gz + Template-Plugin-Number-Format-1.06 + pathname: D/DA/DARREN/Template-Plugin-Number-Format-1.06.tar.gz provides: - Template::Plugin::Comma 0.04 + Template::Plugin::Number::Format 1.06 requirements: ExtUtils::MakeMaker 0 + Number::Format 0 Template 2.07 - Test::More 0.32 Template-Timer-1.00 pathname: P/PE/PETDANCE/Template-Timer-1.00.tar.gz provides: diff --git a/t/app/01app.t b/t/app/01app.t index 02ffcd217..eb98b6319 100644 --- a/t/app/01app.t +++ b/t/app/01app.t @@ -1,10 +1,27 @@ #!/usr/bin/env perl + use strict; use warnings; -use Test::More; +package FixMyStreet::Cobrand::Tester; +use parent 'FixMyStreet::Cobrand::FiksGataMi'; +sub front_stats_data { { new => 0, fixed => 0, updates => 12345 } } + +package main; + +use Test::More; use Catalyst::Test 'FixMyStreet::App'; +use charnames ':full'; +use Encode qw(encode); ok( request('/')->is_success, 'Request should succeed' ); +FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'tester' ], +}, sub { + my $page = get('/'); + my $num = encode('UTF-8', "12\N{NO-BREAK SPACE}345"); + like $page, qr/$num/; +}; + done_testing(); diff --git a/templates/web/base/admin/index.html b/templates/web/base/admin/index.html index dde6523a3..4c4a7b388 100644 --- a/templates/web/base/admin/index.html +++ b/templates/web/base/admin/index.html @@ -28,14 +28,7 @@ and to receive notices of updates. [%- END %] [% END -%] - <ul> - <li>[% tprintf( loc('<strong>%d</strong> live problems'), total_problems_live ) %]; - [% tprintf( loc('from %d different users'), total_problems_users ) %]</li> - <li>[% tprintf( loc('%d live updates'), comments.confirmed || 0 ) %]</li> - <li>[% tprintf( loc('%d confirmed alerts, %d unconfirmed'), alerts.1, alerts.0) %]</li> - <li>[% tprintf( loc('%d questionnaires sent – %d answered (%s%%)'), questionnaires.total, questionnaires.1, questionnaires_pc) %]</li> - <li>[% tprintf( loc('%d council contacts – %d confirmed, %d unconfirmed'), contacts.total, contacts.1, contacts.0) %]</li> - </ul> +[% INCLUDE 'status/stats.html' admin_include_users=1 %] [% IF c.cobrand.admin_show_creation_graph -%] <p> diff --git a/templates/web/base/front/stats.html b/templates/web/base/front/stats.html index 5367f1118..eb671137b 100644 --- a/templates/web/base/front/stats.html +++ b/templates/web/base/front/stats.html @@ -1,8 +1,4 @@ -[% - USE Comma; - # Note - if we want to i18n the commas we should try - # 'Template::Plugin::Number::Format' -%] +[% USE Number.Format %] [% stats = c.cobrand.front_stats_data(); @@ -31,13 +27,16 @@ "<big>%s</big> updates on reports", stats.updates ); - + + new_n = stats.new | format_number; + fixed_n = stats.fixed | format_number; + updates_n = stats.updates | format_number; %] <div id="front_stats"> - <div>[% tprintf( new_text, stats.new ) | comma %]</div> - <div>[% tprintf( fixed_text, stats.fixed ) | comma %]</div> + <div>[% tprintf( new_text, decode(new_n) ) %]</div> + <div>[% tprintf( fixed_text, decode(fixed_n) ) %]</div> [% IF c.cobrand.moniker != 'zurich' %] - <div>[% tprintf( updates_text, stats.updates ) | comma %]</div> + <div>[% tprintf( updates_text, decode(updates_n) ) %]</div> [% END %] </div> diff --git a/templates/web/base/status/index.html b/templates/web/base/status/index.html index 9ed4292b7..34bf62056 100644 --- a/templates/web/base/status/index.html +++ b/templates/web/base/status/index.html @@ -7,13 +7,6 @@ <dd>[% git_version || 'unknown' %]</dd> </dl> -<ul> - <li>[% tprintf( loc('<strong>%d</strong> live problems'), total_problems_live ) %]</li> - <li>[% tprintf( loc('%d live updates'), comments.confirmed || 0 ) %]</li> - <li>[% tprintf( loc('%d confirmed alerts, %d unconfirmed'), alerts.1, alerts.0) %]</li> - <li>[% tprintf( loc('%d questionnaires sent – %d answered (%s%%)'), questionnaires.total, questionnaires.1, questionnaires_pc) %]</li> - <li>[% tprintf( '%d bodies', total_bodies) %], - [% tprintf( loc('%d council contacts – %d confirmed, %d unconfirmed'), contacts.total, contacts.1, contacts.0) %]</li> -</ul> +[% INCLUDE 'status/stats.html' %] [% INCLUDE 'footer.html' %] diff --git a/templates/web/base/status/stats.html b/templates/web/base/status/stats.html new file mode 100644 index 000000000..77c316f12 --- /dev/null +++ b/templates/web/base/status/stats.html @@ -0,0 +1,28 @@ +[% USE Number.Format %] + +[%- + total_problems_live = total_problems_live | format_number; + total_problems_users = total_problems_users | format_number; + comments_confirmed = (comments.confirmed || 0) | format_number; + alerts_1 = alerts.1 | format_number; + alerts_0 = alerts.1 | format_number; + questionnaires_total = questionnaires.total | format_number; + questionnaires_1 = questionnaires.1 | format_number; + total_bodies = total_bodies | format_number; + contacts_total = contacts.total | format_number; + contacts_1 = contacts.1 | format_number; + contacts_0 = contacts.0 | format_number; +-%] + +<ul> + <li>[% tprintf( loc('<strong>%d</strong> live problems'), decode(total_problems_live) ) %] + [% IF admin_include_users %] + [% tprintf( loc('from %d different users'), decode(total_problems_users) ) %] + [% END %] + </li> + <li>[% tprintf( loc('%d live updates'), decode(comments_confirmed) ) %]</li> + <li>[% tprintf( loc('%d confirmed alerts, %d unconfirmed'), decode(alerts_1), decode(alerts_0)) %]</li> + <li>[% tprintf( loc('%d questionnaires sent – %d answered (%s%%)'), decode(questionnaires_total), decode(questionnaires_1), questionnaires_pc) %]</li> + <li>[% tprintf( '%d bodies', decode(total_bodies)) %], + [% tprintf( loc('%d council contacts – %d confirmed, %d unconfirmed'), decode(contacts_total), decode(contacts_1), decode(contacts_0)) %]</li> +</ul> diff --git a/templates/web/emptyhomes/front/stats.html b/templates/web/emptyhomes/front/stats.html index c956b0e2e..5ecc415bf 100644 --- a/templates/web/emptyhomes/front/stats.html +++ b/templates/web/emptyhomes/front/stats.html @@ -1,8 +1,7 @@ -[% USE Comma %] [% stats = c.cobrand.front_stats_data %] <div id="front_stats"> - <div>[% tprintf( loc("<big>%s</big> reports"), stats ) | comma %]</div> + <div>[% tprintf( loc("<big>%s</big> reports"), stats ) %]</div> <!-- <div><a href="/local/">[% loc('Find latest local and national news') %]</a></div> --> <div id="eha-app-link"><a href="https://itunes.apple.com/gb/app/empty-homes-spotter/id482550587?mt=8">Get the Empty Homes Spotter App for iPhone</a></div> </div> |