#!/usr/bin/perl # a lame attempt at xgettext for scheme # adapted from pxgettext as found in the plug-ins/perl directory # TODO: # proper linenumbers # There are rumors that perl version 5.005_02 has a bug # resulting in an endless loop and a memory leak in the # regex machinery. # # It seems to work however. I'll leave this check commented out until # people report problems. # # die ("Your version of Perl (5.005_02) is broken!\nCan't extract the strings from the scripts.\nA lot of messages will be missing from your gimp-script-fu.pot file.\n\n") if $] eq 5.005_02; undef $/; my $file; my $fileposition; my $e; my $s; while (<>) { $file = $ARGV; $file =~ s/\.\.\///; while (/_\(?"((?:[^"\\]+|\\.)*)"\)?/sg) { my $s = $1; if ($s =~ /\n/) { $e = "msgid \"\"\n"; for (split /\n/, $s) { $e .= "\"$_\\n\"\n"; } } else { $e = "msgid \"$s\"\n"; } $e .= "msgstr \"\"\n"; $fileposition = "#: $file:0\n"; push @{$entry{$e}}, $fileposition; } } foreach $e (sort keys %entry) { print @{$entry{$e}}; print $e; print "\n"; }