#!/usr/bin/perl
# generate textdb file out of a tree of fmt files
require 'find.pl';
print "msgid \"\"\n";
print "msgstr \"\"\n";
print "\"blabla meta info hier\"\n";
print "\n";
%already_seen = ();
&find(@ARGV ? @ARGV : '.');
exit;
sub wanted {
# dies sollte -follow implementieren, geht aber nicht
(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
(not $already_seen{"$dev,$ino"}) &&
(($already_seen{"$dev,$ino"} = !(-d _)) || 1) &&
do {
return $prune=1 if $_ eq '.old' or $_ eq 'CVS';
return unless $name =~ s!^./!!o;
return if -d $_;
my $n = $name;
unless ($n =~ s/\.fmt$//o) {
print STDERR "hmm.. $name\n";
return;
}
$n =~ s!/!_!g;
# msgfmt does not like the msgid not ending in a \n
# if the msgstr does... but we dont want to use msgfmt anyway
$c = "";
$d = "";
open(F, $_);
while(<F>) {
chomp;
if ($_ =~ /^##/) {
$c .= $_ . "\n";
} else {
# TODO: we need to quote '"'
# s/../../
$d .= "\"" . $_ . "\\n\"\n";
}
}
print $c;
print "msgid \"_$n\"\n";
# the last newline may be wrong
print "msgstr ", $d;
print "\n\n";
close F;
};
}
See Talk:Textdb.