Module: I18n

Defined in:
lib/m9t/i18n.rb

Overview

Monkey patch I18n i18n does not handle localizing numbers. See the following GitHub issues:

Class Method Summary collapse

Class Method Details

.localize_float(float, options = {}) ⇒ Object

Handle non-English numerical separators with I18n.locale = :it,

I18n.localize_float(5.23) => "5,23000"


19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/m9t/i18n.rb', line 19

def I18n.localize_float(float, options = {})
  format = options[:format] || "%f"
  english = format % float
  integers, decimal = english.split(".")
  integers ||= ""

  thousands_separator = I18n.t("numbers.thousands_separator")
  integers.gsub(",", thousands_separator)

  return integers if decimal.nil?

  decimal_separator = I18n.t("numbers.decimal_separator")
  integers + decimal_separator + decimal
end