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


_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to