Locale::Maketext::Lexicon::Gettext - PO and MO file parser for Maketext
Called via Locale::Maketext::Lexicon:
package Hello::L10N; use base 'Locale::Maketext'; use Locale::Maketext::Lexicon { de => [Gettext => 'hello/de.mo'], };
Directly calling parse():
parse()
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)."
This module implements a perl-based Gettext parser for Locale::Maketext. It transforms all %1, %2, <%*>... sequences to [_1], [_2], [_*], 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 Locale::Maketext::Gettext.
Gettext
%1
%2
[_1]
[_2]
[_*]
Locale::Maketext::Gettext
Since version 0.03, this module also looks for %function(args...) in the lexicon strings, and transform it to [function,args...]. Any %1, %2... sequences inside the args will have their percent signs (%) replaced by underscores (_).
%function(args...)
[function,args...]
%
_
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 (*) or pound sign (#), which are Locale::Maketext's shorthands for quant and numf, respectively.
*
#
Locale::Maketext
quant
numf
As an additional feature, this module also parses MIME-header style metadata specified in the null msgstr (""), and add them to the %Lexicon with a __ prefix. For example, the example above will set __Content-Type to text/plain; charset=iso8859-1, without the newline or the colon.
""
%Lexicon
__
__Content-Type
text/plain; charset=iso8859-1
Any normal entry that duplicates a metadata entry takes precedence. Hence, a msgid "__Content-Type" line occurs anywhere should override the above value.
msgid "__Content-Type"
When parsing PO files, fuzzy entries (entries marked with #, fuzzy) are silently ignored. If you wish to use fuzzy entries, specify a true value to the _use_fuzzy option:
#, fuzzy
_use_fuzzy
use Locale::Maketext::Lexicon { de => [Gettext => 'hello/de.mo'], _use_fuzzy => 1, };
Locale::Maketext, Locale::Maketext::Lexicon
Autrijus Tang <autrijus@autrijus.org>
Copyright 2002, 2003 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
To install Locale::Maketext::Lexicon, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Locale::Maketext::Lexicon
CPAN shell
perl -MCPAN -e shell install Locale::Maketext::Lexicon
For more information on module installation, please visit the detailed CPAN module installation guide.