1 |
#!/usr/bin/perl |
2 |
|
3 |
# For faster multiple execs, start a gimp, and do Xtns/Perl/Server. |
4 |
# Warning! Error message are the worst ever. Unquote the "set_trace" if you need troubleshooting. |
5 |
|
6 |
use Gimp qw(:consts main xlfd_size :auto); |
7 |
use MDK::Common; |
8 |
|
9 |
Gimp::init(); |
10 |
#Gimp::set_trace(TRACE_ALL); |
11 |
|
12 |
$| = 1; |
13 |
|
14 |
sub create_file { |
15 |
my ($backimg, $fontname, $text, $outfile) = @_; |
16 |
my $img = gimp_file_load($backimg, $backimg); |
17 |
gimp_palette_set_foreground([255, 255, 255]); |
18 |
my $layer = gimp_text_fontname($img, -1, 0, 10, $text, 0, 1, 250, 1, $fontname); |
19 |
my $width = gimp_drawable_width($layer); |
20 |
gimp_image_merge_visible_layers($img, 0); |
21 |
gimp_crop($img, $width, 40, 0, 0); |
22 |
gimp_file_save($img, gimp_image_active_drawable($img), $outfile, $outfile); |
23 |
} |
24 |
|
25 |
my $wd = chomp_(`pwd`); |
26 |
|
27 |
my $font = 'SOME NICE FONT'; |
28 |
my %meuh = (install => 'Software Packages Installation', remove => 'Software Packages Removal', update => 'Mandrake Update'); |
29 |
|
30 |
mkdir "title/en"; |
31 |
create_file("$wd/title-back.png", $font, $meuh{$_}, "$wd/title/en/title-$_.png") foreach keys %meuh; |
32 |
|
33 |
foreach my $po (glob('../po/*.po')) { |
34 |
my ($poname) = $po =~ m|/([^/\.]+)\.po$|; |
35 |
print "[$poname] "; |
36 |
my $charset; |
37 |
my @lines = cat_($po); |
38 |
foreach (@lines) { |
39 |
/^"Content-Type: .*; charset=(.*)/ and $charset = $1; |
40 |
} |
41 |
if ($charset =~ /^(iso-8859-15?)|(utf-8)/i) { |
42 |
foreach my $k (keys %meuh) { |
43 |
my $str = $meuh{$k}; |
44 |
my $i18n; |
45 |
each_index { /^msgid "\Q$str/ && ($lines[$::i-1] !~ /fuzzy/) and $i18n = $lines[$::i+1] } @lines; |
46 |
if ($i18n =~ /^msgstr "(.+)"$/) { |
47 |
$i18n = $1; |
48 |
if ($charset =~ /^utf-8/i) { |
49 |
output("/tmp/create_titles_temp", $i18n); |
50 |
$i18n = `iconv -f UTF8 -t iso-8859-1 /tmp/create_titles_temp 2>/dev/null`; |
51 |
$? and next; |
52 |
} |
53 |
mkdir "title/$poname"; |
54 |
create_file("$wd/title-back.png", |
55 |
$font, |
56 |
$i18n, |
57 |
"$wd/title/$poname/title-$k.png"); |
58 |
print "."; |
59 |
} |
60 |
} |
61 |
} else { |
62 |
print "- ignoring, charset is not iso-8859-1 or UTF8\n"; |
63 |
} |
64 |
print "\n"; |
65 |
} |
66 |
|
67 |
Gimp::end(); |
68 |
|