]> git.sur5r.net Git - bacula/bacula/blob - gui/bweb/script/tpl_generate.pl
bweb: Update some GPL2 notice to AGPL
[bacula/bacula] / gui / bweb / script / tpl_generate.pl
1 #!/usr/bin/perl -w
2 use strict;
3
4 =head1 LICENSE
5
6    Bweb - A Bacula web interface
7    Bacula® - The Network Backup Solution
8
9    Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
10
11    The main author of Bweb is Eric Bollengier.
12    The main author of Bacula is Kern Sibbald, with contributions from
13    many others, a complete list can be found in the file AUTHORS.
14    This program is Free Software; you can redistribute it and/or
15    modify it under the terms of version three of the GNU Affero General Public
16    License as published by the Free Software Foundation and included
17    in the file LICENSE.
18
19    This program is distributed in the hope that it will be useful, but
20    WITHOUT ANY WARRANTY; without even the implied warranty of
21    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22    Affero General Public License for more details.
23
24    You should have received a copy of the GNU Affero General Public License
25    along with this program; if not, write to the Free Software
26    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27    02110-1301, USA.
28
29    Bacula® is a registered trademark of Kern Sibbald.
30    The licensor of Bacula is the Free Software Foundation Europe
31    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
32    Switzerland, email:ftf@fsfeurope.org.
33
34 =head1 USAGE
35
36     cd bweb
37     rm -f lang/fr/tpl/*.tpl
38     LANGUAGE=fr ./script/tpl_generate.pl tpl/*.pl
39
40 =head1 VERSION
41
42     $Id$
43
44 =cut
45
46 my $debug=0;
47
48 my $lang = $ENV{LANGUAGE};
49
50 if (!$lang or $lang !~ /^[a-z]+$/) {
51     print "Can't find \$LANGUAGE, please set it before running $0 (to en, fr, it, es...)\n";
52     exit 0;
53 }
54
55 my $out = "lang/$lang/tpl";
56
57 die "Can't write to $out" unless (-d $out);
58
59 print "Using LANGUAGE=$lang and writing tpl to: $out\n";
60
61 use Locale::TextDomain ('bweb', './po/');
62 use File::Basename qw/basename/;
63
64 foreach my $f (@ARGV)
65 {
66     my $nb=0;
67     if (! -f $f) {
68         print STDERR "Skipping $f, file not found\n";
69         next;
70     }
71
72     my $file = basename($f);
73
74     open(FP, $f) or print STDERR "Can't open $f for reading $!\n";
75     open(OUT, ">$out/$file") or print STDERR "Can't open $out/$file for writing $!\n";
76     print "Converting $f -> $out/$file ";
77     while (my $l = <FP>)
78     {
79         my (@str) = ($l =~ m/__(.+?)__/g);
80         
81         while (my $s = shift @str) {
82             $nb++;
83             my $r = __$s;
84
85             if ($debug) {
86                 print STDERR "$s -> $r\n";
87             }
88
89             $s =~ s/[?]/\\?/g;
90             $s =~ s/\$/\\\$/g;
91             $r =~ s/\$/\\\$/g;
92             $s =~ s/([\[\]\(\)])/\\$1/g;
93
94             $l =~ s/__${s}__/$r/g;
95         }
96         print OUT $l;
97     }
98     print "($nb strings)\n";
99     close(OUT);
100     close(FP);
101 }