NAME

Locale::TextDomain::OO::MessagesStruct - Perl Interface extension to use gettext and not mo files

$Id: MessagesStruct.pm 164 2009-12-07 21:29:45Z steffenw $

$HeadURL: https://perl-gettext-oo.svn.sourceforge.net/svnroot/perl-gettext-oo/trunk/lib/Locale/TextDomain/OO/MessagesStruct.pm $

VERSION

0.03

DESCRIPTION

This module allows the access using gettext methods to a data struct. Maybe such data were read from a database.

SYNOPSIS

require Locale::TextDomain::OO;
require Locale::TextDomain::OO::MessagesStruct;

SUBROUTINES/METHODS

method new

my $text_domain = 'text_domain';

my $loc = Locale::TextDomain::OO->new(
   ...
   gettext_object => Locale::TextDomain::OO::MessagesStruct->new(\my %struct),
   ...
);

# Read all the data and safe this into the struct.
my %struct = (
    $text_domain => {
        plural_ref = $loc->get_function_ref_plural(
            # The next line is like Plural-Forms at the po/mo file.
            '$nplurals=2; $plural=$n != 1;'
        ),
        array_ref => [
            # as example the keys with an empty value
            msgctxt      => q{},
            msgid        => 'must have a none empty value',
            msgid_plural => q{},
            msgstr       => q{},
            msgstr_0     => q{},
            msgstr_1     => q{},
            msgstr_2     => q{},
            msgstr_3     => q{},
            msgstr_4     => q{},
            msgstr_5     => q{},
        ],
    },
);

method dgettext

$translation = $loc->dgettext($text_domain, $msgid);

method dngettext

$translation = $loc->dngettext($text_domain, $msgid, $msgid_plural, $count);

method dpgettext

$translation = $loc->dpgettext($text_domain, $msgctxt, $msgid);

method dnpgettext

$translation = dnpgettext($text_domain, $msgctxt, $msgid, $msgid_plural, $count);

EXAMPLE

Inside of this distribution is a directory named example. Run this *.pl files.

DIAGNOSTICS

Error at translating methods.

Undefined text domain

Empty text domain

Data of text domain ... missing

array_ref data for text domain ... missing

plural_ref data for text domain ... missing

CONFIGURATION AND ENVIRONMENT

none

DEPENDENCIES

Carp

INCOMPATIBILITIES

not known

BUGS AND LIMITATIONS

none

SEE ALSO

Locale::TextDoamin:OO

AUTHOR

Steffen Winkler

LICENSE AND COPYRIGHT

Copyright (c) 2009, Steffen Winkler <steffenw at cpan.org>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.