From: Eric Bollengier Date: Sat, 22 Dec 2007 16:29:18 +0000 (+0000) Subject: ebl update to use the new gettext method X-Git-Tag: Release-3.0.0~2121 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=eeee5c4543d91e7a86066b86966876a485f80b90;p=bacula%2Fbacula ebl update to use the new gettext method git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6094 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bweb/script/make_pot.pl b/gui/bweb/script/make_pot.pl new file mode 100755 index 0000000000..dec0c5ccdc --- /dev/null +++ b/gui/bweb/script/make_pot.pl @@ -0,0 +1,40 @@ +#!/usr/bin/perl -w +use strict; +use Getopt::Long; + +# Usage: $0 *.po *.tpl +#my $src = shift or die "Usage $0 pofile"; +# +#my $tab; +#{ +# no strict; +# $tab = eval `cat $src`; +#} + +open(OUT, "|msguniq > bweb.pot"); + +foreach my $f (@ARGV) +{ + next if (! -f $f) ; + + open(FP, $f) or print STDERR "Can't open $f for reading\n"; + while (my $l = ) + { + if ($l =~ m/__(.+?)__/) { + my $s = $1; + my $r = ''; #$tab->{$s} || $s; + $s =~ s/\n/\\n/g; + $s =~ s/"/\\"/g; +# $r =~ s/\n/\\n/g; +# $r =~ s/"/\\"/g; + print OUT "#: $f:$.\n"; + print OUT "msgid \"$s\"\n"; + print OUT "msgstr \"$r\"\n\n"; + } + } + close(FP); +} + +close(OUT); +# msginit pot -> lang.po +# msgmerge fr.po bweb.pot diff --git a/gui/bweb/script/tpl_generate.pl b/gui/bweb/script/tpl_generate.pl index d63f6220b8..d2783d5f2f 100755 --- a/gui/bweb/script/tpl_generate.pl +++ b/gui/bweb/script/tpl_generate.pl @@ -1,31 +1,104 @@ #!/usr/bin/perl -w use strict; -my $f = shift or die "Usage $0 pofile"; +=head1 LICENSE -my $tab; -{ - no strict; - $tab = eval `cat $f`; + Bweb - A Bacula web interface + Bacula® - The Network Backup Solution + + Copyright (C) 2000-2006 Free Software Foundation Europe e.V. + + The main author of Bweb is Eric Bollengier. + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation plus additions + that are listed in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zurich, + Switzerland, email:ftf@fsfeurope.org. + +=head1 USAGE + + cd bweb + rm -f lang/fr/tpl/*.tpl + LANGUAGE=fr ./script/tpl_generate.pl tpl/*.pl + +=head1 VERSION + + $Id$ + +=cut + +my $debug=0; + +my $lang = $ENV{LANGUAGE}; + +if (!$lang or $lang !~ /^[a-z]+$/) { + print "Can't find \$LANGUAGE, please set it before running $0 (to en, fr, it, es...)\n"; + exit 0; } -die "E: Can't read $f" unless ($tab); -my $r; -foreach my $e (keys %$tab) +my $out = "lang/$lang/tpl"; + +die "Can't write to $out" unless (-d $out); + +print "Using LANGUAGE=$lang and writing tpl to: $out\n"; + +use Locale::TextDomain ('bweb', './po/'); +use File::Basename qw/basename/; + +foreach my $f (@ARGV) { - $e =~ s/[?]/\\?/g; - $e =~ s/@/\\@/g; - $r = $tab->{$e} || $e; - $e =~ s/([()])/\\$1/g; - print "s!__${e}__!${r}!g;\n"; -} + my $nb=0; + if (! -f $f) { + print STDERR "Skipping $f, file not found\n"; + next; + } -print "print;"; + my $file = basename($f); + open(FP, $f) or print STDERR "Can't open $f for reading $!\n"; + open(OUT, ">$out/$file") or print STDERR "Can't open $out/$file for writing $!\n"; + print "Converting $f -> $out/$file "; + while (my $l = ) + { + my (@str) = ($l =~ m/__(.+?)__/g); + + while (my $s = shift @str) { + $nb++; + my $r = __$s; -__END__ + if ($debug) { + print STDERR "$s -> $r\n"; + } -copy tpl files -generate perl script -tpl_generate.pl fr.pl > a -perl -i.bak -n a *.tpl + $s =~ s/[?]/\\?/g; + $s =~ s/@/\\@/g; + $r =~ s/@/\\@/g; + $s =~ s/\$/\\\$/g; + $r =~ s/\$/\\\$/g; + $s =~ s/([()])/\\$1/g; + + $l =~ s/__${s}__/$r/g; + } + print OUT $l; + } + print "($nb strings)\n"; + close(OUT); + close(FP); +}