man Locale::Maketext::Lexicon::Gettext () - PO and MO file parser for Maketext
NAME
Locale::Maketext::Lexicon::Gettext - PO and MO file parser for Maketext
SYNOPSIS
Called via Locale::Maketext::Lexicon:
package Hello::I18N;
use base 'Locale::Maketext';
use Locale::Maketext::Lexicon {
de => [Gettext => 'hello/de.mo'],
};
Directly calling CWparse():
use Locale::Maketext::Lexicon::Gettext;
my %Lexicon = %{ Locale::Maketext::Lexicon::Gettext->parse(<DATA>) };
__DATA__
#: Hello.pm:10
msgid "Hello, World!"
msgstr "Hallo, Welt!"
#: Hello.pm:11
msgid "You have %quant(%1,piece) of mail."
msgstr "Sie haben %quant(%1,Poststueck,Poststuecken)."
DESCRIPTION
This module implements a perl-based CWGettext parser for Locale::Maketext. It transforms all CW%1, CW%2, <%*>... sequences to CW[_1], CW[_2], CW[_*], and so on. It accepts either plain PO file, or a MO file which will be handled with a pure-perl parser adapted from Imacat's CWLocale::Maketext::Gettext.
Since version 0.03, this module also looks for CW%CIfunctionCW(CIargs...CW) in the lexicon strings, and transform it to CW[CIfunctionCW,CIargs...CW]. Any CW%1, CW%2... sequences inside the args will have their percent signs (CW%) replaced by underscores (CW_).
The name of function above should begin with a letter or underscore, followed by any number of alphanumeric characters and/or underscores. As an exception, the function name may also consist of a single asterisk (CW*) or pound sign (CW#), which are CWLocale::Maketext's shorthands for CWquant and CWnumf, respectively.
As an additional feature, this module also parses MIME-header style metadata specified in the null msgstr (CW""), and add them to the CW%Lexicon with a CW__ prefix. For example, the example above will set CW__Content-Type to CWtext/plain; charset=iso8859-1, without the newline or the colon.
Any normal entry that duplicates a metadata entry takes precedence. Hence, a CWmsgid "__Content-Type" line occurs anywhere should override the above value.
OPTIONS
use_fuzzy
When parsing PO files, fuzzy entries (entries marked with CW#, fuzzy) are silently ignored. If you wish to use fuzzy entries, specify a true value to the CW_use_fuzzy option:
use Locale::Maketext::Lexicon {
de => [Gettext => 'hello/de.mo'],
_use_fuzzy => 1,
};
allow_empty
When parsing PO files, empty entries (entries with CWmsgstr "") are silently ignored. If you wish to allow empty entries, specify a true value to the CW_allow_empty option:
use Locale::Maketext::Lexicon {
de => [Gettext => 'hello/de.mo'],
_allow_empty => 1,
};
SEE ALSO
Locale::Maketext, Locale::Maketext::Lexicon
AUTHORS
Autrijus Tang <autrijus@autrijus.org>
COPYRIGHT
Copyright 2002, 2003, 2004 by Autrijus Tang <autrijus@autrijus.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See <http://www.perl.com/perl/misc/Artistic.html>