blob: 238c8a96c32ad153d86e7c954f0e2303fc9906fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
package Locale::Maketext::Lexicon::Tie;
$Locale::Maketext::Lexicon::Tie::VERSION = '0.03';
use strict;
use Symbol ();
=head1 NAME
Locale::Maketext::Lexicon::Tie - Use tied hashes as lexicons for Maketext
=head1 SYNOPSIS
package Hello::L10N;
use base 'Locale::Maketext';
use Locale::Maketext::Lexicon {
en => [ Tie => [ DB_File => 'en.db' ] ],
};
=head1 DESCRIPTION
This module lets you easily C<tie> the C<%Lexicon> hash to a database
or other data sources. It takes an array reference of arguments, and
passes them directly to C<tie()>.
Entries will then be fetched whenever it is used; this module does not
cache them.
=cut
sub parse {
my $self = shift;
my $mod = shift;
my $sym = Symbol::gensym();
# Load the target module into memory
{
no strict 'refs';
eval "use $mod; 1" or die $@ unless defined %{"$mod\::"};
}
# Perform the actual tie
tie %{*$sym}, $mod, @_;
# Returns the GLOB reference, so %Lexicon will be tied too
return $sym;
}
1;
=head1 SEE ALSO
L<Locale::Maketext>, L<Locale::Maketext::Lexicon>
=head1 AUTHORS
Autrijus Tang E<lt>autrijus@autrijus.orgE<gt>
=head1 COPYRIGHT
Copyright 2002, 2003, 2004 by Autrijus Tang E<lt>autrijus@autrijus.orgE<gt>.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
See L<http://www.perl.com/perl/misc/Artistic.html>
=cut
|