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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.