From f1680e06d56690fb0daed018903e5d00b0aff0e7 Mon Sep 17 00:00:00 2001 From: acli Date: Tue, 11 Jan 2005 09:50:58 +0000 Subject: [PATCH] More comments in the code to explain what it does and check the language code command line argument a bit more carefully --- misc/translator/po/update.pl | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/misc/translator/po/update.pl b/misc/translator/po/update.pl index 6018e86d1f..e2ba8d4e35 100755 --- a/misc/translator/po/update.pl +++ b/misc/translator/po/update.pl @@ -7,19 +7,34 @@ use strict; use integer; my $lang = $ARGV[0]; -die "Usage: $0 LANG\n" unless defined $lang && $lang =~ /\S/; +die "Usage: $0 LANG\n" unless $lang =~ /^[a-z]{2}(?:_[A-Z]{2})?$/; -my $chdir_needed_p = 1 unless -d('po'); # guess if pwd is translator/ or po/ +# Remember whether we see the "po" directory; this is used later to guess +# whether the current directory is translator/po or translator. +my $chdir_needed_p = 1 unless -d('po'); -for my $spec (['css', 'opac'], ['default', 'intranet']) { +# Go through the theme/module combinations we need to update. There can be +# more than two; e.g., if we want ['default', 'opac'] too we can put it in +for my $spec ( + ['css', 'opac' ], + ['default', 'intranet'] +) { my($theme, $module) = @$spec; my $pid = fork; die "fork: $!\n" unless defined $pid; if (!$pid) { + + # If current directory is translator/po instead of translator, + # then go back to the parent if ($chdir_needed_p) { chdir('..') || die "..: cd: $!\n"; } - exec('./tmpl_process3.pl', 'update', '-i', "../../koha-tmpl/$module-tmpl/$theme/en/", '-s', "po/${theme}_${module}_$lang.po", '-r'); + + # Now call tmpl_process3.pl to do the real work + exec('./tmpl_process3.pl', 'update', + '-i', "../../koha-tmpl/$module-tmpl/$theme/en/", + '-s', "po/${theme}_${module}_$lang.po", '-r'); + die "tmpl_process3.pl: exec: $!\n"; } wait; -- 2.39.5