From afad42bf0227966dedfdbd7272e8cf7fc5e53cc0 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 9 Dec 2015 12:40:06 +0000 Subject: Switch template plugin for nice numbers. Template::Plugin::Number::Format works internationally, whilst Template::Plugin::Comma does not. --- cpanfile | 2 +- cpanfile.snapshot | 16 ++++++++++++---- t/app/01app.t | 19 ++++++++++++++++++- templates/web/base/front/stats.html | 17 ++++++++--------- templates/web/emptyhomes/front/stats.html | 3 +-- 5 files changed, 40 insertions(+), 17 deletions(-) diff --git a/cpanfile b/cpanfile index 25c63c736..eae53fcb1 100644 --- a/cpanfile +++ b/cpanfile @@ -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/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 @@ "%s updates on reports", stats.updates ); - + + new_n = stats.new | format_number; + fixed_n = stats.fixed | format_number; + updates_n = stats.updates | format_number; %]
-
[% tprintf( new_text, stats.new ) | comma %]
-
[% tprintf( fixed_text, stats.fixed ) | comma %]
+
[% tprintf( new_text, decode(new_n) ) %]
+
[% tprintf( fixed_text, decode(fixed_n) ) %]
[% IF c.cobrand.moniker != 'zurich' %] -
[% tprintf( updates_text, stats.updates ) | comma %]
+
[% tprintf( updates_text, decode(updates_n) ) %]
[% END %]
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 %]
-
[% tprintf( loc("%s reports"), stats ) | comma %]
+
[% tprintf( loc("%s reports"), stats ) %]
-- cgit v1.2.3