From 1e846de16b973c0590e67241c7a1eb4612a07782 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 8 Mar 2013 15:08:04 +0100 Subject: [PATCH] SL::Locale::language_join: Arrays menschenlesbar ausgeben MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit z.B. für @ary = qw(links rechts oben): "links, rechts und oben" --- SL/Locale.pm | 13 +++++++++++++ locale/de/all | 1 + 2 files changed, 14 insertions(+) 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', -- 2.20.1