diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2012-12-30 21:03:48 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2012-12-30 21:03:48 +0100 |
commit | f04aa92778dca7f71ca656235885095b13dd3535 (patch) | |
tree | b0ac9cf3dfecbbdb0209c1204054adcac861f001 /app/helpers | |
parent | f3c3e77eaa2b82567f02601b6f66177208674181 (diff) | |
parent | 508871c01cbf02bf6d8d7056c2d5a70e4d67eebf (diff) |
Merge branch 'develop'5.0.2
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/application_helper.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..de4d677 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,22 @@ module ApplicationHelper + + # nicely_joined_with_commata(['1', '2', '3', '4']) + # = '1, 2, 3 und 4' + # + def nicely_joined_with_commata(array_of_things) + if array_of_things.count == 1 + array_of_things.first.to_s + else + if array_of_things.count > 1 + output = array_of_things[0, array_of_things.count - 1].map{|item| item.to_s}.join(', ') + if I18n.locale == :de + output += ' und ' + else + output += ' and ' + end + output += array_of_things.last.to_s + end + end + end + end |