Gettext






Pair Networks
Gettext

NAME

Gettext - Perl extension for emulating gettext-related API.

SYNOPSIS

  use Gettext;

DESCRIPTION

Gettext.pm emulates the gettext library routines in Perl, although it calls the external utility program gettext to actually read .mo files.

man gettext on Solaris has pretty good documentation.

The steps to use this module are:

use Gettext;

my $gt = new Gettext;

$gt->textdomain('domainname');

$gt->bindtextdomain('domainname', 'dirname');

$gt->gettext('msgid');

$gt->dgettext('domainname', 'msgid');

$gt->dcgettext('domainname', 'msgid', 'category (locale)');

SAMPLE

use strict;

use diagnostics;

use POSIX 'locale_h';

use locale;

use Gettext;

   setlocale(LC_CTYPE, 'es_ES');

   my $gt = new Gettext();

   $gt->bindtextdomain("messages", "/root/work");

   print $gt->gettext("flower"),"\n";
   print $gt->gettext("yellow"),"\n";

   print $gt->dgettext("messages", "flower"),"\n";
   print $gt->dgettext("messages", "yellow"),"\n";

   print $gt->dcgettext("messages", "flower", "fr_FR"),"\n";
   print $gt->dcgettext("messages", "yellow", "fr_FR"),"\n";

   print $gt->textdomain(),"\n";
   print $gt->textdomain(''),"\n";

Tested on Solaris 2.6 and Red Hat Linux 6.0

AUTHOR

James Briggs, james@rf.net

SEE ALSO

perldoc perllocale

TO DO

Gettext.pm calls the external gettext utility program, but someday should have an internal routine to directory read .mo files.