From e278c72e918b54e8cd75d034e240256d950d21e5 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Fri, 21 Dec 2007 22:17:13 +0000 Subject: [PATCH] ebl update tools git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6087 91ce42f0-d328-0410-95d8-f526ca767f89 --- gui/bweb/script/tpl_extract_msg.pl | 41 ++++++++++++++++++++++-------- gui/bweb/script/tpl_generate.pl | 31 ++++++++++++++++++++++ 2 files changed, 62 insertions(+), 10 deletions(-) create mode 100755 gui/bweb/script/tpl_generate.pl diff --git a/gui/bweb/script/tpl_extract_msg.pl b/gui/bweb/script/tpl_extract_msg.pl index 666b0e3021..be3fcae48c 100755 --- a/gui/bweb/script/tpl_extract_msg.pl +++ b/gui/bweb/script/tpl_extract_msg.pl @@ -4,7 +4,7 @@ use strict; =head1 LICENSE Bweb - A Bacula web interface - Bacula® - The Network Backup Solution + BaculaÂ® - The Network Backup Solution Copyright (C) 2000-2006 Free Software Foundation Europe e.V. @@ -27,7 +27,7 @@ use strict; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - Bacula® is a registered trademark of John Walker. + 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. @@ -49,20 +49,31 @@ use Locale::PO; my $in_script; my %dict; +my $l=0; +my $file; + +sub init_fp +{ + open(FP, "|sort -n") ; +} + sub print_it { foreach my $w (@_) { +# print "<$w\n"; next if ($w eq ' '); next if ($w !~ /\w/); next if ($w =~ />/); - + next if ($w eq 'checked'); +# print "$w>\n"; next if (exists $dict{$w}); $dict{$w}=1; # we add " at the begining and the end of the string - $w =~ s/(^|$)/"/gm; # " - print "msgid ", $w, "\n"; - print 'msgstr ""', "\n\n"; + #$w =~ s/'/\\'/gm; # " + #print "s\@(?!value='|_)$w\@\$1_${w}_\@g;\n"; + #print "s!(${w})([^a-zA-Z0-9]|\$)!__\$1__\$2!g;\n"; + print "$w\n"; } } @@ -71,7 +82,7 @@ sub text { # between we take only "words" if ($in_script) { - my @words = ($text =~ /"([\w\s]+)"/gs); + my @words = ($text =~ /"([\w\séèàçûôöüïîù!?]+)"/gs); print_it(@words); return; } @@ -114,12 +125,22 @@ sub end { } } +sub finish_fp +{ + close(FP); +} +1; + package main; my $p = new TmplParser; +$p->init_fp(); for (my $f = shift ; $f and -f $f ; $f = shift) { #$TmplParser::nb=0; - print "#============ $f ==========\n"; - $p->parse_file($f); +# print "#============ $f ==========\n"; + $file = $f; + $file =~ s!.*?/([\w\d]+).tpl$!$1!; + $p->parse_file($f); $l=0; } - +$p->finish_fp(); +#print "s/value='__([^']+)__'/value='\$1'/g;\n"; diff --git a/gui/bweb/script/tpl_generate.pl b/gui/bweb/script/tpl_generate.pl new file mode 100755 index 0000000000..d63f6220b8 --- /dev/null +++ b/gui/bweb/script/tpl_generate.pl @@ -0,0 +1,31 @@ +#!/usr/bin/perl -w +use strict; + +my $f = shift or die "Usage $0 pofile"; + +my $tab; +{ + no strict; + $tab = eval `cat $f`; +} + +die "E: Can't read $f" unless ($tab); +my $r; +foreach my $e (keys %$tab) +{ + $e =~ s/[?]/\\?/g; + $e =~ s/@/\\@/g; + $r = $tab->{$e} || $e; + $e =~ s/([()])/\\$1/g; + print "s!__${e}__!${r}!g;\n"; +} + +print "print;"; + + +__END__ + +copy tpl files +generate perl script +tpl_generate.pl fr.pl > a +perl -i.bak -n a *.tpl -- 2.39.5