aboutsummaryrefslogtreecommitdiffstats
path: root/bin/gettext-nget-patch
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 /bin/gettext-nget-patch
parent6642f808d2f53e4b619ef63d50a8c13500ce8333 (diff)
Migrate gettext-extract to find all the new strings.
Diffstat (limited to 'bin/gettext-nget-patch')
-rwxr-xr-xbin/gettext-nget-patch30
1 files changed, 30 insertions, 0 deletions
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');