comparison Lib/IMPL/Resources/Strings.pm @ 292:6dc1c369eb71

sync
author cin
date Tue, 26 Feb 2013 02:21:03 +0400
parents bbc0da7ef90e
children 1838bdb4d238
comparison
equal deleted inserted replaced
291:5d14baa35790 292:6dc1c369eb71
8 use IMPL::Resources::Format qw(FormatMessage); 8 use IMPL::Resources::Format qw(FormatMessage);
9 9
10 our $Locale ||= 'default'; 10 our $Locale ||= 'default';
11 our $Encoding ||= 'utf-8'; 11 our $Encoding ||= 'utf-8';
12 our @Locations; 12 our @Locations;
13 my %maps;
13 14
14 sub import { 15 sub import {
15 my ($self,$refStrings,%options) = @_; 16 my ($self,$refStrings,%options) = @_;
16 17
17 no strict 'refs'; 18 no strict 'refs';
18 19
19 my $class = caller; 20 my $class = caller;
21 my $methods = $options{methods};
20 22
21 if (ref $refStrings eq 'HASH') { 23 if (ref $refStrings eq 'HASH') {
22 my %map; 24 my $map = ( $maps{$class} ||= {} );
23 while(my ($name,$format) = each %$refStrings) { 25 while(my ($name,$format) = each %$refStrings) {
24 $map{default}{$name} = $format; 26 $map->{default}{$name} = $format;
25 27
26 *{"${class}::$name"} = sub { 28 *{"${class}::$name"} = sub {
29 shift if $methods;
27 my $args = @_ == 1 ? shift : { @_ }; 30 my $args = @_ == 1 ? shift : { @_ };
28 31
29 return _FormatMapMessage($class,$name,\%map,$Locale,$args); 32 return _FormatMapMessage($class,$name,$map,$Locale,$args);
30 } 33 }
31 } 34 }
32 } 35 }
33 } 36 }
34 37