hello list,
i try to add a new format to my locales file de.yml
i looks like that:
de:
number:
square_meter:
format:
unit: ‘m²’
format: “%n %u”
precision: 2
separator: ‘,’
delimiter: ‘.’
after that i’ve copied the number_to_currency method to the
application_controller.rb to get maximum comfort
but i get the default view of numbers, so it doesnt find my new yml
section
def number_to_square_meter(number, options = {})
options.symbolize_keys!
defaults = I18n.translate('number.format''number.format', :locale
=> options[:locale], :raise => true) rescue {}
currency =
I18n.translate(‘number.square_meter.format’‘number.square_meter.format’,
:locale
=> options[:locale], :raise => true) rescue {}
defaults = defaults.merge(currency)
precision = options[:precision] || defaults[:precision]
unit = options[:unit] || defaults[:unit]
separator = options[:separator] || defaults[:separator]
delimiter = options[:delimiter] || defaults[:delimiter]
format = options[:format] || defaults[:format]
separator = '' if precision == 0
begin
format.gsub(/%n/, number_with_precision(number,
:precision => precision,
:delimiter => delimiter,
:separator => separator)
).gsub(/%u/, unit)
rescue
number
end
end
do you have any idea how can i solve that?
thanks
best regards
matthias