summaryrefslogtreecommitdiff
path: root/po-sections/menufile2pot
blob: 83aa16494032e0e73701be47f0ee17383b99c1a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/perl

# Little script to read the /usr/lib/menu/* files, and write a
# menu-messages.pot file for them. This file then should contain
# all possible translations, and can be used by translators.'
#
#
# Should be changed to
#  - accept the compat-2 mode
#  - extract /usr/lib/menu/* files from .deb files. Then I'll run it on master.

# Changes:
# - now checks also for longtitles (jfs, Fri Aug 31 02:39:09 CEST 2001)

open(POT, ">menu-messages.pot");

while (</usr/lib/menu/*>){
    my $file=$_;
    open(ME,$_);
    while(<ME>){
	my $line;
	$line=$_;
	chomp($line);
	while($line =~ /\\\s*$/){
	    $line =~ s/\\\s*$//;
	    $line .= <ME>;
	    chomp($line);
	}
	$line =~ s/^[^:]*://;
	$line =~ m/title\s*=\s*"(.*?[^\\])"/ ||
	    $line =~ m/title\s*=\s*([^\s]*)/;
	$title=$1;
	$longtitle=$1 if  $line =~ m/longtitle\s*=\s*"(.*?[^\\])"/;
	$line =~ m/section\s*=\s*"(.*?[^\\])"/ ||
	    $line =~ m/section\s*=\s*([^\s]*)/;
	$section=$1;
	#print "T=$title S=$section LL " . $line . "\n";
	$items{$title}=$file;
	$items{$longtitle}=$file if $longtitle;
	while( $section =~ s%/?([^/]+)/?%% ){
	    $items{$1}=$file;
	}
    }
    close(ME);
}


$date=`/bin/date +"%Y-%d-%m %H:%M+%Z"`;

print POT "# Collection of titles/sections of debian menu's.
# This file is automatically generated. Do not edit.
# It's generated from the /usr/lib/menu/* files.
#
#, fuzzy
msgid \"\"
msgstr \"\"
\"Project-Id-Version: MENU VERSION\\n\"
\"POT-Creation-Date: $date\\n\"
\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\"
\"Last-Translator: FULL NAME <e-mail\@address>\\n\"
\"MIME-Version: 1.0\\n\"
\"Content-Type: text/plain; charset=CHARSET\\n\"
\"Content-Transfer-Encoding: ENCODING\\n\"

";

for my $s (sort keys %items){
    print POT "#: Found in " . $items{$s} . "\n";
    print POT "msgid \"" . $s . "\"\n";
    print POT "msgstr \"\"\n\n";
}