Mercurial > pub > Impl
diff Lib/IMPL/Resources/Strings.pm @ 49:16ada169ca75
migrating to the Eclipse IDE
author | wizard@linux-odin.local |
---|---|
date | Fri, 26 Feb 2010 10:49:21 +0300 |
parents | 75148ccd732d |
children | 521c9c1a3ea1 |
line wrap: on
line diff
--- a/Lib/IMPL/Resources/Strings.pm Fri Feb 26 01:43:42 2010 +0300 +++ b/Lib/IMPL/Resources/Strings.pm Fri Feb 26 10:49:21 2010 +0300 @@ -1,100 +1,100 @@ -use strict; -use warnings; - -package IMPL::Resources::Strings::Storage; -package IMPL::Resources::Strings; -use File::Spec; - -our $Locale ||= 'default'; -our $Base ||='locale'; -our $Encoding ||= 'utf-8'; -our @Locations; - -@Locations = ('.') unless @Locations; - -sub import { - my ($self,$refStrings,%options) = @_; - - my ($class,$pathModule) = caller; - - my ($vol,$dir,$file) = File::Spec->splitpath($pathModule); - my $baseDir = File::Spec->catpath($vol,$dir,''); - - my @pathClass = split /::/,$class; - my $fileClass = pop @pathClass; - - my @ways = map { - my @path = ($_); - push @path,$Base; - push @path,$Locale; - - File::Spec->catfile(@path,@pathClass,$fileClass); - } @Locations; - - push @ways, File::Spec->catfile($baseDir,'locale',$Locale,$fileClass); - - - - my $stringsStorage = findResource(@Locations,$Base,$Locale,) - -} - -sub findResource { - my (@locations,$file,%options) = @_; - - -} - - - -sub parseResource { - my ($fname) = @_; - - open my $hRes, "<:encoding($Encoding)", findFile($fname) or die "Failed to open file $fname: $!"; - - my %Map; - my $line = 1; - while (<$hRes>) { - chomp; - $line ++ and next if /^\s*$/; - - if (/^(\w+)\s*=\s*(.*)$/) { - $Map{$1} = $2; - } else { - die "Invalid resource format in $fname at $line"; - } - $line ++; - } - - return \%Map; -} - -package IMPL::Resources::Strings::Storage; -use base qw(IMPL::Object); - -sub get { - my ($this,$msg_name) = @_; -} -1; - -__END__ - -=pod - -=head1 SYNOPSIS - -package Foo; - -use IMPL::Resources::Strings { - msg_say_hello => "Hello, %name!", - msg_module_name => "Simple Foo class" -}, auto => 1, locale => 'en-us'; - -sub InviteUser { - my ($this,$uname) = @_; - - print msg_say_hello(name => $uname); - -} - -=cut \ No newline at end of file +use strict; +use warnings; + +package IMPL::Resources::Strings::Storage; +package IMPL::Resources::Strings; +use File::Spec; + +our $Locale ||= 'default'; +our $Base ||='locale'; +our $Encoding ||= 'utf-8'; +our @Locations; + +@Locations = ('.') unless @Locations; + +sub import { + my ($self,$refStrings,%options) = @_; + + my ($class,$pathModule) = caller; + + my ($vol,$dir,$file) = File::Spec->splitpath($pathModule); + my $baseDir = File::Spec->catpath($vol,$dir,''); + + my @pathClass = split /::/,$class; + my $fileClass = pop @pathClass; + + my @ways = map { + my @path = ($_); + push @path,$Base; + push @path,$Locale; + + File::Spec->catfile(@path,@pathClass,$fileClass); + } @Locations; + + push @ways, File::Spec->catfile($baseDir,'locale',$Locale,$fileClass); + + + + my $stringsStorage = findResource(@Locations,$Base,$Locale,) + +} + +sub findResource { + my (@locations,$file,%options) = @_; + + +} + + + +sub parseResource { + my ($fname) = @_; + + open my $hRes, "<:encoding($Encoding)", findFile($fname) or die "Failed to open file $fname: $!"; + + my %Map; + my $line = 1; + while (<$hRes>) { + chomp; + $line ++ and next if /^\s*$/; + + if (/^(\w+)\s*=\s*(.*)$/) { + $Map{$1} = $2; + } else { + die "Invalid resource format in $fname at $line"; + } + $line ++; + } + + return \%Map; +} + +package IMPL::Resources::Strings::Storage; +use base qw(IMPL::Object); + +sub get { + my ($this,$msg_name) = @_; +} +1; + +__END__ + +=pod + +=head1 SYNOPSIS + +package Foo; + +use IMPL::Resources::Strings { + msg_say_hello => "Hello, %name!", + msg_module_name => "Simple Foo class" +}, auto => 1, locale => 'en-us'; + +sub InviteUser { + my ($this,$uname) = @_; + + print msg_say_hello(name => $uname); + +} + +=cut