5 use Text::Balanced qw(extract_bracketed extract_delimited extract_tagged);
7 @ARGV >= 1 || die "Usage: $0 <source direcory>\n";
35 if( open F, "find @ARGV -type f '(' -name '*.htm' -or -name '*.lua' ')' |" )
37 while( defined( my $file = readline F ) )
41 if( open S, "< $file" )
50 while( $text =~ s/ ^ .*? (?:translate|translatef|i18n|_) [\n\s]* \( /(/sgx )
52 ( my $code, $text ) = extract_bracketed($text, q{('")});
53 $code =~ s/^\(//; $code =~ s/\)$//;
60 ( $sub, $code ) = extract_delimited($code, q{'"}, q{\s*(?:\.\.\s*)?});
64 $res .= substr $sub, 1, length($sub) - 2;
68 $res = dec_lua_str($res);
75 while( $text =~ s/ ^ .*? <% [:_] -? /<%/sgx )
77 ( my $code, $text ) = extract_tagged($text, '<%', '%>');
81 $code = dec_tpl_str(substr $code, 2, length($code) - 4);
82 $stringtable{$code}++;
92 if( open C, "| msgcat -" )
94 printf C "msgid \"\"\nmsgstr \"Content-Type: text/plain; charset=UTF-8\"\n\n";
96 foreach my $key ( sort keys %stringtable )
101 printf C "msgid \"%s\"\nmsgstr \"\"\n\n", $key;