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

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to