Hi Jean,
On Thursday 21 July 2005 22:59, Jean Delvare wrote:
> 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?
I'm no expert in this, but maybe you like the following snippet slightly
better.
#! /usr/bin/perl -w
use POSIX qw(setlocale LC_MESSAGES);
use strict;
BEGIN {
if (eval { require Locale::gettext }) {
import Locale::gettext;
} else {
eval '
sub bindtextdomain($$) { }
sub textdomain($) { }
sub gettext($) { shift }
'
}
}
setlocale(LC_MESSAGES, "");
bindtextdomain("quilt", "/usr/share/locale");
textdomain("quilt");
sub _($) {
return gettext(shift);
}
print _("Foo") . "\n";
The second eval needs to be passed a string or else Perl will complain.
-- Andreas.
_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev