aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2011-06-09 18:39:24 +0100
committerMatthew Somerville <matthew@mysociety.org>2011-06-09 18:39:24 +0100
commita648b8b4d44752ec3286551478b191ac348a94c5 (patch)
treeda458b6d1e617e21699fdbef4b781c5725aa6eb0
parent6642f808d2f53e4b619ef63d50a8c13500ce8333 (diff)
Migrate gettext-extract to find all the new strings.
-rwxr-xr-xbin/gettext-extract47
-rwxr-xr-xbin/gettext-nget-patch30
-rw-r--r--templates/web/default/front_stats.html8
-rw-r--r--templates/web/default/report/new/no_councils_text.html4
-rw-r--r--templates/web/default/report/new/some_councils_text.html4
5 files changed, 48 insertions, 45 deletions
diff --git a/bin/gettext-extract b/bin/gettext-extract
index 24defd014..55623e86c 100755
--- a/bin/gettext-extract
+++ b/bin/gettext-extract
@@ -4,10 +4,8 @@
# 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.
+# Copyright (c) 2011 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
-#
-# $Id: gettext-extract,v 1.14 2009-11-30 10:21:52 louise Exp $
if [ -e ../../locale ]
then
@@ -25,56 +23,31 @@ 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
rm -f $PO
# Extract from Perl
-xgettext --add-comments=TRANS --language=Perl --keyword=_ --keyword=nget:1,2 --from-code=utf-8 -o $PO `find perllib -name "*.pm"` web/*.cgi bin/send-* db/*.pl web-admin/*.cgi
+xgettext.pl --gnu-gettext --verbose --output $PO --plugin perl=* --plugin tt2 --directory perllib --directory templates/web --directory db --directory bin
# Fix headers
TEMP=`tempfile`
+NOW=`date +"%Y-%m-%d %H:%M%z"`
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/YEAR THE PACKAGE'S COPYRIGHT HOLDER/2011 UK Citizens Online Democracy/;
s/PACKAGE package/main FixMyStreet code/;
- s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR./Matthew Somerville <matthew@mysociety.org>, 2008-04-15./;
+ s/FIRST AUTHOR <EMAIL@ADDRESS>, YEAR./Matthew Somerville <matthew@mysociety.org>, 2011-06-03./;
- s/PACKAGE VERSION/1.0/;
- s/Report-Msgid-Bugs-To: /Report-Msgid-Bugs-To: matthew@mysociety.org/;
+ s/PACKAGE VERSION/1.0\\\n\"\n\"Report-Msgid-Bugs-To: matthew@mysociety.org/;
+ s/POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE/POT-Creation-Date: $NOW/;
s/LL@li.org/team@fixmystreet.com/;
- s/charset=CHARSET/charset=UTF-8/;
+ s/charset=CHARSET/charset=UTF-8/;
+ s/8bit/8bit\\\n\"\n\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;/;
" >> $TEMP
mv $TEMP $PO
-# XXX The XSL page needs including?
-
-# Extract email templates
-echo >> $PO
-echo '#. Please leave the first word "Subject:" untranslated' >> $PO
-for X in templates/emails/* templates/emails/emptyhomes/*
-do
- # TODO: Should check for "*~" type filenames too, and do the *-livesimply case
- # with wildcards rather than checking per template
- if [ ! -d "$X" ]
- then
- echo >> $PO
- echo "#: $X" >> $PO
- echo msgid \"\" >> $PO
- cat "$X" | plain_gettext_escape >> $PO
- echo msgstr \"\" >> $PO
- fi
-done
+echo "$( bin/gettext-nget-patch )" >> $PO
bin/make_emptyhomes_po
diff --git a/bin/gettext-nget-patch b/bin/gettext-nget-patch
new file mode 100755
index 000000000..8f8dbc346
--- /dev/null
+++ b/bin/gettext-nget-patch
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+#
+# xgettext doesn't deal with TT files, but xgettext.pl doesn't find nget()s, sigh.
+# This will find the nget()s and output a .po file excerpt.
+
+use File::Find qw/find/;
+
+find( sub {
+ next unless -f;
+ open (FP, $_) or die $!;
+ while (<FP>) {
+ next unless /nget/;
+ my $line = $.;
+ my $text = $_;
+ do {
+ $text .= <FP>;
+ } until $text =~ /\)/;
+ $text =~ /nget\(\s*"(.*?)"\s*,\s*"(.*?)"\s*,\s*(.*?)\s*\)/s;
+ print <<EOF;
+
+#: $File::Find::name:$line
+#, perl-format
+msgid "$1"
+msgid_plural "$2"
+msgstr[0] ""
+msgstr[1] ""
+EOF
+ }
+ close FP;
+}, 'templates');
diff --git a/templates/web/default/front_stats.html b/templates/web/default/front_stats.html
index 385414768..4b98ef31e 100644
--- a/templates/web/default/front_stats.html
+++ b/templates/web/default/front_stats.html
@@ -12,13 +12,13 @@
new_text =
stats.recency == '1 week'
? nget(
- '<big>%s</big> report in past week',
- '<big>%s</big> reports in past week',
+ "<big>%s</big> report in past week",
+ "<big>%s</big> reports in past week",
stats.new
)
: nget(
- '<big>%s</big> report recently',
- '<big>%s</big> reports recently',
+ "<big>%s</big> report recently",
+ "<big>%s</big> reports recently",
stats.new
);
diff --git a/templates/web/default/report/new/no_councils_text.html b/templates/web/default/report/new/no_councils_text.html
index c3dade610..f991e031f 100644
--- a/templates/web/default/report/new/no_councils_text.html
+++ b/templates/web/default/report/new/no_councils_text.html
@@ -3,8 +3,8 @@
<p>[%
nget(
- 'We do not yet have details for the council that covers this location.',
- 'We do not yet have details for the councils that cover this location.',
+ "We do not yet have details for the council that covers this location.",
+ "We do not yet have details for the councils that cover this location.",
all_councils.size
);
diff --git a/templates/web/default/report/new/some_councils_text.html b/templates/web/default/report/new/some_councils_text.html
index 5019becc8..042e89914 100644
--- a/templates/web/default/report/new/some_councils_text.html
+++ b/templates/web/default/report/new/some_councils_text.html
@@ -12,8 +12,8 @@
%]
[%
nget(
- 'We do <strong>not</strong> yet have details for the other council that covers this location.',
- 'We do <strong>not</strong> yet have details for the other councils that cover this location.',
+ "We do <strong>not</strong> yet have details for the other council that covers this location.",
+ "We do <strong>not</strong> yet have details for the other councils that cover this location.",
missing_details_councils.size
);
%]