++ed by:

1 PAUSE user
1 non-PAUSE user.



Locale::Maketext::Lexicon - Use other catalog formats in Maketext


This document describes version 0.08 of Locale::Maketext::Lexicon.


As part of a localization class:

    package Hello::L10N;
    use base 'Locale::Maketext';
    use Locale::Maketext::Lexicon {de => [Gettext => 'hello_de.po']};

Alternatively, as part of a localization subclass:

    package Hello::L10N::de;
    use base 'Hello::L10N';
    use Locale::Maketext::Lexicon (Gettext => \*DATA);
    # Some sample data
    msgid ""
    msgstr ""
    "Project-Id-Version: Hello\n"
    "MIME-Version: 1.0\n"
    "Content-Type: text/plain; charset=iso8859-1\n"
    "Content-Transfer-Encoding: 8bit\n"

    #: 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 provides lexicon-handling modules to read from other localization formats, such as Gettext, Msgcat, and so on.

The import() function accepts two forms of arguments:

(format, [ filehandle | filename | arrayref ])

This form pass the contents specified by the second argument to Locale::Maketext::Lexicon::format->parse as a plain list, and export its return value as the %Lexicon hash in the calling package.

{ language => [ format, [ filehandle | filename | arrayref ] ] ... }

This form accepts a hash reference. It will export a %Lexicon into the subclasses specified by each language, using the process described above. It is designed to alleviate the need to set up a separate subclass for each localized language, and just use the catalog files.


If you want to implement a new Lexicon::* backend module, please note that parse() takes an array containing the source strings from the specified filehandle or filename, which are not chomped. Although if the source is an array reference, its elements will probably not contain any newline characters.

The parse() function should return a hash reference, which will be assigned to the typeglob (*Lexicon) of the language module. All it amounts to is that if the returned reference points to a tied hash, the %Lexicon will be aliased to the same tied hash.


Thanks to Jesse Vincent for suggesting this module to be written.

Thanks also to Sean M. Burke for coming up with Locale::Maketext in the first place, and encouraging me to experiment with alternative Lexicon syntaxes.


Locale::Maketext, Locale::Maketext::Lexicon::Auto, Locale::Maketext::Lexicon::Gettext, Locale::Maketext::Lexicon::Msgcat, Locale::Maketext::Lexicon::Tie


Autrijus Tang <autrijus@autrijus.org>


Copyright 2002 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