Sanjay has asked for the wisdom of the Perl Monks concerning the following question:

I copied the sample script in the Gettext manual page and made minor changes to match a word in the es.po & fr.po sample files downloaded from the poedit website, & change in the working directory. The script is in D:/temp/gt - the compiled .mo files are D:/temp/gt/es_ES/LC_MESSAGES/es.mo & D:/temp/gt/fr_FR/LC_MESSAGES/fr.mo

Code

use strict; use diagnostics; use POSIX 'locale_h'; use locale; use Gettext; setlocale(LC_CTYPE, 'es_ES'); my $gt = new Gettext(); $gt->bindtextdomain("messages", 'D:/temp/gt'); print $gt->gettext("Close"),"\n"; print $gt->dgettext("messages", "Close"),"\n"; print $gt->dcgettext("messages", "Close", "fr_FR"),"\n"; print $gt->textdomain(),"\n"; print $gt->textdomain(''),"\n"; OUTPUT 'LC_MESSAGES' is not recognized as an internal or external command, operable program or batch file. 'LC_MESSAGES' is not recognized as an internal or external command, operable program or batch file. 'LANGUAGE' is not recognized as an internal or external command, operable program or batch file. messages messages

Replies are listed 'Best First'.
Re: Gettext not working on Windows
by BrowserUk (Patriarch) on Jun 12, 2013 at 12:10 UTC

    From the POD

    Tested on Solaris 2.6 and Red Hat Linux 6.0

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

    Unless you have installed a version of the gettext(.exe?) utility to your Windows system and ensured that it is in your path; the module will not work om Windows.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      gettext is in the path. gettext --help prints the help message.

        Even so, the module will not work on Windows because this syntax will not work there:

        `LANGUAGE=$category;LC_MESSAGES=$category;TEXTDOMAINDIR=$self->{'DIRNA +ME'};$gettextcmd $domainname $msgid`;

        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.