X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FLocale%2FString.pm;h=722974393f8801537b236bcd12ae35b35fda2bbf;hb=30b4a78c4100ebdcd6e6917fbcbf1d12f4f7b4d6;hp=42ceb22a649f100516e234e39236638040d7c32e;hpb=87b0de4c742e6032bcb6bf8750b1d8144e1a9860;p=kivitendo-erp.git diff --git a/SL/Locale/String.pm b/SL/Locale/String.pm index 42ceb22a6..722974393 100644 --- a/SL/Locale/String.pm +++ b/SL/Locale/String.pm @@ -6,20 +6,38 @@ use parent qw(Rose::Object Exporter); use Rose::Object::MakeMethods::Generic ( scalar => [ qw(untranslated) ], + array => [ qw(args) ], ); our @EXPORT = qw(t8); -use overload '""' => \&translated; +use overload + '""' => \&translated, + eq => \&my_eq, + ne => \&my_ne; sub translated { my ($self) = @_; - return $::locale ? $::locale->text($self->untranslated) : $self->untranslated; + return $::locale ? $::locale->text($self->untranslated, $self->args) : $self->untranslated; } sub t8 { - my $string = $_[ ref($_[0]) || ($_[0] eq 'SL::Locale::String') ? 1 : 0 ]; - return SL::Locale::String->new(untranslated => $string); + shift if $_[0] eq __PACKAGE__; + + my $string = shift; + return SL::Locale::String->new(untranslated => $string, args => [ @_ ]); +} + +sub my_eq { + $_[1] eq $_[0]->translated; +} + +sub my_ne { + $_[1] ne $_[0]->translated; +} + +sub TO_JSON { + return $_[0]->translated; } 1;