11 my $domain = shift @ARGV;
24 return ($text =~ s/\n//g);
30 my ($text, $lineno, $comment, $nextlineno, $msgid);
35 open(IN, "< $file") || die "Unable to open $file\n";
40 if ($prefix =~ s/=(.*)//) {
43 $file =~ s{^$prefix}{$repl}o unless $prefix eq '__';
44 # Remove comments if they contain <gettext> or </gettext>
45 $text =~ s/^[ \t]*#.*<\/?gettext\b//mg;
47 while ($text =~ m{\G(.*?)(<gettext\b(?:\s+domain="([^"]+)")?[^>]*>)(.*?)</gettext>}gs) { # " -- to fix vim syntax hilighting :)
49 $lineno += countNewline ($1.$2);
50 $nextlineno = countNewline ($4);;
51 my $dom = ($3) ? $3 : 'templates';
52 if ($domain ne $dom) {
53 $lineno += $nextlineno;
57 if ($1 =~ m/(((^|\n)[ \t]*#.*)+)\n?[^\n]*$/) {
59 $comment =~ s/^\s+#\s*//;
60 $comment =~ s/\n[ \t]*#\s*/\n/g;
62 push (@msgids, $msgid);
63 if (defined ($messages->{$msgid})) {
64 print STDERR "wmlxgettext: Warning: msgid multiple defined:\n\t".
67 $messages->{$msgid} = [];
69 push (@{$messages->{$msgid}}, $comment, $file, $lineno);
70 $lineno += $nextlineno;
78 processFile($_, $opt_p);
81 print "msgid \"\"\nmsgstr \"\"\n".
82 "\"Content-Type: text/plain; charset=ASCII\\n\"\n".
83 "\"Content-Transfer-Encoding: 8bit\\n\"\n\n";
85 foreach my $msgid (@msgids) {
86 next unless $messages->{$msgid};
87 while (@{$messages->{$msgid}}) {
88 $_ = shift(@{$messages->{$msgid}});
90 print "#. ".$_."\n" if $_;
91 print "#: ".shift(@{$messages->{$msgid}}).":".
92 shift(@{$messages->{$msgid}})."\n";
94 print "msgid \"$msgid\"\nmsgstr \"\"\n\n";
95 undef $messages->{$msgid};