summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2005-07-18 22:15:26 +0000
committerAndreas Gruenbacher <agruen@suse.de>2005-07-18 22:15:26 +0000
commit748a4de99a5276a08490f379486a126e91385219 (patch)
treeb97d5af033e63b4dd94f06567530ccf8be3f525f /scripts
parentbf3764a7da111bb34aa430f62eac0b15c738b8e9 (diff)
downloadquilt-748a4de99a5276a08490f379486a126e91385219.tar.gz
- Add internationalization support to Perl scripts as well.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/edmail.in23
-rw-r--r--scripts/parse-patch.in24
-rw-r--r--scripts/patchfns.in23
-rw-r--r--scripts/remove-trailing-ws.in38
4 files changed, 66 insertions, 42 deletions
diff --git a/scripts/edmail.in b/scripts/edmail.in
index 9f1e8f3..24834c9 100644
--- a/scripts/edmail.in
+++ b/scripts/edmail.in
@@ -1,8 +1,18 @@
#! @PERL@ -w
use Getopt::Long;
+use POSIX qw(setlocale);
+use Locale::gettext;
use strict;
+setlocale(LC_MESSAGES, "");
+bindtextdomain("quilt", "@LOCALEDIR@");
+textdomain("quilt");
+
+sub _($) {
+ return gettext(shift);
+}
+
my (%append_name, %append_value, $remove_empty_headers, %remove_header,
%extract_recipients, %replace_name, %replace_value, $charset);
GetOptions('add-recipient:s%' =>
@@ -50,19 +60,22 @@ sub check_recipient($) {
} else {
# The value is not (properly) quoted. Check for invalid characters.
while (/\(/ or /\)/) {
- die "Display name '$display' contains unpaired parentheses\n"
+ die sprintf(
+_("Display name '%s' contains unpaired parentheses\n"), $display)
unless s/\(([^()]*)\)/$1/;
}
- die "Display name '$display' contains invalid characters\n"
+ die sprintf(
+_("Display name '%s' contains invalid characters\n"), $display)
if /[$spldot]/;
}
- die "Display name '$display' contains non-printable or " .
- "8-bit characters\n" if (/[^ \t\40-\176]/);
+ die sprintf(
+_("Display name '%s' contains non-printable or 8-bit characters\n"), $display)
+ if (/[^ \t\40-\176]/);
} else {
$deliver = $_;
}
# Check for a valid delivery address
- die "Delivery address '$deliver' is invalid\n"
+ die sprintf(_("Delivery address '%s' is invalid\n"), $display)
if $deliver =~ /[ \t]/ or $deliver =~ /[^ \t\40-\176]/ or
$deliver !~ /^[^$spl]+@(\[?)[^$spldot]+(?:\.[^$spldot]+)*(\]?)$/ or
(!$1) != (!$2);
diff --git a/scripts/parse-patch.in b/scripts/parse-patch.in
index 56c3c55..6441b82 100644
--- a/scripts/parse-patch.in
+++ b/scripts/parse-patch.in
@@ -12,15 +12,25 @@
use FileHandle;
use Getopt::Long;
use File::Temp qw(tempfile);
+use POSIX qw(setlocale);
+use Locale::gettext;
use strict;
+setlocale(LC_MESSAGES, "");
+bindtextdomain("quilt", "@LOCALEDIR@");
+textdomain("quilt");
+
+sub _($) {
+ return gettext(shift);
+}
+
my $select;
my $update;
if (!GetOptions("s|select=s" => \$select,
"u|update=s" => \$update) ||
(!defined $select && !defined $update)) {
- print STDERR "USAGE: $0 {-s|-u} section file [< replacement]\n";
+ print STDERR sprintf(_("USAGE: %s {-s|-u} section file [< replacement]\n"), $0);
exit 1;
}
@@ -66,13 +76,15 @@ foreach my $arg (@ARGV) {
if ($arg =~ /\.gz$/) {
$fh2->close();
if (! -e $tempname) {
- die "File $tempname disappeared!\n";
+ die sprintf(
+_("File %s disappeared!\n"), $tempname);
}
$fh2 = new FileHandle("| gzip -c > $tempname");
} elsif ($arg =~ /\.bz2$/) {
$fh2->close();
if (! -e $tempname) {
- die "File $tempname disappeared!\n";
+ die sprintf(
+_("File %s disappeared!\n"), $tempname);
}
$fh2 = new FileHandle("| bzip2 -c > $tempname");
}
@@ -117,12 +129,14 @@ foreach my $arg (@ARGV) {
if (-e $arg) {
unlink "$arg~";
unless (rename $arg, "$arg~") {
- die "Failed to rename $arg to $arg~: $!\n";
+ die sprintf(
+_("Failed to rename %s to %s: %s\n"), $arg, "$arg~", $!);
}
}
unless (rename $tempname, $arg) {
rename("$arg~", $arg);
- die "Failed to rename $arg.parse to $arg: $!\n";
+ die sprintf(
+_("Failed to rename %s to %s: %s\n"), $tempname, $arg, $!);
}
}
close $fh;
diff --git a/scripts/patchfns.in b/scripts/patchfns.in
index a70cfed..0738a1b 100644
--- a/scripts/patchfns.in
+++ b/scripts/patchfns.in
@@ -1,3 +1,5 @@
+#! @BASH@
+
# This file contains the common functions used in all quilt script
# It is meant to be sourced by bash scripts.
@@ -313,12 +315,6 @@ is_numeric()
echo $1 | grep -q '^[0-9]*$'
}
-is_applied_last()
-{
- local patch=$1
- [ "$(top_patch)" == $patch ]
-}
-
is_applied()
{
local patch=$1
@@ -521,21 +517,6 @@ files_in_patch_ordered()
'
}
-touched_by_patch()
-{
- local strip=$1 patch=$2
- cat_file $(patch_file_name $patch) \
- | @AWK@ '
- /^\+\+\+[ \t]/ {
- sub(/^\+\+\+[ \t]/, "")
- sub(/[ \t].*/, "")
- sub(/^\/dev\/null/, "")
- for (i=0; i<'$strip'; i++)
- sub(/^[^\/]*\//, "")
- print
- }'
-}
-
diff_file()
{
local file=$1 old_file=$2 new_file=$3
diff --git a/scripts/remove-trailing-ws.in b/scripts/remove-trailing-ws.in
index f14de5d..dfda46b 100644
--- a/scripts/remove-trailing-ws.in
+++ b/scripts/remove-trailing-ws.in
@@ -8,12 +8,22 @@
use strict;
use FileHandle;
use File::Temp qw( :mktemp );
+use POSIX qw(setlocale);
+use Locale::gettext;
use Getopt::Std;
use vars qw($opt_p $opt_n);
+setlocale(LC_MESSAGES, "");
+bindtextdomain("quilt", "@LOCALEDIR@");
+textdomain("quilt");
+
+sub _($) {
+ return gettext(shift);
+}
+
$opt_p = 0;
getopts('np:')
- or die "SYNOPSIS: $0 [-p num] [-n] [patch]\n";
+ or die sprintf(_("SYNOPSIS: %s [-p num] [-n] [patch]\n"), $0);
my %files;
my $file;
@@ -35,7 +45,7 @@ while (<>) {
while ($removed || $added) {
$_ = <>;
defined $_
- or die "$0: I'm confused.\n";
+ or die sprintf(_("%s: I'm confused.\n"), $0);
if (/^\+/) {
push @{$files{$file}}, $line_number
if s/(^\+.*?)[ \t]+$/$1/;
@@ -62,7 +72,7 @@ while (<>) {
while ($line_number <= $last_line) {
$_ = <>;
defined $_
- or die "$0: I'm confused.\n";
+ or die sprintf(_("%s: I'm confused.\n"), $0);
if (s/(^[+!] .*?)[ \t]+$/$1/) {
push @{$files{$file}}, $line_number;
}
@@ -82,18 +92,26 @@ while (<>) {
foreach my $file (keys %files) {
my @lines = @{$files{$file}};
if ($opt_n) {
- print STDERR "Warning: trailing whitespace in line";
+ print STDERR sprintf(
+_("Warning: trailing whitespace in line %s of %s\n"), $lines[0], $file)
+ if @lines == 1;
+ print STDERR sprintf(
+_("Warning: trailing whitespace in lines %s of %s\n"), join(',', @lines), $file)
+ if @lines > 1;
} else {
- print STDERR "Removing trailing whitespace from line";
+ print STDERR sprintf(
+_("Removing trailing whitespace from line %s of %s\n"), $lines[0], $file)
+ if @lines == 1;
+ print STDERR sprintf(
+_("Removing trailing whitespace from lines %s of %s\n"), join(',', @lines), $file)
+ if @lines > 1;
}
- print STDERR "s" if @lines > 1;
- print STDERR " " . join(',', @lines) . " of $file\n";
unless ($opt_n) {
my $fh = new FileHandle("< $file")
or die "$file: $!\n";
my ($tmp, $tmpname) = mkstemp("$file.XXXXXX")
- or die "$file.XXXXXX: $!\n";
+ or die "$file.*: $!\n";
while (<$fh>) {
if (@lines && $lines[0] == $.) {
s/[ \t]+$//;
@@ -105,8 +123,6 @@ foreach my $file (keys %files) {
$tmp->close
or die "$tmpname: $!\n";
rename $tmpname, $file
- or die "Renaming $tmpname to $file: $!\n";
+ or die sprintf(_("Renaming %s to %s: %s\n"), $tmpname, $file, $!);
}
}
-
-#exit (%files ? 1 : 0);