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

sync
author cin
date Tue, 26 Feb 2013 02:21:03 +0400
parents bbc0da7ef90e
children 1838bdb4d238
line wrap: on
line diff
--- a/Lib/IMPL/Resources/Strings.pm	Thu Feb 21 03:44:02 2013 +0400
+++ b/Lib/IMPL/Resources/Strings.pm	Tue Feb 26 02:21:03 2013 +0400
@@ -10,6 +10,7 @@
 our $Locale ||= 'default';
 our $Encoding ||= 'utf-8';
 our @Locations;
+my %maps;
 
 sub import {
     my ($self,$refStrings,%options) = @_;
@@ -17,16 +18,18 @@
     no strict 'refs';
     
     my $class = caller;
+    my $methods = $options{methods};
     
     if (ref $refStrings eq 'HASH') {
-        my %map;
+        my $map = ( $maps{$class} ||= {} );
         while(my ($name,$format) = each %$refStrings) {
-            $map{default}{$name} = $format;
+            $map->{default}{$name} = $format;
             
             *{"${class}::$name"} = sub {
+                shift if $methods;
                 my $args = @_ == 1 ? shift : { @_ };
                 
-                return _FormatMapMessage($class,$name,\%map,$Locale,$args);
+                return _FormatMapMessage($class,$name,$map,$Locale,$args);
             }
         }
     }