diff options
author | matthew <matthew> | 2008-05-15 09:26:56 +0000 |
---|---|---|
committer | matthew <matthew> | 2008-05-15 09:26:56 +0000 |
commit | f4f1efdd55dfced30d61f98c98e0ea27866ab81d (patch) | |
tree | c65f432d9f2eca5edc9083e5fef6d55d1144a49b | |
parent | 3d5a80a3f28ea8a1eece15fc691b71e831d0e674 (diff) |
Translate emails too; couple of missing strings; smaller photos on EHA to
fit in column.
-rwxr-xr-x | bin/gettext-extract | 29 | ||||
-rwxr-xr-x | bin/make_emptyhomes_po | 1 | ||||
-rwxr-xr-x | bin/send-reports | 4 | ||||
-rw-r--r-- | perllib/Page.pm | 13 | ||||
-rw-r--r-- | templates/emails/empty property-confirm | 20 | ||||
-rwxr-xr-x | web/index.cgi | 14 | ||||
-rwxr-xr-x | web/photo.cgi | 24 |
7 files changed, 83 insertions, 22 deletions
diff --git a/bin/gettext-extract b/bin/gettext-extract index 70ed66a4f..eb2682701 100755 --- a/bin/gettext-extract +++ b/bin/gettext-extract @@ -7,7 +7,7 @@ # 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 $ +# $Id: gettext-extract,v 1.2 2008-05-15 09:26:56 matthew Exp $ if [ -e ../../locale ] then @@ -25,6 +25,15 @@ fi fi fi +# Take chunk of text and escape each line in it for putting in catalogue +function plain_gettext_escape() { + IFS="" + while read LINE + do + LINE=${LINE//\"/\\\"} + echo \"$LINE\\n\" + done +} # File to write to, clear it to start with PO=locale/FixMyStreet.po @@ -51,3 +60,21 @@ mv $TEMP $PO # XXX: Email templates - should be in >1 language... # And the XSL page too. +# Extract email templates +echo >> $PO +echo '#. Please leave the first word "Subject:" untranslated' >> $PO +for X in bci/templates/emails/* +do + # TODO: Should check for "*~" type filenames too, and do the *-livesimply case + # with wildcards rather than checking per template + if [ "$X" != "bci/templates/emails/CVS" -a "$X" != "bci/templates/emails/empty property-confirm" ] + then + echo >> $PO + echo "#: $X" >> $PO + echo msgid \"\" >> $PO + cat $X | plain_gettext_escape >> $PO + echo msgstr \"\" >> $PO + fi +done + + diff --git a/bin/make_emptyhomes_po b/bin/make_emptyhomes_po index 56f61cb84..bd8f5c97a 100755 --- a/bin/make_emptyhomes_po +++ b/bin/make_emptyhomes_po @@ -68,6 +68,7 @@ while(<MAINPO>) { $buffer =~ s/Recently put back into use empty properties/Recent empty properties put back into use/; $buffer =~ s/\(like graffiti.*\)/ /; + $buffer =~ s/(Please enter your full name).*? -/$1 -/; print NEWPO $buffer; $buffer = ""; diff --git a/bin/send-reports b/bin/send-reports index 9664832a3..23755bb3a 100755 --- a/bin/send-reports +++ b/bin/send-reports @@ -6,7 +6,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org # -# $Id: send-reports,v 1.48 2007-10-22 18:00:04 matthew Exp $ +# $Id: send-reports,v 1.49 2008-05-15 09:26:56 matthew Exp $ use strict; require 5.8.0; @@ -127,7 +127,7 @@ If you know of an appropriate contact address, please do get in touch. ]\n\n"; $h{closest_address} = sprintf("The closest address, as the crow flies, to the location of this problem, %.0fm away, is: %s - please note that this is automatically generated, so ensure that you check it against the details provided by the user and, if possible, the map.\n\n", $distance, $address) if ($address); my $email = mySociety::Email::construct_email({ - _template_ => $template, + _template_ => _($template), _parameters_ => \%h, To => \@to, From => [ $row->{email}, $row->{name} ], diff --git a/perllib/Page.pm b/perllib/Page.pm index ae5ac0164..cbf694227 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.99 2008-05-14 14:24:11 matthew Exp $ +# $Id: Page.pm,v 1.100 2008-05-15 09:26:56 matthew Exp $ # package Page; @@ -411,13 +411,14 @@ sub send_email { my $sender = mySociety::Config::get('CONTACT_EMAIL'); $sender =~ s/team/fms-DO-NOT-REPLY/; mySociety::EvEl::send({ - _template_ => $template, + _template_ => _($template), _parameters_ => \%h, From => [ $sender, _('FixMyStreet')], To => $to, }, $email); my $action = ($thing eq 'alert') ? 'confirmed' : 'posted'; + $thing .= ' report' if $thing eq _('problem'); my $out = <<EOF; <h1>Nearly Done! Now check your email...</h1> <p>The confirmation email <strong>may</strong> take a few minutes to arrive — <em>please</em> be patient.</p> @@ -524,13 +525,13 @@ sub display_problem_updates { foreach my $row (@$updates) { $out .= "<div><p><a name=\"update_$row->{id}\"></a><em>"; if ($row->{name}) { - $out .= 'Posted by ' . ent($row->{name}); + $out .= sprintf(_('Posted by %s'), ent($row->{name})); } else { - $out .= "Posted anonymously"; + $out .= _("Posted anonymously"); } $out .= " at " . prettify_epoch($row->{created}); - $out .= ', marked fixed' if ($row->{mark_fixed}); - $out .= ', reopened' if ($row->{mark_open}); + $out .= ', ' . _('marked as fixed') if ($row->{mark_fixed}); + $out .= ', ' . _('reopened') if ($row->{mark_open}); $out .= '</em></p>'; $out .= '<p>' . ent($row->{text}) . '</p>'; if ($row->{has_photo}) { diff --git a/templates/emails/empty property-confirm b/templates/emails/empty property-confirm new file mode 100644 index 000000000..14885490d --- /dev/null +++ b/templates/emails/empty property-confirm @@ -0,0 +1,20 @@ +Subject: Confirm your empty property + +Hi <?=$values['name']?>, + +Please click on the link below to confirm the empty property +you just added to the site: + +<?=$values['url']?> + +If your email program does not let you click on this link, +copy and paste it into your web browser and press return. + +Your report had the subject: +<?=$values['title']?> + +And details: +<?=$values['detail']?> + +Yours, +The Empty Homes Agency team diff --git a/web/index.cgi b/web/index.cgi index 2c540d94b..bc72d8797 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.195 2008-05-14 15:02:28 matthew Exp $ +# $Id: index.cgi,v 1.196 2008-05-15 09:26:56 matthew Exp $ use strict; use Standard; @@ -120,7 +120,7 @@ EOF $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')) + ($q->{site} ne 'emptyhomes' && $q->li(_('We send it to the council on your behalf'))) ); $out .= $q->h2(_('FixMyStreet updates')); @@ -201,7 +201,9 @@ sub submit_update { my %h = (); $h{update} = $input{update}; $h{name} = $input{name} ? $input{name} : _("Anonymous"); - $h{url} = mySociety::Config::get('BASE_URL') . '/C/' . mySociety::AuthToken::store('update', $id); + my $base = mySociety::Config::get('BASE_URL'); + $base =~ s/matthew/emptyhomes.matthew/ if $q->{site} eq 'emptyhomes'; # XXX Temp + $h{url} = $base . '/C/' . mySociety::AuthToken::store('update', $id); dbh()->commit(); my $out = Page::send_email($input{email}, $input{name}, 'update', %h); @@ -225,6 +227,8 @@ sub submit_problem { push @errors, $err if $err; } + $input{council} = -1 if $q->{site} eq 'emptyhomes'; # Not sent to council + 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/; @@ -348,7 +352,9 @@ sub submit_problem { $h{title} = $input{title}; $h{detail} = $input{detail}; $h{name} = $input{name}; - $h{url} = mySociety::Config::get('BASE_URL') . '/P/' . mySociety::AuthToken::store('problem', $id); + my $base = mySociety::Config::get('BASE_URL'); + $base =~ s/matthew/emptyhomes.matthew/ if $q->{site} eq 'emptyhomes'; # XXX Temp + $h{url} = $base . '/P/' . mySociety::AuthToken::store('problem', $id); dbh()->commit(); $out = Page::send_email($input{email}, $input{name}, _('problem'), %h); diff --git a/web/photo.cgi b/web/photo.cgi index 33bff0bd7..9b8428a95 100755 --- a/web/photo.cgi +++ b/web/photo.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: photo.cgi,v 1.8 2008-03-28 16:36:48 matthew Exp $ +# $Id: photo.cgi,v 1.9 2008-05-15 09:26:56 matthew Exp $ use strict; use Standard; @@ -32,17 +32,23 @@ sub main { return unless $photo; $photo = $photo->[0]; if ($q->param('tn')) { - use Image::Magick; - my $image = Image::Magick->new; - $image->BlobToImage($photo); - my $err = $image->Scale(geometry => "x100>"); - throw Error::Simple("resize failed: $err") if "$err"; - my @blobs = $image->ImageToBlob(); - undef $image; - $photo = $blobs[0]; + $photo = resize($photo, 'x100'); + } elsif ($q->{site} eq 'emptyhomes') { + $photo = resize($photo, '200x'); } print $photo; } Page::do_fastcgi(\&main); +sub resize { + my ($photo, $size) = @_; + use Image::Magick; + my $image = Image::Magick->new; + $image->BlobToImage($photo); + my $err = $image->Scale(geometry => "$size>"); + throw Error::Simple("resize failed: $err") if "$err"; + my @blobs = $image->ImageToBlob(); + undef $image; + return $blobs[0]; +} |