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