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
- #format_currency(locale, object, format = :default, options = {}) ⇒ Object
- #format_date(locale, object, format = :default, options = {}) ⇒ Object
- #format_datetime(locale, object, format = :default, options = {}) ⇒ Object
- #format_decimal(locale, object, format = :default, options = {}) ⇒ Object
- #format_integer(locale, object, format = :default, options = {}) ⇒ Object
- #format_percent(locale, object, format = :default, options = {}) ⇒ Object
- #format_time(locale, object, format = :default, options = {}) ⇒ Object
- #localize(locale, object, format = :default, options = {}) ⇒ Object
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, = {}) .merge!(:currency => lookup_currency(locale, [:currency], object)) if [:currency].is_a?(Symbol) formatter(locale, :currency, format).apply(object, ) 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, = {}) formatter(locale, :date, format).apply(object, ) 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, = {}) key = :"calendars.gregorian.formats.datetime.#{format}.pattern" date = I18n.l(object, :format => [:date_format] || format, :locale => locale, :as => :date) time = I18n.l(object, :format => [: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, = {}) formatter(locale, :decimal, format).apply(object, ) 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, = {}) format_object(number, .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, = {}) formatter(locale, :percent, format).apply(object, ) 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, = {}) formatter(locale, :time, format).apply(object, ) 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, = {}) [:as] ||= detect_type(object, ) send(:"format_#{[:as]}", locale, object, format, ) end |