
Locale::TextDomain::OO::MessagesStruct - Perl Interface extension to use gettext and not mo files
$Id: MessagesStruct.pm 252 2009-12-29 13:55:33Z steffenw $

0.03

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

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

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{},
],
},
);
$translation = $loc->dgettext($text_domain, $msgid);
$translation = $loc->dngettext($text_domain, $msgid, $msgid_plural, $count);
$translation = $loc->dpgettext($text_domain, $msgctxt, $msgid);
$translation = dnpgettext($text_domain, $msgctxt, $msgid, $msgid_plural, $count);

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

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

none

version
Carp

not known

none


Steffen Winkler

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.