7
use v5.8.0; # We really want decent Unicode support
13
printf ( "%04i", ( $_[5] + 1900 ) );
15
printf ( "%02i", $_[4] + 1);
17
printf ( "%02i", $_[3] );
19
printf ( "%02i", $_[2] );
21
printf ( "%02i", $_[1] );
27
binmode( STDOUT, ":utf8" );
32
print "msgstr \"\"\n";
33
print "\"Project-Id-Version: desktop files\\n\"\n";
34
print "\"Report-Msgid-Bugs-To: http://bugs.kde.org\\n\"\n";
35
print "\"POT-Creation-Date: "; printdate( @now ); print "\\n\"\n";
36
print "\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\"\n";
37
print "\"Last-Translator: FULL NAME <EMAIL\@ADDRESS>\\n\"\n";
38
print "\"Language-Team: LANGUAGE <kde-i18n-doc\@kde.org>\\n\"\n";
39
print "\"MIME-Version: 1.0\\n\"\n";
40
print "\"Content-Type: text/plain; charset=UTF-8\\n\"\n";
41
print "\"Content-Transfer-Encoding: 8bit\\n\"\n";
47
my ( $files, $basedir) = ( @_ );
48
for my $filename ( @$files )
52
open( FH, "<:utf8", $filename ) or warn "Cannot open file $filename";
54
# print STDERR "Processing $filename...\n"; ### DEBUG
56
my $regexp = qr{^(Name|Comment|Language|Keywords|X-KDE-Keywords|About|Description|GenericName|Query|ExtraNames|X-KDE-Submenu)=(.+)};
58
# Context is given by preceeding the entry with # ctxt:... comment.
62
# ends up as "Name|Blah blah" context in the PO file.
63
my $regexp_ctxt = qr{^\s*#\s*ctxt\s*:\s*(.*?)\s*$};
65
my $context_free = "";
73
$context = "$context|$context_free";
74
$context =~ s/\\/\\\\/g;
75
$context =~ s/\"/\\\"/g;
78
$msgid =~ s/$regexp//;
79
$msgid =~ s/\\/\\\\/g;
80
$msgid =~ s/\"/\\\"/g;
81
if ($msgid =~ m/ +$/) {
82
$msgid =~ s/ +$//; # remove trailing spaces
83
print STDERR "ERROR: white space at the end of $msgid in $filename\n";
85
if ($msgid =~ m/\r$/) {
86
$msgid =~ s/[ \r]+$//; # remove trailing space or CR characters
87
print STDERR "ERROR: CR at the end of $msgid in $filename\n";
89
$filename =~ s,^$basedir/,,;
90
print "#: $filename:$.\n";
91
print "msgctxt \"$context\"\n";
92
print "msgid \"$msgid\"\n";
93
print "msgstr \"\"\n";
96
# Free context refers only to the immediate next line.
97
# Thus, if next line is not extracted, current context is gone.
98
if ( m/$regexp_ctxt/o ) {
111
GetOptions ( "file-list=s" => \$onefilelist,
112
"base-dir=s" => \$basedir
117
open( FILELIST, $onefilelist ) or warn ( "Cannot open file list: $onefilelist" );
118
my @thislist = <FILELIST>;
119
processfiles( \@thislist, $basedir );