X-Git-Url: https://git.deb.at/?p=deb%2Fpackages.git;a=blobdiff_plain;f=bin%2Fttxgettext;h=fddfbd0d458d393adf85920acdc0d64a616262df;hp=7464f60f2837147cd23ea221c5cecb15c923fa92;hb=c6fdd0f2653303fcc8a5307e106e77161f436b44;hpb=7c44b4ac80115d6fc519fb5cb18206550c2ab855 diff --git a/bin/ttxgettext b/bin/ttxgettext index 7464f60..fddfbd0 100755 --- a/bin/ttxgettext +++ b/bin/ttxgettext @@ -1,5 +1,14 @@ #! /usr/bin/perl -w +# copied from webwml/english/po/wmlxgettext.pl and +# adapted for Template Toolkit +# Copyright © 2002-2003 Denis Barbier +# Copyright © 2007 Frank Lichtenheld +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. use strict; use Getopt::Std; @@ -41,31 +50,38 @@ sub processFile { $repl = $1; } $file =~ s{^$prefix}{$repl}o unless $prefix eq '__'; - # Remove comments if they contain or - $text =~ s/^[ \t]*#.*<\/?gettext\b//mg; +# # Remove comments if they contain or +# $text =~ s/^[ \t]*#.*<\/?gettext\b//mg; $lineno = 1; - while ($text =~ m{\G(.*?)(]*>)(.*?)}gs) { # " -- to fix vim syntax hilighting :) + while ($text =~ m{\G(.*?) # begin at end of previous match, $1=prefix + (\bg\(\s* # "g(" , $2=whole match + (["']) # " quoting, $3=quotes + (.*?)\3 # string, $4=string + )}gxs) { $msgid = escape($4); $lineno += countNewline ($1.$2); $nextlineno = countNewline ($4);; - my $dom = ($3) ? $3 : 'templates'; - if ($domain ne $dom) { - $lineno += $nextlineno; - next; # wrong domain - } - $comment = ''; - if ($1 =~ m/(((^|\n)[ \t]*#.*)+)\n?[^\n]*$/) { - $comment = $1; - $comment =~ s/^\s+#\s*//; - $comment =~ s/\n[ \t]*#\s*/\n/g; - } - push (@msgids, $msgid); - if (defined ($messages->{$msgid})) { - print STDERR "wmlxgettext: Warning: msgid multiple defined:\n\t". - $msgid."\n"; - } else { - $messages->{$msgid} = []; - } + my $dom = $domain; +# my $dom = ($3) ? $3 : 'templates'; +# if ($domain ne $dom) { +# $lineno += $nextlineno; +# next; # wrong domain +# } + $comment = ''; + if ($1 =~ m/(((^|\n)\s*(\[%)?\s*#.*)+)\n?[^\n]*$/) { + $comment = $1; + $comment =~ s/\[%//g; + $comment =~ s/%\]//g; + $comment =~ s/^\s+#\s*//; + $comment =~ s/\n[ \t]*#\s*/\n/g; + } + push (@msgids, $msgid); +# if (defined ($messages->{$msgid})) { +# print STDERR "ttxgettext: Warning: msgid multiple defined:\n\t". +# $msgid."\n"; +# } else { +# $messages->{$msgid} = []; +# } push (@{$messages->{$msgid}}, $comment, $file, $lineno); $lineno += $nextlineno; } @@ -79,7 +95,7 @@ foreach (@ARGV) { } print "msgid \"\"\nmsgstr \"\"\n". - "\"Content-Type: text/plain; charset=ASCII\\n\"\n". + "\"Content-Type: text/plain; charset=UTF-8\\n\"\n". "\"Content-Transfer-Encoding: 8bit\\n\"\n\n"; foreach my $msgid (@msgids) {