diff Lib/IMPL/Web/View/TTFactory.pm @ 338:c78dfbe658bd

improved string maps loading for TT documents
author cin
date Sat, 15 Jun 2013 02:32:11 +0400
parents f4e14f32cf54
children 97628101b765
line wrap: on
line diff
--- a/Lib/IMPL/Web/View/TTFactory.pm	Fri Jun 14 15:37:34 2013 +0400
+++ b/Lib/IMPL/Web/View/TTFactory.pm	Sat Jun 15 02:32:11 2013 +0400
@@ -15,6 +15,7 @@
 use IMPL::declare {
     require => {
         Loader => 'IMPL::Code::Loader',
+        Resources => 'IMPL::Resources', 
         OpException => '-IMPL::InvalidOperationException',
         ArgException => '-IMPL::InvalidArgumentException'
     },
@@ -32,7 +33,8 @@
         registry => PROP_RO, 
         blocks => PROP_RO,
         path => PROP_RO,
-        _instance => PROP_RW
+        _instance => PROP_RW,
+        _labels => PROP_RW
     ]
 };
 
@@ -117,14 +119,17 @@
 sub LoadLabelsToContext {
 	my ($this,$context) = @_;
 	
-	$this->base->LoadLabelsToContext($context)
+	my %vars;
+	
+	%vars = %{$this->base->_labels || {}}
 	   if $this->base;
+	$this->_labels(\%vars);
 	
 	if(my $fname = $this->registry->loader->ResolveFileName($this->path)) {
         my $flabels = "$fname.labels";
         
         if (-f $flabels) {
-            my %vars;
+            
             my %labels;
             $labels{default} = IMPL::Resources::Strings::ParseStringsMap("$flabels");
             
@@ -132,7 +137,7 @@
             	warn "LABEL: $label";
                 $vars{$label} = sub {
                     my ($params) = @_;
-                    my $locale = 'ru_RU';
+                    my $locale = Resources->currentLocale;
                     
                     unless ($labels{$locale}) {
                         $labels{$locale} = -f "$fname.$locale" ? 
@@ -143,9 +148,10 @@
                     return FormatMessage(($labels{$locale}{$label} || $text),$params);
                 }
             }
-            $context->stash->update(\%vars);
+            
         }
     }
+    $context->stash->update(\%vars);
 }
 
 sub MergeParameters {