Module: I18n::Backend::Cldr

Includes:
Cldr::Format
Defined in:
lib/active_support/vendor/i18n-0.3.7/i18n/backend/cldr.rb

Instance Method Summary collapse

Instance Method Details

#format_currency(locale, object, format = :default, options = {}) ⇒ Object



22
23
24
25
# File 'lib/active_support/vendor/i18n-0.3.7/i18n/backend/cldr.rb', line 22

def format_currency(locale, object, format = :default, options = {})
  options.merge!(:currency => lookup_currency(locale, options[:currency], object)) if options[:currency].is_a?(Symbol)
  formatter(locale, :currency, format).apply(object, options)
end

#format_date(locale, object, format = :default, options = {}) ⇒ Object



31
32
33
# File 'lib/active_support/vendor/i18n-0.3.7/i18n/backend/cldr.rb', line 31

def format_date(locale, object, format = :default, options = {})
  formatter(locale, :date, format).apply(object, options)
end

#format_datetime(locale, object, format = :default, options = {}) ⇒ Object



39
40
41
42
43
44
# File 'lib/active_support/vendor/i18n-0.3.7/i18n/backend/cldr.rb', line 39

def format_datetime(locale, object, format = :default, options = {})
  key  = :"calendars.gregorian.formats.datetime.#{format}.pattern"
  date = I18n.l(object, :format => options[:date_format] || format, :locale => locale, :as => :date)
  time = I18n.l(object, :format => options[:time_format] || format, :locale => locale, :as => :time)
  I18n.t(key, :date => date, :time => time, :locale => locale, :raise => true)
end

#format_decimal(locale, object, format = :default, options = {}) ⇒ Object



14
15
16
# File 'lib/active_support/vendor/i18n-0.3.7/i18n/backend/cldr.rb', line 14

def format_decimal(locale, object, format = :default, options = {})
  formatter(locale, :decimal, format).apply(object, options)
end

#format_integer(locale, object, format = :default, options = {}) ⇒ Object



18
19
20
# File 'lib/active_support/vendor/i18n-0.3.7/i18n/backend/cldr.rb', line 18

def format_integer(locale, object, format = :default, options = {})
  format_object(number, options.merge(:precision => 0))
end

#format_percent(locale, object, format = :default, options = {}) ⇒ Object



27
28
29
# File 'lib/active_support/vendor/i18n-0.3.7/i18n/backend/cldr.rb', line 27

def format_percent(locale, object, format = :default, options = {})
  formatter(locale, :percent, format).apply(object, options)
end

#format_time(locale, object, format = :default, options = {}) ⇒ Object



35
36
37
# File 'lib/active_support/vendor/i18n-0.3.7/i18n/backend/cldr.rb', line 35

def format_time(locale, object, format = :default, options = {})
  formatter(locale, :time, format).apply(object, options)
end

#localize(locale, object, format = :default, options = {}) ⇒ Object



9
10
11
12
# File 'lib/active_support/vendor/i18n-0.3.7/i18n/backend/cldr.rb', line 9

def localize(locale, object, format = :default, options = {})
  options[:as] ||= detect_type(object, options)
  send(:"format_#{options[:as]}", locale, object, format, options)
end