quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Quilt-dev] Call for 0.42


From: Jean Delvare
Subject: Re: [Quilt-dev] Call for 0.42
Date: Thu, 21 Jul 2005 22:59:34 +0200

Hi all,

> Is it technically possible to only use Locale/gettext.pm if it exists,
> and disable internationalization if it doesn't rather than plain die?
> If it is possible, then I'd suggest that we do just that.

I gave this a try and have something that seems to work, but it's not
exactly elegant (especially the "no strict" which is needed). Does it
look like something I can commit, or not?

--- remove-trailing-ws.in       18 Jul 2005 22:15:26 -0000      1.2
+++ remove-trailing-ws.in       21 Jul 2005 20:57:08 -0000
@@ -9,16 +9,27 @@
 use FileHandle;
 use File::Temp qw( :mktemp );
 use POSIX qw(setlocale);
-use Locale::gettext;
 use Getopt::Std;
-use vars qw($opt_p $opt_n);
+use vars qw($opt_p $opt_n $use_gettext);
 
-setlocale(LC_MESSAGES, "");
-bindtextdomain("quilt", "@LOCALEDIR@");
-textdomain("quilt");
+BEGIN {
+    my $mod = 'Locale::gettext';
+    if (eval "require $mod") {
+       $mod->import();
+       $use_gettext = 1;
+    }
+}
+
+if ($use_gettext) {
+    no strict "subs";
+    setlocale(LC_MESSAGES, "");
+    use strict;
+    bindtextdomain("quilt", "@LOCALEDIR@");
+    textdomain("quilt");
+}
 
 sub _($) {
-    return gettext(shift);
+    return ($use_gettext ? gettext(shift) : shift);
 }
 
 $opt_p = 0;


Thanks,
-- 
Jean Delvare




reply via email to

[Prev in Thread] Current Thread [Next in Thread]