use strict;
use warnings;
-our $VERSION = '3.00';
+our $VERSION = '3.01';
sub loc($) {
my $this = shift;
sub FETCH {
my $this = shift;
+ local $_ = shift;
# get setting (denoted by leading dash)
- return wantarray ? @{$this->{$_[0]}} : $this->{$_[0]}->[0]
- if $_[0] eq "-langpref";
- return $this->{$_[0]}
- if $_[0] eq "-path";
+ return wantarray ? @{$this->{$_}} : $this->{$_}->[0]
+ if $_ eq "-langpref";
+ return $this->{$_}
+ if $_ eq "-path" or $_ eq "-seperator";
# array ref used for passing arguments
- @_ = @{$_[0]} if ref $_[0] eq "ARRAY";
- # get localized string by identifier
- local $_ = shift;
+ ($_, @_) = @$_ if ref $_ eq "ARRAY";
# add default path unless specified
- $_ = $this->{-path} . '_' . $_ unless /_/;
- #todo: shouldn't occur - find out where this is done, then fix and remove this check
- # defined $_ or return '';
- $_ = $this->loc($this->{$_}) if exists $this->{$_};
- #todo: else remove path
- # adaptive string (code)
- $_ = $_->(@_) if ref $_ eq "CODE";
+ $_ = $this->{-path} . $this->{-seperator} . $_
+ if defined $this->{-seperator} and not /\Q$this->{-seperator}/;
+ # get localized string by identifier
+ if (exists $this->{$_}) {
+ $_ = $this->loc($this->{$_});
+ # adaptive string (code)
+ $_ = $_->(@_) if ref $_ eq "CODE";
+ } else {
+ #todo: else remove path
+ s/.*\Q$this->{-seperator}//s if defined $this->{-seperator};
+ }
# static output if no arguments given
return $_ unless @_; # unnecessary but faster for common case
# dynamic output
# set order of languages (prefered language first)
$this->{$option} = $val;
} # -langpref
+ elsif ($option eq "-seperator") {
+ $this->{-path} =~ s/\Q$this->{$option}/$val/g
+ if defined $this->{$option}; # replace old occurances
+ $this->{$option} = $val;
+ } # -seperator
else {
$this->{$option} = $val;
# $_[0]->{$_[1]} = $_[2];
use Lirama::Loc3;
tie my %loc, "Lirama::Loc3", {
+ -langs => {en => 100, eo => 95},
+ -seperator => '_',
_test => {
en => "this is a test",
eo => "cxi tio estas testo",