From 4576c39e994befd6e343e3b695f3e2c22c7eadcf Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 28 Nov 2012 12:18:59 +0100 Subject: [PATCH] Bug 9161: Followup: Add a -f param for the translate script Now you can directly call the translate script (misc/translator/translate) with the -f parameter eg.: ./translate install|create|update -f search.tt -f main.tt --- misc/translator/LangInstaller.pm | 39 ++++++++++++++++++++++++++------------ misc/translator/translate | 6 ++++-- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/misc/translator/LangInstaller.pm b/misc/translator/LangInstaller.pm index 00daaf4..18f74ff 100644 --- a/misc/translator/LangInstaller.pm +++ b/misc/translator/LangInstaller.pm @@ -303,7 +303,7 @@ sub install_prefs { sub install_tmpl { - my $self = shift; + my ($self, $files) = @_; say "Install templates" if $self->{verbose}; for my $trans ( @{$self->{interface}} ) { print @@ -318,13 +318,18 @@ sub install_tmpl { "$self->{process} install " . "-i $trans->{dir}/en/ " . "-o $trans->{dir}/$self->{lang} ". - "-s $self->{path_po}/$self->{lang}$trans->{suffix} -r" + "-s $self->{path_po}/$self->{lang}$trans->{suffix} -r " . + ( + $files + ? '-f ' . join ' -f ', @$files + : '' + ) } } sub update_tmpl { - my $self = shift; + my ($self, $files) = @_; say "Update templates" if $self->{verbose}; for my $trans ( @{$self->{interface}} ) { @@ -338,7 +343,12 @@ sub update_tmpl { system "$self->{process} update " . "-i $trans->{dir}/en/ " . - "-s $self->{path_po}/$self->{lang}$trans->{suffix} -r" + "-s $self->{path_po}/$self->{lang}$trans->{suffix} -r " . + ( + $files + ? '-f ' . join ' -f ', @$files + : '' + ) } } @@ -356,7 +366,7 @@ sub create_prefs { sub create_tmpl { - my $self = shift; + my ($self, $files) = @_; say "Create templates\n" if $self->{verbose}; for my $trans ( @{$self->{interface}} ) { @@ -368,15 +378,20 @@ sub create_tmpl { system "$self->{process} create " . "-i $trans->{dir}/en/ " . - "-s $self->{path_po}/$self->{lang}$trans->{suffix} -r" + "-s $self->{path_po}/$self->{lang}$trans->{suffix} -r " . + ( + $files + ? '-f ' . join ' -f ', @$files + : '' + ) } } sub install { - my $self = shift; + my ($self, $files) = @_; return unless $self->{lang}; - $self->install_tmpl() unless $self->{pref_only}; + $self->install_tmpl($files) unless $self->{pref_only}; $self->install_prefs(); } @@ -391,20 +406,20 @@ sub get_all_langs { sub update { - my $self = shift; + my ($self, $files) = @_; my @langs = $self->{lang} ? ($self->{lang}) : $self->get_all_langs(); for my $lang ( @langs ) { $self->set_lang( $lang ); - $self->update_tmpl() unless $self->{pref_only}; + $self->update_tmpl($files) unless $self->{pref_only}; $self->update_prefs(); } } sub create { - my $self = shift; + my ($self, $files) = @_; return unless $self->{lang}; - $self->create_tmpl() unless $self->{pref_only}; + $self->create_tmpl($files) unless $self->{pref_only}; $self->create_prefs(); } diff --git a/misc/translator/translate b/misc/translator/translate index f0c12c9..4beffa3 100755 --- a/misc/translator/translate +++ b/misc/translator/translate @@ -30,9 +30,11 @@ use Pod::Usage; my $verbose = 0; my $pref = 0; my $all = 0; +my @files; GetOptions( 'v|verbose' => \$verbose, 'p' => \$pref, + 'f:s' => \@files, 'a|all' => \$all, ); @@ -57,11 +59,11 @@ if ( $cmd =~ /create|install|update/ ) { usage() if $cmd eq 'create'; for my $lang ( @{$installer->{langs}} ) { $installer->set_lang( $lang ); - $installer->$cmd(); + $installer->$cmd(\@files); } } else { - $installer->$cmd(); + $installer->$cmd(\@files); } } else { -- 1.7.10.4