From 635af4aa84bc88a6cc20e26c5084c188217848ef Mon Sep 17 00:00:00 2001 From: Arnaud Desmons Date: Fri, 9 Aug 2002 08:42:15 +0000 Subject: po support --- drakwizard.pl | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) (limited to 'drakwizard.pl') diff --git a/drakwizard.pl b/drakwizard.pl index 3ce68898..da42865d 100755 --- a/drakwizard.pl +++ b/drakwizard.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -# Wizdrake +# Drakwizard # Copyright (C) 2002 MandrakeSoft Mael Dodin (mdodin@mandrakesoft.com) # @@ -20,7 +20,7 @@ use lib qw(/usr/lib/libDrakX); #use strict; -use vars qw($wizard_title $lib_script $perl_module %variable $in $welcome $rpm $bifield $chooser_hash); +use vars qw($wizard_title $lib_script $perl_module %variable $in $rpm $bifield $chooser_hash $wpo); use XML::Parser; use standalone; @@ -28,10 +28,22 @@ use interactive; use MDK::Common::Func; use common; -defined($ARGV[0]) or die "Usage: drakwizard *.wiz\n"; -my $in = 'interactive'->vnew('su', 'default'); +use POSIX; +use Locale::gettext(); + +#- I18N. +setlocale (LC_ALL, ""); +Locale::gettext::textdomain ("drakwizard"); + +sub translate { + my ($format, @params) = @_; + + !$format and return; + sprintf(Locale::gettext::gettext($format), @params); +} -sub translate { $_[0] } +defined($ARGV[0]) or die "Usage: drakwizard /usr/share/wizards/*/*.wiz\n"; +my $in = 'interactive'->vnew('su', 'default'); sub member { my $e = shift; foreach (@_) { $e eq $_ and return 1 } 0 } @@ -63,18 +75,28 @@ sub get_parameter { $ENV{$leaf->{shellVariable}} = $leaf->{defaultValue}; }, Page => sub { - $welcome ||= $page; my $old_page = $page; push @$o, $page = { %$leaf }; $old_page->{next_page} = $page; if ($leaf->{canBack} =~ /.*false.*/) { $page->{no_prev} = 1} if ($leaf->{canCancel} =~ /.*false.*/) { $page->{no_cancel} = 1} + if ($leaf->{nextFinish} =~ /.*true.*/) { $page->{finish} = 1} }, Target => sub { $page->{Target}->{jumpIndex}->{$leaf->{jumpIndex}} = $leaf->{targetName}; }, Info => sub { + # This is to avoid monospaced text to be interpolated + $leaf->{helpText} = translate($leaf->{helpText}); + if ($leaf->{fontName} eq "Monospaced") { + chomp($leaf->{helpText}); + $leaf->{helpText} = "\n".$leaf->{helpText}; + } $page->{info} = $leaf->{helpText} ? "$page->{info} $leaf->{helpText}" : "$page->{info}\n"; + if ($leaf->{fillScript}) { + $page->{info} .= `source $lib_script; $leaf->{fillScript}`; + } + # XML compatibility $page->{info} =~ s/\\\'/\'/g; $page->{info} =~ s/\\q/\"/g; $page->{info} =~ s/\\a/\&/g; @@ -113,6 +135,9 @@ sub display { if ($page->{no_prev} || $page->{no_cancel}) { $::Wizard_no_previous = 1; } + if ($page->{finish}) { + $::Wizard_finished = 1; + } if ($page->{nextFinish} eq 'true') { $::Wizard_no_previous = 1; $in->ask_okcancel(translate($page->{name}), @@ -128,9 +153,6 @@ sub display { my @liste; my $chooser_var; my @data = map { -# for ($_->{fillScript}) { -# system("source $lib_script ; $_->{fillScript}"); -# } if ($_->{main_order} eq 'combo') { if($_->{fillScript}){ $valeur = `$_->{fillScript}`; @@ -153,6 +175,7 @@ sub display { : { label => translate($_->{helpText}), val => \$ENV{$variable{$_->{variableName}}}, list => [@liste, ""], type => $_->{main_order} }; } @{$page->{freetext}}; + if($page->{executionLevel} eq 'NORMAL'){ $in->ask_from(translate($page->{name}), translate($page->{info}), \@data) or navigation($o, $page->{old_page}); @@ -214,7 +237,7 @@ sub navigation { } my $o = []; -my $xmltree = XML::Parser->new(Style => 'Tree')->parsefile($ARGV[0]); +$xmltree = XML::Parser->new(Style => 'Tree')->parsefile($ARGV[0]); get_parameter($o, $xmltree); -- cgit v1.2.1