From: Moritz Bunkus Date: Fri, 8 Mar 2013 14:08:04 +0000 (+0100) Subject: SL::Locale::language_join: Arrays menschenlesbar ausgeben X-Git-Tag: release-3.1.0beta1~540 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=1e846de16b973c0590e67241c7a1eb4612a07782;p=kivitendo-erp.git SL::Locale::language_join: Arrays menschenlesbar ausgeben z.B. für @ary = qw(links rechts oben): "links, rechts und oben" --- diff --git a/SL/Locale.pm b/SL/Locale.pm index 5503c1b95..3216cd270 100644 --- a/SL/Locale.pm +++ b/SL/Locale.pm @@ -539,7 +539,20 @@ sub get_local_time_zone { return $self->{local_time_zone}; } +sub language_join { + my ($self, $items, %params) = @_; + + $items ||= []; + $params{conjunction} ||= $::locale->text('and'); + my $num = scalar @{ $items }; + + return 0 == $num ? '' + : 1 == $num ? $items->[0] + : join(', ', @{ $items }[0..$num - 2]) . ' ' . $params{conjunction} . ' ' . $items->[$num - 1]; +} + 1; + __END__ =pod diff --git a/locale/de/all b/locale/de/all index 7b561143e..08ed56aae 100644 --- a/locale/de/all +++ b/locale/de/all @@ -2344,6 +2344,7 @@ $self->{texts} = { 'action= not defined!' => 'action= nicht definiert!', 'active' => 'aktiv', 'all entries' => 'alle Einträge', + 'and' => 'und', 'ap_aging_list' => 'liste_offene_verbindlichkeiten', 'ar_aging_list' => 'liste_offene_forderungen', 'as at' => 'zum Stand',