From 748a4de99a5276a08490f379486a126e91385219 Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Mon, 18 Jul 2005 22:15:26 +0000 Subject: - Add internationalization support to Perl scripts as well. --- scripts/parse-patch.in | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'scripts/parse-patch.in') 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; -- cgit