# HG changeset patch # User cin # Date 1371249131 -14400 # Node ID c78dfbe658bdce694ee658aee801bcf8b4f9951d # Parent f4e14f32cf548dc7aa4fdafba6c5985aed337361 improved string maps loading for TT documents diff -r f4e14f32cf54 -r c78dfbe658bd Lib/IMPL/Web/View/TTFactory.pm --- 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 {