Module: Polish::Proxies

Included in:
Polish
Defined in:
lib/polish/proxies.rb

Instance Method Summary collapse

Instance Method Details

#localize(object, options = {}) ⇒ Object Also known as: l

See I18n::localize



10
11
12
# File 'lib/polish/proxies.rb', line 10

def localize(object, options = {})
  I18n.localize(object, options.merge({ :locale => LOCALE }))
end

#pluralize(n, *variants) ⇒ Object Also known as: p

Simple pluralization proxy

Usage:

Polish.pluralize(1, "dom", "domy", "domów")

Raises:

  • (ArgumentError)


24
25
26
27
28
29
# File 'lib/polish/proxies.rb', line 24

def pluralize(n, *variants)
  raise ArgumentError, "Must have a Numeric as a first parameter" unless n.is_a?(Numeric)
  raise ArgumentError, "Must have 3 variants for pluralization" if variants.size < 3
  variants_hash = pluralization_variants_to_hash(*variants)
  I18n.backend.send(:pluralize, LOCALE, variants_hash, n)
end

#strftime(object, format = :default) ⇒ Object

strftime() proxy with Polish localization



16
17
18
# File 'lib/polish/proxies.rb', line 16

def strftime(object, format = :default)
  localize(object, { :format => format })
end

#translate(key, options = {}) ⇒ Object Also known as: t

See I18n::translate



4
5
6
# File 'lib/polish/proxies.rb', line 4

def translate(key, options = {})
  I18n.translate(key, options.merge({ :locale => LOCALE }))
end