From 69c5632cea68018605c5170bc73e8717b3d87be6 Mon Sep 17 00:00:00 2001
From: matthew
Date: Tue, 6 May 2008 10:01:23 +0000
Subject: Various i18n changes; watermark; smaller map possibility.
---
bin/gettext-extract | 53 +++++++
bin/make_emptyhomes_po | 79 ++++++++++
conf/crontab.ugly | 4 +-
perllib/Page.pm | 57 ++++++--
templates/website/emptyhomes-header | 5 +-
web/css/core.css | 9 ++
web/css/emptyhomes.css | 76 ++++++++++
web/css/ie6.css | 4 +
web/css/main-emptyhomes.css | 64 --------
web/css/main-scambs.css | 8 +
web/index.cgi | 281 ++++++++++++++++++------------------
web/js.js | 4 +-
web/mojwatermark5.png | Bin 0 -> 11431 bytes
web/questionnaire.cgi | 9 +-
web/reports.cgi | 43 ++++--
15 files changed, 457 insertions(+), 239 deletions(-)
create mode 100755 bin/gettext-extract
create mode 100755 bin/make_emptyhomes_po
create mode 100644 web/css/emptyhomes.css
create mode 100644 web/css/ie6.css
delete mode 100644 web/css/main-emptyhomes.css
create mode 100644 web/mojwatermark5.png
diff --git a/bin/gettext-extract b/bin/gettext-extract
new file mode 100755
index 000000000..70ed66a4f
--- /dev/null
+++ b/bin/gettext-extract
@@ -0,0 +1,53 @@
+#!/bin/bash
+#
+# bci/bin/gettext-extract
+# Generate English language .po files from the source code and email templates,
+# for FixMyStreet. Writes the output to appropriate .po files in locale/.
+#
+# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
+# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
+#
+# $Id: gettext-extract,v 1.1 2008-05-06 10:01:23 matthew Exp $
+
+if [ -e ../../locale ]
+then
+ cd ../../
+else if [ -e ../locale ]
+then
+ cd ../
+else if [ -e locale ]
+then
+ cd .
+else
+ echo "Please run with current directory bci/bin"
+ exit 1
+fi
+fi
+fi
+
+
+# File to write to, clear it to start with
+PO=locale/FixMyStreet.po
+rm -f $PO
+
+# Extract from Perl
+xgettext --add-comments=TRANS --language=Perl --keyword=_ --from-code=utf-8 -o $PO perllib/mySociety/*.pm bci/perllib/*.pm bci/web/*.cgi bci/bin/send-reports
+
+# Fix headers
+TEMP=`tempfile`
+cat $PO | sed "
+ s/SOME DESCRIPTIVE TITLE/FixMyStreet original .po file, autogenerated by gettext-extract/;
+ s/YEAR THE PACKAGE'S COPYRIGHT HOLDER/2008 UK Citizens Online Democracy/;
+ s/PACKAGE package/main FixMyStreet code/;
+ s/FIRST AUTHOR , YEAR./Matthew Somerville , 2008-04-15./;
+
+ s/PACKAGE VERSION/1.0/;
+ s/Report-Msgid-Bugs-To: /Report-Msgid-Bugs-To: matthew@mysociety.org/;
+ s/LL@li.org/team@fixmystreet.com/;
+ s/charset=CHARSET/charset=UTF-8/;
+" >> $TEMP
+mv $TEMP $PO
+
+# XXX: Email templates - should be in >1 language...
+# And the XSL page too.
+
diff --git a/bin/make_emptyhomes_po b/bin/make_emptyhomes_po
new file mode 100755
index 000000000..69e8c625b
--- /dev/null
+++ b/bin/make_emptyhomes_po
@@ -0,0 +1,79 @@
+#!/usr/bin/perl -w
+use strict;
+
+# Generates EmptyHomes version of .po file, which is a translation
+# into a language the same as English, only "problem" becomes "empty property".
+
+use POSIX;
+use FindBin;
+
+chdir("$FindBin::Bin/../../locale");
+mkdir("en_GB.UTF-8");
+mkdir("en_GB.UTF-8/LC_MESSAGES");
+
+open(MAINPO, "FixMyStreet.po") or die "";
+open(NEWPO, ">en_GB.UTF-8/LC_MESSAGES/FixMyStreet-EmptyHomes.po") or die "";
+
+print NEWPO "# AUTOMATICALLY GENERATED by make_emptyhomes_po, do not edit\n";
+print NEWPO "\n";
+
+my $buffer = "";
+my $start = 0;
+while() {
+ if (!$start) {
+ s/#, fuzzy//;
+ }
+ if (m/"Last-Translator: FULL NAME/) {
+ $_ = '"Last-Translator: mysociety/bin/make_emptyhomes_po\\n"'."\n";
+ }
+ if (m/"PO-Revision-Date: YEAR-MO-DA/) {
+ my $time = POSIX::strftime("%Y-%m-%d %H:%M%z", localtime(time()));
+ $_ = '"PO-Revision-Date: '.$time.'\\n"'."\n";
+ }
+ if (m/"Language-Team: LANGUAGE/) {
+ $_ = '"Language-Team: Live Simply Promise\\n"'."\n";
+ }
+ if (m/"Plural-Forms: nplurals=/) {
+ $_ = '"Plural-Forms: nplurals=2; plural=n != 1;\\n"'."\n";
+ }
+
+ if (m/^#/) {
+ # comment or blank line
+ print NEWPO $_;
+ } elsif (m/^\s+$/) {
+ # blank line
+ $start = 1;
+ $buffer = "";
+ print NEWPO $_;
+ } elsif ($start && (m/^msgstr ""/ || m/^msgstr\[0\] ""/)) {
+ # start of translated text - translate English into Live Simple Promise
+ # langauage
+ if (m/^msgstr\[0\] ""/) {
+ $buffer =~ s/^msgid "/msgstr[0] "/m;
+ $buffer =~ s/^msgid_plural "/msgstr[1] "/m;
+ ; # skip untranslated plural
+ } else {
+ $buffer =~ s/^msgid "/msgstr "/;
+ }
+
+ # Basics
+ $buffer =~ s/FixMyStreet/Empty Homes Agency/g;
+ $buffer =~ s/\bproblem\b/empty property/g;
+ $buffer =~ s/\bProblem\b/Empty property/g;
+ $buffer =~ s/\bproblems\b/empty properties/g;
+ $buffer =~ s/\bProblems\b/Empty properties/g;
+ $buffer =~ s/a empty/an empty/g;
+
+ $buffer =~ s/^\(like graffiti.*/ /;
+
+ print NEWPO $buffer;
+ $buffer = "";
+ } else {
+ # English text
+ print NEWPO $_;
+ $buffer .= $_;
+ }
+
+
+}
+
diff --git a/conf/crontab.ugly b/conf/crontab.ugly
index 3eba692dd..b4d3191bf 100644
--- a/conf/crontab.ugly
+++ b/conf/crontab.ugly
@@ -4,10 +4,10 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org/
#
-# $Id: crontab.ugly,v 1.12 2008-04-11 11:21:31 francis Exp $
+# $Id: crontab.ugly,v 1.13 2008-05-06 10:01:25 matthew Exp $
PATH=/usr/local/bin:/usr/bin:/bin
-!!(* if ($vhost eq "matthew.bci.mysociety.org") { *)!!
+!!(* if ($vhost eq "matthew.fixmystreet.com") { *)!!
MAILTO=matthew@mysociety.org
!!(* } else {*)!!
MAILTO=team@fixmystreet.com
diff --git a/perllib/Page.pm b/perllib/Page.pm
index c6868f508..a3afa5888 100644
--- a/perllib/Page.pm
+++ b/perllib/Page.pm
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Page.pm,v 1.91 2008-04-15 13:54:53 matthew Exp $
+# $Id: Page.pm,v 1.92 2008-05-06 10:01:30 matthew Exp $
#
package Page;
@@ -24,6 +24,7 @@ use URI::Escape;
use mySociety::Config;
use mySociety::DBHandle qw/dbh select_all/;
use mySociety::EvEl;
+use mySociety::Locale;
use mySociety::MaPit;
use mySociety::PostcodeUtil;
use mySociety::Tracking;
@@ -75,6 +76,16 @@ sub microsite {
$q->{site} = 'fixmystreet';
$q->{site} = 'scambs' if $host =~ /scambs/;
$q->{site} = 'emptyhomes' if $host =~ /emptyhomes/;
+
+ if ($q->{site} eq 'emptyhomes') {
+ $q->{thing} = 'empty property';
+ mySociety::Locale::negotiate_language('en-gb,English,en_GB', 'en-gb');
+ mySociety::Locale::gettext_domain('FixMyStreet-EmptyHomes');
+ mySociety::Locale::change();
+ } else {
+ $q->{thing} = 'problem';
+ mySociety::Locale::gettext_domain('FixMyStreet');
+ }
}
=item header Q [PARAM VALUE ...]
@@ -124,6 +135,10 @@ sub header ($%) {
${title}FixMyStreet
+
+
@@ -215,8 +230,12 @@ sub display_map {
$params{pins} ||= '';
$params{pre} ||= '';
$params{post} ||= '';
- my $px = defined($params{px}) ? 254-$params{px} : 0;
- my $py = defined($params{py}) ? 254-$params{py} : 0;
+ my $mid_point = 254;
+ if ($q->{site} eq 'emptyhomes' || $q->{site} eq 'scambs') { # Map is c. 380px wide
+ $mid_point = 189;
+ }
+ my $px = defined($params{px}) ? $mid_point - $params{px} : 0;
+ my $py = defined($params{py}) ? $mid_point - $params{py} : 0;
my $x = int($params{x})<=0 ? 0 : $params{x};
my $y = int($params{y})<=0 ? 0 : $params{y};
my $url = mySociety::Config::get('TILES_URL');
@@ -266,6 +285,7 @@ $params{pre}
$params{pins}
EOF
+ $out .= '';
$out .= compass($q, $x, $y);
$out .= <
@@ -290,7 +310,7 @@ sub display_pin {
$num = '' unless $num;
my %cols = (red=>'R', green=>'G', blue=>'B', purple=>'P');
my $out = '';
return $out unless $_ && $_->{id} && $col ne 'blue';
my $url = NewURL($q, id=>$_->{id}, x=>undef, y=>undef);
@@ -362,6 +382,28 @@ sub click_to_tile {
return $pin_tile + $pin / 254;
}
+sub os_to_px_with_adjust {
+ my ($q, $easting, $northing, $in_x, $in_y) = @_;
+
+ my $x = Page::os_to_tile($easting);
+ my $y = Page::os_to_tile($northing);
+ my $x_tile = $in_x || int($x);
+ my $y_tile = $in_y || int($y);
+ my $px = Page::os_to_px($easting, $x_tile);
+ my $py = Page::os_to_px($northing, $y_tile, 1);
+ if ($q->{site} eq 'emptyhomes' || $q->{site} eq 'scambs') { # Map is 380px
+ if ($py > 380) {
+ $y_tile--;
+ $py = Page::os_to_px($northing, $y_tile, 1);
+ }
+ if ($px > 380) {
+ $x_tile--;
+ $px = Page::os_to_px($easting, $x_tile);
+ }
+ }
+ return ($x, $y, $x_tile, $y_tile, $px, $py);
+}
+
# send_email TO (NAME) TEMPLATE-NAME PARAMETERS
sub send_email {
my ($email, $name, $thing, %h) = @_;
@@ -373,7 +415,7 @@ sub send_email {
mySociety::EvEl::send({
_template_ => $template,
_parameters_ => \%h,
- From => [ $sender, 'FixMyStreet'],
+ From => [ $sender, _('FixMyStreet')],
To => $to,
}, $email);
my $out;
@@ -435,11 +477,6 @@ sub _part {
}
}
-# Simply so I can gettext the code without making the locale stuff all work
-sub _ {
- return $_[0];
-}
-
sub display_problem_text {
my ($q, $problem) = @_;
my $out = $q->h1(ent($problem->{title}));
diff --git a/templates/website/emptyhomes-header b/templates/website/emptyhomes-header
index 79728aa16..e0d86bca5 100644
--- a/templates/website/emptyhomes-header
+++ b/templates/website/emptyhomes-header
@@ -8,10 +8,7 @@
diff --git a/web/css/core.css b/web/css/core.css
index a1fa31b64..9efc0b35a 100644
--- a/web/css/core.css
+++ b/web/css/core.css
@@ -160,6 +160,15 @@ ul#error {
/* Map */
+#watermark {
+ background: url("/mojwatermark5.png");
+ height: 508px;
+ width: 508px;
+ position: absolute;
+ top: 0;
+ left: 0;
+}
+
#map_box {
float: right;
width: 510px;
diff --git a/web/css/emptyhomes.css b/web/css/emptyhomes.css
new file mode 100644
index 000000000..fe2304a71
--- /dev/null
+++ b/web/css/emptyhomes.css
@@ -0,0 +1,76 @@
+label {
+ width: 3em;
+}
+
+#alert_links {
+ float: none;
+}
+
+#map_box {
+ width: 380px;
+}
+#map, #drag {
+ width: 378px;
+ height: 378px;
+}
+
+#toptitle {
+ margin-top: 0.5em;
+}
+#middle {
+ width: 620px;
+}
+#middle p {
+ width: 620px;
+}
+#middle p#copyright {
+ width: auto;
+}
+p#fixed, p#unknown {
+ margin-right: 400px;
+ width: auto;
+}
+
+#left #topbox a, #left #bottombox a {
+ color: #30517A;
+ font-weight: normal;
+ background-color: inherit;
+}
+
+#header, #smallnav, #main {
+ margin: 0 auto;
+}
+
+#search p {
+ text-align: right;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #000000;
+ margin: 0;
+}
+#search p#searchbox {
+ margin: 0.5em 0 0.25em;
+}
+
+#left ol {
+ padding: 0;
+}
+
+blockquote {
+ border-left: solid 4px #013B63;
+}
+
+.a {
+ color: #000000;
+ background-color: #DCDCED; /* #427499; */
+}
+
+#postcodeForm, #front_stats div {
+ background-color: #80AE7D;
+ color: #000000;
+}
+
+#front_stats div {
+ padding: 0.5em 0;
+ width: 6em;
+}
+
diff --git a/web/css/ie6.css b/web/css/ie6.css
new file mode 100644
index 000000000..073905425
--- /dev/null
+++ b/web/css/ie6.css
@@ -0,0 +1,4 @@
+#watermark {
+ background: none;
+ filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/mojwatermark5.png',sizingMethod='scale');
+}
diff --git a/web/css/main-emptyhomes.css b/web/css/main-emptyhomes.css
deleted file mode 100644
index 5e8422601..000000000
--- a/web/css/main-emptyhomes.css
+++ /dev/null
@@ -1,64 +0,0 @@
-#map_box {
- width: 380px;
-}
-#map, #drag {
- width: 378px;
- height: 378px;
-}
-
-#toptitle {
- margin-top: 0.5em;
-}
-#middle {
- width: 570px;
-}
-#middle p {
- width: 580px;
-}
-#middle p#copyright {
- width: auto;
-}
-
-#left #topbox a, #left #bottombox a {
- color: #30517A;
- font-weight: normal;
- background-color: inherit;
-}
-
-#header, #smallnav, #main {
- margin: 0 auto;
-}
-
-#search p {
- text-align: right;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- color: #000000;
- margin: 0;
-}
-#search p#searchbox {
- margin: 0.5em 0 0.25em;
-}
-
-#left ol {
- padding: 0;
-}
-
-blockquote {
- border-left: solid 4px #013B63;
-}
-
-.a {
- color: #000000;
- background-color: #427499;
-}
-
-#postcodeForm, #front_stats div {
- background-color: #80AE7D;
- color: #000000;
-}
-
-#front_stats div {
- padding: 0.5em 0;
- width: 6em;
-}
-
diff --git a/web/css/main-scambs.css b/web/css/main-scambs.css
index 08ed4011e..a8fb0a548 100644
--- a/web/css/main-scambs.css
+++ b/web/css/main-scambs.css
@@ -17,3 +17,11 @@ blockquote {
width: 7em;
}
+#map_box {
+ width: 380px;
+}
+#map, #drag {
+ width: 378px;
+ height: 378px;
+}
+
diff --git a/web/index.cgi b/web/index.cgi
index c84acc934..d69c7248a 100755
--- a/web/index.cgi
+++ b/web/index.cgi
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: index.cgi,v 1.190 2008-04-14 16:06:03 matthew Exp $
+# $Id: index.cgi,v 1.191 2008-05-06 10:01:31 matthew Exp $
use strict;
use Standard;
@@ -45,20 +45,20 @@ sub main {
my $out = '';
my %params;
if ($q->param('submit_problem') || ($q->param('submit_map') && $q->param('submit_map')==2)) {
- $params{title} = 'Submitting your problem';
+ $params{title} = _('Submitting your report');
($out) = submit_problem($q);
} elsif ($q->param('submit_update')) {
- $params{title} = 'Submitting your update';
+ $params{title} = _('Submitting your update');
($out) = submit_update($q);
} elsif ($q->param('submit_map')) {
($out, %params) = display_form($q);
- $params{title} = 'Reporting a problem';
+ $params{title} = _('Reporting a problem');
} elsif ($q->param('id')) {
($out, %params) = display_problem($q);
- $params{title} .= ' - Viewing a problem';
+ $params{title} .= ' - ' . _('Viewing a problem');
} elsif ($q->param('pc') || ($q->param('x') && $q->param('y'))) {
($out, %params) = display_location($q);
- $params{title} = 'Viewing a location';
+ $params{title} = _('Viewing a location');
} else {
$out = front_page($q);
}
@@ -74,10 +74,8 @@ Page::do_fastcgi(\&main);
sub front_page {
my ($q, $error) = @_;
my $pc_h = ent($q->param('pc') || '');
- my $out = <Report, view, or discuss local problems
- (like graffiti, fly tipping, broken paving slabs, or street lighting)
-EOF
+ my $out = '
' . _('Report, view, or discuss local problems') . '
+ ' . _('(like graffiti, fly tipping, broken paving slabs, or street lighting)') . '
';
$out .= '
' . $error . '
' if ($error);
my $fixed = dbh()->selectrow_array("select count(*) from problem where state='fixed' and lastupdate>ms_current_timestamp()-'1 month'::interval");
my $updates = dbh()->selectrow_array("select count(*) from comment where state='confirmed'");
@@ -114,17 +112,17 @@ EOF
+EOF
+ $out .= $q->h2(_('How to report a problem'));
+ $out .= $q->ol(
+ $q->li(_('Enter a nearby UK postcode, or street name and area')),
+ $q->li(_('Locate the problem on a map of the area')),
+ $q->li(_('Enter details of the problem')),
+ $q->li(_('We send it to the council on your behalf'))
+ );
-
How to report a problem
-
-
-
Enter a nearby UK postcode, or street name and area
-
$recent_photos" if $recent_photos;
+ $out .= $q->h2(_('Photos of recent reports')) . $recent_photos if $recent_photos;
my $probs = select_all("select id,title from problem
where state in ('confirmed', 'fixed')
order by confirmed desc limit 5");
- $out .= '
'. ent($_->{title});
$out .= '';
@@ -180,7 +178,7 @@ sub submit_update {
$image = Page::process_photo($fh);
} catch Error::Simple with {
my $e = shift;
- push(@errors, "That image doesn't appear to have uploaded correctly ($e), please try again.");
+ push(@errors, sprintf(_("That image doesn't appear to have uploaded correctly (%s), please try again."), $e));
};
}
@@ -201,7 +199,7 @@ sub submit_update {
my %h = ();
$h{update} = $input{update};
- $h{name} = $input{name} ? $input{name} : "Anonymous";
+ $h{name} = $input{name} ? $input{name} : _("Anonymous");
$h{url} = mySociety::Config::get('BASE_URL') . '/C/' . mySociety::AuthToken::store('update', $id);
dbh()->commit();
@@ -216,7 +214,7 @@ sub submit_problem {
for (qw(title detail)) {
$input{$_} = lc $input{$_} if $input{$_} !~ /[a-z]/;
$input{$_} = ucfirst $input{$_};
- $input{$_} =~ s/\b(dog\s*)shit\b/$1poo/ig;
+ $input{$_} =~ s/\b(dog\s*)shit\b/$1poo/ig;
}
my @errors;
@@ -226,21 +224,21 @@ sub submit_problem {
push @errors, $err if $err;
}
- push(@errors, 'No council selected') unless ($input{council} && $input{council} =~ /^(?:-1|[\d,]+(?:\|[\d,]+)?)$/);
- push(@errors, 'Please enter a subject') unless $input{title} =~ /\S/;
- push(@errors, 'Please enter some details') unless $input{detail} =~ /\S/;
+ push(@errors, _('No council selected')) unless ($input{council} && $input{council} =~ /^(?:-1|[\d,]+(?:\|[\d,]+)?)$/);
+ push(@errors, _('Please enter a subject')) unless $input{title} =~ /\S/;
+ push(@errors, _('Please enter some details')) unless $input{detail} =~ /\S/;
if ($input{name} !~ /\S/) {
- push @errors, 'Please enter your name';
+ push @errors, _('Please enter your name');
} elsif (length($input{name}) < 5 || $input{name} !~ /\s/ || $input{name} =~ /\ba\s*n+on+((y|o)mo?u?s)?(ly)?\b/i) {
- push @errors, 'Please enter your full name, councils need this information - if you do not wish your name to be shown on the site, untick the box';
+ push @errors, _('Please enter your full name, councils need this information - if you do not wish your name to be shown on the site, untick the box');
}
if ($input{email} !~ /\S/) {
- push(@errors, 'Please enter your email');
+ push(@errors, _('Please enter your email'));
} elsif (!mySociety::EmailUtil::is_valid_email($input{email})) {
- push(@errors, 'Please enter a valid email');
+ push(@errors, _('Please enter a valid email'));
}
if ($input{category} && $input{category} eq '-- Pick a category --') {
- push (@errors, 'Please choose a category');
+ push (@errors, _('Please choose a category'));
$input{category} = '';
}
@@ -262,7 +260,7 @@ sub submit_problem {
my @input_councils = split /,|\|/, $input{council};
foreach (@input_councils) {
if (!$councils{$_}) {
- push(@errors, 'That location is not part of that council');
+ push(@errors, _('That location is not part of that council'));
last;
}
}
@@ -282,7 +280,7 @@ sub submit_problem {
@valid_councils = map { $_->{area_id} } @$categories;
foreach my $c (@valid_councils) {
if ($no_details =~ /$c/) {
- push(@errors, 'We have details for that council');
+ push(@errors, _('We have details for that council'));
$no_details =~ s/,?$c//;
}
}
@@ -291,9 +289,9 @@ sub submit_problem {
}
$areas = ',' . join(',', sort keys %$areas) . ',';
} elsif ($input{easting} || $input{northing}) {
- push(@errors, 'Somehow, you only have one co-ordinate. Please try again.');
+ push(@errors, _('Somehow, you only have one co-ordinate. Please try again.'));
} else {
- push(@errors, 'You haven\'t specified any sort of co-ordinates. Please try again.');
+ push(@errors, _('You haven\'t specified any sort of co-ordinates. Please try again.'));
}
my $image;
@@ -302,7 +300,7 @@ sub submit_problem {
$image = Page::process_photo($fh);
} catch Error::Simple with {
my $e = shift;
- push(@errors, "That image doesn't appear to have uploaded correctly ($e), please try again.");
+ push(@errors, sprintf(_("That image doesn't appear to have uploaded correctly (%s), please try again."), $e));
};
}
@@ -316,7 +314,7 @@ sub submit_problem {
delete $input{council} if $input{council} eq '-1';
my $used_map = $input{skipped} ? 'f' : 't';
- $input{category} = 'Other' unless $input{category};
+ $input{category} = _('Other') unless $input{category};
my ($id, $out);
if (my $token = $input{flickr}) {
@@ -330,9 +328,9 @@ sub submit_problem {
$input{phone}, $input{council}, $input{anonymous} ? 'f' : 't',
$input{category}, $id);
dbh()->commit();
- $out = $q->p(sprintf(_('You have successfully confirmed your problem and you can now view it on the site.'), "/?id=$id"));
+ $out = $q->p(sprintf(_('You have successfully confirmed your report and you can now view it on the site.'), "/?id=$id"));
} else {
- $out = $q->p('There appears to have been a problem.');
+ $out = $q->p(_('There appears to have been a problem.'));
}
} else {
$id = dbh()->selectrow_array("select nextval('problem_id_seq');");
@@ -405,10 +403,10 @@ sub display_form {
$py = Page::os_to_px($northing, $input{y}, 1);
} else {
# Normal form submission
- $input{x} = int(Page::os_to_tile($input{easting}));
- $input{y} = int(Page::os_to_tile($input{northing}));
- $px = Page::os_to_px($input{easting}, $input{x});
- $py = Page::os_to_px($input{northing}, $input{y}, 1);
+ my ($x, $y, $tile_x, $tile_y);
+ ($x, $y, $tile_x, $tile_y, $px, $py) = Page::os_to_px_with_adjust($q, $input{easting}, $input{northing}, undef, undef);
+ $input{x} = $tile_x;
+ $input{y} = $tile_y;
$easting = $input_h{easting};
$northing = $input_h{northing};
}
@@ -423,27 +421,29 @@ sub display_form {
#'Litter', 'Neighbourhood noise');
}
$all_councils = [ keys %$all_councils ];
- return display_location($q, 'That spot does not appear to be covered by a council - if it is past the shoreline, for example, please specify the closest point on land.') unless @$all_councils;
+ return display_location($q, _('That spot does not appear to be covered by a council - if it is past the shoreline, for example, please specify the closest point on land.')) unless @$all_councils;
my $areas_info = mySociety::MaPit::get_voting_areas_info($all_councils);
# Look up categories for this council or councils
my $category = '';
my %council_ok;
- my $categories = select_all("select area_id, category from contacts
- where deleted='f' and area_id in (" . join(',', @$all_councils) . ')');
- @$categories = sort { $a->{category} cmp $b->{category} } @$categories;
- my @categories;
- foreach (@$categories) {
- $council_ok{$_->{area_id}} = 1;
- next if $_->{category} eq 'Other';
- push @categories, $_->{category};
- }
- if (@categories) {
- @categories = ('-- Pick a category --', @categories, 'Other');
- $category = $q->div($q->label({'for'=>'form_category'}, 'Category:'),
- $q->popup_menu(-name=>'category', -values=>\@categories,
- -attributes=>{id=>'form_category'})
- );
+ if ($q->{site} ne 'emptyhomes') { # No category
+ my $categories = select_all("select area_id, category from contacts
+ where deleted='f' and area_id in (" . join(',', @$all_councils) . ')');
+ @$categories = sort { $a->{category} cmp $b->{category} } @$categories;
+ my @categories;
+ foreach (@$categories) {
+ $council_ok{$_->{area_id}} = 1;
+ next if $_->{category} eq _('Other');
+ push @categories, $_->{category};
+ }
+ if (@categories) {
+ @categories = ('-- Pick a category --', @categories, _('Other'));
+ $category = $q->div($q->label({'for'=>'form_category'}, _('Category:')),
+ $q->popup_menu(-name=>'category', -values=>\@categories,
+ -attributes=>{id=>'form_category'})
+ );
+ }
}
my @councils = keys %council_ok;
@@ -463,65 +463,66 @@ sub display_form {
-
Reporting a problem
-
EOF
+ $out .= $q->h1(_('Reporting a problem')) . '
';
} else {
my $pins = Page::display_pin($q, $px, $py, 'purple');
$out .= Page::display_map($q, x => $input{x}, y => $input{y}, type => 2,
pins => $pins, px => $px, py => $py );
- $out .= '
Reporting a problem
';
- $out .= '
You have located the problem at the point marked with a purple pin on the map.
-If this is not the correct location, simply click on the map again. ';
- }
-
- if ($details eq 'all') {
- $out .= '
All the information you provide here will be sent to '
- . join(' or ', map { $areas_info->{$_}->{name} } @$all_councils)
- . '. On the site, we will show the subject and details of the problem,
- plus your name if you give us permission.';
- $out .= '';
- } elsif ($details eq 'some') {
- my $e = mySociety::Config::get('CONTACT_EMAIL');
- my %councils = map { $_ => 1 } @councils;
- my @missing;
- foreach (@$all_councils) {
- push @missing, $_ unless $councils{$_};
- }
- my $n = @missing;
- my $list = join(' or ', map { $areas_info->{$_}->{name} } @missing);
- $out .= '
All the information you provide here will be sent to '
- . join(' or ', map { $areas_info->{$_}->{name} } @councils)
- . '. On the site, we will show the subject and details of the problem,
- plus your name if you give us permission.';
- $out .= ' We do not yet have details for the other council';
- $out .= ($n>1) ? 's that cover' : ' that covers';
- $out .= " this location. You can help us by finding a contact email address for local
+ $out .= $q->h1(_('Reporting a problem')) . ' ';
+ $out .= $q->p(_('You have located the problem at the point marked with a purple pin on the map.
+If this is not the correct location, simply click on the map again. '));
+ }
+
+ if ($q->{site} ne 'emptyhomes') { # No "send to council" blurb
+ if ($details eq 'all') {
+ $out .= '
All the information you provide here will be sent to '
+ . join(' or ', map { $areas_info->{$_}->{name} } @$all_councils)
+ . '. On the site, we will show the subject and details of the problem,
+ plus your name if you give us permission.';
+ $out .= '';
+ } elsif ($details eq 'some') {
+ my $e = mySociety::Config::get('CONTACT_EMAIL');
+ my %councils = map { $_ => 1 } @councils;
+ my @missing;
+ foreach (@$all_councils) {
+ push @missing, $_ unless $councils{$_};
+ }
+ my $n = @missing;
+ my $list = join(' or ', map { $areas_info->{$_}->{name} } @missing);
+ $out .= '
All the information you provide here will be sent to '
+ . join(' or ', map { $areas_info->{$_}->{name} } @councils)
+ . '. On the site, we will show the subject and details of the problem,
+ plus your name if you give us permission.';
+ $out .= ' We do not yet have details for the other council';
+ $out .= ($n>1) ? 's that cover' : ' that covers';
+ $out .= " this location. You can help us by finding a contact email address for local
problems for $list and emailing it to us at $e.";
- $out .= '';
- } else {
- my $e = mySociety::Config::get('CONTACT_EMAIL');
- my $list = join(' or ', map { $areas_info->{$_}->{name} } @$all_councils);
- my $n = @$all_councils;
- $out .= '
We do not yet have details for the council';
- $out .= ($n>1) ? 's that cover' : ' that covers';
- $out .= " this location. If you submit a problem here it will be
+ $out .= '';
+ } else {
+ my $e = mySociety::Config::get('CONTACT_EMAIL');
+ my $list = join(' or ', map { $areas_info->{$_}->{name} } @$all_councils);
+ my $n = @$all_councils;
+ $out .= '
We do not yet have details for the council';
+ $out .= ($n>1) ? 's that cover' : ' that covers';
+ $out .= " this location. If you submit a problem here it will be
left on the site, but not reported to the council.
You can help us by finding a contact email address for local
problems for $list and emailing it to us at $e.";
- $out .= '';
+ $out .= '';
+ }
}
if ($input{skipped}) {
- $out .= '
Please fill in the form below with details of the problem, and
-describe the location as precisely as possible in the details box.';
+ $out .= $q->p(_('Please fill in the form below with details of the problem,
+and describe the location as precisely as possible in the details box.'));
} elsif ($details ne 'none') {
$out .= '
Please fill in details of the problem below. The council won\'t be able
to help unless you leave as much detail as you can, so please describe the exact location of
the problem (e.g. on a wall), what it is, how long it has been there, a description (and a
photo of the problem if you have one), etc.';
} else {
- $out .= '
Please fill in details of the problem below.';
+ $out .= $q->p(_('Please fill in details of the problem below.'));
}
$out .= '
@@ -534,10 +535,14 @@ photo of the problem if you have one), etc.';
$out .= <
$category
+EOF
+ $out .= <{site} eq 'emptyhomes'; # No Subject
+EOF
+ $out .= <
-
+
EOF
if (my $token = $input{flickr}) {
my $id = mySociety::AuthToken::retrieve('flickr', $token);
@@ -568,8 +573,10 @@ EOF
-
+
(optional)
+EOF
+ $out .= <{site} eq 'emptyhomes'; # No notes
Please note:
Please be polite, concise and to the point.
@@ -581,6 +588,8 @@ problems that can be fixed. If your problem is not appropriate for
submission via this site remember that you can contact your council
directly using their own website.
+EOF
+ $out .= <
EOF
@@ -619,24 +628,18 @@ sub display_location {
my ($pins, $current_map, $current, $fixed, $dist) = map_pins($q, $x, $y);
my $out = Page::display_map($q, x => $x, y => $y, type => 1, pins => $pins );
- $out .= '
Problems in this area
';
+ $out .= $q->h1(_('Problems in this area'));
if (@errors) {
$out .= '
' . join('
', @errors) . '
';
}
my $skipurl = NewURL($q, 'submit_map'=>1, skipped=>1);
- $out .= <To report a problem, simply click on the map at the correct location.
-
-
If you cannot see a map – if you have images turned off,
+ $out .= $q->p({-id=>'text_map'}, _('To report a problem, simply click on the map at the correct location.'));
+ $out .= $q->p({-id=>'text_no_map'}, sprintf(_("If you cannot see a map – if you have images turned off,
or are using a text only browser, for example – and you
wish to report a problem, please
-skip this step and we will ask you
-to describe the location of your problem instead.
-EOF
- $out .= <
-
Recent problems reported near here
-EOF
+skip this step and we will ask you
+to describe the location of the problem instead."), $skipurl));
+ $out .= '
h2(_('Recent problems reported near here'));
my $list = '';
foreach (@$current_map) {
$list .= '
';
- $out .= $q->p($q->small('Please note that updates are not sent to the council.'));
+ $out .= $q->h2(_('Provide an update'));
+ $out .= $q->p($q->small(_('Please note that updates are not sent to the council.')))
+ unless $q->{site} eq 'emptyhomes'; # No council blurb
if (@errors) {
$out .= '