class TheFox::Timr::Helper::TranslationHelper

Public Class Methods

pluralize(n, singular, plural=nil) click to toggle source

Based on the number n return singular or plural of a given word.

For example:

pluralize(1, 'track', 'tracks')
=> "1 track"
pluralize(2, 'track', 'tracks')
=> "2 tracks"
pluralize(0, 'track', 'tracks')
=> "0 tracks"
# File lib/timr/helper/translation_helper.rb, line 29
def pluralize(n, singular, plural=nil)
    if n == 1
        "1 #{singular}"
    elsif plural
        "#{n} #{plural}"
    else
        "#{n} #{singular}s"
    end
end